enefel 1.2.0 → 1.2.2
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/.yarnrc.yml +5 -0
- package/dist/avatars.js +587 -0
- package/dist/avatarsDefault.js +136 -0
- package/dist/badge.js +60 -0
- package/dist/block.js +104 -0
- package/dist/calcul.js +11 -0
- package/dist/canUseSkills.js +46 -0
- package/dist/card.js +20 -0
- package/dist/career.js +1935 -0
- package/dist/color.js +112 -0
- package/dist/date.js +62 -0
- package/dist/dice.js +13 -0
- package/dist/elo.js +30 -0
- package/dist/game.js +64 -0
- package/dist/iconMap.js +261 -0
- package/dist/improvement.js +103 -0
- package/dist/inducement.js +59 -0
- package/dist/item.js +45 -0
- package/dist/jest.config.js +11 -0
- package/dist/league.js +250 -0
- package/dist/meteo.js +234 -0
- package/dist/moral.js +38 -0
- package/dist/move.js +70 -0
- package/dist/package-lock.json +6658 -0
- package/dist/package.json +43 -0
- package/dist/pitch.js +113 -0
- package/dist/player.js +244 -0
- package/dist/position.js +23 -0
- package/dist/race.js +355 -0
- package/dist/random.js +35 -0
- package/dist/right.js +62 -0
- package/dist/skill.js +421 -0
- package/dist/skillCoach.js +51 -0
- package/dist/stadium.js +320 -0
- package/dist/state.js +91 -0
- package/dist/status.js +52 -0
- package/dist/store.js +104 -0
- package/dist/time.js +80 -0
- package/dist/tsconfig.json +25 -0
- package/dist/types/models.js +2 -0
- package/dist/validator.js +96 -0
- package/dist/version.js +4 -0
- package/package.json +2 -2
- package/.npmrc +0 -1
- package/package-lock.json +0 -6658
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_INDUCEMENT = exports.INDUCEMENT = exports.hasInducement = exports.getInducements = exports.getGameInducements = exports.burnInducement = void 0;
|
|
4
|
+
const random_1 = require("./random");
|
|
5
|
+
const MAX_INDUCEMENT = 5;
|
|
6
|
+
exports.MAX_INDUCEMENT = MAX_INDUCEMENT;
|
|
7
|
+
const INDUCEMENT = {
|
|
8
|
+
APOTHECARY: { key: "apo" },
|
|
9
|
+
HALFLING_MASTER_CHEF: { key: "hmc" },
|
|
10
|
+
SPY: { key: "spy" },
|
|
11
|
+
XXX: { key: "xxx" },
|
|
12
|
+
BRIBE: { key: "bribe", isMulti: true },
|
|
13
|
+
};
|
|
14
|
+
exports.INDUCEMENT = INDUCEMENT;
|
|
15
|
+
const getInducements = (_team, inducementList) => {
|
|
16
|
+
let random = Object.values(INDUCEMENT).filter((value) => {
|
|
17
|
+
return (!inducementList.includes(value.key) || value.isMulti === true);
|
|
18
|
+
});
|
|
19
|
+
if (random.length === 0) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
random = (0, random_1.shuffleArray)(random);
|
|
23
|
+
return random[0].key;
|
|
24
|
+
};
|
|
25
|
+
exports.getInducements = getInducements;
|
|
26
|
+
const getGameInducements = (game) => {
|
|
27
|
+
if (!game) {
|
|
28
|
+
return [null, []];
|
|
29
|
+
}
|
|
30
|
+
const [teamId, inducements] = game.inducements.split(";");
|
|
31
|
+
let inducementList = [];
|
|
32
|
+
if (inducements) {
|
|
33
|
+
inducementList = inducements.split("-");
|
|
34
|
+
}
|
|
35
|
+
return [teamId, inducementList];
|
|
36
|
+
};
|
|
37
|
+
exports.getGameInducements = getGameInducements;
|
|
38
|
+
const hasInducement = (game, currentTeamId, inducement) => {
|
|
39
|
+
const [teamId, inducementList] = getGameInducements(game);
|
|
40
|
+
if (currentTeamId === teamId) {
|
|
41
|
+
return inducementList.includes(inducement.key);
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
};
|
|
45
|
+
exports.hasInducement = hasInducement;
|
|
46
|
+
const burnInducement = (game, inducementKey) => {
|
|
47
|
+
const [teamId, inducements] = game.inducements.split(";");
|
|
48
|
+
if (inducements) {
|
|
49
|
+
let inducementList = inducements.split("-");
|
|
50
|
+
const index = inducementList.indexOf(inducementKey);
|
|
51
|
+
if (index === -1) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
inducementList[index] = `!${inducementList[index]}`;
|
|
55
|
+
game.inducements = `${teamId};${inducementList.join("-")}`;
|
|
56
|
+
}
|
|
57
|
+
return game;
|
|
58
|
+
};
|
|
59
|
+
exports.burnInducement = burnInducement;
|
package/dist/item.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RARITY = exports.ITEM_TYPE = exports.ITEM_ID = exports.getQteFromRarity = void 0;
|
|
4
|
+
var RARITY;
|
|
5
|
+
(function (RARITY) {
|
|
6
|
+
RARITY["COMMUN"] = "c";
|
|
7
|
+
RARITY["UNCOMMUN"] = "u";
|
|
8
|
+
RARITY["RARE"] = "r";
|
|
9
|
+
RARITY["EPIC"] = "e";
|
|
10
|
+
RARITY["LEGENDARY"] = "l";
|
|
11
|
+
})(RARITY || (exports.RARITY = RARITY = {}));
|
|
12
|
+
var ITEM_ID;
|
|
13
|
+
(function (ITEM_ID) {
|
|
14
|
+
ITEM_ID["BEER"] = "beer";
|
|
15
|
+
ITEM_ID["CHAINSAW"] = "chainsaw";
|
|
16
|
+
ITEM_ID["RUSTED_CHAINSAW"] = "rusted-chainsaw";
|
|
17
|
+
ITEM_ID["DRUG"] = "drug";
|
|
18
|
+
ITEM_ID["GREEN_PILL"] = "green-pill";
|
|
19
|
+
ITEM_ID["NEWSPAPER"] = "newspaper";
|
|
20
|
+
ITEM_ID["BOOSTER"] = "booster";
|
|
21
|
+
})(ITEM_ID || (exports.ITEM_ID = ITEM_ID = {}));
|
|
22
|
+
var ITEM_TYPE;
|
|
23
|
+
(function (ITEM_TYPE) {
|
|
24
|
+
ITEM_TYPE["CONSUMABLE"] = "consumable";
|
|
25
|
+
ITEM_TYPE["WEAPON"] = "weapon";
|
|
26
|
+
ITEM_TYPE["FILE"] = "file";
|
|
27
|
+
})(ITEM_TYPE || (exports.ITEM_TYPE = ITEM_TYPE = {}));
|
|
28
|
+
const getQteFromRarity = (rarity) => {
|
|
29
|
+
if (rarity === RARITY.COMMUN) {
|
|
30
|
+
return 10000;
|
|
31
|
+
}
|
|
32
|
+
if (rarity === RARITY.UNCOMMUN) {
|
|
33
|
+
return 1000;
|
|
34
|
+
}
|
|
35
|
+
if (rarity === RARITY.RARE) {
|
|
36
|
+
return 100;
|
|
37
|
+
}
|
|
38
|
+
if (rarity === RARITY.EPIC) {
|
|
39
|
+
return 10;
|
|
40
|
+
}
|
|
41
|
+
if (rarity === RARITY.LEGENDARY) {
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.getQteFromRarity = getQteFromRarity;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
preset: "ts-jest",
|
|
4
|
+
testEnvironment: "node",
|
|
5
|
+
roots: ["<rootDir>/__tests__"],
|
|
6
|
+
testMatch: ["**/*.test.ts"],
|
|
7
|
+
transform: {
|
|
8
|
+
"^.+\\.tsx?$": "ts-jest",
|
|
9
|
+
},
|
|
10
|
+
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
|
|
11
|
+
};
|
package/dist/league.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.playoffNextSeason = exports.NUMBER_TEAM_CHANGE = exports.MIN_OPEN_SIZE = exports.HOME_AND_AWAY = exports.HAS_NEXT_SEASON_PLAYOFF = exports.GROUP_SIZE = exports.forcastNextSeason = exports.CAN_CHOOSE_TO_PARTICIPATE = exports.calculateTeamsStandingForPlayoff = exports.calculateTeamsStandingForNextSeason = void 0;
|
|
4
|
+
exports.hasCalendar = hasCalendar;
|
|
5
|
+
exports.round = round;
|
|
6
|
+
exports.sortLeagues = sortLeagues;
|
|
7
|
+
exports.tournament = tournament;
|
|
8
|
+
const game_1 = require("./game");
|
|
9
|
+
const state_1 = require("./state");
|
|
10
|
+
const MIN_OPEN_SIZE = 4;
|
|
11
|
+
exports.MIN_OPEN_SIZE = MIN_OPEN_SIZE;
|
|
12
|
+
const GROUP_SIZE = 0;
|
|
13
|
+
exports.GROUP_SIZE = GROUP_SIZE;
|
|
14
|
+
const HAS_NEXT_SEASON_PLAYOFF = false;
|
|
15
|
+
exports.HAS_NEXT_SEASON_PLAYOFF = HAS_NEXT_SEASON_PLAYOFF;
|
|
16
|
+
const CAN_CHOOSE_TO_PARTICIPATE = false;
|
|
17
|
+
exports.CAN_CHOOSE_TO_PARTICIPATE = CAN_CHOOSE_TO_PARTICIPATE;
|
|
18
|
+
const HOME_AND_AWAY = false;
|
|
19
|
+
exports.HOME_AND_AWAY = HOME_AND_AWAY;
|
|
20
|
+
const NUMBER_TEAM_CHANGE = 2;
|
|
21
|
+
exports.NUMBER_TEAM_CHANGE = NUMBER_TEAM_CHANGE;
|
|
22
|
+
const calculateTeamsStandingForPlayoff = (flatTeams, division) => {
|
|
23
|
+
const standings = [{ teams: [] }];
|
|
24
|
+
for (let team of flatTeams) {
|
|
25
|
+
standings[standings.length - 1].teams.push(team);
|
|
26
|
+
if (standings[standings.length - 1].teams.length >= GROUP_SIZE &&
|
|
27
|
+
standings.length < 3) {
|
|
28
|
+
standings.push({ teams: [] });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (division.length <= 2) {
|
|
32
|
+
// On prends les 8 premiers
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
for (let i = 0; i < standings.length - 1; ++i) {
|
|
36
|
+
const currentDivision = standings[i];
|
|
37
|
+
const isLeagueA = i === 0;
|
|
38
|
+
const isLeagueB = i === 1;
|
|
39
|
+
// Les derniers des ligues A et B sont relegué dans la league open
|
|
40
|
+
const nextDivisionIndex = i + (isLeagueA ? 2 : 1);
|
|
41
|
+
// TODO : Ce truc doit ps etre fait si la saison courante et pas un playoff
|
|
42
|
+
const nextDivision = standings[nextDivisionIndex];
|
|
43
|
+
if (!nextDivision) {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
const currentDivisionLastTeam = currentDivision.teams[currentDivision.teams.length - 1];
|
|
47
|
+
// Le dernier de la ligue A va remplacer premier de l'open
|
|
48
|
+
// Le dernier de la ligue B va remplacer le second de l'open
|
|
49
|
+
const nextDivisionFirstTeam = nextDivision.teams[isLeagueB ? 1 : 0];
|
|
50
|
+
currentDivision.teams[currentDivision.teams.length - 1] =
|
|
51
|
+
nextDivisionFirstTeam;
|
|
52
|
+
nextDivision.teams[isLeagueB ? 1 : 0] = currentDivisionLastTeam;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Les ligues A est B sont classé par ELO
|
|
56
|
+
const flatedTeams = standings.reduce((p, c) => [...p, ...c.teams], []);
|
|
57
|
+
if (!flatedTeams || flatedTeams.length === 0) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
const size = GROUP_SIZE * 2;
|
|
61
|
+
for (let i = 0; i < size; i++) {
|
|
62
|
+
for (let j = i + 1; j < size; j++) {
|
|
63
|
+
if (!flatedTeams[j] || !flatedTeams[i]) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (flatedTeams[j].elo > flatedTeams[i].elo) {
|
|
67
|
+
let temp = flatedTeams[i];
|
|
68
|
+
flatedTeams[i] = flatedTeams[j];
|
|
69
|
+
flatedTeams[j] = temp;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// 0 1 2 3 4 5 6 7
|
|
74
|
+
// 0 2 4 6 1 3 5 7
|
|
75
|
+
let temp = flatedTeams[1];
|
|
76
|
+
flatedTeams[1] = flatedTeams[4];
|
|
77
|
+
flatedTeams[4] = temp;
|
|
78
|
+
temp = flatedTeams[3];
|
|
79
|
+
flatedTeams[3] = flatedTeams[6];
|
|
80
|
+
flatedTeams[6] = temp;
|
|
81
|
+
return flatedTeams;
|
|
82
|
+
};
|
|
83
|
+
exports.calculateTeamsStandingForPlayoff = calculateTeamsStandingForPlayoff;
|
|
84
|
+
const getIndexNextAvailableTeam = (index, nextDivision, currentSeason, currentDivisionIndex) => {
|
|
85
|
+
if (nextDivision.name === game_1.GAME_TYPE.OPEN) {
|
|
86
|
+
// To avoid some teams block the open, we take the first team with canChampionship
|
|
87
|
+
let alreadyFind = currentDivisionIndex;
|
|
88
|
+
index = nextDivision.teams.findIndex((t, i) => {
|
|
89
|
+
if (i < index) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
if (currentSeason.playoff && i < alreadyFind) {
|
|
93
|
+
// Fix Si CAN_CHOOSE_TO_PARTICIPATE ?
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return t.canChampionship || !CAN_CHOOSE_TO_PARTICIPATE;
|
|
97
|
+
});
|
|
98
|
+
if (index === -1) {
|
|
99
|
+
// TODO : Check if this is correct
|
|
100
|
+
// index = currentSeason.playoff ? i : 0;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return index;
|
|
104
|
+
};
|
|
105
|
+
const calculateTeamsStandingForLeagues = (newStandings, division, currentSeason) => {
|
|
106
|
+
const openDivision = newStandings[division.length - 1];
|
|
107
|
+
for (let i = 0; i < division.length - 1; ++i) {
|
|
108
|
+
const currentDivision = newStandings[i];
|
|
109
|
+
const nextDivision = currentSeason.playoff
|
|
110
|
+
? openDivision
|
|
111
|
+
: newStandings[i + 1];
|
|
112
|
+
const currentDivisionLastTeam = currentDivision.teams[currentDivision.teams.length - 1];
|
|
113
|
+
const currentDivisionPreLastTeam = currentDivision.teams[currentDivision.teams.length - 2];
|
|
114
|
+
let indexNextDivisionFirstTeam = getIndexNextAvailableTeam(0, nextDivision, currentSeason, i);
|
|
115
|
+
const nextDivisionFirstTeam = nextDivision.teams[indexNextDivisionFirstTeam];
|
|
116
|
+
let indexNextDivisionSecondTeam = getIndexNextAvailableTeam(indexNextDivisionFirstTeam + 1, nextDivision, currentSeason, i);
|
|
117
|
+
const nextDivisionSecondTeam = nextDivision.teams[indexNextDivisionSecondTeam];
|
|
118
|
+
if ( /* NUMBER_TEAM_CHANGE === 1 || */!nextDivisionSecondTeam) {
|
|
119
|
+
currentDivision.teams[currentDivision.teams.length - 1] =
|
|
120
|
+
nextDivisionFirstTeam;
|
|
121
|
+
nextDivision.teams[indexNextDivisionFirstTeam] = currentDivisionLastTeam;
|
|
122
|
+
}
|
|
123
|
+
else if (NUMBER_TEAM_CHANGE === 2) {
|
|
124
|
+
currentDivision.teams[currentDivision.teams.length - 2] =
|
|
125
|
+
nextDivisionFirstTeam;
|
|
126
|
+
nextDivision.teams[indexNextDivisionSecondTeam] = currentDivisionLastTeam;
|
|
127
|
+
currentDivision.teams[currentDivision.teams.length - 1] =
|
|
128
|
+
nextDivisionSecondTeam;
|
|
129
|
+
nextDivision.teams[indexNextDivisionFirstTeam] =
|
|
130
|
+
currentDivisionPreLastTeam;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const flatTeams = newStandings
|
|
134
|
+
.reduce((p, c) => [...p, ...c.teams], [])
|
|
135
|
+
.filter((t) => t && (0, state_1.canPlayLeague)(t));
|
|
136
|
+
return flatTeams;
|
|
137
|
+
};
|
|
138
|
+
const calculateTeamsStandingForNextSeason = (division, currentSeason) => {
|
|
139
|
+
division = division.filter((d) => d.name !== game_1.GAME_TYPE.FRIENDLY && d.name !== game_1.GAME_TYPE.PLAYOFF);
|
|
140
|
+
// Standing division should be sorted (playoff, 1, 2, 3, ... , open)
|
|
141
|
+
const newStandings = JSON.parse(JSON.stringify(division));
|
|
142
|
+
const flatTeams = newStandings
|
|
143
|
+
.reduce((p, c) => [...p, ...c.teams], [])
|
|
144
|
+
.filter((t) => t && (0, state_1.canPlayLeague)(t));
|
|
145
|
+
if (HAS_NEXT_SEASON_PLAYOFF && GROUP_SIZE * 3 < flatTeams.length) {
|
|
146
|
+
return calculateTeamsStandingForPlayoff(flatTeams, division);
|
|
147
|
+
}
|
|
148
|
+
return calculateTeamsStandingForLeagues(newStandings, division, currentSeason);
|
|
149
|
+
};
|
|
150
|
+
exports.calculateTeamsStandingForNextSeason = calculateTeamsStandingForNextSeason;
|
|
151
|
+
const forcastNextSeason = (flatTeams) => {
|
|
152
|
+
let groups = [];
|
|
153
|
+
let open = [];
|
|
154
|
+
let currentGroup = [];
|
|
155
|
+
let i = 0;
|
|
156
|
+
flatTeams.forEach((team) => {
|
|
157
|
+
if (!team) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
// En playoff on n'a que les ligues A et B + open
|
|
161
|
+
if ((CAN_CHOOSE_TO_PARTICIPATE && !team.canChampionship) ||
|
|
162
|
+
(i >= 2 && HAS_NEXT_SEASON_PLAYOFF)) {
|
|
163
|
+
open.push(team);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
currentGroup.push(team);
|
|
167
|
+
if (currentGroup.length === GROUP_SIZE) {
|
|
168
|
+
groups = [...groups, currentGroup];
|
|
169
|
+
currentGroup = [];
|
|
170
|
+
++i;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
open = [...currentGroup, ...open];
|
|
174
|
+
if (open.length < MIN_OPEN_SIZE) {
|
|
175
|
+
const lastDivision = groups.pop();
|
|
176
|
+
if (lastDivision) {
|
|
177
|
+
open = [...lastDivision, ...open];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
groups = [...groups, open];
|
|
181
|
+
return { hasPlayoffs: false, groups };
|
|
182
|
+
};
|
|
183
|
+
exports.forcastNextSeason = forcastNextSeason;
|
|
184
|
+
const playoffNextSeason = (flatTeams) => {
|
|
185
|
+
let groups = [];
|
|
186
|
+
let open = [];
|
|
187
|
+
let currentGroup = [];
|
|
188
|
+
// Creation de groupe de GROUP_SIZE
|
|
189
|
+
flatTeams.forEach((team) => {
|
|
190
|
+
if (!team) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
// Obligatoire pour les playoffs
|
|
194
|
+
currentGroup.push(team);
|
|
195
|
+
if (currentGroup.length === GROUP_SIZE) {
|
|
196
|
+
groups = [...groups, currentGroup];
|
|
197
|
+
currentGroup = [];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
// Le reste est mis en open
|
|
201
|
+
open = [...currentGroup, ...open];
|
|
202
|
+
if (open.length < MIN_OPEN_SIZE) {
|
|
203
|
+
const lastDivision = groups.pop();
|
|
204
|
+
if (lastDivision) {
|
|
205
|
+
open = [...lastDivision, ...open];
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
groups = [...groups, open];
|
|
209
|
+
if (HAS_NEXT_SEASON_PLAYOFF === false || groups.length < 3) {
|
|
210
|
+
return forcastNextSeason(flatTeams);
|
|
211
|
+
}
|
|
212
|
+
return { hasPlayoffs: true, groups };
|
|
213
|
+
};
|
|
214
|
+
exports.playoffNextSeason = playoffNextSeason;
|
|
215
|
+
function round(r, teams) {
|
|
216
|
+
const pairs = [];
|
|
217
|
+
const n = teams.length;
|
|
218
|
+
for (var i = 1; i <= n / 2; i++) {
|
|
219
|
+
if (i == 1) {
|
|
220
|
+
pairs.push([teams[0], teams[((r + n - i - 1) % (n - 1)) + 1]]);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
pairs.push([
|
|
224
|
+
teams[((r + i - 2) % (n - 1)) + 1],
|
|
225
|
+
teams[((r + n - i - 1) % (n - 1)) + 1],
|
|
226
|
+
]);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return pairs;
|
|
230
|
+
}
|
|
231
|
+
function tournament(teams) {
|
|
232
|
+
const rounds = [];
|
|
233
|
+
const nbTeams = teams.length;
|
|
234
|
+
for (var r = 1; r < nbTeams; r++) {
|
|
235
|
+
rounds.push(round(r, teams));
|
|
236
|
+
}
|
|
237
|
+
return rounds;
|
|
238
|
+
}
|
|
239
|
+
function hasCalendar(league) {
|
|
240
|
+
return league.name !== game_1.GAME_TYPE.OPEN && league.name !== game_1.GAME_TYPE.FRIENDLY;
|
|
241
|
+
}
|
|
242
|
+
function sortLeagues(a, b) {
|
|
243
|
+
if (a.name < b.name || b.name === game_1.GAME_TYPE.FRIENDLY) {
|
|
244
|
+
return -1;
|
|
245
|
+
}
|
|
246
|
+
if (a.name > b.name || a.name === game_1.GAME_TYPE.FRIENDLY) {
|
|
247
|
+
return 1;
|
|
248
|
+
}
|
|
249
|
+
return 0;
|
|
250
|
+
}
|
package/dist/meteo.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.meteoTakeBall = exports.meteoRerollRoll = exports.meteoPlayerFall = exports.meteoPickUpBall = exports.meteoPassRebound = exports.meteoPassBonus = exports.meteoMaxPassDistance = exports.meteoMaxMA = exports.meteoKO = exports.meteoHasExpulsion = exports.meteoGfi = exports.meteoAttackerStrengthBlitz = exports.METEO = exports.getSeason = exports.getMeteo = void 0;
|
|
4
|
+
var METEO;
|
|
5
|
+
(function (METEO) {
|
|
6
|
+
METEO[METEO["AUTUMN_LEAF_STREWN_PITCH"] = 1] = "AUTUMN_LEAF_STREWN_PITCH";
|
|
7
|
+
METEO[METEO["AUTUMNAL_CHILL"] = 2] = "AUTUMNAL_CHILL";
|
|
8
|
+
METEO[METEO["POURING_RAIN"] = 3] = "POURING_RAIN";
|
|
9
|
+
METEO[METEO["STRONG_WINDS"] = 4] = "STRONG_WINDS";
|
|
10
|
+
METEO[METEO["COLD_WINDS"] = 5] = "COLD_WINDS";
|
|
11
|
+
METEO[METEO["FREEZING"] = 6] = "FREEZING";
|
|
12
|
+
METEO[METEO["PERFECT_CONDITION"] = 7] = "PERFECT_CONDITION";
|
|
13
|
+
METEO[METEO["HEAVY_SNOW"] = 8] = "HEAVY_SNOW";
|
|
14
|
+
METEO[METEO["BLIZZARD"] = 9] = "BLIZZARD";
|
|
15
|
+
METEO[METEO["MORNING_DEW"] = 10] = "MORNING_DEW";
|
|
16
|
+
METEO[METEO["BLOSSOMING_FLOWERS"] = 11] = "BLOSSOMING_FLOWERS";
|
|
17
|
+
METEO[METEO["MISTY_MORNING"] = 12] = "MISTY_MORNING";
|
|
18
|
+
METEO[METEO["HIGH_WINDS"] = 13] = "HIGH_WINDS";
|
|
19
|
+
})(METEO || (exports.METEO = METEO = {}));
|
|
20
|
+
var SEASON;
|
|
21
|
+
(function (SEASON) {
|
|
22
|
+
SEASON[SEASON["WINTER"] = 1] = "WINTER";
|
|
23
|
+
SEASON[SEASON["SPRING"] = 2] = "SPRING";
|
|
24
|
+
SEASON[SEASON["SUMMER"] = 3] = "SUMMER";
|
|
25
|
+
SEASON[SEASON["AUTUMN"] = 4] = "AUTUMN";
|
|
26
|
+
})(SEASON || (SEASON = {}));
|
|
27
|
+
const seasons = [
|
|
28
|
+
{
|
|
29
|
+
name: SEASON.SPRING,
|
|
30
|
+
start: new Date(2000, 2, 21),
|
|
31
|
+
end: new Date(2000, 5, 20),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: SEASON.SUMMER,
|
|
35
|
+
start: new Date(2000, 5, 21),
|
|
36
|
+
end: new Date(2000, 8, 20),
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: SEASON.AUTUMN,
|
|
40
|
+
start: new Date(2000, 8, 21),
|
|
41
|
+
end: new Date(2000, 11, 20),
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: SEASON.WINTER,
|
|
45
|
+
start: new Date(2000, 11, 21),
|
|
46
|
+
end: new Date(2001, 2, 20),
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
/** Checks if a date is within a specified season */
|
|
50
|
+
function checkSeason(season, date) {
|
|
51
|
+
let remappedStart = new Date(2000, season.start.getMonth(), season.start.getDate());
|
|
52
|
+
let remappedDate = new Date(2000, date.getMonth(), date.getDate());
|
|
53
|
+
let remappedEnd = new Date(2000, season.end.getMonth(), season.end.getDate());
|
|
54
|
+
if (season.start.getFullYear() === season.end.getFullYear()) {
|
|
55
|
+
return remappedStart <= remappedDate && remappedDate <= remappedEnd;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return ((remappedStart <= remappedDate &&
|
|
59
|
+
remappedDate <= new Date(2000, 11, 31)) ||
|
|
60
|
+
(new Date(2000, 0, 1) <= remappedDate && remappedDate <= remappedEnd));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function findSeason(seasons, date) {
|
|
64
|
+
for (let i = 0; i < seasons.length; i++) {
|
|
65
|
+
let isInSeason = checkSeason(seasons[i], date);
|
|
66
|
+
if (isInSeason === true) {
|
|
67
|
+
return seasons[i];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const getSeason = () => {
|
|
73
|
+
const season = findSeason(seasons, new Date());
|
|
74
|
+
if (season) {
|
|
75
|
+
return season.name;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
};
|
|
79
|
+
exports.getSeason = getSeason;
|
|
80
|
+
const getMeteo = (value) => {
|
|
81
|
+
const season = getSeason();
|
|
82
|
+
if (season === SEASON.SPRING) {
|
|
83
|
+
switch (value) {
|
|
84
|
+
case 2:
|
|
85
|
+
return METEO.MORNING_DEW;
|
|
86
|
+
case 3:
|
|
87
|
+
return METEO.BLOSSOMING_FLOWERS;
|
|
88
|
+
case 11:
|
|
89
|
+
return METEO.MISTY_MORNING;
|
|
90
|
+
case 12:
|
|
91
|
+
return METEO.HIGH_WINDS;
|
|
92
|
+
default:
|
|
93
|
+
return METEO.PERFECT_CONDITION;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (season === SEASON.WINTER) {
|
|
97
|
+
switch (value) {
|
|
98
|
+
case 2:
|
|
99
|
+
return METEO.COLD_WINDS;
|
|
100
|
+
case 3:
|
|
101
|
+
return METEO.FREEZING;
|
|
102
|
+
case 11:
|
|
103
|
+
return METEO.HEAVY_SNOW;
|
|
104
|
+
case 12:
|
|
105
|
+
return METEO.BLIZZARD;
|
|
106
|
+
default:
|
|
107
|
+
return METEO.PERFECT_CONDITION;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (season === SEASON.AUTUMN) {
|
|
111
|
+
switch (value) {
|
|
112
|
+
case 2:
|
|
113
|
+
return METEO.AUTUMN_LEAF_STREWN_PITCH;
|
|
114
|
+
case 3:
|
|
115
|
+
return METEO.AUTUMNAL_CHILL;
|
|
116
|
+
case 11:
|
|
117
|
+
return METEO.POURING_RAIN;
|
|
118
|
+
case 12:
|
|
119
|
+
return METEO.STRONG_WINDS;
|
|
120
|
+
default:
|
|
121
|
+
return METEO.PERFECT_CONDITION;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return METEO.PERFECT_CONDITION;
|
|
125
|
+
};
|
|
126
|
+
exports.getMeteo = getMeteo;
|
|
127
|
+
const meteoAttackerStrengthBlitz = (meteoValue) => {
|
|
128
|
+
let modif = 0;
|
|
129
|
+
if (meteoValue === METEO.HEAVY_SNOW) {
|
|
130
|
+
modif = -1;
|
|
131
|
+
}
|
|
132
|
+
return modif;
|
|
133
|
+
};
|
|
134
|
+
exports.meteoAttackerStrengthBlitz = meteoAttackerStrengthBlitz;
|
|
135
|
+
const meteoPlayerFall = (meteoValue) => {
|
|
136
|
+
let modif = 0;
|
|
137
|
+
if (meteoValue === METEO.AUTUMN_LEAF_STREWN_PITCH) {
|
|
138
|
+
modif = -1;
|
|
139
|
+
}
|
|
140
|
+
if (meteoValue === METEO.FREEZING) {
|
|
141
|
+
modif = 1;
|
|
142
|
+
}
|
|
143
|
+
return modif;
|
|
144
|
+
};
|
|
145
|
+
exports.meteoPlayerFall = meteoPlayerFall;
|
|
146
|
+
const meteoKO = (meteoValue) => {
|
|
147
|
+
let modif = 0;
|
|
148
|
+
if (meteoValue === METEO.AUTUMNAL_CHILL) {
|
|
149
|
+
modif = -1;
|
|
150
|
+
}
|
|
151
|
+
if (meteoValue === METEO.COLD_WINDS) {
|
|
152
|
+
modif = -1;
|
|
153
|
+
}
|
|
154
|
+
return modif;
|
|
155
|
+
};
|
|
156
|
+
exports.meteoKO = meteoKO;
|
|
157
|
+
// only pickup ball interaction
|
|
158
|
+
const meteoPickUpBall = (meteoValue) => {
|
|
159
|
+
let modif = 0;
|
|
160
|
+
if (meteoValue === METEO.MORNING_DEW) {
|
|
161
|
+
modif = -1;
|
|
162
|
+
}
|
|
163
|
+
return modif;
|
|
164
|
+
};
|
|
165
|
+
exports.meteoPickUpBall = meteoPickUpBall;
|
|
166
|
+
// All ball interaction
|
|
167
|
+
const meteoTakeBall = (meteoValue) => {
|
|
168
|
+
let modif = 0;
|
|
169
|
+
if (meteoValue === METEO.POURING_RAIN) {
|
|
170
|
+
modif = -1;
|
|
171
|
+
}
|
|
172
|
+
return modif;
|
|
173
|
+
};
|
|
174
|
+
exports.meteoTakeBall = meteoTakeBall;
|
|
175
|
+
const meteoPassRebound = (meteoValue) => {
|
|
176
|
+
let modif = 0;
|
|
177
|
+
if (meteoValue === METEO.STRONG_WINDS) {
|
|
178
|
+
modif = 3;
|
|
179
|
+
}
|
|
180
|
+
return modif;
|
|
181
|
+
};
|
|
182
|
+
exports.meteoPassRebound = meteoPassRebound;
|
|
183
|
+
const meteoPassBonus = (meteoValue) => {
|
|
184
|
+
let modif = 0;
|
|
185
|
+
if (meteoValue === METEO.STRONG_WINDS) {
|
|
186
|
+
modif = -1;
|
|
187
|
+
}
|
|
188
|
+
if (meteoValue === METEO.COLD_WINDS) {
|
|
189
|
+
modif = -1;
|
|
190
|
+
}
|
|
191
|
+
return modif;
|
|
192
|
+
};
|
|
193
|
+
exports.meteoPassBonus = meteoPassBonus;
|
|
194
|
+
const meteoGfi = (meteoValue) => {
|
|
195
|
+
let modif = 0;
|
|
196
|
+
if (meteoValue === METEO.BLIZZARD) {
|
|
197
|
+
modif = -1;
|
|
198
|
+
}
|
|
199
|
+
if (meteoValue === METEO.MORNING_DEW) {
|
|
200
|
+
modif = -1;
|
|
201
|
+
}
|
|
202
|
+
return modif;
|
|
203
|
+
};
|
|
204
|
+
exports.meteoGfi = meteoGfi;
|
|
205
|
+
const meteoMaxPassDistance = (meteoValue) => {
|
|
206
|
+
// 3.5, 7, 10.2, 13.1
|
|
207
|
+
let max = 14;
|
|
208
|
+
if (meteoValue === METEO.BLIZZARD || meteoValue === METEO.MISTY_MORNING) {
|
|
209
|
+
max = 7;
|
|
210
|
+
}
|
|
211
|
+
return max;
|
|
212
|
+
};
|
|
213
|
+
exports.meteoMaxPassDistance = meteoMaxPassDistance;
|
|
214
|
+
const meteoHasExpulsion = (meteoValue) => {
|
|
215
|
+
if (meteoValue === METEO.BLOSSOMING_FLOWERS) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
return true;
|
|
219
|
+
};
|
|
220
|
+
exports.meteoHasExpulsion = meteoHasExpulsion;
|
|
221
|
+
const meteoMaxMA = (meteoValue) => {
|
|
222
|
+
if (meteoValue === METEO.MISTY_MORNING) {
|
|
223
|
+
return 6;
|
|
224
|
+
}
|
|
225
|
+
return Infinity;
|
|
226
|
+
};
|
|
227
|
+
exports.meteoMaxMA = meteoMaxMA;
|
|
228
|
+
const meteoRerollRoll = (meteoValue) => {
|
|
229
|
+
if (meteoValue === METEO.HIGH_WINDS) {
|
|
230
|
+
return 2;
|
|
231
|
+
}
|
|
232
|
+
return 1;
|
|
233
|
+
};
|
|
234
|
+
exports.meteoRerollRoll = meteoRerollRoll;
|
package/dist/moral.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getColorFromMoral = getColorFromMoral;
|
|
4
|
+
exports.getMalusFromMoral = getMalusFromMoral;
|
|
5
|
+
function getMalusFromMoral(moral) {
|
|
6
|
+
if (moral < 20) {
|
|
7
|
+
return 20;
|
|
8
|
+
}
|
|
9
|
+
else if (moral < 40) {
|
|
10
|
+
return 15;
|
|
11
|
+
}
|
|
12
|
+
else if (moral < 60) {
|
|
13
|
+
return 10;
|
|
14
|
+
}
|
|
15
|
+
else if (moral < 80) {
|
|
16
|
+
return 5;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function getColorFromMoral(moral) {
|
|
23
|
+
if (moral < 20) {
|
|
24
|
+
return "#ff0000";
|
|
25
|
+
}
|
|
26
|
+
else if (moral < 40) {
|
|
27
|
+
return "#ff7b00";
|
|
28
|
+
}
|
|
29
|
+
else if (moral < 60) {
|
|
30
|
+
return "#ffcc00";
|
|
31
|
+
}
|
|
32
|
+
else if (moral < 80) {
|
|
33
|
+
return "#ffff00";
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return "#00FF00";
|
|
37
|
+
}
|
|
38
|
+
}
|