Skip to content

Commit 49290b8

Browse files
Add gradins bruts visu from game status
1 parent aea30a1 commit 49290b8

File tree

2 files changed

+74
-9
lines changed

2 files changed

+74
-9
lines changed
Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,84 @@
1-
import { Point } from 'app/models/Point';
21
import Konva from 'konva';
3-
import { TABLE } from '../../../constants/constants';
4-
import {GameStatus, Team, } from '../../../models/showMustGoOn/GameStatus';
2+
import {TABLE} from '../../../constants/constants';
3+
import {
4+
GameStatus,
5+
GradinBrut, GradinBrutId,
6+
Team,
7+
} from '../../../models/showMustGoOn/GameStatus';
58

69
export class GameStatusManager {
10+
gradinsBruts: Konva.Group;
711

812
constructor(private mainLayer: Konva.Layer) {
9-
13+
this.gradinsBruts = new Konva.Group();
14+
this.mainLayer.add(this.gradinsBruts);
15+
this.gradinsBruts.moveToBottom();
1016
}
1117

1218
destroy() {
13-
19+
this.gradinsBruts.destroy()
1420
}
1521

1622
update(status: Partial<GameStatus>, team: Team) {
23+
this.gradinsBruts.destroyChildren()
24+
25+
status.gradinBrutStock?.forEach((gradinBrut) => {
26+
this.addGradinBrut(gradinBrut);
27+
});
28+
}
29+
30+
private addGradinBrut(gradinBrut: GradinBrut) {
31+
if (!gradinBrut.present) return;
1732

33+
const isVertical = !!this.isGradinVertical(gradinBrut.id);
34+
35+
const plancheGroup = new Konva.Group({
36+
x: (gradinBrut.x - (isVertical ? 50 : 200)) * TABLE.imageRatio,
37+
y: (TABLE.height - gradinBrut.y - (isVertical ? -200 : 50)) * TABLE.imageRatio,
38+
width: 400,
39+
height: 100,
40+
scaleX: TABLE.imageRatio,
41+
scaleY: TABLE.imageRatio,
42+
rotation: isVertical ? -90 : 0,
43+
})
44+
45+
const planche = new Konva.Rect({
46+
x: 0,
47+
y: 0,
48+
width: 400,
49+
height: 100,
50+
strokeWidth: gradinBrut.bloque ? 10 : 0,
51+
fill: '#a97a57',
52+
stroke: '#ff0000'
53+
})
54+
plancheGroup.add(planche)
55+
planche.moveToBottom()
56+
57+
const plancheText = new Konva.Text({
58+
text: gradinBrut.id.split('_').slice(1, 3).join(' '),
59+
x: 0,
60+
y: 0,
61+
width: 400,
62+
height: 100,
63+
align: 'center',
64+
verticalAlign: 'middle',
65+
fontSize: 40,
66+
fontStyle: 'bold',
67+
fill: 'black',
68+
stroke: 'white',
69+
strokeWidth: 5,
70+
fillAfterStrokeEnabled: true,
71+
})
72+
plancheGroup.add(plancheText)
73+
plancheText.moveToTop()
74+
75+
this.gradinsBruts.add(plancheGroup)
1876
}
77+
78+
private isGradinVertical = (id: GradinBrutId): boolean => ([
79+
GradinBrutId.JAUNE_HAUT_GAUCHE,
80+
GradinBrutId.JAUNE_BAS_GAUCHE,
81+
GradinBrutId.BLEU_HAUT_DROITE,
82+
GradinBrutId.BLEU_BAS_DROITE,
83+
].includes(id))
1984
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ export class MouvementsMockService extends MouvementsService {
7171
},
7272
gameStatus: {
7373
gradinBrutStock: [
74-
{ x: 825, y: 1725, id: GradinBrutId.JAUNE_RESERVE, present: true, bloque: false },
75-
{ x: 75, y: 1325, id: GradinBrutId.JAUNE_HAUT_GAUCHE, present: true, bloque: false },
74+
{ x: 825, y: 1725, id: GradinBrutId.JAUNE_RESERVE, present: false, bloque: false },
75+
{ x: 75, y: 1325, id: GradinBrutId.JAUNE_HAUT_GAUCHE, present: true, bloque: true },
7676
{ x: 1100, y: 950, id: GradinBrutId.JAUNE_MILIEU_CENTRE, present: true, bloque: false },
7777
{ x: 75, y: 400, id: GradinBrutId.JAUNE_BAS_GAUCHE, present: true, bloque: false },
7878
{ x: 775, y: 250, id: GradinBrutId.JAUNE_BAS_CENTRE, present: true, bloque: false },
7979
{ x: 2175, y: 1725, id: GradinBrutId.BLEU_RESERVE, present: true, bloque: false },
8080
{ x: 2925, y: 1325, id: GradinBrutId.BLEU_HAUT_DROITE, present: true, bloque: false },
81-
{ x: 1900, y: 950, id: GradinBrutId.BLEU_MILIEU_CENTRE, present: true, bloque: false },
82-
{ x: 2925, y: 400, id: GradinBrutId.BLEU_BAS_DROITE, present: true, bloque: false },
81+
{ x: 1900, y: 950, id: GradinBrutId.BLEU_MILIEU_CENTRE, present: true, bloque: true },
82+
{ x: 2925, y: 400, id: GradinBrutId.BLEU_BAS_DROITE, present: false, bloque: false },
8383
{ x: 2225, y: 250, id: GradinBrutId.BLEU_BAS_CENTRE, present: true, bloque: false }
8484
],
8585

0 commit comments

Comments
 (0)