gotchi-battler-game-logic 2.0.8 → 4.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.
Files changed (74) hide show
  1. package/.cursor/rules/cursor-rules.mdc +67 -0
  2. package/.cursor/rules/directory-structure.mdc +63 -0
  3. package/.cursor/rules/self-improvement.mdc +64 -0
  4. package/.cursor/rules/tech-stack.mdc +99 -0
  5. package/README.md +7 -3
  6. package/eslint.config.js +31 -0
  7. package/game-logic/index.js +2 -5
  8. package/game-logic/v1.4/constants.js +0 -23
  9. package/game-logic/v1.4/index.js +64 -56
  10. package/game-logic/v1.5/constants.js +0 -23
  11. package/game-logic/v1.5/index.js +27 -21
  12. package/game-logic/v1.6/constants.js +0 -23
  13. package/game-logic/v1.6/index.js +27 -21
  14. package/game-logic/v1.7/constants.js +0 -23
  15. package/game-logic/v1.7/helpers.js +18 -3
  16. package/game-logic/v1.7/index.js +24 -18
  17. package/game-logic/v1.8/constants.js +112 -0
  18. package/game-logic/v1.8/helpers.js +628 -0
  19. package/game-logic/v1.8/index.js +832 -0
  20. package/game-logic/v2.0/constants.js +112 -0
  21. package/game-logic/v2.0/helpers.js +713 -0
  22. package/game-logic/v2.0/index.js +782 -0
  23. package/game-logic/v2.0/statuses.json +439 -0
  24. package/package.json +11 -4
  25. package/schemas/crystal.js +14 -0
  26. package/schemas/effect.js +25 -0
  27. package/schemas/gotchi.js +53 -0
  28. package/schemas/ingameteam.js +14 -0
  29. package/schemas/item.js +13 -0
  30. package/schemas/leaderskill.js +15 -0
  31. package/schemas/leaderskillstatus.js +12 -0
  32. package/schemas/special.js +22 -0
  33. package/schemas/team.js +24 -0
  34. package/schemas/team.json +254 -116
  35. package/scripts/balancing/createCSV.js +1 -1
  36. package/scripts/balancing/createTrainingGotchis.js +267 -0
  37. package/scripts/balancing/extractOnchainTraits.js +61 -0
  38. package/scripts/balancing/fixTrainingGotchis.js +41 -41
  39. package/scripts/balancing/processSims.js +6 -6
  40. package/scripts/balancing/sims.js +10 -17
  41. package/scripts/balancing/v1.7/mapGotchi.js +119 -0
  42. package/scripts/balancing/v1.7/setTeamPositions.js +2 -2
  43. package/scripts/balancing/v1.7/training_gotchis_traits.json +520 -0
  44. package/scripts/balancing/v1.7.1/mapGotchi.js +119 -0
  45. package/scripts/balancing/v1.7.1/setTeamPositions.js +2 -2
  46. package/scripts/balancing/v1.7.1/training_gotchis_traits.json +520 -0
  47. package/scripts/balancing/v1.7.2/mapGotchi.js +157 -0
  48. package/scripts/balancing/v1.7.2/setTeamPositions.js +2 -2
  49. package/scripts/balancing/v1.7.2/training_gotchis_traits.json +520 -0
  50. package/scripts/balancing/v1.7.3/class_combos.js +44 -0
  51. package/scripts/balancing/v1.7.3/mapGotchi.js +164 -0
  52. package/scripts/balancing/v1.7.3/setTeamPositions.js +122 -0
  53. package/scripts/balancing/v1.7.3/training_gotchis.json +22402 -0
  54. package/scripts/balancing/v1.7.3/training_gotchis_traits.json +37 -0
  55. package/scripts/balancing/v1.7.3/trait_combos.json +10 -0
  56. package/scripts/data/dungeon_mob_1.json +87 -0
  57. package/scripts/data/dungeon_mob_2.json +87 -0
  58. package/scripts/data/immaterialTeam1.json +374 -0
  59. package/scripts/data/immaterialTeam2.json +365 -0
  60. package/scripts/data/tournaments.json +5 -0
  61. package/scripts/generateAllSpecialsLogs.js +93 -0
  62. package/scripts/generateSpecialLogs.js +94 -0
  63. package/scripts/runCampaignBattles.js +41 -0
  64. package/scripts/runLocalBattle.js +6 -3
  65. package/scripts/runLocalDungeon.js +52 -0
  66. package/scripts/runPvPBattle.js +16 -0
  67. package/scripts/runRealBattle.js +8 -8
  68. package/scripts/simRealBattle.js +8 -8
  69. package/scripts/validateBattle.js +23 -16
  70. package/scripts/validateTournament.js +9 -9
  71. package/tests/getModifiedStats.test.js +78 -0
  72. package/utils/errors.js +13 -13
  73. package/utils/transforms.js +2 -8
  74. package/scripts/output/.gitkeep +0 -0
@@ -70,7 +70,7 @@ module.exports = (team) => {
70
70
  const frontGotchis = team.formation.front.filter(gotchi => gotchi)
71
71
  if (frontGotchis.length === 5) {
72
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));
73
+ const orderedGotchis = JSON.parse(JSON.stringify(frontGotchis)).sort((a, b) => getFrontRowScore(a.id, team.leader) - getFrontRowScore(b.id, team.leader))
74
74
 
75
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
76
  let hasMoved = 0
@@ -88,7 +88,7 @@ module.exports = (team) => {
88
88
  const backGotchis = team.formation.back.filter(gotchi => gotchi)
89
89
  if (backGotchis.length === 5) {
90
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));
91
+ const orderedGotchis = JSON.parse(JSON.stringify(backGotchis)).sort((a, b) => getFrontRowScore(b.id, team.leader) - getFrontRowScore(a.id, team.leader))
92
92
 
93
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
94
  let hasMoved = 0
@@ -0,0 +1,520 @@
1
+ {
2
+ "godlike": {
3
+ "cleaver": {
4
+ "brs": 783,
5
+ "nrg": [2,97],
6
+ "agg": [null,111],
7
+ "spk": [-2,101],
8
+ "brn": [-8,107],
9
+ "eys": [null,94],
10
+ "eyc": [null,94]
11
+ },
12
+ "cursed": {
13
+ "brs": 783,
14
+ "nrg": [2,97],
15
+ "agg": [-1,100],
16
+ "spk": [null,111],
17
+ "brn": [-9,108],
18
+ "eys": [null,94],
19
+ "eyc": [null,94]
20
+ },
21
+ "mage": {
22
+ "brs": 783,
23
+ "nrg": [1,103],
24
+ "agg": [-2,101],
25
+ "spk": [1,98],
26
+ "brn": [null,114],
27
+ "eys": [null,94],
28
+ "eyc": [null,94]
29
+ },
30
+ "ninja": {
31
+ "brs": 783,
32
+ "nrg": [null,110],
33
+ "agg": [1,98],
34
+ "spk": [-2,101],
35
+ "brn": [-8,107],
36
+ "eys": [null,94],
37
+ "eyc": [null,94]
38
+ },
39
+ "troll": {
40
+ "brs": 783,
41
+ "nrg": [-4,103],
42
+ "agg": [-2,101],
43
+ "spk": [-2,101],
44
+ "brn": [-12],
45
+ "eys": [null,94],
46
+ "eyc": [null,94]
47
+ },
48
+ "healer": {
49
+ "brs": 783,
50
+ "nrg": [-1,100],
51
+ "agg": [-2,101],
52
+ "spk": [-15],
53
+ "brn": [-2,101],
54
+ "eys": [null,94],
55
+ "eyc": [null,94]
56
+ },
57
+ "tank": {
58
+ "brs": 783,
59
+ "nrg": [0,99],
60
+ "agg": [-15],
61
+ "spk": [1,98],
62
+ "brn": [-6,105],
63
+ "eys": [null,94],
64
+ "eyc": [null,94]
65
+ },
66
+ "enlightened": {
67
+ "brs": 783,
68
+ "nrg": [-13],
69
+ "agg": [-1,100],
70
+ "spk": [-1,100],
71
+ "brn": [-5,104],
72
+ "eys": [null,94],
73
+ "eyc": [null,94]
74
+ }
75
+ },
76
+ "mythical": {
77
+ "ninja": {
78
+ "brs": 690,
79
+ "nrg": [null,108],
80
+ "agg": [0,99],
81
+ "spk": [3,96],
82
+ "brn": [1,98],
83
+ "eys": [null,91],
84
+ "eyc": [null,92]
85
+ },
86
+ "cleaver": {
87
+ "brs": 690,
88
+ "nrg": [1,101],
89
+ "agg": [null,109],
90
+ "spk": [4,95],
91
+ "brn": [3,96],
92
+ "eys": [null,91],
93
+ "eyc": [null,92]
94
+ },
95
+ "cursed": {
96
+ "brs": 690,
97
+ "nrg": [3,97],
98
+ "agg": [1,98],
99
+ "spk": [null,108],
100
+ "brn": [1,98],
101
+ "eys": [null,91],
102
+ "eyc": [null,92]
103
+ },
104
+ "mage": {
105
+ "brs": 690,
106
+ "nrg": [2,98],
107
+ "agg": [2,98],
108
+ "spk": [3,96],
109
+ "brn": [null,109],
110
+ "eys": [null,91],
111
+ "eyc": [null,92]
112
+ },
113
+ "troll": {
114
+ "brs": 690,
115
+ "nrg": [0,99],
116
+ "agg": [1,98],
117
+ "spk": [4,95],
118
+ "brn": [-10],
119
+ "eys": [null,91],
120
+ "eyc": [null,92]
121
+ },
122
+ "healer": {
123
+ "brs": 690,
124
+ "nrg": [1,98],
125
+ "agg": [4,95],
126
+ "spk": [-15],
127
+ "brn": [5,94],
128
+ "eys": [null,91],
129
+ "eyc": [null,92]
130
+ },
131
+ "tank": {
132
+ "brs": 690,
133
+ "nrg": [1,98],
134
+ "agg": [-7],
135
+ "spk": [1,98],
136
+ "brn": [0,99],
137
+ "eys": [null,91],
138
+ "eyc": [null,92]
139
+ },
140
+ "enlightened": {
141
+ "brs": 690,
142
+ "nrg": [-10],
143
+ "agg": [3,96],
144
+ "spk": [2,97],
145
+ "brn": [0,99],
146
+ "eys": [null,92],
147
+ "eyc": [null,91]
148
+ }
149
+ },
150
+ "legendary": {
151
+ "ninja": {
152
+ "brs": 638,
153
+ "nrg": [null,106],
154
+ "agg": [4,95],
155
+ "spk": [5,94],
156
+ "brn": [5,94],
157
+ "eys": [null,90],
158
+ "eyc": [null,90]
159
+ },
160
+ "cleaver": {
161
+ "brs": 638,
162
+ "nrg": [5,94],
163
+ "agg": [null,105],
164
+ "spk": [4,95],
165
+ "brn": [-1,95],
166
+ "eys": [null,90],
167
+ "eyc": [null,90]
168
+ },
169
+ "cursed": {
170
+ "brs": 638,
171
+ "nrg": [4,95],
172
+ "agg": [6,93],
173
+ "spk": [null,106],
174
+ "brn": [4,95],
175
+ "eys": [null,90],
176
+ "eyc": [null,90]
177
+ },
178
+ "mage": {
179
+ "brs": 638,
180
+ "nrg": [4,96],
181
+ "agg": [6,93],
182
+ "spk": [6,93],
183
+ "brn": [null,107],
184
+ "eys": [null,90],
185
+ "eyc": [null,90]
186
+ },
187
+ "troll": {
188
+ "brs": 638,
189
+ "nrg": [4,95],
190
+ "agg": [5,94],
191
+ "spk": [3,96],
192
+ "brn": [-5],
193
+ "eys": [null,90],
194
+ "eyc": [null,90]
195
+ },
196
+ "healer": {
197
+ "brs": 638,
198
+ "nrg": [4,95],
199
+ "agg": [6,93],
200
+ "spk": [-7],
201
+ "brn": [4,95],
202
+ "eys": [null,90],
203
+ "eyc": [null,90]
204
+ },
205
+ "tank": {
206
+ "brs": 638,
207
+ "nrg": [3,96],
208
+ "agg": [-6],
209
+ "spk": [5,94],
210
+ "brn": [5,94],
211
+ "eys": [null,90],
212
+ "eyc": [null,90]
213
+ },
214
+ "enlightened": {
215
+ "brs": 638,
216
+ "nrg": [-6],
217
+ "agg": [6,93],
218
+ "spk": [4,95],
219
+ "brn": [3,96],
220
+ "eys": [null,90],
221
+ "eyc": [null,90]
222
+ }
223
+ },
224
+ "rare": {
225
+ "ninja": {
226
+ "brs": 597,
227
+ "nrg": [null,103],
228
+ "agg": [7,92],
229
+ "spk": [8,91],
230
+ "brn": [8,91],
231
+ "eys": [null,88],
232
+ "eyc": [null,89]
233
+ },
234
+ "cleaver": {
235
+ "brs": 597,
236
+ "nrg": [9,90],
237
+ "agg": [null,105],
238
+ "spk": [8,91],
239
+ "brn": [8,91],
240
+ "eys": [null,88],
241
+ "eyc": [null,89]
242
+ },
243
+ "cursed": {
244
+ "brs": 597,
245
+ "nrg": [9,90],
246
+ "agg": [7,92],
247
+ "spk": [null,103],
248
+ "brn": [7,92],
249
+ "eys": [null,88],
250
+ "eyc": [null,89]
251
+ },
252
+ "mage": {
253
+ "brs": 597,
254
+ "nrg": [8,91],
255
+ "agg": [7,92],
256
+ "spk": [8,91],
257
+ "brn": [null,103],
258
+ "eys": [null,88],
259
+ "eyc": [null,89]
260
+ },
261
+ "troll": {
262
+ "brs": 597,
263
+ "nrg": [9,90],
264
+ "agg": [7,92],
265
+ "spk": [7,92],
266
+ "brn": [-4],
267
+ "eys": [null,88],
268
+ "eyc": [null,89]
269
+ },
270
+ "healer": {
271
+ "brs": 597,
272
+ "nrg": [8,91],
273
+ "agg": [7,92],
274
+ "spk": [-3],
275
+ "brn": [7,92],
276
+ "eys": [null,89],
277
+ "eyc": [null,88]
278
+ },
279
+ "tank": {
280
+ "brs": 597,
281
+ "nrg": [7,92],
282
+ "agg": [-3],
283
+ "spk": [8,91],
284
+ "brn": [7,92],
285
+ "eys": [null,88],
286
+ "eyc": [null,89]
287
+ },
288
+ "enlightened": {
289
+ "brs": 597,
290
+ "nrg": [-2],
291
+ "agg": [7,92],
292
+ "spk": [7,92],
293
+ "brn": [7,92],
294
+ "eys": [null,88],
295
+ "eyc": [null,89]
296
+ }
297
+ },
298
+ "uncommon": {
299
+ "ninja": {
300
+ "brs": 556,
301
+ "nrg": [null,102],
302
+ "agg": [12,87],
303
+ "spk": [13,86],
304
+ "brn": [12,87],
305
+ "eys": [null,87],
306
+ "eyc": [null,87]
307
+ },
308
+ "cleaver": {
309
+ "brs": 556,
310
+ "nrg": [12,87],
311
+ "agg": [null,102],
312
+ "spk": [13,86],
313
+ "brn": [11,88],
314
+ "eys": [null,87],
315
+ "eyc": [null,87]
316
+ },
317
+ "cursed": {
318
+ "brs": 556,
319
+ "nrg": [12,87],
320
+ "agg": [12,87],
321
+ "spk": [null,102],
322
+ "brn": [12,87],
323
+ "eys": [null,87],
324
+ "eyc": [null,87]
325
+ },
326
+ "mage": {
327
+ "brs": 556,
328
+ "nrg": [12,87],
329
+ "agg": [11,88],
330
+ "spk": [13,86],
331
+ "brn": [null,102],
332
+ "eys": [null,87],
333
+ "eyc": [null,87]
334
+ },
335
+ "troll": {
336
+ "brs": 556,
337
+ "nrg": [13,86],
338
+ "agg": [12,87],
339
+ "spk": [13,86],
340
+ "brn": [-4],
341
+ "eys": [null,87],
342
+ "eyc": [null,88]
343
+ },
344
+ "healer": {
345
+ "brs": 556,
346
+ "nrg": [13,86],
347
+ "agg": [12,87],
348
+ "spk": [-3],
349
+ "brn": [11,88],
350
+ "eys": [null,87],
351
+ "eyc": [null,87]
352
+ },
353
+ "tank": {
354
+ "brs": 556,
355
+ "nrg": [12,87],
356
+ "agg": [-3],
357
+ "spk": [12,87],
358
+ "brn": [13,87],
359
+ "eys": [null,87],
360
+ "eyc": [null,87]
361
+ },
362
+ "enlightened": {
363
+ "brs": 556,
364
+ "nrg": [-3],
365
+ "agg": [11,88],
366
+ "spk": [13,86],
367
+ "brn": [12,87],
368
+ "eys": [null,87],
369
+ "eyc": [null,87]
370
+ }
371
+ },
372
+ "common": {
373
+ "ninja": {
374
+ "brs": 501,
375
+ "nrg": [null,95],
376
+ "agg": [21,78],
377
+ "spk": [22,77],
378
+ "brn": [21,78],
379
+ "eys": [null,82],
380
+ "eyc": [null,83]
381
+ },
382
+ "cleaver": {
383
+ "brs": 501,
384
+ "nrg": [22,77],
385
+ "agg": [null,96],
386
+ "spk": [21,78],
387
+ "brn": [21,78],
388
+ "eys": [null,82],
389
+ "eyc": [null,83]
390
+ },
391
+ "cursed": {
392
+ "brs": 501,
393
+ "nrg": [22,77],
394
+ "agg": [21,78],
395
+ "spk": [null,96],
396
+ "brn": [21,78],
397
+ "eys": [null,82],
398
+ "eyc": [null,83]
399
+ },
400
+ "mage": {
401
+ "brs": 501,
402
+ "nrg": [22,77],
403
+ "agg": [21,79],
404
+ "spk": [22,77],
405
+ "brn": [null,96],
406
+ "eys": [null,82],
407
+ "eyc": [null,83]
408
+ },
409
+ "troll": {
410
+ "brs": 501,
411
+ "nrg": [22,77],
412
+ "agg": [22,77],
413
+ "spk": [22,77],
414
+ "brn": [3],
415
+ "eys": [null,83],
416
+ "eyc": [null,84]
417
+ },
418
+ "healer": {
419
+ "brs": 501,
420
+ "nrg": [22,77],
421
+ "agg": [22,77],
422
+ "spk": [3],
423
+ "brn": [21,78],
424
+ "eys": [null,83],
425
+ "eyc": [null,82]
426
+ },
427
+ "tank": {
428
+ "brs": 501,
429
+ "nrg": [22,77],
430
+ "agg": [3],
431
+ "spk": [22,77],
432
+ "brn": [21,78],
433
+ "eys": [null,83],
434
+ "eyc": [null,82]
435
+ },
436
+ "enlightened": {
437
+ "brs": 501,
438
+ "nrg": [4],
439
+ "agg": [21,78],
440
+ "spk": [22,77],
441
+ "brn": [21,78],
442
+ "eys": [null,83],
443
+ "eyc": [null,82]
444
+ }
445
+ },
446
+ "garbage": {
447
+ "ninja": {
448
+ "brs": 400,
449
+ "nrg": [null,51],
450
+ "agg": [49,50],
451
+ "spk": [49,50],
452
+ "brn": [49,50],
453
+ "eys": [null,50],
454
+ "eyc": [null,50]
455
+ },
456
+ "cleaver": {
457
+ "brs": 400,
458
+ "nrg": [49,50],
459
+ "agg": [null,50],
460
+ "spk": [49,50],
461
+ "brn": [49,50],
462
+ "eys": [null,50],
463
+ "eyc": [null,50]
464
+ },
465
+ "cursed": {
466
+ "brs": 400,
467
+ "nrg": [49,50],
468
+ "agg": [49,50],
469
+ "spk": [null,50],
470
+ "brn": [49,50],
471
+ "eys": [null,50],
472
+ "eyc": [null,50]
473
+ },
474
+ "mage": {
475
+ "brs": 400,
476
+ "nrg": [49,50],
477
+ "agg": [49,50],
478
+ "spk": [49,50],
479
+ "brn": [null,50],
480
+ "eys": [null,50],
481
+ "eyc": [null,50]
482
+ },
483
+ "troll": {
484
+ "brs": 400,
485
+ "nrg": [49,50],
486
+ "agg": [49,50],
487
+ "spk": [49,50],
488
+ "brn": [49],
489
+ "eys": [null,50],
490
+ "eyc": [null,50]
491
+ },
492
+ "healer": {
493
+ "brs": 400,
494
+ "nrg": [49,50],
495
+ "agg": [49,50],
496
+ "spk": [49],
497
+ "brn": [49,50],
498
+ "eys": [null,50],
499
+ "eyc": [null,50]
500
+ },
501
+ "tank": {
502
+ "brs": 400,
503
+ "nrg": [49,50],
504
+ "agg": [49],
505
+ "spk": [49,50],
506
+ "brn": [49,50],
507
+ "eys": [null,50],
508
+ "eyc": [null,50]
509
+ },
510
+ "enlightened": {
511
+ "brs": 400,
512
+ "nrg": [49],
513
+ "agg": [49,50],
514
+ "spk": [49,50],
515
+ "brn": [49,50],
516
+ "eys": [null,50],
517
+ "eyc": [null,50]
518
+ }
519
+ }
520
+ }
@@ -0,0 +1,119 @@
1
+ const mapTeam = (team) => {
2
+ for(const gotchi of team.formation.front) {
3
+ if (gotchi) mapGotchi(gotchi)
4
+ }
5
+
6
+ for(const gotchi of team.formation.back) {
7
+ if (gotchi) mapGotchi(gotchi)
8
+ }
9
+ }
10
+
11
+ // This is copied/hacked from the mapGotchi function in the backend
12
+ const mapGotchi = (gotchi) => {
13
+ const traitMaps = {
14
+ speed: {
15
+ baseFormula: 100,
16
+ multiplier: 1,
17
+ traitKey: 0,
18
+ isNegative: false
19
+ },
20
+ health: {
21
+ baseFormula: 'brs*0.75',
22
+ multiplier: 12,
23
+ traitKey: 0,
24
+ isNegative: true
25
+ },
26
+ crit: {
27
+ baseFormula: 0,
28
+ multiplier: 0.5,
29
+ traitKey: 1,
30
+ isNegative: false
31
+ },
32
+ armor: {
33
+ baseFormula: 0,
34
+ multiplier: 2,
35
+ traitKey: 1,
36
+ isNegative: true
37
+ },
38
+ evade: {
39
+ baseFormula: 0,
40
+ multiplier: 0.3,
41
+ traitKey: 2,
42
+ isNegative: false
43
+ },
44
+ resist: {
45
+ baseFormula: 0,
46
+ multiplier: 1,
47
+ traitKey: 2,
48
+ isNegative: true
49
+ },
50
+ magic: {
51
+ baseFormula: 'brs*0.25',
52
+ multiplier: 5,
53
+ traitKey: 3,
54
+ isNegative: false
55
+ },
56
+ physical: {
57
+ baseFormula: 'brs*0.25',
58
+ multiplier: 5,
59
+ traitKey: 3,
60
+ isNegative: true
61
+ },
62
+ accuracy: {
63
+ baseFormula: 50,
64
+ multiplier: 0.5,
65
+ traitKey: 45,
66
+ isNegative: false
67
+ }
68
+ }
69
+
70
+ const traitValue = (trait) => {
71
+ return trait < 50 ? 50 - trait : trait - 50 + 1
72
+ }
73
+
74
+ const onchainVals = [
75
+ gotchi.nrg,
76
+ gotchi.agg,
77
+ gotchi.spk,
78
+ gotchi.brn,
79
+ gotchi.eyc,
80
+ gotchi.eys
81
+ ]
82
+ // Convert trait value to in-game value
83
+ const traitValues = onchainVals.map(x => { return traitValue(x) })
84
+
85
+ // Map traits
86
+ for(const trait in traitMaps) {
87
+ const traitMap = traitMaps[trait]
88
+ const onchainVal = onchainVals[traitMap.traitKey]
89
+
90
+ let base = traitMap.baseFormula
91
+
92
+ // If baseFormula is a string and contains a * then it is a formula
93
+ if (typeof traitMap.baseFormula === 'string' && traitMap.baseFormula.includes('*')) {
94
+ const formula = traitMap.baseFormula.split('*')
95
+
96
+ if (!gotchi[formula[0]]) throw new Error('Trait not found: ', formula[0])
97
+
98
+ base = Math.round(Number(gotchi[formula[0]]) * Number(formula[1]))
99
+ }
100
+
101
+ let newTrait
102
+ if (trait !== 'accuracy') {
103
+ if (traitMap.isNegative) {
104
+ newTrait = onchainVal < 50 ? Math.round(base + (traitValues[traitMap.traitKey] * traitMap.multiplier)) : base
105
+ } else {
106
+ newTrait = onchainVal < 50 ? base : Math.round(base + (traitValues[traitMap.traitKey] * traitMap.multiplier))
107
+ }
108
+ } else {
109
+ newTrait = base + ((traitValues[4] + traitValues[5]) * traitMap.multiplier)
110
+ }
111
+
112
+ if (newTrait !== gotchi[trait]) gotchi[trait] = newTrait
113
+ }
114
+ }
115
+
116
+ module.exports = {
117
+ mapGotchi,
118
+ mapTeam
119
+ }
@@ -87,7 +87,7 @@ module.exports = (team) => {
87
87
  const frontGotchis = team.formation.front.filter(gotchi => gotchi)
88
88
  if (frontGotchis.length === 5) {
89
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));
90
+ const orderedGotchis = JSON.parse(JSON.stringify(frontGotchis)).sort((a, b) => getFrontRowScore(a.id, team.leader) - getFrontRowScore(b.id, team.leader))
91
91
 
92
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
93
  let hasMoved = 0
@@ -105,7 +105,7 @@ module.exports = (team) => {
105
105
  const backGotchis = team.formation.back.filter(gotchi => gotchi)
106
106
  if (backGotchis.length === 5) {
107
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));
108
+ const orderedGotchis = JSON.parse(JSON.stringify(backGotchis)).sort((a, b) => getFrontRowScore(b.id, team.leader) - getFrontRowScore(a.id, team.leader))
109
109
 
110
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
111
  let hasMoved = 0