218 lines
5.3 KiB
Plaintext
218 lines
5.3 KiB
Plaintext
|
|
---
|
||
|
|
title: Avalam - Diagramme de classes (complet)
|
||
|
|
---
|
||
|
|
classDiagram
|
||
|
|
|
||
|
|
class AvalamBoard{
|
||
|
|
+SIZE: int
|
||
|
|
-MAX_HEIGHT: int
|
||
|
|
-grid: Tower[][]
|
||
|
|
-gameOver: boolean
|
||
|
|
-result: Result
|
||
|
|
|
||
|
|
+AvalamBoard(Tower[][] initialGrid, Player startingPlayer)
|
||
|
|
+AvalamBoard(Tower[][] initialGrid)
|
||
|
|
-AvalamBoard(Tower[][] grid, Player current, boolean gameOver, Result result)
|
||
|
|
+getTowerAt(int row, int col): Tower
|
||
|
|
-inBounds(int r, int c): boolean
|
||
|
|
-areAdjacent(int r1, int c1, int r2, int c2): boolean
|
||
|
|
-colorForPlayer(Player p): Color
|
||
|
|
+isGameOver(): boolean
|
||
|
|
+getResult(): Result
|
||
|
|
+isLegal(AbstractPly c): boolean
|
||
|
|
+doPly(AbstractPly c): void
|
||
|
|
+iterator(): Iterator<AbstractPly>
|
||
|
|
+safeCopy(): IBoard
|
||
|
|
}
|
||
|
|
|
||
|
|
AvalamBoard "1" *-- "many" Tower
|
||
|
|
AvalamBoard ..> AvalamPly
|
||
|
|
|
||
|
|
class AvalamPly{
|
||
|
|
-xFrom : int
|
||
|
|
-yFrom : int
|
||
|
|
-xTo : int
|
||
|
|
-yTo : int
|
||
|
|
|
||
|
|
+AvalamPly(Player player, int xFrom, int yFrom, int xTo, int yTo)
|
||
|
|
+getXFrom(): int
|
||
|
|
+getXFrom(): int
|
||
|
|
+getXFrom(): int
|
||
|
|
+getXFrom(): int
|
||
|
|
|
||
|
|
+toString(): String
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
class AvalamWindow{
|
||
|
|
-board : AvalamBoard
|
||
|
|
-scoreView : ScoreView
|
||
|
|
-turnView : TurnView
|
||
|
|
-boardView : BoardView
|
||
|
|
-mode: GameMode
|
||
|
|
-botPlayer: Player
|
||
|
|
-idiotBot: IdiotBot
|
||
|
|
-alphaBot: AlphaBetaBot
|
||
|
|
-divineBot: Object
|
||
|
|
-botAnimating: boolean
|
||
|
|
|
||
|
|
+AvalamWindow()
|
||
|
|
+AvalamWindow(GameMode mode)
|
||
|
|
+AvalamWindow(GameMode mode, int alphaDepth)
|
||
|
|
+onBoardUpdated(): void
|
||
|
|
-maybePlayBotTurn(): void
|
||
|
|
-computeScore(Color c): int
|
||
|
|
-turnMessage(): String
|
||
|
|
}
|
||
|
|
|
||
|
|
AvalamWindow *-- AvalamBoard
|
||
|
|
AvalamWindow *-- BoardView
|
||
|
|
AvalamWindow *-- ScoreView
|
||
|
|
AvalamWindow *-- TurnView
|
||
|
|
AvalamWindow --> GameMode
|
||
|
|
|
||
|
|
class BoardLoader{
|
||
|
|
+loadFromFile(String resourcePath): Tower[][]
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
class BoardView{
|
||
|
|
-board: AvalamBoard
|
||
|
|
-backgroundLayer: BackgroundLayer
|
||
|
|
-highlightLayer: HighlightLayer
|
||
|
|
-pieceLayer: PieceLayer
|
||
|
|
-controller: InteractionController
|
||
|
|
-size: int
|
||
|
|
-spacing: int
|
||
|
|
-xBase: int
|
||
|
|
-yBase: int
|
||
|
|
-boardUpdateCallback: Runnable
|
||
|
|
|
||
|
|
+BoardView(AvalamBoard board, Runnable boardUpdateCallback)
|
||
|
|
+getController(): InteractionController
|
||
|
|
+setInteractionEnabled(boolean enabled): void
|
||
|
|
+onBoardUpdated(): void
|
||
|
|
+refresh(): void
|
||
|
|
-boardGrid(): Tower[][]
|
||
|
|
-boardGrid(): Tower[][]
|
||
|
|
}
|
||
|
|
|
||
|
|
BoardView *-- BackgroundLayer
|
||
|
|
BoardView *-- HighlightLayer
|
||
|
|
BoardView *-- PieceLayer
|
||
|
|
BoardView *-- InteractionController
|
||
|
|
BoardView --> AvalamBoard
|
||
|
|
|
||
|
|
class BackgroundLayer{
|
||
|
|
-img: Image
|
||
|
|
+BackgroundLayer(String resourcePath)
|
||
|
|
#paintComponent(Graphics g): void
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
class Color{
|
||
|
|
-YELLOW(int r, int g, int b)
|
||
|
|
-RED(int r, int g, int b)
|
||
|
|
-swingColor: java.awt.Color
|
||
|
|
+Color(int r, int g, int b)
|
||
|
|
+getSwingColor(): java.awt.Color
|
||
|
|
+toPlayer(): fr.iut_fbleau.GameAPI.Player
|
||
|
|
}
|
||
|
|
|
||
|
|
class GameMode{
|
||
|
|
PVP
|
||
|
|
PVBOT
|
||
|
|
PVALPHA
|
||
|
|
PVGOD
|
||
|
|
}
|
||
|
|
|
||
|
|
class HighlightLayer{
|
||
|
|
-xBase: int
|
||
|
|
-yBase: int
|
||
|
|
-spacing: int
|
||
|
|
-size: int
|
||
|
|
-legalMoves: List<Point>
|
||
|
|
|
||
|
|
+HighlightLayer(int xBase, int yBase, int spacing, int size)
|
||
|
|
+setLegalMoves(List<Point> moves): void
|
||
|
|
#paintComponent(Graphics g): void
|
||
|
|
}
|
||
|
|
|
||
|
|
class InteractionController{
|
||
|
|
-board: AvalamBoard
|
||
|
|
-selectedRow: int
|
||
|
|
-selectedCol: int
|
||
|
|
-legalMoves: List<Point>
|
||
|
|
-view: BoardView
|
||
|
|
|
||
|
|
+InteractionController(AvalamBoard board, BoardView view)
|
||
|
|
+onPieceClicked(int r, int c): void
|
||
|
|
+selectTower(int r, int c): void
|
||
|
|
-clearSelection(): void
|
||
|
|
-computeLegalMoves(): void
|
||
|
|
-tryMove(int r, int c): void
|
||
|
|
}
|
||
|
|
|
||
|
|
InteractionController --> AvalamBoard
|
||
|
|
InteractionController --> BoardView
|
||
|
|
|
||
|
|
class Main{
|
||
|
|
+main(String[] args): void
|
||
|
|
}
|
||
|
|
|
||
|
|
Main ..> AvalamWindow
|
||
|
|
Main ..> GameMode
|
||
|
|
|
||
|
|
class PieceButton{
|
||
|
|
-color: java.awt.Color
|
||
|
|
-height: int
|
||
|
|
-hover: boolean
|
||
|
|
+row: int
|
||
|
|
+col: int
|
||
|
|
|
||
|
|
+PieceButton(java.awt.Color c, int height, int row, int col)
|
||
|
|
#paintComponent(Graphics g): void
|
||
|
|
+contains(int x, int y): boolean
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
class PieceLayer{
|
||
|
|
+PieceLayer()
|
||
|
|
+displayGrid(Tower[][] grid, int xBase, int yBase, int spacing, int size, java.util.function.BiConsumer<Integer, Integer> clickCallback): void
|
||
|
|
}
|
||
|
|
|
||
|
|
class ScoreView{
|
||
|
|
-scoreY: JLabel
|
||
|
|
-scoreR: JLabel
|
||
|
|
|
||
|
|
+ScoreView(int y, int r)
|
||
|
|
+updateScores(int y, int r): void
|
||
|
|
}
|
||
|
|
|
||
|
|
class Tower{
|
||
|
|
-height: byte
|
||
|
|
-color: Color
|
||
|
|
|
||
|
|
+Tower(int height, Color color)
|
||
|
|
+createTower(Color color): Tower
|
||
|
|
+getHeight(): int
|
||
|
|
+getColor(): Color
|
||
|
|
+mergeTower(Tower src): void
|
||
|
|
+toString(): String
|
||
|
|
}
|
||
|
|
|
||
|
|
Tower --> Color
|
||
|
|
|
||
|
|
class TurnView{
|
||
|
|
-text: JLabel
|
||
|
|
|
||
|
|
+TurnView(String initial)
|
||
|
|
+setTurn(String s): void
|
||
|
|
}
|
||
|
|
|
||
|
|
BoardLoader ..> Tower
|
||
|
|
PieceLayer ..> Tower
|
||
|
|
PieceButton ..> Tower
|