diff options
25 files changed, 505 insertions, 47 deletions
diff --git a/src/docs/class.puml b/src/docs/class.puml index 21add0d..68aaf5e 100644 --- a/src/docs/class.puml +++ b/src/docs/class.puml | |||
@@ -126,26 +126,33 @@ package model { | |||
126 | GARBAGE | 126 | GARBAGE |
127 | ROBOT | 127 | ROBOT |
128 | BOMB | 128 | BOMB |
129 | |||
130 | boolean isBounding() | ||
131 | boolean mustBeReachable() | ||
132 | boolean isTraversable() | ||
133 | boolean isMovableByExplosion() | ||
129 | } | 134 | } |
130 | 135 | ||
131 | class BlockFactory { | 136 | class BlockFactory { |
132 | Block build(BlockType, Vec2) | 137 | Block build(BlockType, TileVec2) |
133 | } | 138 | } |
134 | 139 | ||
135 | abstract class Block { | 140 | abstract class Block { |
141 | BlockType | ||
136 | List<Controller> | 142 | List<Controller> |
143 | Vec2 | ||
137 | 144 | ||
138 | Block(Vec2) | 145 | Block(BlockType, List<Controller>, Vec2) |
139 | Vec2 getPosition() | 146 | void setPos(Vec2) |
140 | void setPosition(Vec2) | 147 | BlockType getBlockType() |
148 | Vec2 getPos() | ||
149 | TileVec2 getTile() | ||
141 | List<Event> update(Context) | 150 | List<Event> update(Context) |
142 | } | 151 | } |
143 | 152 | ||
144 | abstract class StaticBlock extends Block | 153 | class WallBlock extends Block |
145 | class WallBlock extends StaticBlock | 154 | class TrashBlock extends Block |
146 | class TrashBlock extends StaticBlock | 155 | class BombBlock extends Block |
147 | class BombBlock extends StaticBlock | ||
148 | |||
149 | class GarbageBlock extends Block | 156 | class GarbageBlock extends Block |
150 | class RobotBlock extends Block | 157 | class RobotBlock extends Block |
151 | 158 | ||
@@ -167,7 +174,6 @@ package controller { | |||
167 | abstract class BlockController implements Controller { | 174 | abstract class BlockController implements Controller { |
168 | Block | 175 | Block |
169 | Controller(Block) | 176 | Controller(Block) |
170 | Block getBlock() | ||
171 | } | 177 | } |
172 | 178 | ||
173 | class BlockControllerFactory { | 179 | class BlockControllerFactory { |
diff --git a/src/main/java/fr/umlv/java/wallj/controller/BlockController.java b/src/main/java/fr/umlv/java/wallj/controller/BlockController.java index 7ab6aec..bafa74a 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/BlockController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/BlockController.java | |||
@@ -1,8 +1,21 @@ | |||
1 | package fr.umlv.java.wallj.controller; | 1 | package fr.umlv.java.wallj.controller; |
2 | 2 | ||
3 | import fr.umlv.java.wallj.context.Context; | 3 | import fr.umlv.java.wallj.context.Context; |
4 | import fr.umlv.java.wallj.event.Event; | ||
5 | import fr.umlv.java.wallj.model.Block; | ||
6 | |||
7 | import java.util.List; | ||
8 | import java.util.Objects; | ||
9 | |||
10 | public abstract class BlockController implements Controller { | ||
11 | |||
12 | private final Block block; | ||
13 | |||
14 | BlockController(Block block) { | ||
15 | this.block = Objects.requireNonNull(block); | ||
16 | } | ||
4 | 17 | ||
5 | public abstract class BlockController implements Controller{ | ||
6 | //TODO Check UML to implement BlockController | 18 | //TODO Check UML to implement BlockController |
7 | public abstract void update(Context context); | 19 | public abstract List<Event> update(Context context); |
20 | |||
8 | } | 21 | } |
diff --git a/src/main/java/fr/umlv/java/wallj/controller/BlockControllerFactory.java b/src/main/java/fr/umlv/java/wallj/controller/BlockControllerFactory.java index c820315..89d45ca 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/BlockControllerFactory.java +++ b/src/main/java/fr/umlv/java/wallj/controller/BlockControllerFactory.java | |||
@@ -1,5 +1,49 @@ | |||
1 | package fr.umlv.java.wallj.controller; | 1 | package fr.umlv.java.wallj.controller; |
2 | 2 | ||
3 | public class BlockControllerFactory { | 3 | import fr.umlv.java.wallj.model.*; |
4 | //TODO | 4 | |
5 | import java.util.Arrays; | ||
6 | import java.util.Collections; | ||
7 | import java.util.List; | ||
8 | |||
9 | /** | ||
10 | * A block controller factory. | ||
11 | * "I am the man who arranges the blocks that descend upon me from up above..." | ||
12 | * | ||
13 | * @author Pacien TRAN-GIRARD | ||
14 | */ | ||
15 | public final class BlockControllerFactory { | ||
16 | |||
17 | /** | ||
18 | * @implNote no Lists.of in JDK8 | ||
19 | */ | ||
20 | private static List<BlockController> listOf(BlockController... controllers) { | ||
21 | return Collections.unmodifiableList(Arrays.asList(controllers)); | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * Builds the controllers for the given block. | ||
26 | * | ||
27 | * @param b block | ||
28 | * @return list of controllers | ||
29 | */ | ||
30 | public static List<BlockController> build(Block b) { | ||
31 | if (b instanceof WallBlock) | ||
32 | return listOf(new WallPhysicsController((WallBlock) b), new WallDisplayController((WallBlock) b)); | ||
33 | if (b instanceof TrashBlock) | ||
34 | return listOf(new TrashPhysicsController((TrashBlock) b), new TrashDisplayController((TrashBlock) b)); | ||
35 | if (b instanceof GarbageBlock) | ||
36 | return listOf(new GarbagePhysicsController((GarbageBlock) b), new GarbageDisplayController((GarbageBlock) b)); | ||
37 | if (b instanceof RobotBlock) | ||
38 | return listOf(new RobotPhysicsController((RobotBlock) b), new RobotDisplayController((RobotBlock) b)); | ||
39 | if (b instanceof BombBlock) | ||
40 | return listOf(new BombPhysicsController((BombBlock) b), new BombDisplayController((BombBlock) b)); | ||
41 | |||
42 | return Collections.emptyList(); | ||
43 | } | ||
44 | |||
45 | private BlockControllerFactory() { | ||
46 | // static class | ||
47 | } | ||
48 | |||
5 | } | 49 | } |
diff --git a/src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java b/src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java index 43452d9..3347b73 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java | |||
@@ -1,10 +1,25 @@ | |||
1 | package fr.umlv.java.wallj.controller; | 1 | package fr.umlv.java.wallj.controller; |
2 | 2 | ||
3 | import fr.umlv.java.wallj.context.Context; | 3 | import fr.umlv.java.wallj.context.Context; |
4 | import fr.umlv.java.wallj.event.Event; | ||
5 | import fr.umlv.java.wallj.model.BombBlock; | ||
6 | |||
7 | import java.util.List; | ||
8 | import java.util.Objects; | ||
4 | 9 | ||
5 | public class BombDisplayController extends DisplayController { | 10 | public class BombDisplayController extends DisplayController { |
11 | |||
12 | private final BombBlock bomb; | ||
13 | |||
14 | BombDisplayController(BombBlock bomb) { | ||
15 | super(bomb); | ||
16 | this.bomb = Objects.requireNonNull(bomb); | ||
17 | } | ||
18 | |||
6 | @Override | 19 | @Override |
7 | public void update(Context context) { | 20 | public List<Event> update(Context context) { |
8 | //TODO | 21 | //TODO |
22 | return null; | ||
9 | } | 23 | } |
24 | |||
10 | } | 25 | } |
diff --git a/src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java b/src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java index 948dcfb..02f00a3 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java | |||
@@ -1,10 +1,25 @@ | |||
1 | package fr.umlv.java.wallj.controller; | 1 | package fr.umlv.java.wallj.controller; |
2 | 2 | ||
3 | import fr.umlv.java.wallj.context.Context; | 3 | import fr.umlv.java.wallj.context.Context; |
4 | import fr.umlv.java.wallj.event.Event; | ||
5 | import fr.umlv.java.wallj.model.BombBlock; | ||