-
Notifications
You must be signed in to change notification settings - Fork 3
/
TileHeatmaps.ts
98 lines (96 loc) · 2.47 KB
/
TileHeatmaps.ts
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
import TileTrackerBase from '../TileTrackerBase.js';
import type { SquareData } from '../../interfaces/index.js';
export default {
TILE_OCC_ALL: {
scope: 'global',
unit: '%',
description:
'Tile <loopSqrData> had a piece on it for X% of all moves.',
calc: (data: TileTrackerBase, loopSqrData: SquareData) => {
const { coords } = loopSqrData;
let val =
data.tiles[coords[0]][coords[1]].w.wasOn +
data.tiles[coords[0]][coords[1]].b.wasOn;
val = (val * 100) / data.cntMovesTotal;
return val;
}
},
TILE_OCC_WHITE: {
scope: 'global',
unit: '%',
description:
'Tile <loopSqrData> had a white piece on it for X% of all moves.',
calc: (data: TileTrackerBase, loopSqrData: SquareData) => {
const { coords } = loopSqrData;
let val = data.tiles[coords[0]][coords[1]].w.wasOn;
val = (val * 100) / data.cntMovesTotal;
return val;
}
},
TILE_OCC_BLACK: {
scope: 'global',
unit: '%',
description: 'Tile X had a black piece on it for Y% of all moves.',
calc: (data: TileTrackerBase, loopSqrData: SquareData) => {
const { coords } = loopSqrData;
let val = data.tiles[coords[0]][coords[1]].b.wasOn;
val = (val * 100) / data.cntMovesTotal;
return val;
}
},
TILE_OCC_BY_PIECE: {
scope: 'specific',
unit: '%',
description:
'Selected tile was occupated by piece X during Y% of all moves.',
calc: (
data: TileTrackerBase,
loopSqrData: SquareData,
sqrData: SquareData
) => {
const sqrCoords = sqrData.coords;
const { piece } = loopSqrData;
let val = 0;
if (piece) {
val =
data.tiles[sqrCoords[0]][sqrCoords[1]][piece.color][
piece.name
].wasOn;
}
val = (val * 100) / data.cntMovesTotal;
return val;
}
},
TILE_KILLCOUNT: {
scope: 'global',
unit: '',
description: 'Count of Pieces that were taken on each tile.',
calc: (data: TileTrackerBase, loopSqrData: SquareData) => {
const { coords } = loopSqrData;
const val =
data.tiles[coords[0]][coords[1]].b.wasKilledOn +
data.tiles[coords[0]][coords[1]].w.wasKilledOn;
return val;
}
},
PIECE_MOVED_TO_TILE: {
scope: 'specific',
unit: '',
description: 'Selected piece had tile X as a move target Y times.',
calc: (
data: TileTrackerBase,
loopSqrData: SquareData,
sqrData: SquareData
) => {
const { piece } = sqrData;
const { coords } = loopSqrData;
let val = 0;
if (piece) {
val =
data.tiles[coords[0]][coords[1]][piece.color][piece.name]
.movedTo;
}
return val;
}
}
};