enefel 1.0.117 → 1.0.120
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/color.js +25 -1
- package/game.js +41 -0
- package/improvement.js +49 -7
- package/index.js +3 -19
- package/league.js +54 -21
- package/package.json +1 -1
- package/right.js +2 -1
- package/skill.js +4 -0
package/color.js
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
const _ = require("lodash");
|
|
2
2
|
|
|
3
|
+
const colorShade = (col, amt) => {
|
|
4
|
+
col = col.replace(/^#/, "");
|
|
5
|
+
if (col.length === 3)
|
|
6
|
+
col = col[0] + col[0] + col[1] + col[1] + col[2] + col[2];
|
|
7
|
+
|
|
8
|
+
let [r, g, b] = col.match(/.{2}/g);
|
|
9
|
+
[r, g, b] = [
|
|
10
|
+
parseInt(r, 16) + amt,
|
|
11
|
+
parseInt(g, 16) + amt,
|
|
12
|
+
parseInt(b, 16) + amt,
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
r = Math.max(Math.min(255, r), 0).toString(16);
|
|
16
|
+
g = Math.max(Math.min(255, g), 0).toString(16);
|
|
17
|
+
b = Math.max(Math.min(255, b), 0).toString(16);
|
|
18
|
+
|
|
19
|
+
const rr = (r.length < 2 ? "0" : "") + r;
|
|
20
|
+
const gg = (g.length < 2 ? "0" : "") + g;
|
|
21
|
+
const bb = (b.length < 2 ? "0" : "") + b;
|
|
22
|
+
|
|
23
|
+
return `#${rr}${gg}${bb}`;
|
|
24
|
+
};
|
|
25
|
+
|
|
3
26
|
function deltaE(rgbA, rgbB) {
|
|
4
27
|
let labA = rgb2lab(rgbA);
|
|
5
28
|
let labB = rgb2lab(rgbB);
|
|
@@ -97,8 +120,9 @@ const getGameColors = (game) => {
|
|
|
97
120
|
};
|
|
98
121
|
|
|
99
122
|
module.exports = {
|
|
123
|
+
colorShade,
|
|
124
|
+
getGameColors,
|
|
100
125
|
invertColor,
|
|
101
126
|
isColor,
|
|
102
127
|
isColorTooClose,
|
|
103
|
-
getGameColors,
|
|
104
128
|
};
|
package/game.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const GAME_TYPE = {
|
|
2
|
+
DIVISION: "division",
|
|
3
|
+
FRIENDLY: "friendly",
|
|
4
|
+
OPEN: "open",
|
|
5
|
+
PLAYOFF: "playoff",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const GAME_STATUS = {
|
|
9
|
+
WAITING: 0,
|
|
10
|
+
BEFORE: 1,
|
|
11
|
+
ONGOING: 2,
|
|
12
|
+
TD: 3,
|
|
13
|
+
END: 4,
|
|
14
|
+
FINISH: 5, // pop and po calculated
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const hasGameCasualty = (game) => {
|
|
18
|
+
return game.type !== GAME_TYPE.FRIENDLY;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getGameFanBonus = (game) => {
|
|
22
|
+
if (game.type === GAME_TYPE.FRIENDLY) {
|
|
23
|
+
return -5;
|
|
24
|
+
}
|
|
25
|
+
if (game.type === GAME_TYPE.PLAYOFF) {
|
|
26
|
+
return 5;
|
|
27
|
+
}
|
|
28
|
+
return 0;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const getGameFan = (game) => {
|
|
32
|
+
return Random.d6(2) + getGameFanBonus(game);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
GAME_TYPE,
|
|
37
|
+
GAME_STATUS,
|
|
38
|
+
hasGameCasualty,
|
|
39
|
+
getGameFan,
|
|
40
|
+
getGameFanBonus,
|
|
41
|
+
};
|
package/improvement.js
CHANGED
|
@@ -1,15 +1,56 @@
|
|
|
1
|
+
const { GAME_TYPE } = require("./game");
|
|
2
|
+
|
|
1
3
|
// STAR PLAYER POINTS
|
|
4
|
+
const SPP_TYPE = {
|
|
5
|
+
BONUS: "BONUS",
|
|
6
|
+
INT: "INT",
|
|
7
|
+
KO: "KO",
|
|
8
|
+
REU: "REU",
|
|
9
|
+
SOR: "SOR",
|
|
10
|
+
TD: "TD",
|
|
11
|
+
};
|
|
12
|
+
|
|
2
13
|
const SPP = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
[GAME_TYPE.FRIENDLY]: {
|
|
15
|
+
EXP_BONUS: 0,
|
|
16
|
+
EXP_INT: 1,
|
|
17
|
+
EXP_KO: 0,
|
|
18
|
+
EXP_REU: 0,
|
|
19
|
+
EXP_SOR: 1,
|
|
20
|
+
EXP_TD: 1,
|
|
21
|
+
},
|
|
22
|
+
[GAME_TYPE.DIVISION]: {
|
|
23
|
+
EXP_BONUS: 1,
|
|
24
|
+
EXP_INT: 2,
|
|
25
|
+
EXP_KO: 1,
|
|
26
|
+
EXP_REU: 1,
|
|
27
|
+
EXP_SOR: 2,
|
|
28
|
+
EXP_TD: 3,
|
|
29
|
+
},
|
|
30
|
+
[GAME_TYPE.OPEN]: {
|
|
31
|
+
EXP_BONUS: 1,
|
|
32
|
+
EXP_INT: 2,
|
|
33
|
+
EXP_KO: 1,
|
|
34
|
+
EXP_REU: 1,
|
|
35
|
+
EXP_SOR: 2,
|
|
36
|
+
EXP_TD: 3,
|
|
37
|
+
},
|
|
38
|
+
[GAME_TYPE.PLAYOFF]: {
|
|
39
|
+
EXP_BONUS: 1,
|
|
40
|
+
EXP_INT: 2,
|
|
41
|
+
EXP_KO: 1,
|
|
42
|
+
EXP_REU: 1,
|
|
43
|
+
EXP_SOR: 2,
|
|
44
|
+
EXP_TD: 3,
|
|
45
|
+
},
|
|
9
46
|
};
|
|
10
47
|
const ranges = [6, 16, 31, 51, 76, 176];
|
|
11
48
|
const coachRanges = [3, 8, 15, 25, 36, 80];
|
|
12
49
|
|
|
50
|
+
const getSPP = (game, type) => {
|
|
51
|
+
return SPP[game.type][`EXP_${type}`];
|
|
52
|
+
};
|
|
53
|
+
|
|
13
54
|
const getNextRange = (currentRange) => {
|
|
14
55
|
for (let i = 0; i < ranges.length; i++) {
|
|
15
56
|
if (currentRange < ranges[i]) {
|
|
@@ -43,6 +84,7 @@ module.exports = {
|
|
|
43
84
|
coachRanges,
|
|
44
85
|
getNextRange,
|
|
45
86
|
getNextRangeCoach,
|
|
87
|
+
getSPP,
|
|
46
88
|
ranges,
|
|
47
|
-
|
|
89
|
+
SPP_TYPE,
|
|
48
90
|
};
|
package/index.js
CHANGED
|
@@ -21,6 +21,7 @@ const {
|
|
|
21
21
|
const { distance } = require("./calcul");
|
|
22
22
|
const { getCareerFromPlayer } = require("./race");
|
|
23
23
|
const { getMaxMA } = require("./player");
|
|
24
|
+
const { GAME_STATUS } = require("./game");
|
|
24
25
|
|
|
25
26
|
const POSTULATION_HOURS = 24;
|
|
26
27
|
const INACTIVE_DAYS = 10;
|
|
@@ -160,12 +161,13 @@ const GAME_HISTORY_INFO = {
|
|
|
160
161
|
PASS: "p",
|
|
161
162
|
REJECTION: "r",
|
|
162
163
|
REROLL_COACH: "rc",
|
|
163
|
-
REROLL_RACE_MALUS: "rrm",
|
|
164
164
|
REROLL_METEO: "rm",
|
|
165
|
+
REROLL_RACE_MALUS: "rrm",
|
|
165
166
|
REROLL: "re",
|
|
166
167
|
SCATTER: "sc",
|
|
167
168
|
SKILL: "sk",
|
|
168
169
|
SPY: "spy",
|
|
170
|
+
STANDUP: "st",
|
|
169
171
|
START_FAN: "fan",
|
|
170
172
|
STATUS: "s",
|
|
171
173
|
TAKE_BALL: "t",
|
|
@@ -203,22 +205,6 @@ const PLAYER_HISTORY_INFO = {
|
|
|
203
205
|
EXP_COACH: "ecoach",
|
|
204
206
|
};
|
|
205
207
|
|
|
206
|
-
const GAME_STATUS = {
|
|
207
|
-
WAITING: 0,
|
|
208
|
-
BEFORE: 1,
|
|
209
|
-
ONGOING: 2,
|
|
210
|
-
TD: 3,
|
|
211
|
-
END: 4,
|
|
212
|
-
FINISH: 5, // pop and po calculated
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
const GAME_TYPE = {
|
|
216
|
-
DIVISION: "division",
|
|
217
|
-
FRIENDLY: "friendly",
|
|
218
|
-
OPEN: "open",
|
|
219
|
-
PLAYOFF: "playoff",
|
|
220
|
-
};
|
|
221
|
-
|
|
222
208
|
const TAKE_BALL_TYPE = {
|
|
223
209
|
CATCH_PASS: "pass",
|
|
224
210
|
CATCH_HANDOFF: "hand-off",
|
|
@@ -917,8 +903,6 @@ module.exports = {
|
|
|
917
903
|
FORMATION_DEFAULT_NAME,
|
|
918
904
|
GAME_HISTORY_INFO,
|
|
919
905
|
GAME_HISTORY_TYPE,
|
|
920
|
-
GAME_STATUS,
|
|
921
|
-
GAME_TYPE,
|
|
922
906
|
getAttackerStrength,
|
|
923
907
|
getBestInterceptor,
|
|
924
908
|
getBlockAssistance,
|
package/league.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { GAME_TYPE } = require("
|
|
1
|
+
const { GAME_TYPE } = require("./game");
|
|
2
2
|
const { canPlayLeague } = require("./state");
|
|
3
3
|
|
|
4
4
|
const MIN_OPEN_SIZE = 4;
|
|
@@ -6,6 +6,7 @@ const GROUP_SIZE = 8;
|
|
|
6
6
|
const HAS_NEXT_SEASON_PLAYOFF = false;
|
|
7
7
|
const CAN_CHOOSE_TO_PARTICIPATE = false;
|
|
8
8
|
const HOME_AND_AWAY = false;
|
|
9
|
+
const NUMBER_TEAM_CHANGE = 2;
|
|
9
10
|
|
|
10
11
|
const calculateTeamsStandingForPlayoff = (flatTeams, division) => {
|
|
11
12
|
const standings = [{ teams: [] }];
|
|
@@ -78,6 +79,32 @@ const calculateTeamsStandingForPlayoff = (flatTeams, division) => {
|
|
|
78
79
|
return flatedTeams;
|
|
79
80
|
};
|
|
80
81
|
|
|
82
|
+
const getIndexNextAvailableTeam = (
|
|
83
|
+
index,
|
|
84
|
+
nextDivision,
|
|
85
|
+
currentSeason,
|
|
86
|
+
currentDivisionIndex
|
|
87
|
+
) => {
|
|
88
|
+
if (nextDivision.name === GAME_TYPE.OPEN) {
|
|
89
|
+
// To avoid some teams block the open, we take the first team with canChampionship
|
|
90
|
+
|
|
91
|
+
let alreadyFind = currentDivisionIndex;
|
|
92
|
+
index = nextDivision.teams.findIndex((t, i) => {
|
|
93
|
+
if (i < index) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (currentSeason.playoff && i < alreadyFind) {
|
|
97
|
+
// Fix Si CAN_CHOOSE_TO_PARTICIPATE ?
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return t.canChampionship || !CAN_CHOOSE_TO_PARTICIPATE;
|
|
101
|
+
});
|
|
102
|
+
if (index === -1) {
|
|
103
|
+
index = currentSeason.playoff ? i : 0;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return index;
|
|
107
|
+
};
|
|
81
108
|
const calculateTeamsStandingForLeagues = (
|
|
82
109
|
newStandings,
|
|
83
110
|
division,
|
|
@@ -92,32 +119,38 @@ const calculateTeamsStandingForLeagues = (
|
|
|
92
119
|
|
|
93
120
|
const currentDivisionLastTeam =
|
|
94
121
|
currentDivision.teams[currentDivision.teams.length - 1];
|
|
122
|
+
const currentDivisionPreLastTeam =
|
|
123
|
+
currentDivision.teams[currentDivision.teams.length - 2];
|
|
95
124
|
|
|
96
|
-
let indexNextDivisionFirstTeam =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
indexNextDivisionFirstTeam = nextDivision.teams.findIndex((t, i) => {
|
|
103
|
-
if (currentSeason.playoff && i < alreadyFind) {
|
|
104
|
-
// Fix Si CAN_CHOOSE_TO_PARTICIPATE ?
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
return t.canChampionship || !CAN_CHOOSE_TO_PARTICIPATE;
|
|
108
|
-
});
|
|
109
|
-
if (indexNextDivisionFirstTeam === -1) {
|
|
110
|
-
indexNextDivisionFirstTeam = currentSeason.playoff ? i : 0;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
125
|
+
let indexNextDivisionFirstTeam = getIndexNextAvailableTeam(
|
|
126
|
+
0,
|
|
127
|
+
nextDivision,
|
|
128
|
+
currentSeason,
|
|
129
|
+
i
|
|
130
|
+
);
|
|
113
131
|
|
|
114
132
|
const nextDivisionFirstTeam =
|
|
115
133
|
nextDivision.teams[indexNextDivisionFirstTeam];
|
|
116
134
|
|
|
135
|
+
let indexNextDivisionSecondTeam = getIndexNextAvailableTeam(
|
|
136
|
+
indexNextDivisionFirstTeam + 1,
|
|
137
|
+
nextDivision,
|
|
138
|
+
currentSeason,
|
|
139
|
+
i
|
|
140
|
+
);
|
|
141
|
+
const nextDivisionSecondTeam =
|
|
142
|
+
nextDivision.teams[indexNextDivisionSecondTeam];
|
|
143
|
+
|
|
117
144
|
currentDivision.teams[currentDivision.teams.length - 1] =
|
|
118
145
|
nextDivisionFirstTeam;
|
|
119
|
-
|
|
120
146
|
nextDivision.teams[indexNextDivisionFirstTeam] = currentDivisionLastTeam;
|
|
147
|
+
|
|
148
|
+
if (NUMBER_TEAM_CHANGE === 2 && nextDivisionSecondTeam) {
|
|
149
|
+
currentDivision.teams[currentDivision.teams.length - 2] =
|
|
150
|
+
nextDivisionSecondTeam;
|
|
151
|
+
nextDivision.teams[indexNextDivisionSecondTeam] =
|
|
152
|
+
currentDivisionPreLastTeam;
|
|
153
|
+
}
|
|
121
154
|
}
|
|
122
155
|
const flatTeams = newStandings
|
|
123
156
|
.reduce((p, c) => [...p, ...c.teams], [])
|
|
@@ -148,7 +181,6 @@ const calculateTeamsStandingForNextSeason = (division, currentSeason) => {
|
|
|
148
181
|
};
|
|
149
182
|
|
|
150
183
|
const forcastNextSeason = (flatTeams) => {
|
|
151
|
-
// debugger;
|
|
152
184
|
let groups = [];
|
|
153
185
|
let open = [];
|
|
154
186
|
let currentGroup = [];
|
|
@@ -189,7 +221,7 @@ const playoffNextSeason = (flatTeams) => {
|
|
|
189
221
|
let open = [];
|
|
190
222
|
let currentGroup = [];
|
|
191
223
|
|
|
192
|
-
// Creation de groupe de
|
|
224
|
+
// Creation de groupe de GROUP_SIZE
|
|
193
225
|
flatTeams.forEach((team) => {
|
|
194
226
|
if (!team) {
|
|
195
227
|
return;
|
|
@@ -269,6 +301,7 @@ module.exports = {
|
|
|
269
301
|
hasCalendar,
|
|
270
302
|
HOME_AND_AWAY,
|
|
271
303
|
MIN_OPEN_SIZE,
|
|
304
|
+
NUMBER_TEAM_CHANGE,
|
|
272
305
|
playoffNextSeason,
|
|
273
306
|
sortLeagues,
|
|
274
307
|
tournament,
|
package/package.json
CHANGED
package/right.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const { MAX_PLAYER_TEAM
|
|
1
|
+
const { MAX_PLAYER_TEAM } = require(".");
|
|
2
|
+
const { GAME_STATUS } = require("./game");
|
|
2
3
|
const { getSkillLimitSizeTeam } = require("./skill");
|
|
3
4
|
const { canJoinTeamWithState, isTeamActive, isActive } = require("./state");
|
|
4
5
|
|