enefel 1.0.100 → 1.0.101

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.
Files changed (2) hide show
  1. package/league.js +15 -6
  2. package/package.json +1 -1
package/league.js CHANGED
@@ -28,6 +28,9 @@ const calculateTeamsStandingForPlayoff = (flatTeams, division) => {
28
28
  const nextDivisionIndex = i + (isLeagueA ? 2 : 1);
29
29
  // TODO : Ce truc doit ps etre fait si la saison courante et pas un playoff
30
30
  const nextDivision = standings[nextDivisionIndex];
31
+ if (!nextDivision) {
32
+ break;
33
+ }
31
34
  const currentDivisionLastTeam =
32
35
  currentDivision.teams[currentDivision.teams.length - 1];
33
36
 
@@ -50,6 +53,9 @@ const calculateTeamsStandingForPlayoff = (flatTeams, division) => {
50
53
  const size = GROUP_SIZE * 2;
51
54
  for (i = 0; i < size; i++) {
52
55
  for (j = i + 1; j < size; j++) {
56
+ if (!flatedTeams[j] || !flatedTeams[i]) {
57
+ continue;
58
+ }
53
59
  if (flatedTeams[j].elo > flatedTeams[i].elo) {
54
60
  let temp = flatedTeams[i];
55
61
  flatedTeams[i] = flatedTeams[j];
@@ -57,12 +63,15 @@ const calculateTeamsStandingForPlayoff = (flatTeams, division) => {
57
63
  }
58
64
  }
59
65
  }
60
- // On met ensemble le 1, 3, 5, 7 et 2, 4, 6, 8 (B)
61
- for (i = 1; i < GROUP_SIZE; i += 2) {
62
- let temp = flatedTeams[i];
63
- flatedTeams[i] = flatedTeams[i + GROUP_SIZE - 1];
64
- flatedTeams[i + GROUP_SIZE - 1] = temp;
65
- }
66
+ // 0 1 2 3 4 5 6 7
67
+ // 0 2 4 6 1 3 5 7
68
+ let temp = flatedTeams[1];
69
+ flatedTeams[1] = flatedTeams[4];
70
+ flatedTeams[4] = temp;
71
+ temp = flatedTeams[3];
72
+ flatedTeams[3] = flatedTeams[6];
73
+ flatedTeams[6] = temp;
74
+
66
75
  return flatedTeams;
67
76
  };
68
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "enefel",
3
- "version": "1.0.100",
3
+ "version": "1.0.101",
4
4
  "main": "index.js",
5
5
  "author": "Manest",
6
6
  "license": "MIT",