enefel 1.0.122 → 1.0.125

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/index.js CHANGED
@@ -148,7 +148,9 @@ const GAME_HISTORY_INFO = {
148
148
  END_TURN: "et",
149
149
  FOUL: "f",
150
150
  GO_FOR_IT: "gfi",
151
+ HANDICAP: "handi",
151
152
  HANDING_OFF: "ho",
153
+ INDUCEMENT_HALFLING_MASTER_CHEF: "ihmc",
152
154
  INJURY: "in",
153
155
  INTERCEPTION: "i",
154
156
  JUMP_UP: "ju",
@@ -178,6 +180,7 @@ const GAME_HISTORY_INFO = {
178
180
  };
179
181
 
180
182
  const PLAYER_HISTORY_TYPE = {
183
+ AGING: "ag",
181
184
  COACH_SKILL: "cs",
182
185
  CREATE_TEAM: "ct",
183
186
  CREATED: "c",
@@ -216,10 +219,6 @@ const p = (x, y) => {
216
219
  return { x: +x, y: +y };
217
220
  };
218
221
 
219
- function shuffleArray(array) {
220
- return [...array].sort(() => 0.5 - Math.random());
221
- }
222
-
223
222
  function addSeconds(date, days) {
224
223
  const result = new Date(date);
225
224
  result.setSeconds(result.getSeconds() + days);
@@ -830,6 +829,9 @@ const isCoach = (player, team = null) => {
830
829
  };
831
830
 
832
831
  const getMoralModifier = (player) => {
832
+ if (player.experience == null) {
833
+ throw Error("empty experience player");
834
+ }
833
835
  const career = getCareerFromPlayer(player);
834
836
  let range = ranges.findIndex((range) => player.experience < range);
835
837
  if (range === -1) {
@@ -838,6 +840,26 @@ const getMoralModifier = (player) => {
838
840
  return career.cost / 10 + range;
839
841
  };
840
842
 
843
+ const getTeamXP = (team) => {
844
+ let xp = 0;
845
+ for (const player of team.players) {
846
+ xp += player.experience;
847
+ }
848
+ return xp;
849
+ };
850
+
851
+ const getTeamMoral = (team) => {
852
+ let moral = 0;
853
+ for (const player of team.players) {
854
+ moral += getMoralModifier(player);
855
+ }
856
+ return moral;
857
+ };
858
+
859
+ const getTeamMoralByPlayer = (team) => {
860
+ return Math.round(getTeamMoral(team) / team.players.length);
861
+ };
862
+
841
863
  const getAttackerStrength = (
842
864
  player,
843
865
  isBlitz = false,
@@ -930,7 +952,9 @@ module.exports = {
930
952
  PLAYER_HISTORY_TYPE,
931
953
  PLAYER_STAT,
932
954
  POSTULATION_HOURS,
933
- shuffleArray,
934
955
  arrayMove,
935
956
  TAKE_BALL_TYPE,
957
+ getTeamMoralByPlayer,
958
+ getTeamMoral,
959
+ getTeamXP,
936
960
  };
package/inducement.js ADDED
@@ -0,0 +1,41 @@
1
+ const { shuffleArray } = require("./random");
2
+
3
+ const MAX_INDUCEMENT = 5;
4
+ const INDUCEMENT = {
5
+ // APOTHECARY: { key: "apo" },
6
+ HALFLING_MASTER_CHEF: { key: "hmc" },
7
+ SPY: { key: "spy" },
8
+ XXX: { key: "xxx" },
9
+ };
10
+
11
+ const getInducements = (team, inducementList) => {
12
+ let random = Object.values(INDUCEMENT).filter((value) => {
13
+ return !inducementList.includes(value.key);
14
+ });
15
+
16
+ if (random.length === 0) {
17
+ return null;
18
+ }
19
+
20
+ random = shuffleArray(random);
21
+ return random[0].key;
22
+ };
23
+
24
+ const getGameInducements = (game) => {
25
+ if (!game) {
26
+ return [null, []];
27
+ }
28
+ const [teamId, inducements] = game.inducements.split(";");
29
+ let inducementList = [];
30
+ if (inducements) {
31
+ inducementList = inducements.split("-");
32
+ }
33
+ return [teamId, inducementList];
34
+ };
35
+
36
+ module.exports = {
37
+ getGameInducements,
38
+ getInducements,
39
+ INDUCEMENT,
40
+ MAX_INDUCEMENT,
41
+ };
package/league.js CHANGED
@@ -2,7 +2,7 @@ const { GAME_TYPE } = require("./game");
2
2
  const { canPlayLeague } = require("./state");
3
3
 
4
4
  const MIN_OPEN_SIZE = 4;
5
- const GROUP_SIZE = 8;
5
+ const GROUP_SIZE = 6;
6
6
  const HAS_NEXT_SEASON_PLAYOFF = false;
7
7
  const CAN_CHOOSE_TO_PARTICIPATE = false;
8
8
  const HOME_AND_AWAY = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "enefel",
3
- "version": "1.0.122",
3
+ "version": "1.0.125",
4
4
  "main": "index.js",
5
5
  "author": "Manest",
6
6
  "license": "MIT",
package/player.js CHANGED
@@ -1,6 +1,13 @@
1
1
  const { meteoMaxMA } = require("./meteo");
2
2
  const { hasSkill, SKILL_NAMES } = require("./skill");
3
3
 
4
+ const PLAYER_CARAC = {
5
+ AG: "AG",
6
+ AV: "AV",
7
+ MA: "MA",
8
+ ST: "ST",
9
+ };
10
+
4
11
  function getMaxMA(player, game) {
5
12
  if (!player) {
6
13
  return null;
@@ -20,4 +27,48 @@ function getMaxGfi(player) {
20
27
  return hasSkill(player, SKILL_NAMES.SPRINT) ? 3 : 2;
21
28
  }
22
29
 
23
- module.exports = { getMaxGfi, getMaxMA };
30
+ const AGING_SIZE_RANGE = 5;
31
+
32
+ function gamesforAgingRoll(totalGames) {
33
+ if (totalGames <= 0) {
34
+ return AGING_SIZE_RANGE;
35
+ }
36
+ if (totalGames % AGING_SIZE_RANGE === 0) {
37
+ return 0;
38
+ }
39
+
40
+ return AGING_SIZE_RANGE - (totalGames % AGING_SIZE_RANGE);
41
+ }
42
+
43
+ function getAgingBonus(totalGames) {
44
+ const initialBonus = 5;
45
+ const minBonus = -3;
46
+
47
+ if (gamesforAgingRoll(totalGames) !== 0) {
48
+ return null;
49
+ }
50
+
51
+ const range = totalGames / AGING_SIZE_RANGE;
52
+ // 5 = 1 = 4
53
+ // 10 = 2 = 3
54
+ // 15 = 3 = 2
55
+ // 20 = 4 = 1
56
+ // 25 = 5 = 0
57
+ // 30 = 6 = -1
58
+ // 35 = 7 = -2
59
+ // 40 = 8 = -3
60
+ let bonus = initialBonus - range;
61
+ if (bonus < minBonus) {
62
+ bonus = minBonus;
63
+ }
64
+ return bonus;
65
+ }
66
+
67
+ module.exports = {
68
+ AGING_SIZE_RANGE,
69
+ gamesforAgingRoll,
70
+ getAgingBonus,
71
+ getMaxGfi,
72
+ getMaxMA,
73
+ PLAYER_CARAC,
74
+ };
package/random.js CHANGED
@@ -6,6 +6,10 @@ const rollDice = (quantity, max) => {
6
6
  return total;
7
7
  };
8
8
 
9
+ function shuffleArray(array) {
10
+ return [...array].sort(() => 0.5 - Math.random());
11
+ }
12
+
9
13
  const tools = {
10
14
  getRandomNumber: (min, max, r = Math.random) => {
11
15
  return Math.floor(r() * (max - min + 1)) + min;
@@ -22,5 +26,7 @@ const tools = {
22
26
  d3: (quantity = 1, max = 3) => {
23
27
  return rollDice(quantity, max);
24
28
  },
29
+
30
+ shuffleArray,
25
31
  };
26
32
  module.exports = tools;
package/skill.js CHANGED
@@ -9,10 +9,10 @@ const SPECIALIST_LIMIT = 6;
9
9
  const SKILL_INFO_ACTIVE = "active";
10
10
  const SKILL_INFO_INACTIVE = "inactive";
11
11
 
12
- // TODO
12
+ // TODO
13
13
  // Take Root
14
14
  // Timmm-ber!
15
-
15
+
16
16
  // Missing for races
17
17
  const SKILL_NAMES = {
18
18
  ACCURATE: "accurate",
package/state.js CHANGED
@@ -70,6 +70,9 @@ function canPlayLeague(team) {
70
70
  ) {
71
71
  return false;
72
72
  }
73
+ // if (team.id === "c28c487a-5b6c-45a2-be33-9b3460b957b6") {
74
+ // return false;
75
+ // }
73
76
  return true;
74
77
  }
75
78
 
package/status.js CHANGED
@@ -29,6 +29,13 @@ const hasStatusStanding = (player) => {
29
29
  );
30
30
  };
31
31
 
32
+ const hasStatusInjury = (player) => {
33
+ return (
34
+ player.status === PLAYER_STATUS.KO ||
35
+ player.status === PLAYER_STATUS.CASUALTY
36
+ );
37
+ };
38
+
32
39
  const hasStatusFall = (player) => {
33
40
  return (
34
41
  player.status === PLAYER_STATUS.KNOCKED_DOWN ||
@@ -50,9 +57,10 @@ module.exports = {
50
57
  PLAYER_STATUS,
51
58
  hasStatusCanFaceup,
52
59
  hasStatusCanStandup,
53
- hasStatusStanding,
60
+ hasStatusCantPlay,
54
61
  hasStatusFall,
62
+ hasStatusInjury,
55
63
  hasStatusOnField,
64
+ hasStatusStanding,
56
65
  hasStatusTacleZone,
57
- hasStatusCantPlay,
58
66
  };