enefel 2.0.7 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/calcul.ts +7 -0
- package/canUseSkills.ts +15 -17
- package/dist/calcul.js +7 -0
- package/dist/canUseSkills.d.ts +4 -5
- package/dist/canUseSkills.js +13 -12
- package/dist/index.d.ts +11 -11
- package/dist/index.js +35 -17
- package/dist/package-lock.json +2 -2
- package/dist/package.json +1 -1
- package/dist/pitch.d.ts +1 -1
- package/dist/position.d.ts +2 -3
- package/dist/position.js +6 -6
- package/dist/stadium.d.ts +6 -37
- package/dist/status.d.ts +18 -19
- package/dist/status.js +13 -13
- package/dist/types/models.d.ts +23 -17
- package/index.ts +39 -13
- package/package.json +1 -1
- package/pitch.ts +1 -1
- package/position.ts +5 -7
- package/stadium.ts +8 -1
- package/status.ts +18 -30
- package/types/models.ts +23 -17
package/calcul.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { Point } from "types/models";
|
|
2
2
|
|
|
3
3
|
export const distance = (p1: Point, p2: Point): number => {
|
|
4
|
+
if (p1.x === null || p1.y === null || p2.x === null || p2.y === null) {
|
|
5
|
+
return Infinity;
|
|
6
|
+
}
|
|
4
7
|
return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
|
|
5
8
|
};
|
|
6
9
|
|
|
10
|
+
// Est ce que distance est inférieure ou égale à distance
|
|
7
11
|
export const distanceSquares = (
|
|
8
12
|
p1: Point,
|
|
9
13
|
p2: Point,
|
|
10
14
|
distance: number
|
|
11
15
|
): boolean => {
|
|
16
|
+
if (p1.x === null || p1.y === null || p2.x === null || p2.y === null) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
12
19
|
return Math.abs(p1.x - p2.x) <= distance && Math.abs(p1.y - p2.y) <= distance;
|
|
13
20
|
};
|
package/canUseSkills.ts
CHANGED
|
@@ -3,11 +3,11 @@ import { SKILL_NAMES, hasSkill } from "./skill";
|
|
|
3
3
|
import { hasStatusFall, hasStatusTacleZone } from "./status";
|
|
4
4
|
import { PlayerWithSkill } from "./types/models";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export const canUseFend = (
|
|
7
7
|
playerFrom: PlayerWithSkill,
|
|
8
8
|
playerTo: PlayerWithSkill,
|
|
9
9
|
isBlitz: boolean
|
|
10
|
-
) {
|
|
10
|
+
) => {
|
|
11
11
|
if (!hasSkill(playerTo, SKILL_NAMES.FEND)) {
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
@@ -15,13 +15,13 @@ function canUseFend(
|
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
17
|
return true;
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
playerFrom: PlayerWithSkill,
|
|
22
|
-
playerTo: PlayerWithSkill,
|
|
23
|
-
isBlitz
|
|
24
|
-
) {
|
|
20
|
+
export const canUseStandFirm = (
|
|
21
|
+
playerFrom: PlayerWithSkill | null,
|
|
22
|
+
playerTo: PlayerWithSkill | null,
|
|
23
|
+
isBlitz?: boolean
|
|
24
|
+
) => {
|
|
25
25
|
if (playerTo && !hasSkill(playerTo, SKILL_NAMES.STAND_FIRM)) {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
@@ -29,13 +29,13 @@ function canUseStandFirm(
|
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
31
|
return true;
|
|
32
|
-
}
|
|
32
|
+
};
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
export const canUseStandWrestle = (
|
|
35
35
|
playerFrom: PlayerWithSkill,
|
|
36
36
|
playerTo: PlayerWithSkill,
|
|
37
37
|
isBlitz: boolean
|
|
38
|
-
) {
|
|
38
|
+
) => {
|
|
39
39
|
if (hasSkill(playerFrom, SKILL_NAMES.JUGGERNAUT) && isBlitz) {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
@@ -46,12 +46,12 @@ function canUseStandWrestle(
|
|
|
46
46
|
return true;
|
|
47
47
|
}
|
|
48
48
|
return false;
|
|
49
|
-
}
|
|
49
|
+
};
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
export const canUsePileDriver = (
|
|
52
52
|
playerFrom: PlayerWithSkill,
|
|
53
53
|
playerTo: PlayerWithSkill
|
|
54
|
-
) {
|
|
54
|
+
) => {
|
|
55
55
|
if (
|
|
56
56
|
hasSkill(playerFrom, SKILL_NAMES.PILE_DRIVER) &&
|
|
57
57
|
hasStatusTacleZone(playerFrom) &&
|
|
@@ -61,6 +61,4 @@ function canUsePileDriver(
|
|
|
61
61
|
return true;
|
|
62
62
|
}
|
|
63
63
|
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { canUseFend, canUsePileDriver, canUseStandFirm, canUseStandWrestle };
|
|
64
|
+
};
|
package/dist/calcul.js
CHANGED
|
@@ -2,10 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.distanceSquares = exports.distance = void 0;
|
|
4
4
|
const distance = (p1, p2) => {
|
|
5
|
+
if (p1.x === null || p1.y === null || p2.x === null || p2.y === null) {
|
|
6
|
+
return Infinity;
|
|
7
|
+
}
|
|
5
8
|
return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
|
|
6
9
|
};
|
|
7
10
|
exports.distance = distance;
|
|
11
|
+
// Est ce que distance est inférieure ou égale à distance
|
|
8
12
|
const distanceSquares = (p1, p2, distance) => {
|
|
13
|
+
if (p1.x === null || p1.y === null || p2.x === null || p2.y === null) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
9
16
|
return Math.abs(p1.x - p2.x) <= distance && Math.abs(p1.y - p2.y) <= distance;
|
|
10
17
|
};
|
|
11
18
|
exports.distanceSquares = distanceSquares;
|
package/dist/canUseSkills.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PlayerWithSkill } from "./types/models";
|
|
2
|
-
declare
|
|
3
|
-
declare
|
|
4
|
-
declare
|
|
5
|
-
declare
|
|
6
|
-
export { canUseFend, canUsePileDriver, canUseStandFirm, canUseStandWrestle };
|
|
2
|
+
export declare const canUseFend: (playerFrom: PlayerWithSkill, playerTo: PlayerWithSkill, isBlitz: boolean) => boolean;
|
|
3
|
+
export declare const canUseStandFirm: (playerFrom: PlayerWithSkill | null, playerTo: PlayerWithSkill | null, isBlitz?: boolean) => boolean;
|
|
4
|
+
export declare const canUseStandWrestle: (playerFrom: PlayerWithSkill, playerTo: PlayerWithSkill, isBlitz: boolean) => boolean;
|
|
5
|
+
export declare const canUsePileDriver: (playerFrom: PlayerWithSkill, playerTo: PlayerWithSkill) => boolean;
|
package/dist/canUseSkills.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.canUseFend =
|
|
4
|
-
exports.canUsePileDriver = canUsePileDriver;
|
|
5
|
-
exports.canUseStandFirm = canUseStandFirm;
|
|
6
|
-
exports.canUseStandWrestle = canUseStandWrestle;
|
|
3
|
+
exports.canUsePileDriver = exports.canUseStandWrestle = exports.canUseStandFirm = exports.canUseFend = void 0;
|
|
7
4
|
const position_1 = require("./position");
|
|
8
5
|
const skill_1 = require("./skill");
|
|
9
6
|
const status_1 = require("./status");
|
|
10
|
-
|
|
7
|
+
const canUseFend = (playerFrom, playerTo, isBlitz) => {
|
|
11
8
|
if (!(0, skill_1.hasSkill)(playerTo, skill_1.SKILL_NAMES.FEND)) {
|
|
12
9
|
return false;
|
|
13
10
|
}
|
|
@@ -15,8 +12,9 @@ function canUseFend(playerFrom, playerTo, isBlitz) {
|
|
|
15
12
|
return false;
|
|
16
13
|
}
|
|
17
14
|
return true;
|
|
18
|
-
}
|
|
19
|
-
|
|
15
|
+
};
|
|
16
|
+
exports.canUseFend = canUseFend;
|
|
17
|
+
const canUseStandFirm = (playerFrom, playerTo, isBlitz) => {
|
|
20
18
|
if (playerTo && !(0, skill_1.hasSkill)(playerTo, skill_1.SKILL_NAMES.STAND_FIRM)) {
|
|
21
19
|
return false;
|
|
22
20
|
}
|
|
@@ -24,8 +22,9 @@ function canUseStandFirm(playerFrom, playerTo, isBlitz) {
|
|
|
24
22
|
return false;
|
|
25
23
|
}
|
|
26
24
|
return true;
|
|
27
|
-
}
|
|
28
|
-
|
|
25
|
+
};
|
|
26
|
+
exports.canUseStandFirm = canUseStandFirm;
|
|
27
|
+
const canUseStandWrestle = (playerFrom, playerTo, isBlitz) => {
|
|
29
28
|
if ((0, skill_1.hasSkill)(playerFrom, skill_1.SKILL_NAMES.JUGGERNAUT) && isBlitz) {
|
|
30
29
|
return false;
|
|
31
30
|
}
|
|
@@ -34,8 +33,9 @@ function canUseStandWrestle(playerFrom, playerTo, isBlitz) {
|
|
|
34
33
|
return true;
|
|
35
34
|
}
|
|
36
35
|
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
36
|
+
};
|
|
37
|
+
exports.canUseStandWrestle = canUseStandWrestle;
|
|
38
|
+
const canUsePileDriver = (playerFrom, playerTo) => {
|
|
39
39
|
if ((0, skill_1.hasSkill)(playerFrom, skill_1.SKILL_NAMES.PILE_DRIVER) &&
|
|
40
40
|
(0, status_1.hasStatusTacleZone)(playerFrom) &&
|
|
41
41
|
(0, status_1.hasStatusFall)(playerTo) &&
|
|
@@ -43,4 +43,5 @@ function canUsePileDriver(playerFrom, playerTo) {
|
|
|
43
43
|
return true;
|
|
44
44
|
}
|
|
45
45
|
return false;
|
|
46
|
-
}
|
|
46
|
+
};
|
|
47
|
+
exports.canUsePileDriver = canUsePileDriver;
|
package/dist/index.d.ts
CHANGED
|
@@ -195,17 +195,17 @@ declare const PLAYER_HISTORY_INFO: {
|
|
|
195
195
|
EXP_KO: string;
|
|
196
196
|
EXP_TD: string;
|
|
197
197
|
};
|
|
198
|
-
declare
|
|
199
|
-
CATCH_PASS
|
|
200
|
-
CATCH_HANDOFF
|
|
201
|
-
PICKUP
|
|
202
|
-
CATCH_BOUNCE
|
|
203
|
-
}
|
|
204
|
-
declare const p: (x: number, y: number) => Point;
|
|
198
|
+
declare enum TAKE_BALL_TYPE {
|
|
199
|
+
CATCH_PASS = "pass",// Reception passe
|
|
200
|
+
CATCH_HANDOFF = "hand-off",// Reception d'une Transmission
|
|
201
|
+
PICKUP = "pick-up",// Ramasse la balle au sol
|
|
202
|
+
CATCH_BOUNCE = "bounce"
|
|
203
|
+
}
|
|
204
|
+
declare const p: (x: number | string, y: number | string) => Point;
|
|
205
205
|
declare function addSeconds(date: Date, days: number): Date;
|
|
206
|
-
declare const isSquareValidToPushBack: (availableSquares: Point[], targetIndex: number, players:
|
|
207
|
-
declare const getPlayerOnCell: (x: number, y: number, players:
|
|
208
|
-
declare const getHypnoticGazeMalus: (player: Player, target: Player, players: Player
|
|
206
|
+
declare const isSquareValidToPushBack: (availableSquares: Point[], targetIndex: number, players: Record<string, PlayerWithSkill>, w: number, h: number, busy?: Point[]) => boolean;
|
|
207
|
+
declare const getPlayerOnCell: (x: number | null, y: number | null, players: Record<string, PlayerWithSkill>) => false | PlayerWithSkill | undefined;
|
|
208
|
+
declare const getHypnoticGazeMalus: (player: Player, target: Player, players: Record<string, Player>) => number;
|
|
209
209
|
declare const getBlockAssistance: (attackerPlayer: PlayerWithSkill, defenderPlayer: PlayerWithSkill, players: PlayerWithSkill[], isAttacker?: boolean) => PlayerWithSkill[];
|
|
210
210
|
declare const getDicesBlock: (attackerStrength: number, defenderStrength: number) => 2 | 1 | 3;
|
|
211
211
|
declare const haveSameTeam: (p1: Player, p2: Player) => boolean;
|
|
@@ -219,7 +219,7 @@ declare const isOnLine: (A: Point, B: Point, C: Point) => boolean;
|
|
|
219
219
|
declare const getThrowingBonus: (p1: Point, p2: Point, game: Game) => 0 | 1 | -1 | -2 | null;
|
|
220
220
|
declare const isOnField: (x: number, y: number, w: number, h: number) => boolean;
|
|
221
221
|
declare const canPlayerIntercepts: (playerFrom: PlayerWithSkill, player: PlayerWithSkill, pointTo: Point) => boolean;
|
|
222
|
-
declare const getBestInterceptor: (playerFrom: PlayerWithSkill, pointTo: Point, players: PlayerWithSkill[]) => null;
|
|
222
|
+
declare const getBestInterceptor: (playerFrom: PlayerWithSkill, pointTo: Point, players: PlayerWithSkill[]) => PlayerWithSkill | null;
|
|
223
223
|
declare function canBlock(attacker: PlayerWithSkill, defender: PlayerWithSkill, attackerTeam: Team, game: Game, withModif?: boolean, checkBlitz?: boolean): boolean;
|
|
224
224
|
declare function canFoul(attacker: PlayerWithSkill, defender: PlayerWithSkill, attackerTeam: Team): boolean;
|
|
225
225
|
declare function canPass(player: PlayerWithSkill, playerTeam: Team, playerIdWithBall: string): boolean;
|
package/dist/index.js
CHANGED
|
@@ -233,13 +233,13 @@ const PLAYER_HISTORY_INFO = {
|
|
|
233
233
|
EXP_TD: "etd",
|
|
234
234
|
};
|
|
235
235
|
exports.PLAYER_HISTORY_INFO = PLAYER_HISTORY_INFO;
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
exports.TAKE_BALL_TYPE = TAKE_BALL_TYPE;
|
|
236
|
+
var TAKE_BALL_TYPE;
|
|
237
|
+
(function (TAKE_BALL_TYPE) {
|
|
238
|
+
TAKE_BALL_TYPE["CATCH_PASS"] = "pass";
|
|
239
|
+
TAKE_BALL_TYPE["CATCH_HANDOFF"] = "hand-off";
|
|
240
|
+
TAKE_BALL_TYPE["PICKUP"] = "pick-up";
|
|
241
|
+
TAKE_BALL_TYPE["CATCH_BOUNCE"] = "bounce";
|
|
242
|
+
})(TAKE_BALL_TYPE || (exports.TAKE_BALL_TYPE = TAKE_BALL_TYPE = {}));
|
|
243
243
|
const p = (x, y) => {
|
|
244
244
|
return { x: +x, y: +y };
|
|
245
245
|
};
|
|
@@ -250,7 +250,9 @@ function addSeconds(date, days) {
|
|
|
250
250
|
return result;
|
|
251
251
|
}
|
|
252
252
|
const isSquareValidToPushBack = (availableSquares, targetIndex, players, w, h, busy = []) => {
|
|
253
|
-
if (!availableSquares[targetIndex]
|
|
253
|
+
if (!availableSquares[targetIndex] ||
|
|
254
|
+
availableSquares[targetIndex].x === null ||
|
|
255
|
+
availableSquares[targetIndex].y === null) {
|
|
254
256
|
return false;
|
|
255
257
|
}
|
|
256
258
|
const player = getPlayerOnCell(availableSquares[targetIndex].x, availableSquares[targetIndex].y, players);
|
|
@@ -263,6 +265,9 @@ const isSquareValidToPushBack = (availableSquares, targetIndex, players, w, h, b
|
|
|
263
265
|
}
|
|
264
266
|
// All the spaces are full, we can't push back
|
|
265
267
|
const noEmptySquares = availableSquares.every((point) => {
|
|
268
|
+
if (point.x === null || point.y === null) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
266
271
|
return (getPlayerOnCell(point.x, point.y, players) ||
|
|
267
272
|
busy.some((b) => b.x === point.x && b.y === point.y) ||
|
|
268
273
|
!isOnField(point.x, point.y, w, h));
|
|
@@ -271,6 +276,9 @@ const isSquareValidToPushBack = (availableSquares, targetIndex, players, w, h, b
|
|
|
271
276
|
};
|
|
272
277
|
exports.isSquareValidToPushBack = isSquareValidToPushBack;
|
|
273
278
|
const getPlayerOnCell = (x, y, players) => {
|
|
279
|
+
if (x === null || y === null) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
274
282
|
return Object.values(players).find((player) => player.x === x && player.y === y && (0, status_1.hasStatusOnField)(player));
|
|
275
283
|
};
|
|
276
284
|
exports.getPlayerOnCell = getPlayerOnCell;
|
|
@@ -364,7 +372,11 @@ const isSamePlayer = (p1, p2) => {
|
|
|
364
372
|
};
|
|
365
373
|
exports.isSamePlayer = isSamePlayer;
|
|
366
374
|
const availableSquaresToPushBack = (p1, p2) => {
|
|
367
|
-
if (!(0, position_1.isAdjacent)(p1, p2)
|
|
375
|
+
if (!(0, position_1.isAdjacent)(p1, p2) ||
|
|
376
|
+
p1.x === null ||
|
|
377
|
+
p1.y === null ||
|
|
378
|
+
p2.x === null ||
|
|
379
|
+
p2.y === null) {
|
|
368
380
|
return [];
|
|
369
381
|
}
|
|
370
382
|
const xFrom = p1.x;
|
|
@@ -543,14 +555,20 @@ const isOnLine = (A, B, C) => {
|
|
|
543
555
|
};
|
|
544
556
|
exports.isOnLine = isOnLine;
|
|
545
557
|
const getThrowingBonus = (p1, p2, game) => {
|
|
546
|
-
if (!
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
558
|
+
if (!p1 ||
|
|
559
|
+
!p2 ||
|
|
560
|
+
p1.x === null ||
|
|
561
|
+
p1.y === null ||
|
|
562
|
+
p2.x === null ||
|
|
563
|
+
p2.y === null ||
|
|
564
|
+
!(Number.isInteger(p1.x) &&
|
|
565
|
+
Number.isInteger(p1.y) &&
|
|
566
|
+
Number.isInteger(p2.x) &&
|
|
567
|
+
Number.isInteger(p2.y) &&
|
|
568
|
+
p1.x >= 0 &&
|
|
569
|
+
p1.y >= 0 &&
|
|
570
|
+
p2.x >= 0 &&
|
|
571
|
+
p2.y >= 0)) {
|
|
554
572
|
return null;
|
|
555
573
|
}
|
|
556
574
|
var dist = (0, calcul_1.distance)(p1, p2);
|
package/dist/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "enefel",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "enefel",
|
|
9
|
-
"version": "2.0
|
|
9
|
+
"version": "2.1.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"seedrandom": "3.0.5",
|
package/dist/package.json
CHANGED
package/dist/pitch.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare function getTdTile(teamNumber: number): TILES.TD1 | TILES.TD2;
|
|
|
21
21
|
declare function getCenterTile(teamNumber: number): TILES.CENTRE1 | TILES.CENTRE2;
|
|
22
22
|
declare function getTile(game: Game, x: number, y: number): string;
|
|
23
23
|
declare function getIndexFromXY(x: number, y: number, width: number): number;
|
|
24
|
-
declare function getHalfStadium(side:
|
|
24
|
+
declare function getHalfStadium(side: 1 | 2, width: number): import("types/models").Point;
|
|
25
25
|
declare function getNumberPlayerZone(teamNumber: number, players: Player[], game: Game): {
|
|
26
26
|
playerScrimmage: number;
|
|
27
27
|
playerLateralA: number;
|
package/dist/position.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { PlayerWithSkill, Point } from "./types/models";
|
|
2
|
-
declare const isAdjacent: (p1: Point, p2: Point) => boolean;
|
|
3
|
-
declare
|
|
4
|
-
export { getEnemyTackleZones, isAdjacent };
|
|
2
|
+
export declare const isAdjacent: (p1: Point, p2: Point) => boolean;
|
|
3
|
+
export declare const getEnemyTackleZones: (location: Point, teamId: string, players: Record<string, PlayerWithSkill>) => PlayerWithSkill[];
|
package/dist/position.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAdjacent = void 0;
|
|
4
|
-
exports.getEnemyTackleZones = getEnemyTackleZones;
|
|
3
|
+
exports.getEnemyTackleZones = exports.isAdjacent = void 0;
|
|
5
4
|
const status_1 = require("./status");
|
|
6
5
|
const isAdjacent = (p1, p2) => {
|
|
7
|
-
if (!p1 || !p2) {
|
|
6
|
+
if (!p1 || !p2 || !p1.x || !p1.y || !p2.x || !p2.y) {
|
|
8
7
|
return false;
|
|
9
8
|
}
|
|
10
9
|
return ((p1.x !== p2.x || p1.y !== p2.y) &&
|
|
@@ -12,12 +11,13 @@ const isAdjacent = (p1, p2) => {
|
|
|
12
11
|
Math.abs(p1.y - p2.y) <= 1);
|
|
13
12
|
};
|
|
14
13
|
exports.isAdjacent = isAdjacent;
|
|
15
|
-
|
|
14
|
+
const getEnemyTackleZones = (location, teamId, players) => {
|
|
16
15
|
// player a un format : { id1: {player1}, id2:{player2} etc...}
|
|
17
16
|
return Object.values(players).filter((player) => {
|
|
18
17
|
const res = (0, status_1.hasStatusTacleZone)(player) &&
|
|
19
18
|
player.teamId !== teamId &&
|
|
20
|
-
isAdjacent(player, location);
|
|
19
|
+
(0, exports.isAdjacent)(player, location);
|
|
21
20
|
return res;
|
|
22
21
|
});
|
|
23
|
-
}
|
|
22
|
+
};
|
|
23
|
+
exports.getEnemyTackleZones = getEnemyTackleZones;
|
package/dist/stadium.d.ts
CHANGED
|
@@ -55,44 +55,13 @@ declare const getTeamStadium: (team: Team, size: STADIUM_SIZE) => {
|
|
|
55
55
|
height: number | undefined;
|
|
56
56
|
width: number | undefined;
|
|
57
57
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
icons: number[];
|
|
64
|
-
};
|
|
65
|
-
b: {
|
|
66
|
-
y: number;
|
|
67
|
-
price: number;
|
|
68
|
-
wear: number;
|
|
69
|
-
icons: number[];
|
|
70
|
-
};
|
|
71
|
-
c: {
|
|
72
|
-
y: number;
|
|
73
|
-
price: number;
|
|
74
|
-
wear: number;
|
|
75
|
-
icons: number[];
|
|
76
|
-
};
|
|
77
|
-
d: {
|
|
78
|
-
y: number;
|
|
79
|
-
price: number;
|
|
80
|
-
wear: number;
|
|
81
|
-
icons: number[];
|
|
82
|
-
};
|
|
83
|
-
e: {
|
|
84
|
-
y: number;
|
|
85
|
-
price: number;
|
|
86
|
-
wear: number;
|
|
87
|
-
icons: number[];
|
|
88
|
-
};
|
|
89
|
-
f: {
|
|
90
|
-
y: number;
|
|
91
|
-
price: number;
|
|
92
|
-
wear: number;
|
|
93
|
-
icons: number[];
|
|
94
|
-
};
|
|
58
|
+
export type TileStadium = {
|
|
59
|
+
y: number;
|
|
60
|
+
price: number;
|
|
61
|
+
wear: number;
|
|
62
|
+
icons: number[];
|
|
95
63
|
};
|
|
64
|
+
declare const TILES_STADIUM: Record<string, TileStadium>;
|
|
96
65
|
declare const minWidth = 20;
|
|
97
66
|
declare const maxWidth = 26;
|
|
98
67
|
declare const minHeight = 11;
|
package/dist/status.d.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { Player } from "types/models";
|
|
2
|
-
declare
|
|
3
|
-
STANDING
|
|
4
|
-
KNOCKED_DOWN
|
|
5
|
-
STUNNED
|
|
6
|
-
RESERVE
|
|
7
|
-
KO
|
|
8
|
-
CASUALTY
|
|
9
|
-
SENDOFF
|
|
10
|
-
BONE_HEAD
|
|
11
|
-
}
|
|
12
|
-
declare const hasStatusCanFaceup: (player: Player) => boolean;
|
|
13
|
-
declare const hasStatusCanStandup: (player: Player) => boolean;
|
|
14
|
-
declare const hasStatusTacleZone: (player: Player) => boolean;
|
|
15
|
-
declare const hasStatusStanding: (player: Player) => boolean;
|
|
16
|
-
declare const hasStatusInjury: (player: Player) => boolean;
|
|
17
|
-
declare const hasStatusFall: (player: Player) => boolean;
|
|
18
|
-
declare const hasStatusOnField: (player: Player) => boolean;
|
|
19
|
-
declare const hasStatusCantPlay: (player: Player) => boolean;
|
|
20
|
-
export { hasStatusCanFaceup, hasStatusCanStandup, hasStatusCantPlay, hasStatusFall, hasStatusInjury, hasStatusOnField, hasStatusStanding, hasStatusTacleZone, PLAYER_STATUS, };
|
|
2
|
+
export declare enum PLAYER_STATUS {
|
|
3
|
+
STANDING = 0,
|
|
4
|
+
KNOCKED_DOWN = 1,// Sur le dos
|
|
5
|
+
STUNNED = 2,// Sur le ventre
|
|
6
|
+
RESERVE = 3,// Dans la réserve
|
|
7
|
+
KO = 4,
|
|
8
|
+
CASUALTY = 5,// Blessé
|
|
9
|
+
SENDOFF = 6,// Expulsé
|
|
10
|
+
BONE_HEAD = 7
|
|
11
|
+
}
|
|
12
|
+
export declare const hasStatusCanFaceup: (player: Player) => boolean;
|
|
13
|
+
export declare const hasStatusCanStandup: (player: Player) => boolean;
|
|
14
|
+
export declare const hasStatusTacleZone: (player: Player) => boolean;
|
|
15
|
+
export declare const hasStatusStanding: (player: Player) => boolean;
|
|
16
|
+
export declare const hasStatusInjury: (player: Player) => boolean;
|
|
17
|
+
export declare const hasStatusFall: (player: Player) => boolean;
|
|
18
|
+
export declare const hasStatusOnField: (player: Player) => boolean;
|
|
19
|
+
export declare const hasStatusCantPlay: (player: Player) => boolean;
|
package/dist/status.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
exports.hasStatusCantPlay = exports.hasStatusOnField = exports.hasStatusFall = exports.hasStatusInjury = exports.hasStatusStanding = exports.hasStatusTacleZone = exports.hasStatusCanStandup = exports.hasStatusCanFaceup = exports.PLAYER_STATUS = void 0;
|
|
4
|
+
var PLAYER_STATUS;
|
|
5
|
+
(function (PLAYER_STATUS) {
|
|
6
|
+
PLAYER_STATUS[PLAYER_STATUS["STANDING"] = 0] = "STANDING";
|
|
7
|
+
PLAYER_STATUS[PLAYER_STATUS["KNOCKED_DOWN"] = 1] = "KNOCKED_DOWN";
|
|
8
|
+
PLAYER_STATUS[PLAYER_STATUS["STUNNED"] = 2] = "STUNNED";
|
|
9
|
+
PLAYER_STATUS[PLAYER_STATUS["RESERVE"] = 3] = "RESERVE";
|
|
10
|
+
PLAYER_STATUS[PLAYER_STATUS["KO"] = 4] = "KO";
|
|
11
|
+
PLAYER_STATUS[PLAYER_STATUS["CASUALTY"] = 5] = "CASUALTY";
|
|
11
12
|
// For other casuality (death), update all playerTo.status === PLAYER_STATUS.CASUALTY
|
|
12
|
-
SENDOFF
|
|
13
|
-
BONE_HEAD
|
|
14
|
-
};
|
|
15
|
-
exports.PLAYER_STATUS = PLAYER_STATUS;
|
|
13
|
+
PLAYER_STATUS[PLAYER_STATUS["SENDOFF"] = 6] = "SENDOFF";
|
|
14
|
+
PLAYER_STATUS[PLAYER_STATUS["BONE_HEAD"] = 7] = "BONE_HEAD";
|
|
15
|
+
})(PLAYER_STATUS || (exports.PLAYER_STATUS = PLAYER_STATUS = {}));
|
|
16
16
|
const hasStatusCanFaceup = (player) => {
|
|
17
17
|
return player.status === PLAYER_STATUS.STUNNED;
|
|
18
18
|
};
|
|
@@ -42,7 +42,7 @@ const hasStatusFall = (player) => {
|
|
|
42
42
|
};
|
|
43
43
|
exports.hasStatusFall = hasStatusFall;
|
|
44
44
|
const hasStatusOnField = (player) => {
|
|
45
|
-
return hasStatusStanding(player) || hasStatusFall(player);
|
|
45
|
+
return (0, exports.hasStatusStanding)(player) || (0, exports.hasStatusFall)(player);
|
|
46
46
|
};
|
|
47
47
|
exports.hasStatusOnField = hasStatusOnField;
|
|
48
48
|
const hasStatusCantPlay = (player) => {
|
package/dist/types/models.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface Point {
|
|
2
|
-
x: number;
|
|
3
|
-
y: number;
|
|
2
|
+
x: number | null;
|
|
3
|
+
y: number | null;
|
|
4
4
|
}
|
|
5
5
|
export interface Inducement {
|
|
6
6
|
key: string;
|
|
@@ -30,11 +30,11 @@ export interface Team {
|
|
|
30
30
|
coach_id: string;
|
|
31
31
|
league_id: string;
|
|
32
32
|
game_id: string;
|
|
33
|
-
date_next_transmission: Date;
|
|
34
|
-
date_next_pass: Date;
|
|
35
|
-
date_next_foul: Date;
|
|
36
|
-
date_next_blitz: Date;
|
|
37
|
-
date_next_reroll: Date;
|
|
33
|
+
date_next_transmission: Date | null;
|
|
34
|
+
date_next_pass: Date | null;
|
|
35
|
+
date_next_foul: Date | null;
|
|
36
|
+
date_next_blitz: Date | null;
|
|
37
|
+
date_next_reroll: Date | null;
|
|
38
38
|
color1: string;
|
|
39
39
|
color2: string;
|
|
40
40
|
isOpen: boolean;
|
|
@@ -57,7 +57,7 @@ export interface Team {
|
|
|
57
57
|
stadium_state_l: string;
|
|
58
58
|
players: PlayerWithSkill[];
|
|
59
59
|
}
|
|
60
|
-
export interface Player {
|
|
60
|
+
export interface Player extends Point {
|
|
61
61
|
id: string;
|
|
62
62
|
order: number;
|
|
63
63
|
name: string;
|
|
@@ -72,8 +72,6 @@ export interface Player {
|
|
|
72
72
|
active: string;
|
|
73
73
|
experience: number;
|
|
74
74
|
experienceCoach: number;
|
|
75
|
-
x: number;
|
|
76
|
-
y: number;
|
|
77
75
|
MA: number;
|
|
78
76
|
ST: number;
|
|
79
77
|
AG: number;
|
|
@@ -83,8 +81,8 @@ export interface Player {
|
|
|
83
81
|
current_AG: number;
|
|
84
82
|
current_AV: number;
|
|
85
83
|
current_gfi: number;
|
|
86
|
-
date_next_action: Date;
|
|
87
|
-
date_next_block: Date;
|
|
84
|
+
date_next_action: Date | null;
|
|
85
|
+
date_next_block: Date | null;
|
|
88
86
|
date_last_gfi: Date;
|
|
89
87
|
date_last_move: Date;
|
|
90
88
|
teamId: string;
|
|
@@ -93,7 +91,7 @@ export interface Player {
|
|
|
93
91
|
icon_id: string;
|
|
94
92
|
state: number;
|
|
95
93
|
ni: number;
|
|
96
|
-
date_next_standup: Date;
|
|
94
|
+
date_next_standup: Date | null;
|
|
97
95
|
can_auto_standup: boolean;
|
|
98
96
|
reroll_counter: number;
|
|
99
97
|
can_reroll: boolean;
|
|
@@ -109,10 +107,18 @@ export interface Player {
|
|
|
109
107
|
quote: string;
|
|
110
108
|
speak: string;
|
|
111
109
|
raz: boolean;
|
|
112
|
-
last_injury: string;
|
|
110
|
+
last_injury: string | null;
|
|
113
111
|
can_jump: boolean;
|
|
114
112
|
isCoach: boolean;
|
|
115
113
|
avatarDefault: string;
|
|
114
|
+
improvements: number[];
|
|
115
|
+
changed: any;
|
|
116
|
+
previous: any;
|
|
117
|
+
hadRegen: boolean;
|
|
118
|
+
checkByReferee: boolean;
|
|
119
|
+
prevX: number | null;
|
|
120
|
+
prevY: number | null;
|
|
121
|
+
hasEndTurn: boolean;
|
|
116
122
|
}
|
|
117
123
|
export interface PlayerWithSkill extends Player {
|
|
118
124
|
skills: PlayerSkill[];
|
|
@@ -128,9 +134,9 @@ export interface Game {
|
|
|
128
134
|
fan2: number;
|
|
129
135
|
reroll1: number;
|
|
130
136
|
reroll2: number;
|
|
131
|
-
ball_x: number;
|
|
132
|
-
ball_y: number;
|
|
133
|
-
ball_player_id: string;
|
|
137
|
+
ball_x: number | null;
|
|
138
|
+
ball_y: number | null;
|
|
139
|
+
ball_player_id: string | null;
|
|
134
140
|
status: number;
|
|
135
141
|
date_start: Date;
|
|
136
142
|
date_kickoff: Date;
|
package/index.ts
CHANGED
|
@@ -222,14 +222,14 @@ const PLAYER_HISTORY_INFO = {
|
|
|
222
222
|
EXP_TD: "etd",
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
-
|
|
226
|
-
CATCH_PASS
|
|
227
|
-
CATCH_HANDOFF
|
|
228
|
-
PICKUP
|
|
229
|
-
CATCH_BOUNCE
|
|
230
|
-
}
|
|
225
|
+
enum TAKE_BALL_TYPE {
|
|
226
|
+
CATCH_PASS = "pass", // Reception passe
|
|
227
|
+
CATCH_HANDOFF = "hand-off", // Reception d'une Transmission
|
|
228
|
+
PICKUP = "pick-up", // Ramasse la balle au sol
|
|
229
|
+
CATCH_BOUNCE = "bounce", // Reception d'un rebond
|
|
230
|
+
}
|
|
231
231
|
|
|
232
|
-
const p = (x: number, y: number): Point => {
|
|
232
|
+
const p = (x: number | string, y: number | string): Point => {
|
|
233
233
|
return { x: +x, y: +y };
|
|
234
234
|
};
|
|
235
235
|
|
|
@@ -242,12 +242,16 @@ function addSeconds(date: Date, days: number) {
|
|
|
242
242
|
const isSquareValidToPushBack = (
|
|
243
243
|
availableSquares: Point[],
|
|
244
244
|
targetIndex: number,
|
|
245
|
-
players:
|
|
245
|
+
players: Record<string, PlayerWithSkill>,
|
|
246
246
|
w: number,
|
|
247
247
|
h: number,
|
|
248
248
|
busy: Point[] = []
|
|
249
249
|
) => {
|
|
250
|
-
if (
|
|
250
|
+
if (
|
|
251
|
+
!availableSquares[targetIndex] ||
|
|
252
|
+
availableSquares[targetIndex].x === null ||
|
|
253
|
+
availableSquares[targetIndex].y === null
|
|
254
|
+
) {
|
|
251
255
|
return false;
|
|
252
256
|
}
|
|
253
257
|
const player = getPlayerOnCell(
|
|
@@ -272,6 +276,9 @@ const isSquareValidToPushBack = (
|
|
|
272
276
|
}
|
|
273
277
|
// All the spaces are full, we can't push back
|
|
274
278
|
const noEmptySquares = availableSquares.every((point) => {
|
|
279
|
+
if (point.x === null || point.y === null) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
275
282
|
return (
|
|
276
283
|
getPlayerOnCell(point.x, point.y, players) ||
|
|
277
284
|
busy.some((b: Point) => b.x === point.x && b.y === point.y) ||
|
|
@@ -281,7 +288,14 @@ const isSquareValidToPushBack = (
|
|
|
281
288
|
return noEmptySquares;
|
|
282
289
|
};
|
|
283
290
|
|
|
284
|
-
const getPlayerOnCell = (
|
|
291
|
+
const getPlayerOnCell = (
|
|
292
|
+
x: number | null,
|
|
293
|
+
y: number | null,
|
|
294
|
+
players: Record<string, PlayerWithSkill>
|
|
295
|
+
) => {
|
|
296
|
+
if (x === null || y === null) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
285
299
|
return Object.values(players).find(
|
|
286
300
|
(player) => player.x === x && player.y === y && hasStatusOnField(player)
|
|
287
301
|
);
|
|
@@ -290,7 +304,7 @@ const getPlayerOnCell = (x: number, y: number, players: Player[]) => {
|
|
|
290
304
|
const getHypnoticGazeMalus = (
|
|
291
305
|
player: Player,
|
|
292
306
|
target: Player,
|
|
293
|
-
players: Player
|
|
307
|
+
players: Record<string, Player>
|
|
294
308
|
) => {
|
|
295
309
|
const adjacentEnemyPlayers = Object.values(players).filter((p) => {
|
|
296
310
|
return (
|
|
@@ -401,7 +415,13 @@ const isSamePlayer = (p1: Player, p2: Player) => {
|
|
|
401
415
|
};
|
|
402
416
|
|
|
403
417
|
const availableSquaresToPushBack = (p1: Point, p2: Point) => {
|
|
404
|
-
if (
|
|
418
|
+
if (
|
|
419
|
+
!isAdjacent(p1, p2) ||
|
|
420
|
+
p1.x === null ||
|
|
421
|
+
p1.y === null ||
|
|
422
|
+
p2.x === null ||
|
|
423
|
+
p2.y === null
|
|
424
|
+
) {
|
|
405
425
|
return [];
|
|
406
426
|
}
|
|
407
427
|
const xFrom = p1.x;
|
|
@@ -584,6 +604,12 @@ const isOnLine = (A: Point, B: Point, C: Point) => {
|
|
|
584
604
|
|
|
585
605
|
const getThrowingBonus = (p1: Point, p2: Point, game: Game) => {
|
|
586
606
|
if (
|
|
607
|
+
!p1 ||
|
|
608
|
+
!p2 ||
|
|
609
|
+
p1.x === null ||
|
|
610
|
+
p1.y === null ||
|
|
611
|
+
p2.x === null ||
|
|
612
|
+
p2.y === null ||
|
|
587
613
|
!(
|
|
588
614
|
Number.isInteger(p1.x) &&
|
|
589
615
|
Number.isInteger(p1.y) &&
|
|
@@ -662,7 +688,7 @@ const getBestInterceptor = (
|
|
|
662
688
|
playerFrom: PlayerWithSkill,
|
|
663
689
|
pointTo: Point,
|
|
664
690
|
players: PlayerWithSkill[]
|
|
665
|
-
) => {
|
|
691
|
+
): PlayerWithSkill | null => {
|
|
666
692
|
const possiblePlayers = players.filter((foe) => {
|
|
667
693
|
return canPlayerIntercepts(playerFrom, foe, pointTo);
|
|
668
694
|
});
|
package/package.json
CHANGED
package/pitch.ts
CHANGED
|
@@ -58,7 +58,7 @@ function getIndexFromXY(x: number, y: number, width: number) {
|
|
|
58
58
|
return width * y + x;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
function getHalfStadium(side:
|
|
61
|
+
function getHalfStadium(side: 1 | 2, width: number) {
|
|
62
62
|
let offset = 0;
|
|
63
63
|
if (width === 20) {
|
|
64
64
|
offset = 3;
|
package/position.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { hasStatusTacleZone } from "./status";
|
|
2
2
|
import { PlayerWithSkill, Point } from "./types/models";
|
|
3
3
|
|
|
4
|
-
const isAdjacent = (p1: Point, p2: Point) => {
|
|
5
|
-
if (!p1 || !p2) {
|
|
4
|
+
export const isAdjacent = (p1: Point, p2: Point): boolean => {
|
|
5
|
+
if (!p1 || !p2 || !p1.x || !p1.y || !p2.x || !p2.y) {
|
|
6
6
|
return false;
|
|
7
7
|
}
|
|
8
8
|
return (
|
|
@@ -12,11 +12,11 @@ const isAdjacent = (p1: Point, p2: Point) => {
|
|
|
12
12
|
);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
export const getEnemyTackleZones = (
|
|
16
16
|
location: Point,
|
|
17
17
|
teamId: string,
|
|
18
18
|
players: Record<string, PlayerWithSkill>
|
|
19
|
-
) {
|
|
19
|
+
): PlayerWithSkill[] => {
|
|
20
20
|
// player a un format : { id1: {player1}, id2:{player2} etc...}
|
|
21
21
|
return Object.values(players).filter((player) => {
|
|
22
22
|
const res =
|
|
@@ -25,6 +25,4 @@ function getEnemyTackleZones(
|
|
|
25
25
|
isAdjacent(player, location);
|
|
26
26
|
return res;
|
|
27
27
|
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { getEnemyTackleZones, isAdjacent };
|
|
28
|
+
};
|
package/stadium.ts
CHANGED
|
@@ -130,7 +130,14 @@ const getTeamStadium = (team: Team, size: STADIUM_SIZE) => {
|
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
export type TileStadium = {
|
|
134
|
+
y: number;
|
|
135
|
+
price: number;
|
|
136
|
+
wear: number;
|
|
137
|
+
icons: number[];
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const TILES_STADIUM: Record<string, TileStadium> = {
|
|
134
141
|
a: {
|
|
135
142
|
y: 5,
|
|
136
143
|
price: 0,
|
package/status.ts
CHANGED
|
@@ -1,70 +1,58 @@
|
|
|
1
1
|
import { Player } from "types/models";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
STANDING
|
|
5
|
-
KNOCKED_DOWN
|
|
6
|
-
STUNNED
|
|
7
|
-
RESERVE
|
|
8
|
-
KO
|
|
9
|
-
CASUALTY
|
|
3
|
+
export enum PLAYER_STATUS {
|
|
4
|
+
STANDING = 0,
|
|
5
|
+
KNOCKED_DOWN = 1, // Sur le dos
|
|
6
|
+
STUNNED = 2, // Sur le ventre
|
|
7
|
+
RESERVE = 3, // Dans la réserve
|
|
8
|
+
KO = 4,
|
|
9
|
+
CASUALTY = 5, // Blessé
|
|
10
10
|
// For other casuality (death), update all playerTo.status === PLAYER_STATUS.CASUALTY
|
|
11
|
-
SENDOFF
|
|
12
|
-
BONE_HEAD
|
|
13
|
-
}
|
|
11
|
+
SENDOFF = 6, // Expulsé
|
|
12
|
+
BONE_HEAD = 7, // Plus de zdt
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
const hasStatusCanFaceup = (player: Player) => {
|
|
15
|
+
export const hasStatusCanFaceup = (player: Player) => {
|
|
16
16
|
return player.status === PLAYER_STATUS.STUNNED;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const hasStatusCanStandup = (player: Player) => {
|
|
19
|
+
export const hasStatusCanStandup = (player: Player) => {
|
|
20
20
|
return player.status === PLAYER_STATUS.KNOCKED_DOWN;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const hasStatusTacleZone = (player: Player) => {
|
|
23
|
+
export const hasStatusTacleZone = (player: Player) => {
|
|
24
24
|
// BONE_HEAD doesn't have table zone
|
|
25
25
|
return player.status === PLAYER_STATUS.STANDING;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const hasStatusStanding = (player: Player) => {
|
|
28
|
+
export const hasStatusStanding = (player: Player) => {
|
|
29
29
|
return (
|
|
30
30
|
player.status === PLAYER_STATUS.STANDING ||
|
|
31
31
|
player.status === PLAYER_STATUS.BONE_HEAD
|
|
32
32
|
);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
const hasStatusInjury = (player: Player) => {
|
|
35
|
+
export const hasStatusInjury = (player: Player) => {
|
|
36
36
|
return (
|
|
37
37
|
player.status === PLAYER_STATUS.KO ||
|
|
38
38
|
player.status === PLAYER_STATUS.CASUALTY
|
|
39
39
|
);
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
const hasStatusFall = (player: Player) => {
|
|
42
|
+
export const hasStatusFall = (player: Player) => {
|
|
43
43
|
return (
|
|
44
44
|
player.status === PLAYER_STATUS.KNOCKED_DOWN ||
|
|
45
45
|
player.status === PLAYER_STATUS.STUNNED
|
|
46
46
|
);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
const hasStatusOnField = (player: Player) => {
|
|
49
|
+
export const hasStatusOnField = (player: Player) => {
|
|
50
50
|
return hasStatusStanding(player) || hasStatusFall(player);
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
const hasStatusCantPlay = (player: Player) => {
|
|
53
|
+
export const hasStatusCantPlay = (player: Player) => {
|
|
54
54
|
return (
|
|
55
55
|
player.status === PLAYER_STATUS.SENDOFF ||
|
|
56
56
|
player.status === PLAYER_STATUS.CASUALTY
|
|
57
57
|
);
|
|
58
58
|
};
|
|
59
|
-
|
|
60
|
-
export {
|
|
61
|
-
hasStatusCanFaceup,
|
|
62
|
-
hasStatusCanStandup,
|
|
63
|
-
hasStatusCantPlay,
|
|
64
|
-
hasStatusFall,
|
|
65
|
-
hasStatusInjury,
|
|
66
|
-
hasStatusOnField,
|
|
67
|
-
hasStatusStanding,
|
|
68
|
-
hasStatusTacleZone,
|
|
69
|
-
PLAYER_STATUS,
|
|
70
|
-
};
|
package/types/models.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface Point {
|
|
2
|
-
x: number;
|
|
3
|
-
y: number;
|
|
2
|
+
x: number | null;
|
|
3
|
+
y: number | null;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export interface Inducement {
|
|
@@ -33,11 +33,11 @@ export interface Team {
|
|
|
33
33
|
coach_id: string;
|
|
34
34
|
league_id: string;
|
|
35
35
|
game_id: string;
|
|
36
|
-
date_next_transmission: Date;
|
|
37
|
-
date_next_pass: Date;
|
|
38
|
-
date_next_foul: Date;
|
|
39
|
-
date_next_blitz: Date;
|
|
40
|
-
date_next_reroll: Date;
|
|
36
|
+
date_next_transmission: Date | null;
|
|
37
|
+
date_next_pass: Date | null;
|
|
38
|
+
date_next_foul: Date | null;
|
|
39
|
+
date_next_blitz: Date | null;
|
|
40
|
+
date_next_reroll: Date | null;
|
|
41
41
|
color1: string;
|
|
42
42
|
color2: string;
|
|
43
43
|
isOpen: boolean;
|
|
@@ -61,7 +61,7 @@ export interface Team {
|
|
|
61
61
|
players: PlayerWithSkill[];
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export interface Player {
|
|
64
|
+
export interface Player extends Point {
|
|
65
65
|
id: string;
|
|
66
66
|
order: number;
|
|
67
67
|
name: string;
|
|
@@ -76,8 +76,6 @@ export interface Player {
|
|
|
76
76
|
active: string;
|
|
77
77
|
experience: number;
|
|
78
78
|
experienceCoach: number;
|
|
79
|
-
x: number;
|
|
80
|
-
y: number;
|
|
81
79
|
MA: number;
|
|
82
80
|
ST: number;
|
|
83
81
|
AG: number;
|
|
@@ -87,8 +85,8 @@ export interface Player {
|
|
|
87
85
|
current_AG: number;
|
|
88
86
|
current_AV: number;
|
|
89
87
|
current_gfi: number;
|
|
90
|
-
date_next_action: Date;
|
|
91
|
-
date_next_block: Date;
|
|
88
|
+
date_next_action: Date | null;
|
|
89
|
+
date_next_block: Date | null;
|
|
92
90
|
date_last_gfi: Date;
|
|
93
91
|
date_last_move: Date;
|
|
94
92
|
teamId: string;
|
|
@@ -97,7 +95,7 @@ export interface Player {
|
|
|
97
95
|
icon_id: string;
|
|
98
96
|
state: number;
|
|
99
97
|
ni: number;
|
|
100
|
-
date_next_standup: Date;
|
|
98
|
+
date_next_standup: Date | null;
|
|
101
99
|
can_auto_standup: boolean;
|
|
102
100
|
reroll_counter: number;
|
|
103
101
|
can_reroll: boolean;
|
|
@@ -113,10 +111,18 @@ export interface Player {
|
|
|
113
111
|
quote: string;
|
|
114
112
|
speak: string;
|
|
115
113
|
raz: boolean;
|
|
116
|
-
last_injury: string;
|
|
114
|
+
last_injury: string | null;
|
|
117
115
|
can_jump: boolean;
|
|
118
116
|
isCoach: boolean; // add by resolver
|
|
119
117
|
avatarDefault: string; // add by resolver
|
|
118
|
+
improvements: number[];
|
|
119
|
+
changed: any; // Game sequelize model
|
|
120
|
+
previous: any; // Game sequelize model
|
|
121
|
+
hadRegen: boolean; // add by Game
|
|
122
|
+
checkByReferee: boolean; // add by Game
|
|
123
|
+
prevX: number | null; // add by Game
|
|
124
|
+
prevY: number | null; // add by Game
|
|
125
|
+
hasEndTurn: boolean; // add by Game
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
export interface PlayerWithSkill extends Player {
|
|
@@ -134,9 +140,9 @@ export interface Game {
|
|
|
134
140
|
fan2: number;
|
|
135
141
|
reroll1: number;
|
|
136
142
|
reroll2: number;
|
|
137
|
-
ball_x: number;
|
|
138
|
-
ball_y: number;
|
|
139
|
-
ball_player_id: string;
|
|
143
|
+
ball_x: number | null;
|
|
144
|
+
ball_y: number | null;
|
|
145
|
+
ball_player_id: string | null;
|
|
140
146
|
status: number;
|
|
141
147
|
date_start: Date;
|
|
142
148
|
date_kickoff: Date;
|