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.
- package/.vscode/settings.json +4 -4
- package/Dockerfile +9 -9
- package/README.md +49 -49
- package/cloudbuild.yaml +27 -27
- package/constants/tournamentManagerAbi.json +208 -208
- package/game-logic/index.js +6 -6
- package/game-logic/v1.4/constants.js +114 -114
- package/game-logic/v1.4/index.js +1366 -1366
- package/game-logic/v1.6/constants.js +123 -123
- package/game-logic/v1.6/index.js +1406 -1406
- package/game-logic/v1.7/constants.js +142 -140
- package/game-logic/v1.7/helpers.js +595 -593
- package/game-logic/v1.7/index.js +802 -795
- package/index.js +12 -12
- package/package.json +26 -26
- package/schemas/team.json +349 -343
- package/scripts/balancing/createCSV.js +126 -126
- package/scripts/balancing/fixTrainingGotchis.js +155 -259
- package/scripts/balancing/processSims.js +229 -229
- package/scripts/balancing/sims.js +278 -278
- package/scripts/balancing/v1.7/class_combos.js +43 -43
- package/scripts/balancing/v1.7/setTeamPositions.js +105 -105
- package/scripts/balancing/v1.7/training_gotchis.json +20161 -20161
- package/scripts/balancing/v1.7/trait_combos.json +9 -9
- package/scripts/balancing/v1.7.1/class_combos.js +43 -43
- package/scripts/balancing/v1.7.1/setTeamPositions.js +122 -122
- package/scripts/balancing/v1.7.1/training_gotchis.json +22401 -22401
- package/scripts/balancing/v1.7.1/trait_combos.json +9 -9
- package/scripts/balancing/v1.7.2/class_combos.js +44 -0
- package/scripts/balancing/v1.7.2/setTeamPositions.js +122 -0
- package/scripts/balancing/v1.7.2/training_gotchis.json +22402 -0
- package/scripts/balancing/v1.7.2/trait_combos.json +10 -0
- package/scripts/data/team1.json +213 -213
- package/scripts/data/team2.json +200 -200
- package/scripts/data/tournaments.json +66 -66
- package/scripts/{runBattle.js → runLocalBattle.js} +18 -18
- package/scripts/runRealBattle.js +52 -0
- package/scripts/simRealBattle.js +121 -0
- package/scripts/validateBattle.js +74 -70
- package/scripts/validateTournament.js +101 -101
- package/utils/contracts.js +12 -12
- package/utils/errors.js +29 -29
- package/utils/mapGotchi.js +119 -0
- package/utils/transforms.js +89 -88
- package/utils/validations.js +39 -39
package/utils/transforms.js
CHANGED
|
@@ -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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
}
|
package/utils/validations.js
CHANGED
|
@@ -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
|
}
|