diff options
author | Timothée Floure | 2016-03-09 17:27:13 +0100 |
---|---|---|
committer | Timothée Floure | 2016-03-09 17:27:56 +0100 |
commit | b73b2050d345e0ee47fd38952047bdf9d36365d3 (patch) | |
tree | 94d22a21ad4512c0698965a4531b64792fec8bbe /src/ch | |
parent | b0356d4ff6694ccc7f8fae1766b73b0e99c78ed9 (diff) | |
download | xblast-b73b2050d345e0ee47fd38952047bdf9d36365d3.tar.gz |
Structure of the fourth week assignment
Diffstat (limited to 'src/ch')
-rw-r--r-- | src/ch/epfl/xblast/Lists.java | 9 | ||||
-rw-r--r-- | src/ch/epfl/xblast/Time.java | 8 | ||||
-rw-r--r-- | src/ch/epfl/xblast/server/Block.java | 45 | ||||
-rw-r--r-- | src/ch/epfl/xblast/server/Bonus.java | 18 | ||||
-rw-r--r-- | src/ch/epfl/xblast/server/GameState.java | 49 | ||||
-rw-r--r-- | src/ch/epfl/xblast/server/Ticks.java | 7 |
6 files changed, 135 insertions, 1 deletions
diff --git a/src/ch/epfl/xblast/Lists.java b/src/ch/epfl/xblast/Lists.java index 51e76b0..f541b37 100644 --- a/src/ch/epfl/xblast/Lists.java +++ b/src/ch/epfl/xblast/Lists.java | |||
@@ -44,4 +44,13 @@ public final class Lists { | |||
44 | .collect(Collectors.toList()); | 44 | .collect(Collectors.toList()); |
45 | } | 45 | } |
46 | 46 | ||
47 | /** | ||
48 | * Returns all the permutations of the elements of the given list | ||
49 | * | ||
50 | * @param l given list | ||
51 | * @return a list of all the permutations of the list | ||
52 | */ | ||
53 | public static <T> List<List<T>> permutations(List<T> l) { | ||
54 | return null; | ||
55 | } | ||
47 | } | 56 | } |
diff --git a/src/ch/epfl/xblast/Time.java b/src/ch/epfl/xblast/Time.java new file mode 100644 index 0000000..fa18f86 --- /dev/null +++ b/src/ch/epfl/xblast/Time.java | |||
@@ -0,0 +1,8 @@ | |||
1 | package ch.epfl.xblast; | ||
2 | |||
3 | public interface Time { | ||
4 | int S_PER_MIN = 60; | ||
5 | int MS_PER_S = 1000; | ||
6 | int US_PER_S = 1000*MS_PER_S; | ||
7 | int NS_PER_S = 1000*US_PER_S; | ||
8 | } | ||
diff --git a/src/ch/epfl/xblast/server/Block.java b/src/ch/epfl/xblast/server/Block.java index 409f68e..4903e2b 100644 --- a/src/ch/epfl/xblast/server/Block.java +++ b/src/ch/epfl/xblast/server/Block.java | |||
@@ -26,7 +26,36 @@ public enum Block { | |||
26 | /** | 26 | /** |
27 | * Crumbling Wall. | 27 | * Crumbling Wall. |
28 | */ | 28 | */ |
29 | CRUMBLING_WALL; | 29 | CRUMBLING_WALL, |
30 | |||
31 | /** | ||
32 | * | ||
33 | */ | ||
34 | BONUS_BOMB(Bonus.INC_BOMB), | ||
35 | |||
36 | /** | ||
37 | * | ||
38 | */ | ||
39 | BONUS_RANGE(Bonus.INC_RANGE); | ||
40 | |||
41 | /** | ||
42 | * Corresponding bonus, or null | ||
43 | */ | ||
44 | private Bonus maybeAssociatedBonus; | ||
45 | |||
46 | /** | ||
47 | * Main builder, used by the bonus blocks | ||
48 | */ | ||
49 | private Block(Bonus maybeAssociatedBonus) { | ||
50 | this.maybeAssociatedBonus = maybeAssociatedBonus; | ||
51 | } | ||
52 | |||
53 | /** | ||
54 | * Default builder, used by the ither blocks | ||
55 | */ | ||
56 | private Block() { | ||
57 | this.maybeAssociatedBonus = null; | ||
58 | } | ||
30 | 59 | ||
31 | /** | 60 | /** |
32 | * Returns T(this block is free). | 61 | * Returns T(this block is free). |
@@ -55,4 +84,18 @@ public enum Block { | |||
55 | return this == INDESTRUCTIBLE_WALL || this == DESTRUCTIBLE_WALL || this == CRUMBLING_WALL; | 84 | return this == INDESTRUCTIBLE_WALL || this == DESTRUCTIBLE_WALL || this == CRUMBLING_WALL; |
56 | } | 85 | } |
57 | 86 | ||
87 | /** | ||
88 | * | ||
89 | */ | ||
90 | public boolean isBonus() { | ||
91 | return false; | ||
92 | } | ||
93 | |||
94 | /** | ||
95 | * | ||
96 | */ | ||
97 | public Bonus associatedBonus() { | ||
98 | return null; | ||
99 | } | ||
100 | |||
58 | } | 101 | } |
diff --git a/src/ch/epfl/xblast/server/Bonus.java b/src/ch/epfl/xblast/server/Bonus.java new file mode 100644 index 0000000..43be24f --- /dev/null +++ b/src/ch/epfl/xblast/server/Bonus.java | |||
@@ -0,0 +1,18 @@ | |||
1 | package ch.epfl.xblast.server; | ||
2 | |||
3 | /** | ||
4 | * @author TimothéE FLOURE (257420) | ||
5 | */ | ||
6 | public enum Bonus { | ||
7 | INC_BOMB { | ||
8 | @Override | ||
9 | public Player applyTo(Player player) { return null; } | ||
10 | }, | ||
11 | |||
12 | INC_RANGE { | ||
13 | @Override | ||
14 | public Player applyTo(Player player) { return null; } | ||
15 | }; | ||
16 | |||
17 | abstract public Player applyTo(Player player); | ||
18 | } | ||
diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java new file mode 100644 index 0000000..625767a --- /dev/null +++ b/src/ch/epfl/xblast/server/GameState.java | |||
@@ -0,0 +1,49 @@ | |||
1 | package ch.epfl.xblast.server; | ||
2 | |||
3 | import java.util.List; | ||
4 | import java.util.Optional; | ||
5 | import ch.epfl.xblast.*; | ||
6 | import ch.epfl.cs108.Sq; | ||
7 | |||
8 | public final class GameState { | ||
9 | private final int ticks; | ||
10 | private final Board board; | ||
11 | private final List<Player> players; | ||
12 | private final List<Bomb> bombs; | ||
13 | private final List<Sq<Sq<Cell>>> explosions; | ||
14 | private final List<Sq<Cell>> blasts; | ||
15 | |||
16 | public GameState(int ticks, Board board, List<Player> players, List<Bomb> bombs, List<Sq<Sq<Cell>>> explosions, List<Sq<Cell>> blasts) { | ||
17 | } | ||
18 | |||
19 | public GameState(Board board, List<Player> players) { | ||
20 | } | ||
21 | |||
22 | public int ticks() { | ||
23 | return 0; | ||
24 | } | ||
25 | |||
26 | public boolean isGameOver() { | ||
27 | return false; | ||
28 | } | ||
29 | |||
30 | public double remainingTime() { | ||
31 | return 0; | ||
32 | } | ||
33 | |||
34 | public Optional<PlayerID> winner() { | ||
35 | return null; | ||
36 | } | ||
37 | |||
38 | public Board board() { | ||
39 | return null; | ||
40 | } | ||
41 | |||
42 | public List<Player> players() { | ||
43 | return null; | ||
44 | } | ||
45 | |||
46 | public List<Player> alivePlayers() { | ||
47 | return null; | ||
48 | } | ||
49 | } | ||
diff --git a/src/ch/epfl/xblast/server/Ticks.java b/src/ch/epfl/xblast/server/Ticks.java index aa08a23..fe3f40c 100644 --- a/src/ch/epfl/xblast/server/Ticks.java +++ b/src/ch/epfl/xblast/server/Ticks.java | |||
@@ -1,5 +1,7 @@ | |||
1 | package ch.epfl.xblast.server; | 1 | package ch.epfl.xblast.server; |
2 | 2 | ||
3 | import ch.epfl.xblast.Time; | ||
4 | |||
3 | /** | 5 | /** |
4 | * The Ticks interface defines durations in ticks of time-sensitive aspects of the game. | 6 | * The Ticks interface defines durations in ticks of time-sensitive aspects of the game. |
5 | * | 7 | * |
@@ -38,4 +40,9 @@ public interface Ticks { | |||
38 | */ | 40 | */ |
39 | int BONUS_DISAPPEARING_TICKS = EXPLOSION_TICKS; | 41 | int BONUS_DISAPPEARING_TICKS = EXPLOSION_TICKS; |
40 | 42 | ||
43 | int TICKS_PER_SECOND = 20; | ||
44 | |||
45 | int TICK_NANOSECOND_DURATION = TICKS_PER_SECOND / Time.NS_PER_S; | ||
46 | |||
47 | int TOTAL_TICKS = 2 * Time.S_PER_MIN * TICKS_PER_SECOND; | ||
41 | } | 48 | } |