gotchi-battler-game-logic 2.0.6 → 2.0.8

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 (45) hide show
  1. package/.vscode/settings.json +4 -4
  2. package/Dockerfile +9 -9
  3. package/README.md +49 -49
  4. package/cloudbuild.yaml +27 -27
  5. package/constants/tournamentManagerAbi.json +208 -208
  6. package/game-logic/index.js +6 -6
  7. package/game-logic/v1.4/constants.js +114 -114
  8. package/game-logic/v1.4/index.js +1366 -1366
  9. package/game-logic/v1.6/constants.js +123 -123
  10. package/game-logic/v1.6/index.js +1406 -1406
  11. package/game-logic/v1.7/constants.js +142 -140
  12. package/game-logic/v1.7/helpers.js +595 -593
  13. package/game-logic/v1.7/index.js +802 -795
  14. package/index.js +12 -12
  15. package/package.json +26 -26
  16. package/schemas/team.json +349 -343
  17. package/scripts/balancing/createCSV.js +126 -126
  18. package/scripts/balancing/fixTrainingGotchis.js +155 -259
  19. package/scripts/balancing/processSims.js +229 -229
  20. package/scripts/balancing/sims.js +278 -278
  21. package/scripts/balancing/v1.7/class_combos.js +43 -43
  22. package/scripts/balancing/v1.7/setTeamPositions.js +105 -105
  23. package/scripts/balancing/v1.7/training_gotchis.json +20161 -20161
  24. package/scripts/balancing/v1.7/trait_combos.json +9 -9
  25. package/scripts/balancing/v1.7.1/class_combos.js +43 -43
  26. package/scripts/balancing/v1.7.1/setTeamPositions.js +122 -122
  27. package/scripts/balancing/v1.7.1/training_gotchis.json +22401 -22401
  28. package/scripts/balancing/v1.7.1/trait_combos.json +9 -9
  29. package/scripts/balancing/v1.7.2/class_combos.js +44 -0
  30. package/scripts/balancing/v1.7.2/setTeamPositions.js +122 -0
  31. package/scripts/balancing/v1.7.2/training_gotchis.json +22402 -0
  32. package/scripts/balancing/v1.7.2/trait_combos.json +10 -0
  33. package/scripts/data/team1.json +213 -213
  34. package/scripts/data/team2.json +200 -200
  35. package/scripts/data/tournaments.json +66 -66
  36. package/scripts/{runBattle.js → runLocalBattle.js} +18 -18
  37. package/scripts/runRealBattle.js +52 -0
  38. package/scripts/simRealBattle.js +121 -0
  39. package/scripts/validateBattle.js +74 -70
  40. package/scripts/validateTournament.js +101 -101
  41. package/utils/contracts.js +12 -12
  42. package/utils/errors.js +29 -29
  43. package/utils/mapGotchi.js +119 -0
  44. package/utils/transforms.js +89 -88
  45. package/utils/validations.js +39 -39
@@ -1,89 +1,90 @@
1
- const logToInGameTeams = (originalLog) => {
2
- // Deep copy the log to avoid modifying the original log
3
- const log = JSON.parse(JSON.stringify(originalLog))
4
-
5
- const teams = [];
6
-
7
- [0, 1].forEach((teamIndex) => {
8
- teams.push({
9
- formation: {
10
- front: log.layout.teams[teamIndex].rows[0].slots.map((slot) => {
11
- if (slot.isActive) {
12
- const gotchi = log.gotchis.find((gotchi) => gotchi.id === slot.id)
13
-
14
- if (!gotchi) {
15
- throw new Error(`Gotchi not found: ${slot.id}`)
16
- }
17
-
18
- return gotchi
19
- } else {
20
- return null
21
- }
22
- }),
23
- back: log.layout.teams[teamIndex].rows[1].slots.map((slot) => {
24
- if (slot.isActive) {
25
- const gotchi = log.gotchis.find((gotchi) => gotchi.id === slot.id)
26
-
27
- if (!gotchi) {
28
- throw new Error(`Gotchi not found: ${slot.id}`)
29
- }
30
-
31
- return gotchi
32
- } else {
33
- return null
34
- }
35
- })
36
- },
37
- leader: log.layout.teams[teamIndex].leaderId,
38
- name: log.layout.teams[teamIndex].name,
39
- owner: log.layout.teams[teamIndex].owner
40
- })
41
- });
42
-
43
- return teams
44
- }
45
-
46
- const webappTeamToInGameTeam = (webappTeam) => {
47
- const inGameTeam = {
48
- formation: {
49
- front: [front1Gotchi, front2Gotchi, front3Gotchi, front4Gotchi, front5Gotchi],
50
- back: [back1Gotchi, back2Gotchi, back3Gotchi, back4Gotchi, back5Gotchi],
51
- },
52
- leader: webappTeam.leader,
53
- name: webappTeam.name,
54
- owner: webappTeam.owner
55
- }
56
-
57
- inGameTeam.formation.front.forEach(gotchi => {
58
- // remove availableSpecials
59
- delete gotchi.availableSpecials
60
- })
61
-
62
- return inGameTeam
63
- }
64
-
65
- const inGameTeamToWebappTeam = (inGameTeam) => {
66
- const webappTeam = {
67
- front1Gotchi: inGameTeam.formation.front[0],
68
- front2Gotchi: inGameTeam.formation.front[1],
69
- front3Gotchi: inGameTeam.formation.front[2],
70
- front4Gotchi: inGameTeam.formation.front[3],
71
- front5Gotchi: inGameTeam.formation.front[4],
72
- back1Gotchi: inGameTeam.formation.back[0],
73
- back2Gotchi: inGameTeam.formation.back[1],
74
- back3Gotchi: inGameTeam.formation.back[2],
75
- back4Gotchi: inGameTeam.formation.back[3],
76
- back5Gotchi: inGameTeam.formation.back[4],
77
- leader: inGameTeam.leader,
78
- name: inGameTeam.name,
79
- owner: inGameTeam.owner
80
- }
81
-
82
- return webappTeam
83
- }
84
-
85
- module.exports = {
86
- logToInGameTeams,
87
- webappTeamToInGameTeam,
88
- inGameTeamToWebappTeam
1
+ const logToInGameTeams = (originalLog) => {
2
+ // Deep copy the log to avoid modifying the original log
3
+ const log = JSON.parse(JSON.stringify(originalLog))
4
+
5
+ const teams = [];
6
+
7
+ [0, 1].forEach((teamIndex) => {
8
+ teams.push({
9
+ formation: {
10
+ front: log.layout.teams[teamIndex].rows[0].slots.map((slot) => {
11
+ if (slot.isActive) {
12
+ const gotchi = log.gotchis.find((gotchi) => gotchi.id === slot.id)
13
+
14
+ if (!gotchi) {
15
+ throw new Error(`Gotchi not found: ${slot.id}`)
16
+ }
17
+
18
+ return gotchi
19
+ } else {
20
+ return null
21
+ }
22
+ }),
23
+ back: log.layout.teams[teamIndex].rows[1].slots.map((slot) => {
24
+ if (slot.isActive) {
25
+ const gotchi = log.gotchis.find((gotchi) => gotchi.id === slot.id)
26
+
27
+ if (!gotchi) {
28
+ throw new Error(`Gotchi not found: ${slot.id}`)
29
+ }
30
+
31
+ return gotchi
32
+ } else {
33
+ return null
34
+ }
35
+ })
36
+ },
37
+ leader: log.layout.teams[teamIndex].leaderId,
38
+ name: log.layout.teams[teamIndex].name,
39
+ owner: log.layout.teams[teamIndex].owner
40
+ })
41
+ });
42
+
43
+ return teams
44
+ }
45
+
46
+ const webappTeamToInGameTeam = (webappTeam) => {
47
+ const inGameTeam = {
48
+ formation: {
49
+ front: [webappTeam.front1Gotchi, webappTeam.front2Gotchi, webappTeam.front3Gotchi, webappTeam.front4Gotchi, webappTeam.front5Gotchi],
50
+ back: [webappTeam.back1Gotchi, webappTeam.back2Gotchi, webappTeam.back3Gotchi, webappTeam.back4Gotchi, webappTeam.back5Gotchi],
51
+ },
52
+ leader: webappTeam.leader,
53
+ name: webappTeam.name,
54
+ owner: webappTeam.owner
55
+ }
56
+
57
+ inGameTeam.formation.front.forEach(gotchi => {
58
+ if (!gotchi) return
59
+ // remove availableSpecials
60
+ delete gotchi.availableSpecials
61
+ })
62
+
63
+ return inGameTeam
64
+ }
65
+
66
+ const inGameTeamToWebappTeam = (inGameTeam) => {
67
+ const webappTeam = {
68
+ front1Gotchi: inGameTeam.formation.front[0],
69
+ front2Gotchi: inGameTeam.formation.front[1],
70
+ front3Gotchi: inGameTeam.formation.front[2],
71
+ front4Gotchi: inGameTeam.formation.front[3],
72
+ front5Gotchi: inGameTeam.formation.front[4],
73
+ back1Gotchi: inGameTeam.formation.back[0],
74
+ back2Gotchi: inGameTeam.formation.back[1],
75
+ back3Gotchi: inGameTeam.formation.back[2],
76
+ back4Gotchi: inGameTeam.formation.back[3],
77
+ back5Gotchi: inGameTeam.formation.back[4],
78
+ leader: inGameTeam.leader,
79
+ name: inGameTeam.name,
80
+ owner: inGameTeam.owner
81
+ }
82
+
83
+ return webappTeam
84
+ }
85
+
86
+ module.exports = {
87
+ logToInGameTeams,
88
+ webappTeamToInGameTeam,
89
+ inGameTeamToWebappTeam
89
90
  }
@@ -1,40 +1,40 @@
1
- const { ValidationError } = require('./errors')
2
-
3
- const compareLogs = (originalLogs, newLogs) => {
4
- // Check winner, loser and numOfTurns properties
5
- if (originalLogs.result.winner !== newLogs.result.winner) {
6
- throw new ValidationError(`Winner mismatch: ${originalLogs.result.winner} !== ${newLogs.result.winner}`, originalLogs, newLogs)
7
- }
8
-
9
- if (originalLogs.result.loser !== newLogs.result.loser) {
10
- throw new ValidationError(`Loser mismatch: ${originalLogs.result.loser} !== ${newLogs.result.loser}`, originalLogs, newLogs)
11
- }
12
-
13
- if (originalLogs.result.numOfTurns !== newLogs.result.numOfTurns) {
14
- throw new ValidationError(`numOfTurns mismatch: ${originalLogs.result.numOfTurns} !== ${newLogs.result.numOfTurns}`, originalLogs, newLogs)
15
- }
16
-
17
- // Validate winningTeam array
18
- originalLogs.result.winningTeam.forEach((gotchi) => {
19
- // Check id, name and health properties
20
- const gotchi2 = newLogs.result.winningTeam.find((gotchi2) => gotchi2.id === gotchi.id)
21
-
22
- if (!gotchi2) {
23
- throw new ValidationError(`Gotchi not found in winningTeam: ${gotchi.id}`, originalLogs, newLogs)
24
- }
25
-
26
- if (gotchi.name !== gotchi2.name) {
27
- throw new ValidationError(`Gotchi name mismatch: ${gotchi.name} !== ${gotchi2.name}`, originalLogs, newLogs)
28
- }
29
-
30
- if (gotchi.health !== gotchi2.health) {
31
- throw new ValidationError(`Gotchi health mismatch: ${gotchi.health} !== ${gotchi2.health}`, originalLogs, newLogs)
32
- }
33
- })
34
-
35
- return true
36
- }
37
-
38
- module.exports = {
39
- compareLogs
1
+ const { ValidationError } = require('./errors')
2
+
3
+ const compareLogs = (originalLogs, newLogs) => {
4
+ // Check winner, loser and numOfTurns properties
5
+ if (originalLogs.result.winner !== newLogs.result.winner) {
6
+ throw new ValidationError(`Winner mismatch: ${originalLogs.result.winner} !== ${newLogs.result.winner}`, originalLogs, newLogs)
7
+ }
8
+
9
+ if (originalLogs.result.loser !== newLogs.result.loser) {
10
+ throw new ValidationError(`Loser mismatch: ${originalLogs.result.loser} !== ${newLogs.result.loser}`, originalLogs, newLogs)
11
+ }
12
+
13
+ if (originalLogs.result.numOfTurns !== newLogs.result.numOfTurns) {
14
+ throw new ValidationError(`numOfTurns mismatch: ${originalLogs.result.numOfTurns} !== ${newLogs.result.numOfTurns}`, originalLogs, newLogs)
15
+ }
16
+
17
+ // Validate winningTeam array
18
+ originalLogs.result.winningTeam.forEach((gotchi) => {
19
+ // Check id, name and health properties
20
+ const gotchi2 = newLogs.result.winningTeam.find((gotchi2) => gotchi2.id === gotchi.id)
21
+
22
+ if (!gotchi2) {
23
+ throw new ValidationError(`Gotchi not found in winningTeam: ${gotchi.id}`, originalLogs, newLogs)
24
+ }
25
+
26
+ if (gotchi.name !== gotchi2.name) {
27
+ throw new ValidationError(`Gotchi name mismatch: ${gotchi.name} !== ${gotchi2.name}`, originalLogs, newLogs)
28
+ }
29
+
30
+ if (gotchi.health !== gotchi2.health) {
31
+ throw new ValidationError(`Gotchi health mismatch: ${gotchi.health} !== ${gotchi2.health}`, originalLogs, newLogs)
32
+ }
33
+ })
34
+
35
+ return true
36
+ }
37
+
38
+ module.exports = {
39
+ compareLogs
40
40
  }