gotchi-battler-game-logic 1.0.0 → 2.0.1

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 (40) hide show
  1. package/.env.example +1 -0
  2. package/.vscode/settings.json +4 -4
  3. package/Dockerfile +10 -0
  4. package/README.md +49 -49
  5. package/cloudbuild.yaml +27 -0
  6. package/constants/tournamentManagerAbi.json +208 -208
  7. package/game-logic/index.js +6 -5
  8. package/game-logic/v1.4/constants.js +120 -120
  9. package/game-logic/v1.4/index.js +1366 -1353
  10. package/game-logic/v1.5/index.js +8 -8
  11. package/game-logic/v1.6/constants.js +129 -129
  12. package/game-logic/v1.6/index.js +1406 -1402
  13. package/game-logic/v1.7/constants.js +147 -0
  14. package/game-logic/v1.7/helpers.js +605 -0
  15. package/game-logic/v1.7/index.js +796 -0
  16. package/index.js +13 -6
  17. package/package.json +26 -22
  18. package/schemas/team.json +262 -203
  19. package/scripts/balancing/createCSV.js +126 -0
  20. package/scripts/balancing/fixTrainingGotchis.js +260 -0
  21. package/scripts/balancing/processSims.js +230 -0
  22. package/scripts/balancing/sims.js +278 -0
  23. package/scripts/balancing/v1.7/class_combos.js +44 -0
  24. package/scripts/balancing/v1.7/setTeamPositions.js +105 -0
  25. package/scripts/balancing/v1.7/training_gotchis.json +20162 -0
  26. package/scripts/balancing/v1.7/trait_combos.json +10 -0
  27. package/scripts/balancing/v1.7.1/class_combos.js +44 -0
  28. package/scripts/balancing/v1.7.1/setTeamPositions.js +122 -0
  29. package/scripts/balancing/v1.7.1/training_gotchis.json +22402 -0
  30. package/scripts/balancing/v1.7.1/trait_combos.json +10 -0
  31. package/scripts/data/team1.json +213 -200
  32. package/scripts/data/team2.json +200 -200
  33. package/scripts/data/tournaments.json +66 -66
  34. package/scripts/runBattle.js +18 -16
  35. package/scripts/validateBattle.js +70 -64
  36. package/scripts/validateTournament.js +101 -101
  37. package/utils/contracts.js +12 -12
  38. package/utils/errors.js +29 -29
  39. package/utils/transforms.js +88 -47
  40. package/utils/validations.js +39 -39
@@ -0,0 +1,10 @@
1
+ [
2
+ ["avg"],
3
+ ["avg"],
4
+ ["avg"],
5
+ ["avg"],
6
+ ["avg"],
7
+ ["avg"],
8
+ ["avg"],
9
+ ["avg"]
10
+ ]
@@ -0,0 +1,44 @@
1
+ const generateClassCombinations = () => {
2
+ // Generate combinations of the 8 classes for the 4 non-leader spots
3
+ const combinations = []
4
+
5
+ for (let i = 1; i <= 8; i++) {
6
+ for (let j = 1; j <= 8; j++) {
7
+ for (let k = 1; k <= 8; k++) {
8
+ for (let l = 1; l <= 8; l++) {
9
+ combinations.push([i, j, k, l].sort())
10
+ }
11
+ }
12
+ }
13
+ }
14
+
15
+ // Remove duplicate combinations, so [1,1,1,1] is allowed but [1,1,1,2] and [1,1,2,1] are duplicates
16
+ // Keep as numbers for now, convert to strings to remove duplicates, then convert back to numbers
17
+ const uniqueCombinations = [...new Set(combinations.map((combination) => combination.join('')))].map((combination) => combination.split('').map((number) => parseInt(number)))
18
+
19
+ return uniqueCombinations
20
+ }
21
+
22
+ const getCombinationsForALeader = (leaderClass) => {
23
+ const combinations = generateClassCombinations()
24
+
25
+ const combinationsForALeader = combinations.map((combination) => {
26
+ return [leaderClass, ...combination]
27
+ })
28
+
29
+ return combinationsForALeader
30
+ }
31
+
32
+ const getAllClassCombos = () => {
33
+ const allClassCombos = []
34
+
35
+ for (let i = 1; i <= 8; i++) {
36
+ allClassCombos.push(...getCombinationsForALeader(i))
37
+ }
38
+
39
+ return allClassCombos
40
+ }
41
+
42
+ const allClassCombos = getAllClassCombos()
43
+
44
+ module.exports = allClassCombos
@@ -0,0 +1,122 @@
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
+ let score = 0
10
+
11
+ switch (gotchi.specialId) {
12
+ case 1: // Ninja
13
+ score = 2
14
+ break
15
+ case 2: // Enlightened
16
+ score = 6
17
+ break
18
+ case 3: // Cleaver
19
+ score = 1
20
+ break
21
+ case 4: // Tank
22
+ score = 2
23
+ break
24
+ case 5: // Cursed
25
+ score = 4
26
+ break
27
+ case 6: // Healer
28
+ // If leader is healer then healer is good up front
29
+ if (leader.specialId === 6) {
30
+ score = 5
31
+ } else {
32
+ score = 1
33
+ }
34
+ break
35
+ case 7: // Mage
36
+ score = 0
37
+ break
38
+ case 8: // Troll
39
+ score = 1
40
+ break
41
+ }
42
+
43
+ return score
44
+ }
45
+
46
+ // High health gotchis do well up front
47
+ const isHighHealth = gotchi.nrg < 50
48
+
49
+ // High armor gotchis do well up front
50
+ const isLowAgg = gotchi.agg < 50
51
+
52
+ // High evasion gotchis do well up front
53
+ const isHighSpk = gotchi.spk >= 50
54
+
55
+ const isLowBrn = gotchi.brn < 50
56
+
57
+ // Create a score from 0 to 6 based on how much they favour the front
58
+
59
+ let score = 0
60
+
61
+ if (gotchi.specialId === 2) score +=2 // Enlightened
62
+ if (isHighHealth) score++
63
+ if (isLowBrn) score++
64
+ if (isLowAgg) score++
65
+ if (isHighSpk) score++
66
+
67
+ return score
68
+ }
69
+
70
+ module.exports = (team) => {
71
+ // All gotchis are currently in the back row
72
+ // Get the score for each gotchi for how much they favour the front row
73
+ const teamFrontRowScores = team.formation.back.map((gotchi) => getFrontRowScore(gotchi.id, team.leader));
74
+
75
+ [0,1,2,3,4].forEach((i) => {
76
+ const gotchi = team.formation.back[i]
77
+ const score = teamFrontRowScores[i]
78
+
79
+ // If score is >= 3 then move to front row
80
+ if (score >= 3) {
81
+ team.formation.front[i] = gotchi
82
+ team.formation.back[i] = null
83
+ }
84
+ })
85
+
86
+ // If you have 5 gotchis in the front then send the lowest 2 to the back
87
+ const frontGotchis = team.formation.front.filter(gotchi => gotchi)
88
+ if (frontGotchis.length === 5) {
89
+ // Sort the gotchis by score in ascending order (lowest score first)
90
+ const orderedGotchis = JSON.parse(JSON.stringify(frontGotchis)).sort((a, b) => getFrontRowScore(a.id, team.leader) - getFrontRowScore(b.id, team.leader));
91
+
92
+ // 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
93
+ let hasMoved = 0
94
+ team.formation.front.forEach((gotchi, i) => {
95
+ if (hasMoved < 2 && (gotchi.id === orderedGotchis[0].id || gotchi.id === orderedGotchis[1].id)) {
96
+ team.formation.back[i] = gotchi
97
+ team.formation.front[i] = null
98
+
99
+ hasMoved++
100
+ }
101
+ })
102
+ }
103
+
104
+ // If you have 5 gotchis in the back then send the highest 2 to the front
105
+ const backGotchis = team.formation.back.filter(gotchi => gotchi)
106
+ if (backGotchis.length === 5) {
107
+ // Sort the gotchis by score in descending order (highest score first)
108
+ const orderedGotchis = JSON.parse(JSON.stringify(backGotchis)).sort((a, b) => getFrontRowScore(b.id, team.leader) - getFrontRowScore(a.id, team.leader));
109
+
110
+ // 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
111
+ let hasMoved = 0
112
+ team.formation.back.forEach((gotchi, i) => {
113
+ if (hasMoved < 2 && (gotchi.id === orderedGotchis[0].id || gotchi.id === orderedGotchis[1].id)) {
114
+ team.formation.front[i] = gotchi
115
+ team.formation.back[i] = null
116
+
117
+ hasMoved++
118
+ }
119
+ })
120
+ }
121
+ }
122
+