gotchi-battler-game-logic 1.0.0 → 2.0.0
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/.env.example +1 -0
- package/.vscode/settings.json +4 -4
- package/Dockerfile +10 -0
- package/README.md +49 -49
- package/cloudbuild.yaml +27 -0
- package/constants/tournamentManagerAbi.json +208 -208
- package/game-logic/index.js +6 -5
- package/game-logic/v1.4/constants.js +120 -120
- package/game-logic/v1.4/index.js +1366 -1353
- package/game-logic/v1.5/index.js +8 -8
- package/game-logic/v1.6/constants.js +129 -129
- package/game-logic/v1.6/index.js +1406 -1402
- package/game-logic/v1.7/constants.js +147 -0
- package/game-logic/v1.7/index.js +1389 -0
- package/index.js +13 -6
- package/package.json +26 -22
- package/schemas/team.json +208 -203
- package/scripts/balancing/createCSV.js +126 -0
- package/scripts/balancing/fixTrainingGotchis.js +260 -0
- package/scripts/balancing/processSims.js +230 -0
- package/scripts/balancing/sims.js +278 -0
- package/scripts/balancing/v1.7/class_combos.js +44 -0
- package/scripts/balancing/v1.7/setTeamPositions.js +105 -0
- package/scripts/balancing/v1.7/training_gotchis.json +20162 -0
- package/scripts/balancing/v1.7/trait_combos.json +10 -0
- package/scripts/balancing/v1.7.1/class_combos.js +44 -0
- package/scripts/balancing/v1.7.1/setTeamPositions.js +122 -0
- package/scripts/balancing/v1.7.1/training_gotchis.json +22402 -0
- package/scripts/balancing/v1.7.1/trait_combos.json +10 -0
- package/scripts/data/team1.json +200 -200
- package/scripts/data/team2.json +200 -200
- package/scripts/data/tournaments.json +66 -66
- package/scripts/runBattle.js +15 -15
- package/scripts/validateBattle.js +70 -64
- package/scripts/validateTournament.js +101 -101
- package/utils/contracts.js +12 -12
- package/utils/errors.js +29 -29
- package/utils/transforms.js +88 -47
- package/utils/validations.js +39 -39
package/index.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
// Export the gameLoop function for the current version of the game logic
|
|
2
|
-
const versions = require('./game-logic')
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// Export the gameLoop function for the current version of the game logic
|
|
2
|
+
const versions = require('./game-logic')
|
|
3
|
+
const currentVersion = versions[versions.current]
|
|
4
|
+
|
|
5
|
+
const teamSchema = require('./schemas/team')
|
|
6
|
+
const { webappTeamToInGameTeam, inGameTeamToWebappTeam } = require('./utils/transforms')
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
game: currentVersion.gameLoop,
|
|
10
|
+
teamSchema,
|
|
11
|
+
webappTeamToInGameTeam,
|
|
12
|
+
inGameTeamToWebappTeam
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "gotchi-battler-game-logic",
|
|
3
|
-
"version": "
|
|
4
|
-
"main": "index.js",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
-
},
|
|
8
|
-
"author": "Galaxy Brain Studios",
|
|
9
|
-
"description": "The game logic for the Gotchi Battler game",
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "Galaxy-Brain-Studios/gotchi-battler-game-logic"
|
|
13
|
-
},
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "gotchi-battler-game-logic",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
},
|
|
8
|
+
"author": "Galaxy Brain Studios",
|
|
9
|
+
"description": "The game logic for the Gotchi Battler game",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "Galaxy-Brain-Studios/gotchi-battler-game-logic"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"seedrandom": "^3.0.5",
|
|
16
|
+
"z-schema": "^6.0.2"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@google-cloud/storage": "^7.13.0",
|
|
20
|
+
"axios": "^1.7.4",
|
|
21
|
+
"axios-retry": "^4.5.0",
|
|
22
|
+
"dotenv": "^16.4.5",
|
|
23
|
+
"ethers": "^5.7.0",
|
|
24
|
+
"json-csv": "^4.0.18"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/schemas/team.json
CHANGED
|
@@ -1,204 +1,209 @@
|
|
|
1
|
-
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
"
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
"
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
"
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
"
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
"
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
"
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
"
|
|
190
|
-
"
|
|
191
|
-
"
|
|
192
|
-
"
|
|
193
|
-
"
|
|
194
|
-
"
|
|
195
|
-
"
|
|
196
|
-
"
|
|
197
|
-
"
|
|
198
|
-
"
|
|
199
|
-
"
|
|
200
|
-
"
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"properties": {
|
|
4
|
+
"formation": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["front", "back"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"front": {
|
|
9
|
+
"type": "array",
|
|
10
|
+
"minItems": 5,
|
|
11
|
+
"maxItems": 5,
|
|
12
|
+
"items": {
|
|
13
|
+
"oneOf": [
|
|
14
|
+
{
|
|
15
|
+
"$ref": "#/definitions/gotchi"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"type": "null"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"back": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"minItems": 5,
|
|
26
|
+
"maxItems": 5,
|
|
27
|
+
"items": {
|
|
28
|
+
"oneOf": [
|
|
29
|
+
{
|
|
30
|
+
"$ref": "#/definitions/gotchi"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"type": "null"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"leader": {
|
|
41
|
+
"type": "integer"
|
|
42
|
+
},
|
|
43
|
+
"name": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
},
|
|
46
|
+
"owner": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"pattern": "^0x[a-fA-F0-9]{40}$"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"required": ["formation", "leader", "name", "owner"],
|
|
52
|
+
"additionalProperties": false,
|
|
53
|
+
"definitions": {
|
|
54
|
+
"gotchi": {
|
|
55
|
+
"type": "object",
|
|
56
|
+
"properties": {
|
|
57
|
+
"id": {
|
|
58
|
+
"type": "integer"
|
|
59
|
+
},
|
|
60
|
+
"snapshotBlock": {
|
|
61
|
+
"type": "integer"
|
|
62
|
+
},
|
|
63
|
+
"onchainId": {
|
|
64
|
+
"type": "integer"
|
|
65
|
+
},
|
|
66
|
+
"name": {
|
|
67
|
+
"type": "string"
|
|
68
|
+
},
|
|
69
|
+
"brs": {
|
|
70
|
+
"type": "integer"
|
|
71
|
+
},
|
|
72
|
+
"nrg": {
|
|
73
|
+
"type": "integer"
|
|
74
|
+
},
|
|
75
|
+
"agg": {
|
|
76
|
+
"type": "integer"
|
|
77
|
+
},
|
|
78
|
+
"spk": {
|
|
79
|
+
"type": "integer"
|
|
80
|
+
},
|
|
81
|
+
"brn": {
|
|
82
|
+
"type": "integer"
|
|
83
|
+
},
|
|
84
|
+
"eyc": {
|
|
85
|
+
"type": "integer"
|
|
86
|
+
},
|
|
87
|
+
"eys": {
|
|
88
|
+
"type": "integer"
|
|
89
|
+
},
|
|
90
|
+
"kinship": {
|
|
91
|
+
"type": "integer"
|
|
92
|
+
},
|
|
93
|
+
"xp": {
|
|
94
|
+
"type": "integer"
|
|
95
|
+
},
|
|
96
|
+
"speed": {
|
|
97
|
+
"type": "integer"
|
|
98
|
+
},
|
|
99
|
+
"health": {
|
|
100
|
+
"type": "integer"
|
|
101
|
+
},
|
|
102
|
+
"crit": {
|
|
103
|
+
"type": "integer"
|
|
104
|
+
},
|
|
105
|
+
"armor": {
|
|
106
|
+
"type": "integer"
|
|
107
|
+
},
|
|
108
|
+
"evade": {
|
|
109
|
+
"type": "integer"
|
|
110
|
+
},
|
|
111
|
+
"resist": {
|
|
112
|
+
"type": "integer"
|
|
113
|
+
},
|
|
114
|
+
"magic": {
|
|
115
|
+
"type": "integer"
|
|
116
|
+
},
|
|
117
|
+
"physical": {
|
|
118
|
+
"type": "integer"
|
|
119
|
+
},
|
|
120
|
+
"accuracy": {
|
|
121
|
+
"type": "number"
|
|
122
|
+
},
|
|
123
|
+
"attack": {
|
|
124
|
+
"type": "string",
|
|
125
|
+
"enum": ["physical", "magic"]
|
|
126
|
+
},
|
|
127
|
+
"actionDelay": {
|
|
128
|
+
"type": "number"
|
|
129
|
+
},
|
|
130
|
+
"svgFront": {
|
|
131
|
+
"type": "string",
|
|
132
|
+
"format": "uri"
|
|
133
|
+
},
|
|
134
|
+
"svgBack": {
|
|
135
|
+
"type": "string",
|
|
136
|
+
"format": "uri"
|
|
137
|
+
},
|
|
138
|
+
"svgLeft": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"format": "uri"
|
|
141
|
+
},
|
|
142
|
+
"svgRight": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"format": "uri"
|
|
145
|
+
},
|
|
146
|
+
"specialId": {
|
|
147
|
+
"type": "integer"
|
|
148
|
+
},
|
|
149
|
+
"special": {
|
|
150
|
+
"type": "object",
|
|
151
|
+
"properties": {
|
|
152
|
+
"id": {
|
|
153
|
+
"type": "integer"
|
|
154
|
+
},
|
|
155
|
+
"class": {
|
|
156
|
+
"type": "string"
|
|
157
|
+
},
|
|
158
|
+
"gotchiClass": {
|
|
159
|
+
"type": "string"
|
|
160
|
+
},
|
|
161
|
+
"name": {
|
|
162
|
+
"type": "string"
|
|
163
|
+
},
|
|
164
|
+
"cooldown": {
|
|
165
|
+
"type": "integer"
|
|
166
|
+
},
|
|
167
|
+
"leaderPassive": {
|
|
168
|
+
"type": "string"
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"required": ["id", "name", "cooldown", "leaderPassive"],
|
|
172
|
+
"additionalProperties": false
|
|
173
|
+
},
|
|
174
|
+
"statuses": {
|
|
175
|
+
"type": "array",
|
|
176
|
+
"items": {
|
|
177
|
+
"type": "string"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"createdAt": {
|
|
181
|
+
"type": "string"
|
|
182
|
+
},
|
|
183
|
+
"updatedAt": {
|
|
184
|
+
"type": "string"
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"additionalProperties": false,
|
|
188
|
+
"required": [
|
|
189
|
+
"id",
|
|
190
|
+
"name",
|
|
191
|
+
"speed",
|
|
192
|
+
"health",
|
|
193
|
+
"crit",
|
|
194
|
+
"armor",
|
|
195
|
+
"evade",
|
|
196
|
+
"resist",
|
|
197
|
+
"magic",
|
|
198
|
+
"physical",
|
|
199
|
+
"accuracy",
|
|
200
|
+
"svgFront",
|
|
201
|
+
"svgBack",
|
|
202
|
+
"svgLeft",
|
|
203
|
+
"svgRight",
|
|
204
|
+
"specialId",
|
|
205
|
+
"special"
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
}
|
|
204
209
|
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
require('dotenv').config()
|
|
2
|
+
const { writeFile } = require('node:fs/promises')
|
|
3
|
+
const path = require('node:path')
|
|
4
|
+
|
|
5
|
+
const { Storage } = require('@google-cloud/storage')
|
|
6
|
+
const storage = new Storage()
|
|
7
|
+
// Use key file locally
|
|
8
|
+
process.env.GOOGLE_APPLICATION_CREDENTIALS = path.join(__dirname, '../../keyfile.json')
|
|
9
|
+
|
|
10
|
+
const jsoncsv = require('json-csv')
|
|
11
|
+
|
|
12
|
+
// Generate csv files for a Google Cloud run job
|
|
13
|
+
const main = async () => {
|
|
14
|
+
if (!process.argv[2]) {
|
|
15
|
+
throw new Error('Execution ID required')
|
|
16
|
+
}
|
|
17
|
+
const executionId = process.argv[2]
|
|
18
|
+
// const numOfTasks = 2640
|
|
19
|
+
const numOfTasks = 5280
|
|
20
|
+
|
|
21
|
+
const results = []
|
|
22
|
+
|
|
23
|
+
// Download all the files in batches of 100
|
|
24
|
+
for (let i = 0; i < numOfTasks; i += 100) {
|
|
25
|
+
const batch = []
|
|
26
|
+
|
|
27
|
+
for (let j = 0; j < 100; j++) {
|
|
28
|
+
if (i + j < numOfTasks) {
|
|
29
|
+
batch.push(storage.bucket(process.env.SIMS_BUCKET).file(`${executionId}_${i + j}.json`).download())
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const batchResults = await Promise.all(batch)
|
|
34
|
+
results.push(...batchResults)
|
|
35
|
+
|
|
36
|
+
console.log(`Downloaded ${i + batchResults.length} files`)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const combinedResults = []
|
|
40
|
+
|
|
41
|
+
for (const result of results) {
|
|
42
|
+
combinedResults.push(JSON.parse(result.toString()))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const fields = [
|
|
46
|
+
{
|
|
47
|
+
name: 'id',
|
|
48
|
+
label: 'id'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'slot1',
|
|
52
|
+
label: 'slot1'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'slot2',
|
|
56
|
+
label: 'slot2'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'slot3',
|
|
60
|
+
label: 'slot3'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'slot4',
|
|
64
|
+
label: 'slot4'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'slot5',
|
|
68
|
+
label: 'slot5'
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'wins',
|
|
72
|
+
label: 'wins'
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'draws',
|
|
76
|
+
label: 'draws'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'losses',
|
|
80
|
+
label: 'losses'
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
// Check which powerLevels are present
|
|
85
|
+
const powerLevels = ['Godlike', 'Mythical', 'Legendary', 'Rare', 'Uncommon', 'Common', 'Garbage']
|
|
86
|
+
for (const powerLevel of powerLevels) {
|
|
87
|
+
if (combinedResults[0][`wins${powerLevel}`]) {
|
|
88
|
+
fields.push({
|
|
89
|
+
name: `wins${powerLevel}`,
|
|
90
|
+
label: `wins${powerLevel}`
|
|
91
|
+
})
|
|
92
|
+
fields.push({
|
|
93
|
+
name: `draws${powerLevel}`,
|
|
94
|
+
label: `draws${powerLevel}`
|
|
95
|
+
})
|
|
96
|
+
fields.push({
|
|
97
|
+
name: `losses${powerLevel}`,
|
|
98
|
+
label: `losses${powerLevel}`
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const csv = await jsoncsv.buffered(combinedResults, {
|
|
104
|
+
fields
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
await writeFile(path.join(__dirname, `/output/${executionId}.csv`), csv)
|
|
108
|
+
console.log(`Wrote ${executionId}.csv`)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
module.exports = main
|
|
112
|
+
|
|
113
|
+
if (require.main === module) {
|
|
114
|
+
// node scripts/balancing/createCSV.js balancing-sims-fgpsl
|
|
115
|
+
|
|
116
|
+
main()
|
|
117
|
+
.then(() => {
|
|
118
|
+
console.log('Done')
|
|
119
|
+
process.exit(0)
|
|
120
|
+
})
|
|
121
|
+
.catch((err) => {
|
|
122
|
+
console.error(err)
|
|
123
|
+
process.exit(1)
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|