enefel 1.0.127 → 1.0.129
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/game.js +23 -2
- package/index.js +7 -3
- package/meteo.js +57 -2
- package/package.json +1 -1
- package/time.js +10 -0
package/game.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const Random = require("./random");
|
|
2
|
+
const { getTime, TYPE_TIMER } = require("./time");
|
|
2
3
|
|
|
3
4
|
const GAME_TYPE = {
|
|
4
5
|
DIVISION: "division",
|
|
@@ -14,6 +15,7 @@ const GAME_STATUS = {
|
|
|
14
15
|
TD: 3,
|
|
15
16
|
END: 4,
|
|
16
17
|
FINISH: 5, // pop and po calculated
|
|
18
|
+
HALFTIME: 6,
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
const hasGameCasualty = (game) => {
|
|
@@ -34,10 +36,29 @@ const getGameFan = (game) => {
|
|
|
34
36
|
return Random.d6(2) + getGameFanBonus(game);
|
|
35
37
|
};
|
|
36
38
|
|
|
39
|
+
const getDateStartHalfTime = (game) => {
|
|
40
|
+
const start = new Date(game.date_start);
|
|
41
|
+
const end = new Date(game.date_end);
|
|
42
|
+
return new Date(start.getTime() + (end.getTime() - start.getTime()) / 2);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getDateEndHalfTime = (game) => {
|
|
46
|
+
const half = getDateStartHalfTime(game);
|
|
47
|
+
return new Date(half.getTime() + getTime(TYPE_TIMER.HALF_TIME_PAUSE) * 1000);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const isGameFirstHalfTime = (game) => {
|
|
51
|
+
const now = new Date(Date.now());
|
|
52
|
+
return getDateStartHalfTime(game) - now > 0;
|
|
53
|
+
};
|
|
54
|
+
|
|
37
55
|
module.exports = {
|
|
38
|
-
GAME_TYPE,
|
|
39
56
|
GAME_STATUS,
|
|
40
|
-
|
|
57
|
+
GAME_TYPE,
|
|
58
|
+
getDateEndHalfTime,
|
|
59
|
+
getDateStartHalfTime,
|
|
41
60
|
getGameFan,
|
|
42
61
|
getGameFanBonus,
|
|
62
|
+
hasGameCasualty,
|
|
63
|
+
isGameFirstHalfTime,
|
|
43
64
|
};
|
package/index.js
CHANGED
|
@@ -124,7 +124,6 @@ const GAME_HISTORY_TYPE = {
|
|
|
124
124
|
END: "END",
|
|
125
125
|
FACEUP: "F",
|
|
126
126
|
FOUL: "FO",
|
|
127
|
-
FRENZY: "F",
|
|
128
127
|
KICKOFF: "K",
|
|
129
128
|
MOVE: "M",
|
|
130
129
|
PASS: "P",
|
|
@@ -808,11 +807,16 @@ function isGameRunning(game) {
|
|
|
808
807
|
return (
|
|
809
808
|
game.status === GAME_STATUS.BEFORE ||
|
|
810
809
|
game.status === GAME_STATUS.ONGOING ||
|
|
811
|
-
game.status === GAME_STATUS.TD
|
|
810
|
+
game.status === GAME_STATUS.TD ||
|
|
811
|
+
game.status === GAME_STATUS.HALFTIME
|
|
812
812
|
);
|
|
813
813
|
}
|
|
814
814
|
function isSetUp(game) {
|
|
815
|
-
return
|
|
815
|
+
return (
|
|
816
|
+
game.status === GAME_STATUS.BEFORE ||
|
|
817
|
+
game.status === GAME_STATUS.TD ||
|
|
818
|
+
game.status === GAME_STATUS.HALFTIME
|
|
819
|
+
);
|
|
816
820
|
}
|
|
817
821
|
|
|
818
822
|
function getTeamColor(game, side) {
|
package/meteo.js
CHANGED
|
@@ -21,9 +21,63 @@ const SEASON = {
|
|
|
21
21
|
AUTUMN: 4,
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
const seasons = [
|
|
25
|
+
{
|
|
26
|
+
name: SEASON.SPRING,
|
|
27
|
+
start: new Date(2000, 2, 21),
|
|
28
|
+
end: new Date(2000, 5, 20),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: SEASON.SUMMER,
|
|
32
|
+
start: new Date(2000, 5, 21),
|
|
33
|
+
end: new Date(2000, 8, 20),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: SEASON.AUTUMN,
|
|
37
|
+
start: new Date(2000, 8, 21),
|
|
38
|
+
end: new Date(2000, 11, 20),
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: SEASON.WINTER,
|
|
42
|
+
start: new Date(2000, 11, 21),
|
|
43
|
+
end: new Date(2001, 2, 20),
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
/** Checks if a date is within a specified season */
|
|
48
|
+
function checkSeason(season, date) {
|
|
49
|
+
let remappedStart = new Date(
|
|
50
|
+
2000,
|
|
51
|
+
season.start.getMonth(),
|
|
52
|
+
season.start.getDate()
|
|
53
|
+
);
|
|
54
|
+
let remappedDate = new Date(2000, date.getMonth(), date.getDate());
|
|
55
|
+
let remappedEnd = new Date(2000, season.end.getMonth(), season.end.getDate());
|
|
56
|
+
|
|
57
|
+
if (season.start.getFullYear() === season.end.getFullYear()) {
|
|
58
|
+
return remappedStart <= remappedDate && remappedDate <= remappedEnd;
|
|
59
|
+
} else {
|
|
60
|
+
return (
|
|
61
|
+
(remappedStart <= remappedDate &&
|
|
62
|
+
remappedDate <= new Date(2000, 11, 31)) ||
|
|
63
|
+
(new Date(2000, 0, 1) <= remappedDate && remappedDate <= remappedEnd)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function findSeason(seasons, date) {
|
|
69
|
+
for (let i = 0; i < seasons.length; i++) {
|
|
70
|
+
let isInSeason = checkSeason(seasons[i], date);
|
|
71
|
+
if (isInSeason === true) {
|
|
72
|
+
return seasons[i];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
24
79
|
const getSeason = () => {
|
|
25
|
-
return
|
|
26
|
-
// return SEASON.AUTUMN;
|
|
80
|
+
return findSeason(seasons, new Date()).name;
|
|
27
81
|
};
|
|
28
82
|
|
|
29
83
|
const getMeteo = (value) => {
|
|
@@ -182,6 +236,7 @@ const meteoRerollRoll = (meteoValue) => {
|
|
|
182
236
|
return 1;
|
|
183
237
|
};
|
|
184
238
|
const tools = {
|
|
239
|
+
getSeason,
|
|
185
240
|
getMeteo,
|
|
186
241
|
METEO,
|
|
187
242
|
meteoAttackerStrengthBlitz,
|
package/package.json
CHANGED
package/time.js
CHANGED
|
@@ -12,6 +12,8 @@ const TYPE_TIMER = {
|
|
|
12
12
|
TURNOVER: "turnover",
|
|
13
13
|
WAITING_GAME: "waitingGame",
|
|
14
14
|
TIME_SEASON_IF_NO_LEAGUE: "timeSeasonIfNoLeague",
|
|
15
|
+
HALF_TIME_GAME: "halfTime",
|
|
16
|
+
HALF_TIME_PAUSE: "halfTimePause",
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
const getTime = (type) => {
|
|
@@ -26,6 +28,7 @@ const getTime = (type) => {
|
|
|
26
28
|
|
|
27
29
|
// Total game time = TIME_BEFORE + TIME_GAME
|
|
28
30
|
const TIME_GAME = 5 * 24 * 60 * 60;
|
|
31
|
+
const TIME_HALF_TIME_GAME = 6 * 24 * 60 * 60;
|
|
29
32
|
|
|
30
33
|
// Time of setup after a TD
|
|
31
34
|
const TIME_TD = 3 * 60 * 60;
|
|
@@ -38,13 +41,20 @@ const getTime = (type) => {
|
|
|
38
41
|
|
|
39
42
|
// before league games (last game end + 1 day)
|
|
40
43
|
const TIME_INIT_LEAGUE = 1 * 24 * 60 * 60;
|
|
44
|
+
|
|
41
45
|
// between each league games
|
|
42
46
|
const TIME_BETWEEN_GAME_LEAGUE = TIME_GAME + 2 * 24 * 60 * 60;
|
|
43
47
|
|
|
44
48
|
// 2 months, 30 days
|
|
45
49
|
const TIME_SEASON_IF_NO_LEAGUE = 60 * 24 * 60 * 30;
|
|
46
50
|
|
|
51
|
+
const TIME_HALF_TIME_PAUSE = 6 * 60 * 60;
|
|
52
|
+
|
|
47
53
|
switch (type) {
|
|
54
|
+
case TYPE_TIMER.HALF_TIME_GAME:
|
|
55
|
+
return TIME_HALF_TIME_GAME;
|
|
56
|
+
case TYPE_TIMER.HALF_TIME_PAUSE:
|
|
57
|
+
return TIME_HALF_TIME_PAUSE;
|
|
48
58
|
case TYPE_TIMER.ACTION_FULL:
|
|
49
59
|
return TIME_ACTION_FULL;
|
|
50
60
|
case TYPE_TIMER.TIME_SEASON_IF_NO_LEAGUE:
|