diff options
Diffstat (limited to 'src')
9 files changed, 143 insertions, 46 deletions
diff --git a/src/docs/class.puml b/src/docs/class.puml index 869a707..6a527ae 100644 --- a/src/docs/class.puml +++ b/src/docs/class.puml | |||
@@ -12,20 +12,23 @@ package utils { | |||
12 | 12 | ||
13 | package viewer { | 13 | package viewer { |
14 | class Viewer { | 14 | class Viewer { |
15 | Game | 15 | final Game |
16 | Stage | 16 | Viewer(List<Board>) |
17 | void main(String[]) | 17 | void main(String[]) |
18 | void eventLoop(ApplicationContext) | 18 | void eventLoop(ApplicationContext) |
19 | void renderFrame(Graphics2D,ApplicationContext) | 19 | void renderFrame(Graphics2D,ApplicationContext,List<Event>) |
20 | } | 20 | } |
21 | } | 21 | } |
22 | 22 | ||
23 | package context { | 23 | package context { |
24 | class Context { | 24 | class Context { |
25 | Context(Stage,List<Event>,GraphicsContext) | 25 | Context(Game,List<Event>,GraphicsContext) |
26 | final Stage | 26 | final Game |
27 | final List<Event> | 27 | final List<Event> |
28 | final GraphicsContext | 28 | final GraphicsContext |
29 | Game getGame() | ||
30 | List<Event> getEvents() | ||
31 | GraphicsContext getGraphicsContext() | ||
29 | } | 32 | } |
30 | 33 | ||
31 | class GraphicsContext { | 34 | class GraphicsContext { |
@@ -49,10 +52,18 @@ package context { | |||
49 | } | 52 | } |
50 | 53 | ||
51 | class Game { | 54 | class Game { |
52 | final GameController | 55 | Stage |
53 | int index | 56 | final List<Controller> |
57 | int indexBoard | ||
54 | final List<Board> | 58 | final List<Board> |
55 | Game(GameController,List<Board>) | 59 | bool over |
60 | Game(List<Board>) | ||
61 | Stage getStage() | ||
62 | bool isOver() | ||
63 | void setOver() | ||
64 | void nextStage() | ||
65 | void retryStage() | ||
66 | List<Event> update(Context context) | ||
56 | } | 67 | } |
57 | } | 68 | } |
58 | 69 | ||
@@ -77,6 +88,8 @@ package event { | |||
77 | } | 88 | } |
78 | 89 | ||
79 | class ConfirmEvent implements InputEvent | 90 | class ConfirmEvent implements InputEvent |
91 | class GameOverEvent implements Event | ||
92 | |||
80 | 93 | ||
81 | class ExplosionEvent implements GameEvent { | 94 | class ExplosionEvent implements GameEvent { |
82 | Block source | 95 | Block source |
@@ -157,8 +170,8 @@ package model { | |||
157 | class RobotBlock extends Block | 170 | class RobotBlock extends Block |
158 | 171 | ||
159 | class Stage { | 172 | class Stage { |
160 | StageController | ||
161 | List<Block> | 173 | List<Block> |
174 | Board | ||
162 | Stage(Board) | 175 | Stage(Board) |
163 | List<Block> getBlocks() | 176 | List<Block> getBlocks() |
164 | List<Event> update(Context) | 177 | List<Event> update(Context) |
@@ -179,9 +192,7 @@ package controller { | |||
179 | class BlockControllerFactory { | 192 | class BlockControllerFactory { |
180 | BlockController build(Block) | 193 | BlockController build(Block) |
181 | } | 194 | } |
182 | |||
183 | class GameController implements Controller | 195 | class GameController implements Controller |
184 | class StageController implements Controller | ||
185 | 196 | ||
186 | abstract class PhysicsController extends BlockController | 197 | abstract class PhysicsController extends BlockController |
187 | abstract class DisplayController extends BlockController | 198 | abstract class DisplayController extends BlockController |
diff --git a/src/main/java/fr/umlv/java/wallj/board/BoardConverter.java b/src/main/java/fr/umlv/java/wallj/board/BoardConverter.java index 6231875..c4d47cc 100644 --- a/src/main/java/fr/umlv/java/wallj/board/BoardConverter.java +++ b/src/main/java/fr/umlv/java/wallj/board/BoardConverter.java | |||
@@ -6,13 +6,17 @@ import java.util.ArrayList; | |||
6 | import java.util.List; | 6 | import java.util.List; |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * Operations of conversion on Board and List of blocks | ||
9 | * @author Adam NAILI | 10 | * @author Adam NAILI |
10 | */ | 11 | */ |
11 | public final class BoardConverter { | 12 | public final class BoardConverter { |
12 | //TODO | ||
13 | private BoardConverter() { | 13 | private BoardConverter() { |
14 | } | 14 | } |
15 | 15 | ||
16 | /** | ||
17 | * @param blocks the list of blocks to convert in a board | ||
18 | * @return the converted board | ||
19 | */ | ||
16 | public static Board worldToBoard(List<Block> blocks) { | 20 | public static Board worldToBoard(List<Block> blocks) { |
17 | int width = blocks.stream().map(Block::getTile).mapToInt(TileVec2::getCol).max().orElse(-1) + 1; | 21 | int width = blocks.stream().map(Block::getTile).mapToInt(TileVec2::getCol).max().orElse(-1) + 1; |
18 | int height = blocks.stream().map(Block::getTile).mapToInt(TileVec2::getRow).max().orElse(-1) + 1; | 22 | int height = blocks.stream().map(Block::getTile).mapToInt(TileVec2::getRow).max().orElse(-1) + 1; |
@@ -24,6 +28,10 @@ public final class BoardConverter { | |||
24 | return builder.build(); | 28 | return builder.build(); |
25 | } | 29 | } |
26 | 30 | ||
31 | /** | ||
32 | * @param board the board to convert into a list of blocks | ||
33 | * @return the list of blocks converted | ||
34 | */ | ||
27 | public static List<Block> boardToWorld(Board board) { | 35 | public static List<Block> boardToWorld(Board board) { |
28 | ArrayList<Block> blocks = new ArrayList<>(); | 36 | ArrayList<Block> blocks = new ArrayList<>(); |
29 | int nbRow = board.getDim().getRow(); | 37 | int nbRow = board.getDim().getRow(); |
@@ -31,7 +39,7 @@ public final class BoardConverter { | |||
31 | for (int i = 0; i < nbRow; i++) { | 39 | for (int i = 0; i < nbRow; i++) { |
32 | for (int j = 0; j < nbCol; j++) { | 40 | for (int j = 0; j < nbCol; j++) { |
33 | Block block; | 41 | Block block; |
34 | TileVec2 location = TileVec2.of(j,i); | 42 | TileVec2 location = TileVec2.of(j, i); |
35 | block = BlockFactory.build(board.getBlockTypeAt(location), location); | 43 | block = BlockFactory.build(board.getBlockTypeAt(location), location); |
36 | if (block != null) { | 44 | if (block != null) { |
37 | blocks.add(block); | 45 | blocks.add(block); |
diff --git a/src/main/java/fr/umlv/java/wallj/context/Context.java b/src/main/java/fr/umlv/java/wallj/context/Context.java index 053bc8e..01b1f3f 100644 --- a/src/main/java/fr/umlv/java/wallj/context/Context.java +++ b/src/main/java/fr/umlv/java/wallj/context/Context.java | |||
@@ -13,17 +13,17 @@ import java.util.Objects; | |||
13 | */ | 13 | */ |
14 | public final class Context { | 14 | public final class Context { |
15 | //TODO Class Context | 15 | //TODO Class Context |
16 | private final Stage stage; | 16 | private final Game game; |
17 | private final List<Event> events; | 17 | private final List<Event> events; |
18 | private final GraphicsContext graphicsContext; | 18 | private final GraphicsContext graphicsContext; |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * @param stage the current stage | 21 | * @param game the current game |
22 | * @param events the list of events of the tick | 22 | * @param events the list of events of the tick |
23 | * @param graphicsContext the current graphics context | 23 | * @param graphicsContext the current graphics context |
24 | */ | 24 | */ |
25 | public Context(Stage stage, List<Event> events, GraphicsContext graphicsContext) { | 25 | public Context(Game game, List<Event> events, GraphicsContext graphicsContext) { |
26 | this.stage = Objects.requireNonNull(stage); | 26 | this.game = Objects.requireNonNull(game); |
27 | this.events = Objects.requireNonNull(events); | 27 | this.events = Objects.requireNonNull(events); |
28 | this.graphicsContext = Objects.requireNonNull(graphicsContext); | 28 | this.graphicsContext = Objects.requireNonNull(graphicsContext); |
29 | } | 29 | } |
@@ -31,8 +31,8 @@ public final class Context { | |||
31 | /** | 31 | /** |
32 | * @return the stage | 32 | * @return the stage |
33 | */ | 33 | */ |
34 | public Stage getStage() { | 34 | public Game getGame() { |
35 | return stage; | 35 | return game; |
36 | } | 36 | } |
37 | 37 | ||
38 | /** | 38 | /** |
diff --git a/src/main/java/fr/umlv/java/wallj/context/Game.java b/src/main/java/fr/umlv/java/wallj/context/Game.java index 7ddac02..c7dd6f1 100644 --- a/src/main/java/fr/umlv/java/wallj/context/Game.java +++ b/src/main/java/fr/umlv/java/wallj/context/Game.java | |||
@@ -1,66 +1,84 @@ | |||
1 | package fr.umlv.java.wallj.context; | 1 | package fr.umlv.java.wallj.context; |
2 | 2 | ||
3 | import fr.umlv.java.wallj.board.Board; | 3 | import fr.umlv.java.wallj.board.Board; |
4 | import fr.umlv.java.wallj.controller.Controller; | ||
4 | import fr.umlv.java.wallj.controller.GameController; | 5 | import fr.umlv.java.wallj.controller.GameController; |
6 | import fr.umlv.java.wallj.event.Event; | ||
7 | import fr.umlv.java.wallj.model.Stage; | ||
5 | 8 | ||
6 | import java.util.Collections; | 9 | import java.util.*; |
7 | import java.util.List; | ||
8 | import java.util.NoSuchElementException; | ||
9 | import java.util.Objects; | ||
10 | 10 | ||
11 | /** | 11 | /** |
12 | * A game. | 12 | * A game. |
13 | * | ||
13 | * @author Adam NAILI | 14 | * @author Adam NAILI |
14 | */ | 15 | */ |
15 | public final class Game { | 16 | public final class Game { |
16 | //TODO | 17 | private Stage currentStage; |