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.
Files changed (39) 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/index.js +1389 -0
  15. package/index.js +13 -6
  16. package/package.json +26 -22
  17. package/schemas/team.json +208 -203
  18. package/scripts/balancing/createCSV.js +126 -0
  19. package/scripts/balancing/fixTrainingGotchis.js +260 -0
  20. package/scripts/balancing/processSims.js +230 -0
  21. package/scripts/balancing/sims.js +278 -0
  22. package/scripts/balancing/v1.7/class_combos.js +44 -0
  23. package/scripts/balancing/v1.7/setTeamPositions.js +105 -0
  24. package/scripts/balancing/v1.7/training_gotchis.json +20162 -0
  25. package/scripts/balancing/v1.7/trait_combos.json +10 -0
  26. package/scripts/balancing/v1.7.1/class_combos.js +44 -0
  27. package/scripts/balancing/v1.7.1/setTeamPositions.js +122 -0
  28. package/scripts/balancing/v1.7.1/training_gotchis.json +22402 -0
  29. package/scripts/balancing/v1.7.1/trait_combos.json +10 -0
  30. package/scripts/data/team1.json +200 -200
  31. package/scripts/data/team2.json +200 -200
  32. package/scripts/data/tournaments.json +66 -66
  33. package/scripts/runBattle.js +15 -15
  34. package/scripts/validateBattle.js +70 -64
  35. package/scripts/validateTournament.js +101 -101
  36. package/utils/contracts.js +12 -12
  37. package/utils/errors.js +29 -29
  38. package/utils/transforms.js +88 -47
  39. package/utils/validations.js +39 -39
@@ -1,6 +1,6 @@
1
1
  const seedrandom = require('seedrandom')
2
- const Validator = require('jsonschema').Validator
3
- const v = new Validator()
2
+ const ZSchema = require('z-schema')
3
+ const validator = new ZSchema()
4
4
  const teamSchema = require('../../schemas/team.json')
5
5
 
6
6
  const { GameError } = require('../../utils/errors')
@@ -586,14 +586,14 @@ const gameLoop = (team1, team2, seed, debug) => {
586
586
  if (!seed) throw new Error("Seed not found")
587
587
 
588
588
  // Validate team objects
589
- const team1Validation = v.validate(team1, teamSchema)
590
- if (team1Validation.errors.length) {
591
- console.error('Team 1 validation failed: ', JSON.stringify(team1Validation.errors))
589
+ const team1Validation = validator.validate(team1, teamSchema)
590
+ if (!team1Validation) {
591
+ console.error('Team 1 validation failed: ', JSON.stringify(validator.getLastErrors(), null, 2))
592
592
  throw new Error(`Team 1 validation failed`)
593
593
  }
594
- const team2Validation = v.validate(team2, teamSchema)
595
- if (team2Validation.errors.length) {
596
- console.error('Team 2 validation failed: ', team2Validation.errors)
594
+ const team2Validation = validator.validate(team2, teamSchema)
595
+ if (!team2Validation) {
596
+ console.error('Team 2 validation failed: ', JSON.stringify(validator.getLastErrors(), null, 2))
597
597
  throw new Error(`Team 2 validation failed`)
598
598
  }
599
599
 
@@ -1,130 +1,130 @@
1
- const PASSIVES = ['sharp_blades', 'cloud_of_zen', 'frenzy', 'fortify', 'spread_the_fear', 'cleansing_aura', 'channel_the_coven', 'clan_momentum']
2
- const DEBUFF_STATUSES = ['bleed', 'stun', 'fear']
3
- const BUFF_STATUSES = ['taunt']
4
-
5
- const BUFF_MULT_EFFECTS = {
6
- power_up_1: {
7
- magic: 0.15,
8
- physical: 0.15
9
- },
10
- power_up_2: {
11
- crit: 0.5,
12
- resist: 0.25,
13
- magic: 0.435,
14
- physical: 0.335
15
- },
16
- fortify: {
17
- armor: 1
18
- },
19
- taunt: {
20
- armor: 0.4
21
- }
22
- }
23
-
24
- const BUFF_FLAT_EFFECTS = {
25
- fortify: {
26
- armor: 80
27
- },
28
- frenzy: {
29
- crit: 23
30
- }
31
- }
32
-
33
- // Combine all buffs
34
- const BUFFS = [...PASSIVES, ...BUFF_STATUSES, ...Object.keys(BUFF_MULT_EFFECTS), ...Object.keys(BUFF_FLAT_EFFECTS)]
35
-
36
- const DEBUFF_MULT_EFFECTS = {
37
- fear: {
38
- resist: 0.5
39
- }
40
- }
41
-
42
- const DEBUFF_FLAT_EFFECTS = {
43
-
44
- }
45
-
46
- // Combine all debuffs
47
- const DEBUFFS = [...DEBUFF_STATUSES, ...Object.keys(DEBUFF_MULT_EFFECTS), ...Object.keys(DEBUFF_FLAT_EFFECTS)]
48
-
49
- const MULTS = {
50
- FRONT_ROW_PHY_ATK: 1.1,
51
- FRONT_ROW_PHY_DEF: 0.9,
52
- EXPIRE_LEADERSKILL: 0,
53
- SPEED_PENALTY: 2.5,
54
- MAX_STATUSES: 3,
55
- CRIT_MULTIPLIER_FAST: 1.8,
56
- CRIT_MULTIPLIER_SLOW: 1.8,
57
- FORTIFY_COUNTER_CHANCE: 20,
58
- COUNTER_CHANCE_MIN: 0,
59
- COUNTER_SPEED_BONUS: 20,
60
- COUNTER_DAMAGE: 1.4,
61
- SHARP_BLADES_BLEED_CHANCE: 1,
62
- BLEED_DAMAGE: 9,
63
- SPECTRAL_STRIKE_DAMAGE: 1.1,
64
- CLEAVE_DAMAGE: 1.05,
65
- CURSE_DAMAGE: 1.3,
66
- CURSE_HEAL: 1,
67
- CURSE_SPEED_PENALTY: 0,
68
- SPREAD_THE_FEAR_CHANCE: 1,
69
- SPREAD_THE_FEAR_SPEED_PENALTY: 0,
70
- BLESSING_HEAL: 4.5,
71
- BLESSING_HEAL_SPEED_PENALTY: 2.5,
72
- CLEANSING_AURA_HEAL: 7,
73
- CLEANSING_AURA_HEAL_SPEED_PENALTY: 3.5,
74
- BLESSING_HEAL_CRIT_MULTIPLIER: 1.25,
75
- CLEANSING_AURA_REGEN: 1,
76
- CLEANSING_AURA_NON_HEALER_REGEN: 10,
77
- THUNDER_DAMAGE_SLOW: 1.15,
78
- THUNDER_DAMAGE_FAST: 0.95,
79
- THUNDER_CRIT_MULTIPLIER: 1.4,
80
- CHANNEL_THE_COVEN_CRIT_MULTIPLIER: 1.4,
81
- CHANNEL_THE_COVEN_DAMAGE_CHANCE: 0.75,
82
- CHANNEL_THE_COVEN_DAMAGE_SLOW: 1.1,
83
- CHANNEL_THE_COVEN_DAMAGE_FAST: 0.8,
84
- DEVESTATING_SMASH_DAMAGE: 3.2,
85
- DEVESTATING_SMASH_SPEED_PENALTY: 2.5,
86
- CLAN_MOMENTUM_DAMAGE: 3.1
87
- }
88
-
89
- const passiveIcons = {
90
- 'sharp_blades': 'https://game-icons.net/1x1/lorc/plain-dagger.html',
91
- 'cloud_of_zen': 'https://game-icons.net/1x1/lorc/meditation.html',
92
- 'frenzy': 'https://game-icons.net/1x1/lorc/totem-head.html',
93
- 'fortify': 'https://game-icons.net/1x1/lorc/crenulated-shield.html',
94
- 'spread_the_fear': 'https://game-icons.net/1x1/lorc/evil-book.html',
95
- 'cleansing_aura': 'https://game-icons.net/1x1/lorc/aura.html',
96
- 'channel_the_coven': 'https://game-icons.net/1x1/lorc/witch-flight.html',
97
- 'clan_momentum': 'https://game-icons.net/1x1/delapouite/bully-minion.html'
98
- }
99
-
100
- const debuffIcons = {
101
- 'bleed': 'https://game-icons.net/1x1/lorc/broken-heart.html',
102
- 'stun': 'https://game-icons.net/1x1/sbed/electric.html',
103
- 'fear': 'https://game-icons.net/1x1/lorc/screaming.html'
104
- }
105
-
106
- const buffIcons = {
107
- 'taunt': 'https://game-icons.net/1x1/lorc/archery-target.html',
108
- 'power_up_1': 'https://game-icons.net/1x1/lorc/strong.html',
109
- 'power_up_2': 'https://game-icons.net/1x1/delapouite/mighty-force.html'
110
- }
111
-
112
- module.exports = {
113
- PASSIVES,
114
- DEBUFF_STATUSES,
115
- BUFF_STATUSES,
116
- BUFF_MULT_EFFECTS,
117
- BUFF_FLAT_EFFECTS,
118
- BUFFS,
119
- DEBUFF_MULT_EFFECTS,
120
- DEBUFF_FLAT_EFFECTS,
121
- DEBUFFS,
122
- MULTS
123
- }
124
-
125
- // node services/game-logic/constants.js
126
- if (require.main === module) {
127
- console.log("Buffs", BUFFS)
128
- console.log("Debuffs", DEBUFFS)
129
- process.exit(0)
1
+ const PASSIVES = ['sharp_blades', 'cloud_of_zen', 'frenzy', 'fortify', 'spread_the_fear', 'cleansing_aura', 'channel_the_coven', 'clan_momentum']
2
+ const DEBUFF_STATUSES = ['bleed', 'stun', 'fear']
3
+ const BUFF_STATUSES = ['taunt']
4
+
5
+ const BUFF_MULT_EFFECTS = {
6
+ power_up_1: {
7
+ magic: 0.15,
8
+ physical: 0.15
9
+ },
10
+ power_up_2: {
11
+ crit: 0.5,
12
+ resist: 0.25,
13
+ magic: 0.435,
14
+ physical: 0.335
15
+ },
16
+ fortify: {
17
+ armor: 1
18
+ },
19
+ taunt: {
20
+ armor: 0.4
21
+ }
22
+ }
23
+
24
+ const BUFF_FLAT_EFFECTS = {
25
+ fortify: {
26
+ armor: 80
27
+ },
28
+ frenzy: {
29
+ crit: 23
30
+ }
31
+ }
32
+
33
+ // Combine all buffs
34
+ const BUFFS = [...PASSIVES, ...BUFF_STATUSES, ...Object.keys(BUFF_MULT_EFFECTS), ...Object.keys(BUFF_FLAT_EFFECTS)]
35
+
36
+ const DEBUFF_MULT_EFFECTS = {
37
+ fear: {
38
+ resist: 0.5
39
+ }
40
+ }
41
+
42
+ const DEBUFF_FLAT_EFFECTS = {
43
+
44
+ }
45
+
46
+ // Combine all debuffs
47
+ const DEBUFFS = [...DEBUFF_STATUSES, ...Object.keys(DEBUFF_MULT_EFFECTS), ...Object.keys(DEBUFF_FLAT_EFFECTS)]
48
+
49
+ const MULTS = {
50
+ FRONT_ROW_PHY_ATK: 1.1,
51
+ FRONT_ROW_PHY_DEF: 0.9,
52
+ EXPIRE_LEADERSKILL: 0,
53
+ SPEED_PENALTY: 2.5,
54
+ MAX_STATUSES: 3,
55
+ CRIT_MULTIPLIER_FAST: 1.8,
56
+ CRIT_MULTIPLIER_SLOW: 1.8,
57
+ FORTIFY_COUNTER_CHANCE: 20,
58
+ COUNTER_CHANCE_MIN: 0,
59
+ COUNTER_SPEED_BONUS: 20,
60
+ COUNTER_DAMAGE: 1.4,
61
+ SHARP_BLADES_BLEED_CHANCE: 1,
62
+ BLEED_DAMAGE: 9,
63
+ SPECTRAL_STRIKE_DAMAGE: 1.1,
64
+ CLEAVE_DAMAGE: 1.05,
65
+ CURSE_DAMAGE: 1.3,
66
+ CURSE_HEAL: 1,
67
+ CURSE_SPEED_PENALTY: 0,
68
+ SPREAD_THE_FEAR_CHANCE: 1,
69
+ SPREAD_THE_FEAR_SPEED_PENALTY: 0,
70
+ BLESSING_HEAL: 4.5,
71
+ BLESSING_HEAL_SPEED_PENALTY: 2.5,
72
+ CLEANSING_AURA_HEAL: 7,
73
+ CLEANSING_AURA_HEAL_SPEED_PENALTY: 3.5,
74
+ BLESSING_HEAL_CRIT_MULTIPLIER: 1.25,
75
+ CLEANSING_AURA_REGEN: 1,
76
+ CLEANSING_AURA_NON_HEALER_REGEN: 10,
77
+ THUNDER_DAMAGE_SLOW: 1.15,
78
+ THUNDER_DAMAGE_FAST: 0.95,
79
+ THUNDER_CRIT_MULTIPLIER: 1.4,
80
+ CHANNEL_THE_COVEN_CRIT_MULTIPLIER: 1.4,
81
+ CHANNEL_THE_COVEN_DAMAGE_CHANCE: 0.75,
82
+ CHANNEL_THE_COVEN_DAMAGE_SLOW: 1.1,
83
+ CHANNEL_THE_COVEN_DAMAGE_FAST: 0.8,
84
+ DEVESTATING_SMASH_DAMAGE: 3.2,
85
+ DEVESTATING_SMASH_SPEED_PENALTY: 2.5,
86
+ CLAN_MOMENTUM_DAMAGE: 3.1
87
+ }
88
+
89
+ const passiveIcons = {
90
+ 'sharp_blades': 'https://game-icons.net/1x1/lorc/plain-dagger.html',
91
+ 'cloud_of_zen': 'https://game-icons.net/1x1/lorc/meditation.html',
92
+ 'frenzy': 'https://game-icons.net/1x1/lorc/totem-head.html',
93
+ 'fortify': 'https://game-icons.net/1x1/lorc/crenulated-shield.html',
94
+ 'spread_the_fear': 'https://game-icons.net/1x1/lorc/evil-book.html',
95
+ 'cleansing_aura': 'https://game-icons.net/1x1/lorc/aura.html',
96
+ 'channel_the_coven': 'https://game-icons.net/1x1/lorc/witch-flight.html',
97
+ 'clan_momentum': 'https://game-icons.net/1x1/delapouite/bully-minion.html'
98
+ }
99
+
100
+ const debuffIcons = {
101
+ 'bleed': 'https://game-icons.net/1x1/lorc/broken-heart.html',
102
+ 'stun': 'https://game-icons.net/1x1/sbed/electric.html',
103
+ 'fear': 'https://game-icons.net/1x1/lorc/screaming.html'
104
+ }
105
+
106
+ const buffIcons = {
107
+ 'taunt': 'https://game-icons.net/1x1/lorc/archery-target.html',
108
+ 'power_up_1': 'https://game-icons.net/1x1/lorc/strong.html',
109
+ 'power_up_2': 'https://game-icons.net/1x1/delapouite/mighty-force.html'
110
+ }
111
+
112
+ module.exports = {
113
+ PASSIVES,
114
+ DEBUFF_STATUSES,
115
+ BUFF_STATUSES,
116
+ BUFF_MULT_EFFECTS,
117
+ BUFF_FLAT_EFFECTS,
118
+ BUFFS,
119
+ DEBUFF_MULT_EFFECTS,
120
+ DEBUFF_FLAT_EFFECTS,
121
+ DEBUFFS,
122
+ MULTS
123
+ }
124
+
125
+ // node services/game-logic/constants.js
126
+ if (require.main === module) {
127
+ console.log("Buffs", BUFFS)
128
+ console.log("Debuffs", DEBUFFS)
129
+ process.exit(0)
130
130
  }