Skip to content

Commit 858021c

Browse files
Add aires construction visu from game status
1 parent 49290b8 commit 858021c

File tree

2 files changed

+68
-12
lines changed

2 files changed

+68
-12
lines changed

src/app/components/map/input/game-status.manager.ts

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
11
import Konva from 'konva';
22
import {TABLE} from '../../../constants/constants';
3-
import {
4-
GameStatus,
5-
GradinBrut, GradinBrutId,
6-
Team,
7-
} from '../../../models/showMustGoOn/GameStatus';
3+
import {GameStatus, GradinBrut, GradinBrutId, Team,} from '../../../models/showMustGoOn/GameStatus';
4+
import {start} from "@popperjs/core";
85

96
export class GameStatusManager {
107
gradinsBruts: Konva.Group;
8+
airesConstruction: Konva.Group;
119

1210
constructor(private mainLayer: Konva.Layer) {
1311
this.gradinsBruts = new Konva.Group();
1412
this.mainLayer.add(this.gradinsBruts);
1513
this.gradinsBruts.moveToBottom();
14+
15+
this.airesConstruction = new Konva.Group();
16+
this.mainLayer.add(this.airesConstruction);
17+
this.airesConstruction.moveToBottom();
1618
}
1719

1820
destroy() {
1921
this.gradinsBruts.destroy()
22+
this.airesConstruction.destroy()
2023
}
2124

2225
update(status: Partial<GameStatus>, team: Team) {
2326
this.gradinsBruts.destroyChildren()
27+
this.airesConstruction.destroyChildren()
2428

2529
status.gradinBrutStock?.forEach((gradinBrut) => {
2630
this.addGradinBrut(gradinBrut);
2731
});
32+
33+
this.addAireConstruction(status.airesConstruction?.petitEquipe, team === Team.JAUNE ? 550 : 2000)
34+
this.addAireConstruction(status.airesConstruction?.grandEquipe, team === Team.JAUNE ? 1000 : 1550)
35+
this.addAireConstruction(status.airesConstruction?.petitAdverse, team === Team.JAUNE ? 2000 : 550)
36+
this.addAireConstruction(status.airesConstruction?.grandAdverse, team === Team.JAUNE ? 1550 : 1000)
2837
}
2938

3039
private addGradinBrut(gradinBrut: GradinBrut) {
@@ -75,6 +84,53 @@ export class GameStatusManager {
7584
this.gradinsBruts.add(plancheGroup)
7685
}
7786

87+
private addAireConstruction(aireConstruction: boolean[][], startX: number) {
88+
aireConstruction.forEach((gradinConstruit, index) => this.addGradinConstruit(gradinConstruit, startX, index))
89+
}
90+
91+
private addGradinConstruit(gradinConstruit: boolean[], startX: number, index: number) {
92+
if (!gradinConstruit[0]) return;
93+
94+
const gradinGroup = new Konva.Group({
95+
x: (startX + 25) * TABLE.imageRatio,
96+
y: (TABLE.height - 150 - index * 125) * TABLE.imageRatio,
97+
width: 400,
98+
height: 100,
99+
scaleX: TABLE.imageRatio,
100+
scaleY: TABLE.imageRatio,
101+
})
102+
103+
const gradin = new Konva.Rect({
104+
x: 0,
105+
y: 0,
106+
width: 400,
107+
height: 100,
108+
fill: '#a97a57',
109+
})
110+
gradinGroup.add(gradin)
111+
gradin.moveToBottom()
112+
113+
const gradinText = new Konva.Text({
114+
text: (gradinConstruit.lastIndexOf(true) + 1).toString(),
115+
x: 0,
116+
y: 0,
117+
width: 400,
118+
height: 100,
119+
align: 'center',
120+
verticalAlign: 'middle',
121+
fontSize: 65,
122+
fontStyle: 'bold',
123+
fill: 'black',
124+
stroke: 'white',
125+
strokeWidth: 5,
126+
fillAfterStrokeEnabled: true,
127+
})
128+
gradinGroup.add(gradinText)
129+
gradinText.moveToTop()
130+
131+
this.gradinsBruts.add(gradinGroup)
132+
}
133+
78134
private isGradinVertical = (id: GradinBrutId): boolean => ([
79135
GradinBrutId.JAUNE_HAUT_GAUCHE,
80136
GradinBrutId.JAUNE_BAS_GAUCHE,

src/app/services/mock/mouvements.mock-service.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,20 @@ export class MouvementsMockService extends MouvementsService {
8585

8686
airesConstruction: {
8787
grandEquipe: [
88-
[ false, false, false ],
89-
[ false, false, false ],
90-
[ false, false, false ],
88+
[ true, true, true ],
89+
[ true, true, false ],
90+
[ true, false, false ],
9191
],
9292
petitAdverse: [
93-
[ false, false, false ],
93+
[ true, true, false ],
9494
],
9595
petitEquipe: [
96-
[ false, false, false ],
96+
[ true, false, false ],
9797
],
9898
grandAdverse: [
9999
[ false, false, false ],
100-
[ false, false, false ],
101-
[ false, false, false ],
100+
[ true, false, false ],
101+
[ true, true, false ],
102102
]
103103
},
104104

0 commit comments

Comments
 (0)