aboutsummaryrefslogtreecommitdiff
path: root/src/docs/class.puml
blob: 8dffde5decc5e398b53e94251eb08862ed31b18c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
@startuml

skinparam linetype ortho

package utils {
  class Matrix {
    static int getWidth(...)
    static int getHeight(...)
    static boolean isShapeValid(...)
  }
}

package viewer {
  class Viewer {
    final Game
    Viewer(List<Board>)
    void main(String[])
    void eventLoop(ApplicationContext)
    void renderFrame(Graphics2D,ApplicationContext,List<Event>)
  }
}

package context {
  class Context {
    Context(Game,List<Event>,GraphicsContext)
    final Game
    final List<Event>
    final GraphicsContext
    Game getGame()
    List<Event> getEvents()
    GraphicsContext getGraphicsContext()
  }

  class GraphicsContext {
    final Graphics2D
    final ScreenInfo
    paintCircle(Color, Vec2, float)
    paintSquare(Color, Vec2, float, float)
  }

  class InputHandler {
    private final ApplicationContext
    InputHandler(ApplicationContext)
    List<Event> getEvents()
  }

  class ScreenManager {
    private final ApplicationContext
    private final Graphics2D
    ScreenManager(ApplicationContext,Graphics2D)
    GraphicsContext clearScreen()
  }

  class Game {
    Stage
    final List<Controller>
    int indexBoard
    final List<Board>
    bool over
    Game(List<Board>)
    Stage getStage()
    bool isOver()
    void setOver()
    void nextStage()
    void retryStage()
    List<Event> update(Context context)
  }
}

package event {
  interface Event

  interface InputEvent implements Event
  interface GameEvent implements Event

  class DropBombEvent implements InputEvent

  class AddBombEvent implements InputEvent {
    final TileVec2
    AddBombEvent(TileVec2)
    TileVec2 getTile()
  }

  class MoveRobotEvent implements InputEvent {
    final TileVec2
    MoveRobotEvent(TileVec2)
    TileVec2 getTile()
  }

  class ConfirmEvent implements InputEvent
  class GameOverEvent implements Event


  class ExplosionEvent implements GameEvent {
    Block source
    Body source
  }
}

package board {
  class Board {
    Board(width, height)
    BlockType getBlockTypeAt(TileVec2)
    BlockType setBlockTypeAt(TileVec2, BlockType)
    Stream<Map.Entry<TileVec2, BlockType>> stream()
  }

  class BoardParser {
    static Board parse(File)
  }

  class BoardValidator {
    static class Constraint
    Board

    BoardValidator(Board)
    BoardValidator validate(Predicate<Board>, String error)
    Board get()
  }

  class BoardConverter {
    static Board worldToBoard(List<Block>)
    static List<Block> boardToWorld(Board)
  }

  class TileVec2 {
    static final int TILE_DIM
    static TileVec2 fromVec2(Vec2)

    Vec2
    TileVec2(col, row)
    Vec2 toPixelPos()
    List<TileVec2> neighbors()
  }

  class PathFinder {
    Graph

    PathFinder(Board)
    List<TileVec2> findPath(TileVec2 origin, TileVec2 target)
  }
}

package block {
  enum BlockType {
    FREE
    WALL
    TRASH
    GARBAGE
    ROBOT
    BOMB

    boolean isBounding()
    boolean mustBeReachable()
    boolean isTraversable()
    boolean isMovableByExplosion()
  }

  class BlockFactory {
    Block build(BlockType, TileVec2)
  }

  abstract class Block {
    BlockType
    List<Controller>
    Vec2

    Block(BlockType, List<Controller>, Vec2)
    void setPos(Vec2)
    BlockType getBlockType()
    Vec2 getPos()
    TileVec2 getTile()
    List<Event> update(Context)
  }

  class WallBlock extends Block
  class TrashBlock extends Block
  class BombBlock extends Block
  class GarbageBlock extends Block
  class RobotBlock extends Block

  class Stage {
    List<Block>
    Board
    Stage(Board)
    List<Block> getBlocks()
    List<Event> update(Context)
    bool isCleared()
  }
}

package controller {
  interface Controller {
    List<Event> update(Context)
  }

  abstract class BlockController implements Controller {
    Block
    Controller(Block)
  }

  class BlockControllerFactory {
    BlockController build(Block)
  }
  class GameController implements Controller

  abstract class PhysicsController extends BlockController
  abstract class DisplayController extends BlockController

  class WallPhysicsController extends PhysicsController
  class WallDisplayController extends DisplayController

  class TrashPhysicsController extends PhysicsController
  class TrashDisplayController extends DisplayController

  class GarbagePhysicsController extends PhysicsController
  class GarbageDisplayController extends DisplayController

  class RobotPhysicsController extends PhysicsController {
    List<TileVec2> path
  }

  class RobotDisplayController extends DisplayController

  class BombPhysicsController extends PhysicsController
  class BombDisplayController extends DisplayController
}

RobotPhysicsController --> PathFinder
RobotPhysicsController --> BoardConverter

Stage --> BoardConverter

PhysicsController --() JBox2D
Zen5 ()-- Viewer

viewer --> context
viewer --> model

context --> event

model --> controller

board --> model

@enduml