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,105 +1,105 @@
1
- const trainingGotchis = require('./training_gotchis.json')
2
-
3
- const getFrontRowScore = (gotchiId, leaderId) => {
4
- const gotchi = trainingGotchis.find(gotchi => gotchi.id === gotchiId)
5
- const leader = trainingGotchis.find(gotchi => gotchi.id === leaderId)
6
-
7
- if (gotchi.name.includes(' avg ')) {
8
-
9
- if (gotchi.specialId === 2) {
10
- // Enlightened are the best up front
11
- return 6
12
- } else if (leader.specialId === 6 && gotchi.specialId === 6) {
13
- // Healer with a healer leader are the second best up front
14
- return 5
15
- } else if (gotchi.specialId === 5) {
16
- // Cursed are the third best up front
17
- return 4
18
- } else if (gotchi.specialId === 6) {
19
- // Healers do ok
20
- return 2
21
- } else if (gotchi.specialId === 7) {
22
- // Mages always go to the back
23
- return 0
24
- } else {
25
- return 1
26
- }
27
- }
28
-
29
- // High health gotchis do well up front
30
- const isHighHealth = gotchi.nrg < 50
31
-
32
- // High armor gotchis do well up front
33
- const isLowAgg = gotchi.agg < 50
34
-
35
- // High evasion gotchis do well up front
36
- const isHighSpk = gotchi.spk >= 50
37
-
38
- const isLowBrn = gotchi.brn < 50
39
-
40
- // Create a score from 0 to 6 based on how much they favour the front
41
-
42
- let score = 0
43
-
44
- if (gotchi.specialId === 2) score +=2 // Enlightened
45
- if (isHighHealth) score++
46
- if (isLowBrn) score++
47
- if (isLowAgg) score++
48
- if (isHighSpk) score++
49
-
50
- return score
51
- }
52
-
53
- module.exports = (team) => {
54
- // All gotchis are currently in the back row
55
- // Get the score for each gotchi for how much they favour the front row
56
- const teamFrontRowScores = team.formation.back.map((gotchi) => getFrontRowScore(gotchi.id, team.leader));
57
-
58
- [0,1,2,3,4].forEach((i) => {
59
- const gotchi = team.formation.back[i]
60
- const score = teamFrontRowScores[i]
61
-
62
- // If score is >= 3 then move to front row
63
- if (score >= 3) {
64
- team.formation.front[i] = gotchi
65
- team.formation.back[i] = null
66
- }
67
- })
68
-
69
- // If you have 5 gotchis in the front then send the lowest 2 to the back
70
- const frontGotchis = team.formation.front.filter(gotchi => gotchi)
71
- if (frontGotchis.length === 5) {
72
- // Sort the gotchis by score in ascending order (lowest score first)
73
- const orderedGotchis = JSON.parse(JSON.stringify(frontGotchis)).sort((a, b) => getFrontRowScore(a.id, team.leader) - getFrontRowScore(b.id, team.leader));
74
-
75
- // Loop through the front row and the first 2 gotchis that have a score of either orderedGotchis[0] or orderedGotchis[1] move to the back
76
- let hasMoved = 0
77
- team.formation.front.forEach((gotchi, i) => {
78
- if (hasMoved < 2 && (gotchi.id === orderedGotchis[0].id || gotchi.id === orderedGotchis[1].id)) {
79
- team.formation.back[i] = gotchi
80
- team.formation.front[i] = null
81
-
82
- hasMoved++
83
- }
84
- })
85
- }
86
-
87
- // If you have 5 gotchis in the back then send the highest 2 to the front
88
- const backGotchis = team.formation.back.filter(gotchi => gotchi)
89
- if (backGotchis.length === 5) {
90
- // Sort the gotchis by score in descending order (highest score first)
91
- const orderedGotchis = JSON.parse(JSON.stringify(backGotchis)).sort((a, b) => getFrontRowScore(b.id, team.leader) - getFrontRowScore(a.id, team.leader));
92
-
93
- // Loop through the back row and the first 2 gotchis that have a score of either orderedGotchis[0] or orderedGotchis[1] move to the front
94
- let hasMoved = 0
95
- team.formation.back.forEach((gotchi, i) => {
96
- if (hasMoved < 2 && (gotchi.id === orderedGotchis[0].id || gotchi.id === orderedGotchis[1].id)) {
97
- team.formation.front[i] = gotchi
98
- team.formation.back[i] = null
99
-
100
- hasMoved++
101
- }
102
- })
103
- }
104
- }
105
-
1
+ const trainingGotchis = require('./training_gotchis.json')
2
+
3
+ const getFrontRowScore = (gotchiId, leaderId) => {
4
+ const gotchi = trainingGotchis.find(gotchi => gotchi.id === gotchiId)
5
+ const leader = trainingGotchis.find(gotchi => gotchi.id === leaderId)
6
+
7
+ if (gotchi.name.includes(' avg ')) {
8
+
9
+ if (gotchi.specialId === 2) {
10
+ // Enlightened are the best up front
11
+ return 6
12
+ } else if (leader.specialId === 6 && gotchi.specialId === 6) {
13
+ // Healer with a healer leader are the second best up front
14
+ return 5
15
+ } else if (gotchi.specialId === 5) {
16
+ // Cursed are the third best up front
17
+ return 4
18
+ } else if (gotchi.specialId === 6) {
19
+ // Healers do ok
20
+ return 2
21
+ } else if (gotchi.specialId === 7) {
22
+ // Mages always go to the back
23
+ return 0
24
+ } else {
25
+ return 1
26
+ }
27
+ }
28
+
29
+ // High health gotchis do well up front
30
+ const isHighHealth = gotchi.nrg < 50
31
+
32
+ // High armor gotchis do well up front
33
+ const isLowAgg = gotchi.agg < 50
34
+
35
+ // High evasion gotchis do well up front
36
+ const isHighSpk = gotchi.spk >= 50
37
+
38
+ const isLowBrn = gotchi.brn < 50
39
+
40
+ // Create a score from 0 to 6 based on how much they favour the front
41
+
42
+ let score = 0
43
+
44
+ if (gotchi.specialId === 2) score +=2 // Enlightened
45
+ if (isHighHealth) score++
46
+ if (isLowBrn) score++
47
+ if (isLowAgg) score++
48
+ if (isHighSpk) score++
49
+
50
+ return score
51
+ }
52
+
53
+ module.exports = (team) => {
54
+ // All gotchis are currently in the back row
55
+ // Get the score for each gotchi for how much they favour the front row
56
+ const teamFrontRowScores = team.formation.back.map((gotchi) => getFrontRowScore(gotchi.id, team.leader));
57
+
58
+ [0,1,2,3,4].forEach((i) => {
59
+ const gotchi = team.formation.back[i]
60
+ const score = teamFrontRowScores[i]
61
+
62
+ // If score is >= 3 then move to front row
63
+ if (score >= 3) {
64
+ team.formation.front[i] = gotchi
65
+ team.formation.back[i] = null
66
+ }
67
+ })
68
+
69
+ // If you have 5 gotchis in the front then send the lowest 2 to the back
70
+ const frontGotchis = team.formation.front.filter(gotchi => gotchi)
71
+ if (frontGotchis.length === 5) {
72
+ // Sort the gotchis by score in ascending order (lowest score first)
73
+ const orderedGotchis = JSON.parse(JSON.stringify(frontGotchis)).sort((a, b) => getFrontRowScore(a.id, team.leader) - getFrontRowScore(b.id, team.leader));
74
+
75
+ // Loop through the front row and the first 2 gotchis that have a score of either orderedGotchis[0] or orderedGotchis[1] move to the back
76
+ let hasMoved = 0
77
+ team.formation.front.forEach((gotchi, i) => {
78
+ if (hasMoved < 2 && (gotchi.id === orderedGotchis[0].id || gotchi.id === orderedGotchis[1].id)) {
79
+ team.formation.back[i] = gotchi
80
+ team.formation.front[i] = null
81
+
82
+ hasMoved++
83
+ }
84
+ })
85
+ }
86
+
87
+ // If you have 5 gotchis in the back then send the highest 2 to the front
88
+ const backGotchis = team.formation.back.filter(gotchi => gotchi)
89
+ if (backGotchis.length === 5) {
90
+ // Sort the gotchis by score in descending order (highest score first)
91
+ const orderedGotchis = JSON.parse(JSON.stringify(backGotchis)).sort((a, b) => getFrontRowScore(b.id, team.leader) - getFrontRowScore(a.id, team.leader));
92
+
93
+ // Loop through the back row and the first 2 gotchis that have a score of either orderedGotchis[0] or orderedGotchis[1] move to the front
94
+ let hasMoved = 0
95
+ team.formation.back.forEach((gotchi, i) => {
96
+ if (hasMoved < 2 && (gotchi.id === orderedGotchis[0].id || gotchi.id === orderedGotchis[1].id)) {
97
+ team.formation.front[i] = gotchi
98
+ team.formation.back[i] = null
99
+
100
+ hasMoved++
101
+ }
102
+ })
103
+ }
104
+ }
105
+