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

skinparam linetype ortho
skinparam monochrome reverse
skinparam backgroundColor #FFFFFF

package viewer {
  class Viewer {
    final Game
    Viewer(List<Board>)
    void eventLoop(ApplicationContext)
  }

  class Main {
    static void main(String[])
  }

  class StopWatich {
    Duration peek()
  }
}

package context {
  interface Updateable {
    Stream<Event> update(Context)
  }

  class Updateables {
    static Stream<Event> updateAll(Context, List<Updateable>)
    static Stream<Event> updateAll(Context, Updateable...)
  }

  class Context {
    Context(Game, List<Event>, GraphicsContext)
    Game getGame()
    List<Event> getEvents()
    GraphicsContext getGraphicsContext()
    Duration getTimeDelta()
  }

  class GraphicsContext {
    Graphics2D, ScreenInfo

    paintCircle(Color, Vec2, float)
    paintSquare(Color, Vec2, float, float)
    paintString(Color, Vec2,String)
  }

  class Game implements Updateable {
    Stage
    final List<Controller>
    int indexBoard
    final List<Board>
    bool over

    Game(List<Board>)
    Stage getStage()
    bool isOver()
    Stream<Event> update(Context)
  }

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

package event {
  class Events {
    static <T extends Event> Stream<T> filter(List<Event>, Class<T>)
    static <T extends Event> Optional<T> findFirst(List<Event>, Class<T>)
  }

  interface Event
  interface GameEvent implements Event
  interface InputEvent implements Event

  class ConfirmOrder implements InputEvent
  class BombSetupOrder implements InputEvent

  class MoveRobotOrder implements InputEvent {
    MoveRobotEvent(TileVec2)
    TileVec2 getTarget()
  }

  class BombSetupEvent implements GameEvent {
    BombSetupEvent(TileVec2)
    TileVec2 getSource()
  }

  class BombExplosionEvent implements GameEvent {
    BombExplosionEvent(TileVec2)
    TileVec2 getSource()
  }

  class GameOverEvent implements GameEvent
  class BlockCreateEvent implements GameEvent
  class BlockDestroyEvent implements GameEvent
}

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

    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)

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

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

  class PathFinder {
    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 implements Updateable {
    Block(BlockType)
    BlockType getType()
    TileVec2 getTile()
    abstract Vec2 getPos()
    abstract void link(World)
  }
  
  abstract class JBoxBlock extends Block {
    JBoxBlock(BlockType, BodyType, Shape, Vec2)
    Vec2 getPos()
    void link(World)
    void unlink(World)
    Stream<ContactEdge> streamContactEdges()
  }
  
  class RobotBlock extends Block {
    Vec2 getPos()
    void link(World world)
    Stream<Event> update(Context)
  }

  class WallBlock extends JBoxBlock {
    Stream<Event> update(Context)
  }

  class TrashBlock extends JBoxBlock {
    Stream<Event> update(Context)
  }

  class BombBlock extends JBoxBlock {
    Stream<Event> update(Context)
  }

  class GarbageBlock extends JBoxBlock {
    Stream<Event> update(Context)
  }
}

@enduml