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,5 +1,5 @@
1
- {
2
- "files.exclude": {
3
- "**/.git": false
4
- }
1
+ {
2
+ "files.exclude": {
3
+ "**/.git": false
4
+ }
5
5
  }
package/Dockerfile CHANGED
@@ -1,10 +1,10 @@
1
- FROM node:18
2
-
3
- WORKDIR /usr/src/app
4
-
5
- COPY package*.json ./
6
- RUN npm i
7
-
8
- COPY . .
9
-
1
+ FROM node:18-alpine
2
+
3
+ WORKDIR /usr/src/app
4
+
5
+ COPY package*.json ./
6
+ RUN npm i
7
+
8
+ COPY . .
9
+
10
10
  CMD ["node", "scripts/balancing/sims.js"]
package/README.md CHANGED
@@ -1,50 +1,50 @@
1
- # Galaxy Brain Studios - Gotchi Battler Game Logic
2
-
3
- This npm module contains the game logic for the Gotchi Battler game developed by Galaxy Brain Studios.
4
-
5
- ## Installation
6
-
7
- To install the module, run the following command:
8
-
9
- ```
10
- npm install gotchi-battler-game-logic
11
- ```
12
-
13
- ## Usage
14
-
15
- To use the module in your project, import it as follows:
16
-
17
- ```javascript
18
- const { battle } = require('gotchi-battler-game-logic')
19
-
20
- // team1 and team2 an in-game team objects (see below)
21
- // seed is a random seed for the game
22
- const result = battle(team1, team2, seed)
23
- ```
24
- The schema for the in-game team object can be found in `/schemas/team.json`
25
-
26
- Examples of the in-game team object can be found in `/scripts/data/team1.json` and `/scripts/data/team2.json`
27
-
28
- ## Development
29
-
30
- ### Validate Tournament
31
-
32
- The validate tournament script does the following:
33
- - Fetches the data of a tournament from the Gotchi Battler website
34
- - Loops through all the battles in the tournament, bracket by bracket, round by round
35
- - For each battle, the logs are fetched from the Gotchi Battler website
36
- - The battle is then simulated using the game logic
37
- - The result of the simulation is compared to the actual result of the battle
38
-
39
- To validate the battles from the RF8 100K Tournament, run the following command:
40
-
41
- ```bash
42
- node scripts/validateTournament.js 15
43
- ```
44
-
45
- Get the tournament id from the URL of the tournament page on the Gotchi Battler website.
46
-
47
-
48
- PLEASE NOTE:
49
- - Currently, only the tournaments from Rarity Farming season 8 are supported (Tournament IDs 13-15)
1
+ # Galaxy Brain Studios - Gotchi Battler Game Logic
2
+
3
+ This npm module contains the game logic for the Gotchi Battler game developed by Galaxy Brain Studios.
4
+
5
+ ## Installation
6
+
7
+ To install the module, run the following command:
8
+
9
+ ```
10
+ npm install gotchi-battler-game-logic
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ To use the module in your project, import it as follows:
16
+
17
+ ```javascript
18
+ const { battle } = require('gotchi-battler-game-logic')
19
+
20
+ // team1 and team2 an in-game team objects (see below)
21
+ // seed is a random seed for the game
22
+ const result = battle(team1, team2, seed)
23
+ ```
24
+ The schema for the in-game team object can be found in `/schemas/team.json`
25
+
26
+ Examples of the in-game team object can be found in `/scripts/data/team1.json` and `/scripts/data/team2.json`
27
+
28
+ ## Development
29
+
30
+ ### Validate Tournament
31
+
32
+ The validate tournament script does the following:
33
+ - Fetches the data of a tournament from the Gotchi Battler website
34
+ - Loops through all the battles in the tournament, bracket by bracket, round by round
35
+ - For each battle, the logs are fetched from the Gotchi Battler website
36
+ - The battle is then simulated using the game logic
37
+ - The result of the simulation is compared to the actual result of the battle
38
+
39
+ To validate the battles from the RF8 100K Tournament, run the following command:
40
+
41
+ ```bash
42
+ node scripts/validateTournament.js 15
43
+ ```
44
+
45
+ Get the tournament id from the URL of the tournament page on the Gotchi Battler website.
46
+
47
+
48
+ PLEASE NOTE:
49
+ - Currently, only the tournaments from Rarity Farming season 8 are supported (Tournament IDs 13-15)
50
50
  - The script can take a while to run, in local testing it took around 20 minutes
package/cloudbuild.yaml CHANGED
@@ -1,27 +1,27 @@
1
- steps:
2
- - name: gcr.io/cloud-builders/docker
3
- args:
4
- - build
5
- - '--no-cache'
6
- - '-t'
7
- - $_AR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA
8
- - '-t'
9
- - $_AR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:latest
10
- - .
11
- - '-f'
12
- - Dockerfile
13
- id: Build
14
- - name: gcr.io/cloud-builders/docker
15
- args:
16
- - push
17
- - '$_AR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME'
18
- - '--all-tags'
19
- id: Push
20
- images:
21
- - $_AR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA
22
- options:
23
- substitutionOption: ALLOW_LOOSE
24
- logging: CLOUD_LOGGING_ONLY
25
- substitutions:
26
- _AR_HOSTNAME: europe-west1-docker.pkg.dev
27
- _SERVICE_NAME: gotchi-battler-game-logic
1
+ steps:
2
+ - name: gcr.io/cloud-builders/docker
3
+ args:
4
+ - build
5
+ - '--no-cache'
6
+ - '-t'
7
+ - $_AR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA
8
+ - '-t'
9
+ - $_AR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:latest
10
+ - .
11
+ - '-f'
12
+ - Dockerfile
13
+ id: Build
14
+ - name: gcr.io/cloud-builders/docker
15
+ args:
16
+ - push
17
+ - '$_AR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME'
18
+ - '--all-tags'
19
+ id: Push
20
+ images:
21
+ - $_AR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA
22
+ options:
23
+ substitutionOption: ALLOW_LOOSE
24
+ logging: CLOUD_LOGGING_ONLY
25
+ substitutions:
26
+ _AR_HOSTNAME: europe-west1-docker.pkg.dev
27
+ _SERVICE_NAME: gotchi-battler-game-logic
@@ -1,209 +1,209 @@
1
- [
2
- {
3
- "inputs": [
4
- {
5
- "internalType": "uint64",
6
- "name": "subscriptionId",
7
- "type": "uint64"
8
- },
9
- {
10
- "internalType": "address",
11
- "name": "vrfCoordinator",
12
- "type": "address"
13
- },
14
- {
15
- "internalType": "address",
16
- "name": "link",
17
- "type": "address"
18
- },
19
- {
20
- "internalType": "bytes32",
21
- "name": "keyHash",
22
- "type": "bytes32"
23
- },
24
- {
25
- "internalType": "address",
26
- "name": "feeTokenAddress",
27
- "type": "address"
28
- }
29
- ],
30
- "stateMutability": "nonpayable",
31
- "type": "constructor"
32
- },
33
- {
34
- "inputs": [
35
- {
36
- "internalType": "address",
37
- "name": "have",
38
- "type": "address"
39
- },
40
- {
41
- "internalType": "address",
42
- "name": "want",
43
- "type": "address"
44
- }
45
- ],
46
- "name": "OnlyCoordinatorCanFulfill",
47
- "type": "error"
48
- },
49
- {
50
- "anonymous": false,
51
- "inputs": [
52
- {
53
- "indexed": false,
54
- "internalType": "uint32",
55
- "name": "roundNumber",
56
- "type": "uint32"
57
- },
58
- {
59
- "indexed": false,
60
- "internalType": "uint256",
61
- "name": "randomWords",
62
- "type": "uint256"
63
- }
64
- ],
65
- "name": "ReturnedRoundRandomness",
66
- "type": "event"
67
- },
68
- {
69
- "inputs": [
70
- {
71
- "internalType": "uint32",
72
- "name": "askedRound",
73
- "type": "uint32"
74
- }
75
- ],
76
- "name": "askRoundSeed",
77
- "outputs": [],
78
- "stateMutability": "nonpayable",
79
- "type": "function"
80
- },
81
- {
82
- "inputs": [],
83
- "name": "contractOwner",
84
- "outputs": [
85
- {
86
- "internalType": "address",
87
- "name": "",
88
- "type": "address"
89
- }
90
- ],
91
- "stateMutability": "view",
92
- "type": "function"
93
- },
94
- {
95
- "inputs": [],
96
- "name": "invalidateTournament",
97
- "outputs": [],
98
- "stateMutability": "nonpayable",
99
- "type": "function"
100
- },
101
- {
102
- "inputs": [
103
- {
104
- "internalType": "uint32",
105
- "name": "",
106
- "type": "uint32"
107
- }
108
- ],
109
- "name": "isRoundSeedRequested",
110
- "outputs": [
111
- {
112
- "internalType": "bool",
113
- "name": "",
114
- "type": "bool"
115
- }
116
- ],
117
- "stateMutability": "view",
118
- "type": "function"
119
- },
120
- {
121
- "inputs": [],
122
- "name": "isValid",
123
- "outputs": [
124
- {
125
- "internalType": "bool",
126
- "name": "",
127
- "type": "bool"
128
- }
129
- ],
130
- "stateMutability": "view",
131
- "type": "function"
132
- },
133
- {
134
- "inputs": [
135
- {
136
- "internalType": "uint256",
137
- "name": "requestId",
138
- "type": "uint256"
139
- },
140
- {
141
- "internalType": "uint256[]",
142
- "name": "randomWords",
143
- "type": "uint256[]"
144
- }
145
- ],
146
- "name": "rawFulfillRandomWords",
147
- "outputs": [],
148
- "stateMutability": "nonpayable",
149
- "type": "function"
150
- },
151
- {
152
- "inputs": [],
153
- "name": "roundNumber",
154
- "outputs": [
155
- {
156
- "internalType": "uint32",
157
- "name": "",
158
- "type": "uint32"
159
- }
160
- ],
161
- "stateMutability": "view",
162
- "type": "function"
163
- },
164
- {
165
- "inputs": [
166
- {
167
- "internalType": "uint32",
168
- "name": "",
169
- "type": "uint32"
170
- }
171
- ],
172
- "name": "roundSeeds",
173
- "outputs": [
174
- {
175
- "internalType": "uint256",
176
- "name": "",
177
- "type": "uint256"
178
- }
179
- ],
180
- "stateMutability": "view",
181
- "type": "function"
182
- },
183
- {
184
- "inputs": [],
185
- "name": "s_requestId",
186
- "outputs": [
187
- {
188
- "internalType": "uint256",
189
- "name": "",
190
- "type": "uint256"
191
- }
192
- ],
193
- "stateMutability": "view",
194
- "type": "function"
195
- },
196
- {
197
- "inputs": [
198
- {
199
- "internalType": "address",
200
- "name": "_owner",
201
- "type": "address"
202
- }
203
- ],
204
- "name": "setOwner",
205
- "outputs": [],
206
- "stateMutability": "nonpayable",
207
- "type": "function"
208
- }
1
+ [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "uint64",
6
+ "name": "subscriptionId",
7
+ "type": "uint64"
8
+ },
9
+ {
10
+ "internalType": "address",
11
+ "name": "vrfCoordinator",
12
+ "type": "address"
13
+ },
14
+ {
15
+ "internalType": "address",
16
+ "name": "link",
17
+ "type": "address"
18
+ },
19
+ {
20
+ "internalType": "bytes32",
21
+ "name": "keyHash",
22
+ "type": "bytes32"
23
+ },
24
+ {
25
+ "internalType": "address",
26
+ "name": "feeTokenAddress",
27
+ "type": "address"
28
+ }
29
+ ],
30
+ "stateMutability": "nonpayable",
31
+ "type": "constructor"
32
+ },
33
+ {
34
+ "inputs": [
35
+ {
36
+ "internalType": "address",
37
+ "name": "have",
38
+ "type": "address"
39
+ },
40
+ {
41
+ "internalType": "address",
42
+ "name": "want",
43
+ "type": "address"
44
+ }
45
+ ],
46
+ "name": "OnlyCoordinatorCanFulfill",
47
+ "type": "error"
48
+ },
49
+ {
50
+ "anonymous": false,
51
+ "inputs": [
52
+ {
53
+ "indexed": false,
54
+ "internalType": "uint32",
55
+ "name": "roundNumber",
56
+ "type": "uint32"
57
+ },
58
+ {
59
+ "indexed": false,
60
+ "internalType": "uint256",
61
+ "name": "randomWords",
62
+ "type": "uint256"
63
+ }
64
+ ],
65
+ "name": "ReturnedRoundRandomness",
66
+ "type": "event"
67
+ },
68
+ {
69
+ "inputs": [
70
+ {
71
+ "internalType": "uint32",
72
+ "name": "askedRound",
73
+ "type": "uint32"
74
+ }
75
+ ],
76
+ "name": "askRoundSeed",
77
+ "outputs": [],
78
+ "stateMutability": "nonpayable",
79
+ "type": "function"
80
+ },
81
+ {
82
+ "inputs": [],
83
+ "name": "contractOwner",
84
+ "outputs": [
85
+ {
86
+ "internalType": "address",
87
+ "name": "",
88
+ "type": "address"
89
+ }
90
+ ],
91
+ "stateMutability": "view",
92
+ "type": "function"
93
+ },
94
+ {
95
+ "inputs": [],
96
+ "name": "invalidateTournament",
97
+ "outputs": [],
98
+ "stateMutability": "nonpayable",
99
+ "type": "function"
100
+ },
101
+ {
102
+ "inputs": [
103
+ {
104
+ "internalType": "uint32",
105
+ "name": "",
106
+ "type": "uint32"
107
+ }
108
+ ],
109
+ "name": "isRoundSeedRequested",
110
+ "outputs": [
111
+ {
112
+ "internalType": "bool",
113
+ "name": "",
114
+ "type": "bool"
115
+ }
116
+ ],
117
+ "stateMutability": "view",
118
+ "type": "function"
119
+ },
120
+ {
121
+ "inputs": [],
122
+ "name": "isValid",
123
+ "outputs": [
124
+ {
125
+ "internalType": "bool",
126
+ "name": "",
127
+ "type": "bool"
128
+ }
129
+ ],
130
+ "stateMutability": "view",
131
+ "type": "function"
132
+ },
133
+ {
134
+ "inputs": [
135
+ {
136
+ "internalType": "uint256",
137
+ "name": "requestId",
138
+ "type": "uint256"
139
+ },
140
+ {
141
+ "internalType": "uint256[]",
142
+ "name": "randomWords",
143
+ "type": "uint256[]"
144
+ }
145
+ ],
146
+ "name": "rawFulfillRandomWords",
147
+ "outputs": [],
148
+ "stateMutability": "nonpayable",
149
+ "type": "function"
150
+ },
151
+ {
152
+ "inputs": [],
153
+ "name": "roundNumber",
154
+ "outputs": [
155
+ {
156
+ "internalType": "uint32",
157
+ "name": "",
158
+ "type": "uint32"
159
+ }
160
+ ],
161
+ "stateMutability": "view",
162
+ "type": "function"
163
+ },
164
+ {
165
+ "inputs": [
166
+ {
167
+ "internalType": "uint32",
168
+ "name": "",
169
+ "type": "uint32"
170
+ }
171
+ ],
172
+ "name": "roundSeeds",
173
+ "outputs": [
174
+ {
175
+ "internalType": "uint256",
176
+ "name": "",
177
+ "type": "uint256"
178
+ }
179
+ ],
180
+ "stateMutability": "view",
181
+ "type": "function"
182
+ },
183
+ {
184
+ "inputs": [],
185
+ "name": "s_requestId",
186
+ "outputs": [
187
+ {
188
+ "internalType": "uint256",
189
+ "name": "",
190
+ "type": "uint256"
191
+ }
192
+ ],
193
+ "stateMutability": "view",
194
+ "type": "function"
195
+ },
196
+ {
197
+ "inputs": [
198
+ {
199
+ "internalType": "address",
200
+ "name": "_owner",
201
+ "type": "address"
202
+ }
203
+ ],
204
+ "name": "setOwner",
205
+ "outputs": [],
206
+ "stateMutability": "nonpayable",
207
+ "type": "function"
208
+ }
209
209
  ]
@@ -1,7 +1,7 @@
1
- module.exports = {
2
- 'v1.4': require('./v1.4'),
3
- 'v1.5': require('./v1.5'),
4
- 'v1.6': require('./v1.6'),
5
- 'v1.7': require('./v1.7'),
6
- current: 'v1.7'
1
+ module.exports = {
2
+ 'v1.4': require('./v1.4'),
3
+ 'v1.5': require('./v1.5'),
4
+ 'v1.6': require('./v1.6'),
5
+ 'v1.7': require('./v1.7'),
6
+ current: 'v1.7'
7
7
  }