-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmastermind.puml
275 lines (240 loc) · 9.14 KB
/
mastermind.puml
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
@startuml
skinparam style strictuml
skinparam classAttributeIconSize 0
hide enum methods
hide empty members
class MastermindApp {
+ {static} main(args : String[])
}
class controller.GameController {
+ GameController(roundController : RoundController, game : Game)
+ setWindow(window : MastermindWindow)
+ startGame(attemptNumber : Integer, combinationLength : Integer, pawnNumber : Integer, mode : Mode, playerName String, roundNumber Integer)
+ resetGame()
+ nextRound()
+ giveUpRound()
+ endGame()
+ returnToMenu()
}
class controller.RoundController {
+ addRoundObserveur((observer : RoundObserver)
+ setRound(round : Round)
+ launchAttempt(pawns : Pawn[])
+ giveUpRound()
}
class model.Combination {
+ Combination(pawns : Pawn[])
+ setPawns(pawns : Pawn[])
+ getPawn(index : Integer) : Pawn
+ getCombinationLength() : Integer
+ containsPawn(pawn : Pawn) : Boolean
}
class model.Game {
- roundNumber : Integer
+ Game()
+ configureGame(settings : Settings, roundNumber : Integer)
+ nextRound() : Round
+ getFinalScore() : Integer
+ restartGame()
+ addObserver(observer : GameObserver)
- notifyGameStart()
- notifyGameEnd()
}
class model.GameObserver {
+ reactToGameStart(roundNumber : Integer, attemptNumber : Integer, pawnNumber : Integer, combinationLength : Integer, mode Mode)
+ reactToGameEnd(score : Integer, rounds Rounds[], playerName String)
}
enum model.Hint {
+ RIGHT_PLACE
+ WRONG_PLACE
+ ABSENT
}
class model.HintLine {
+ HintLine(combination : Combination, secretCombination : SecretCombination)
+ getHint(index : Integer) : Hint
+ perfectMatch() : Boolean
+ hintLineLength() : Integer
}
enum model.Mode {
+ EASY
+ CLASSIC
+ NUMERIC
}
enum model.Pawn {
+ RED
+ GREEN
+ YELLOW
+ BLUE
+ BLACK
+ ORANGE
+ PURPLE
+ PINK
}
class model.Round {
+ Round(settings : Settings)
+ checkAttempt(combination : Combination) : Boolean
+ computeScore() : Integer
+ giveUpRound()
+ addObserver(observer : RoundObserver)
- notifyAttempt()
- notifyRoundEnd(roundWon : Boolean, score : Integer)
}
interface model.RoundObserver {
+ reactToAttempt(attemptID Integer, hintLine : HintLine)
+ reactToRoundEnd(roundWon : Boolean, score : Integer, secretCombination Combination)
}
class model.SecretCombination extends model.Combination{
+ <<create>> SecretCombination(combinationLength : Integer, pawnNumber : Integer))
}
class model.Settings {
- attemptNumber : Integer
- combinationLength : Integer
- pawnNumber : Integer
- playerName : String
+ Settings(attemptNumber : Integer, combinationLength : Integer, pawnNumber : Integer, mode : Mode, playerName String)
+ getAttemptNumber() : Integer
+ getPlayeurName() : String
+ setMode(mode : Mode)
+ getCombinationLength() : Integer
+ getPawnNumber() : Integer
+ getMode() : Mode
}
class view.MastermindWindow {
+ MastermindWindow(endPanel : EndPanel, gamePanel : GamePanel, startPanel : StartPanel)
+ showStartPanel()
+ showGamePanel()
+ showEndPanel()
+ getStartPanel() : StartPanel
+ getGamePanel() : GamePanel
+ getEndPanel() : EndPanel
}
class view.StartPanel {
- verticalGap : Integer
+ StartPanel(gameController : GameController)
- createVGroup() : GroupLayout.SequentialGroup
- updateVerticalGap
+ setSizeWindow(size : Integer)
+ setSlider(slider Jslider)
+ getMode(indexCB : Integer) : Mode
}
class view.GamePanel implements model.RoundObserver, model.GameObserver{
+ GamePanel(roundController : RoundController, gameController : GameController)
- resizeImage(image : ImageICon, height : Integer, width : Integer) : ImageICon
+ reactToAttempt(attemptId : Integer, hintLine : HintLine)
+ reactToRoundEnd(roundWon : Boolean, score : Integer, secretCombination, Combination)
+ reactToGameStart(roundNumber : Integer, attemptNumber : Integer, pawnNumber : Integer, combinationLength : Integer, mode : Mode)
+ reactToGameEnd(score : Integer, rounds Round[], playeurName : String)
}
class view.EndPanel implements model.GameObserver, model.RoundObserver {
- roundsWon : Integer
+ EndPanel(gameController : GameController)
- resizeImage(image : ImageICon, height : Integer, width : Integer) : ImageICon
+ reactToGameStart(roundNumber : Integer, attemptNumber : Integer, pawnNumber : Integer, combinationLength : Integer, mode : Mode)
+ reactToGameEnd(score : Integer, rounds : Rounds[], playeurName : String)
+ reactToAttempt(attemptId : Integer, hintLine : HintLine)
+ reactToRoundEnd(roundWon : Boolean, score : Integer, secretCombination : Combination)
}
class view.GameBoard {
- selectedColor : Color
- inactiveColor : Color
- defaultColor : Color
- currentAttempt : Integer
+ GameBoard(combinationLength : Integerattempt, attemptNumber : Integer, pawnNumber : Integer)
+ setUpPalette(palette : CombinationBox)
+ prepareAttempt(attemptId : Integer)
+ setHints(hintsId : Integer, colors : Color[])
+ getCombination() : Pawn[]
+ getColors() : Color[]
+ resetBoard()
}
class view.RecapRound{
+ RecapRound(roundId : Integer, colors : Color[], score : Integer, victory : Boolean)
}
class view.Circle {
- color : Color
- diameter : Integer
+ Circle(diameter : Integer, color : Color)
+ setColor(color : Color)
+ getColor() : Color
}
abstract class view.HintBox {
{static} + defaultColor : Color
{abstract} + setHintsColor(colors : Color[])
}
class view.NumericHintBox extends view.HintBox {
- rightPlacedColor : Color
- wrongPlacedColor : Color
+ NumericHintBox(rightPlacedColor : Color, wrongPlacedColor : Color)
+ setHintsColors(colors : Color[])
}
class view.ClassicHintBox extends view.HintBox {
+ ClassicHintBox(combinationLenght : Integer)
+ setHintsColors(colors : Color[])
}
class view.CombinationBox {
+ CombinationBox(combinationLenght : Integer, defaultColor : Color)
+ CombinationBox(colors : Color[])
+ setPawnColor(n : Integer, color : Color)
+ setClickEvent(mouseAdapteur : MouseAdapteur)
+ unsetClickEvent()
}
interface view.HintDisplayMode {
+ convertHintLine(hintLine : HintLine) : Color[]
}
class view.ClassicMode implements view.HintDisplayMode {
+ convertHintLine(hintLine : HintLine) : Color[]
}
class view.EasyMode implements view.HintDisplayMode {
+ convertHintLine(hintLine : HintLine) : Color[]
}
class view.CombinationConverter {
+ colorsToPawns(colors : Color[]) : Pawn[]
+ pawnToColor(pawn : Pawn) : Color
}
MastermindApp ..> "<<uses>>" view.MastermindWindow
MastermindApp ..> "<<uses>>" view.EndPanel
MastermindApp ..> "<<uses>>" view.StartPanel
MastermindApp ..> "<<uses>>" view.GamePanel
MastermindApp ..> "<<uses>>" model.Game
MastermindApp ..> "<<uses>>" controller.GameController
MastermindApp ..> "<<uses>>" controller.RoundController
controller.GameController ..> "<<uses>>" model.Settings
controller.GameController o--> "1\n-roundController" controller.RoundController : voie >
controller.GameController o--> "1\n-window" view.MastermindWindow : dirige >
controller.GameController o-> "1\n-game" model.Game : gère >
controller.RoundController o-> "1\n-round" model.Round : gère >
controller.RoundController ..> "<<uses>>" model.Combination
controller.RoundController ..> "<<uses>>" model.Pawn
controller.RoundController o--> "*\n-roundObservers" model.RoundObserver
model.Game o--> "1\n-settings" model.Settings : Configure <
model.Game *---> "1 .. 5\n-rounds" model.Round : contient >
model.Game o--> "*\n-observers" model.GameObserver
model.Round o--> "1\n-settings" model.Settings : Configure <
model.Round *--> "1\n-secretCombination" model.SecretCombination : conserve >
model.Round o--> "1 .. 12\n-attempts" model.Combination : garde >
model.Round o--> "1 .. 12\n-hintLines" model.HintLine : > garde
model.Round ..> "<<uses>>" model.Hint
model.Round ..> "<<uses>>" model.Mode
model.Round o--> "*\n-observers" model.RoundObserver
model.Settings o--> "1\n-mode" model.Mode : influence <
model.HintLine o-> "2 .. 6\n-hints" model.Hint : contient >
model.Combination o--> "2 .. 6\n-pawns" model.Pawn : compose <
view.MastermindWindow o-> "1\n-gamePanel" view.GamePanel : contient >
view.MastermindWindow o-> "1\n-startPanel" view.StartPanel : contient >
view.MastermindWindow o--> "1\n-endPanel" view.EndPanel : contient >
view.StartPanel ..> "<<uses>>" model.Mode
view.EndPanel ..> "<<uses>>" view.RecapRound
view.EndPanel ..> "<<uses>>" controller.GameController
view.GamePanel o--> "1\n-displayMode" view.HintDisplayMode : utilise >
view.GamePanel o--> "1\n-gameBoard" view.GameBoard : utilise >
view.GamePanel o--> "1\n-gameControlleur" controller.GameController : utilise >
view.GamePanel ..> "<<uses>>" controller.RoundController
view.GameBoard ..> "<<uses>>" view.Circle
view.GameBoard ..> "<<uses>>" model.Pawn
view.GameBoard *--> "*\n-attempts" CombinationBox
view.GameBoard *--> "*\n-hints" HintBox
view.GameBoard *--> "1\n-converter" view.CombinationConverter
view.CombinationConverter ..> "<<uses>>" model.Pawn
view.ClassicHintBox ..> "<<uses>>" view.Circle
view.RecapRound ...> "<<uses>>" view.CombinationBox
@enduml