aboutsummaryrefslogtreecommitdiff
path: root/src/docs/class.puml
blob: 68aaf5e0b94d09ce5be55146e7ec107af3a01ff7 (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
@startuml

skinparam linetype ortho

package utils {
  class PathFinder {
    static List<Vec2> findPath(Board, TileVec2, TileVec2)
  }

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

package viewer {
  class Viewer {
    Game
    Stage
    void main(String[])
    void eventLoop(ApplicationContext)
    void renderFrame(Graphics2D,ApplicationContext)
  }
}

package context {
  class Context {
    Context(Stage,List<Event>,GraphicsContext)
    final Stage
    final List<Event>
    final GraphicsContext
  }

  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 {
    final GameController
    int index
    final List<Board>
    Game(GameController,List<Board>)
  }
}

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 ExplosionEvent implements GameEvent {
    Block source
    Body source
  }
}

package board {
  class Board {
    Board(width, height)
    BlockType getBlockTypeAt(TileVec2)
    BlockType setBlockTypeAt(TileVec2, BlockType)
  }

  class BoardParser {
    static Board parse(File)
  }

  class BoardValidator {
    static bool validate(Board)
  }

  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()
  }
}

package model {
  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 {
    StageController
    List<Block>
    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
  class StageController 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