gotchi-battler-game-logic 4.0.2 → 4.0.4

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.
@@ -264,11 +264,18 @@ const getDamage = (attackingGotchi, defendingGotchi, multiplier) => {
264
264
  return damage
265
265
  }
266
266
 
267
- const getHealFromMultiplier = (healingGotchi, multiplier) => {
267
+ const getHealFromMultiplier = (healingGotchi, target, multiplier) => {
268
+ // % of original target health
269
+ let amountToHeal = Math.round(target.fullHealth * multiplier)
268
270
 
269
- const modifiedHealingGotchi = getModifiedStats(healingGotchi)
271
+ // Don't allow amountToHeal to be more than the difference between current health and max health
272
+ if (amountToHeal > target.fullHealth - target.health) {
273
+ amountToHeal = target.fullHealth - target.health
274
+ }
270
275
 
271
- const amountToHeal = Math.round(modifiedHealingGotchi.resist * multiplier)
276
+ // Handle stats
277
+ healingGotchi.stats.healGiven += amountToHeal
278
+ target.stats.healReceived += amountToHeal
272
279
 
273
280
  return amountToHeal
274
281
  }
@@ -441,6 +448,9 @@ const addLeaderToTeam = (team, addStatuses) => {
441
448
  const addStatusToGotchi = (gotchi, status, count) => {
442
449
  if (!count) count = 1
443
450
 
451
+ // Only allow a maximum of 3 of the same status
452
+ if (gotchi.statuses.filter(x => x === status).length >= 3) return false
453
+
444
454
  for (let i = 0; i < count; i++) {
445
455
  gotchi.statuses.push(status)
446
456
  }
@@ -74,7 +74,9 @@ const gameLoop = (team1, team2, seed, options = { debug: false, type: 'training'
74
74
  try {
75
75
  while (getAlive(team1).length && getAlive(team2).length) {
76
76
  // Check if turnCounter is ready for environment effects (99,149,199, etc)
77
- let isEnvironmentTurn = [99, 149, 199, 249, 299].includes(turnCounter)
77
+ let isEnvironmentTurn = [
78
+ 99, 149, 199, 249, 299, 349, 399, 449, 499,
79
+ 549, 599, 649, 699, 749, 799, 849, 899, 949, 999].includes(turnCounter)
78
80
  if (isEnvironmentTurn) {
79
81
  allAliveGotchis.forEach(x => {
80
82
  x.environmentEffects.push('damage_up')
@@ -119,7 +121,7 @@ const gameLoop = (team1, team2, seed, options = { debug: false, type: 'training'
119
121
  }
120
122
 
121
123
  logs.result.winner = getAlive(team1).length ? 1 : 2
122
- logs.result.winningTeam = getTeamGotchis(team1).length ? getTeamGotchis(team1) : getTeamGotchis(team2)
124
+ logs.result.winningTeam = logs.result.winner === 1 ? getTeamGotchis(team1) : getTeamGotchis(team2)
123
125
  logs.result.winningTeam = logs.result.winningTeam.map((gotchi) => {
124
126
  return {
125
127
  id: gotchi.id,
@@ -414,7 +416,7 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
414
416
  target.stats.dmgReceived += damage
415
417
 
416
418
  } else if (action === 'heal') {
417
- const amountToHeal = getHealFromMultiplier(attackingGotchi, actionMultipler)
419
+ const amountToHeal = getHealFromMultiplier(attackingGotchi, target, actionMultipler)
418
420
 
419
421
  targetActionEffect = {
420
422
  target: target.id,
@@ -426,10 +428,6 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
426
428
  // Handle healing
427
429
  target.health += amountToHeal
428
430
 
429
- // Handle stats
430
- attackingGotchi.stats.healGiven += amountToHeal
431
- target.stats.healReceived += amountToHeal
432
-
433
431
  } else if (action === 'none') {
434
432
  // Do nothing
435
433
  } else {
@@ -487,18 +485,20 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
487
485
  switch (attackEffect.type) {
488
486
  case 'apply_status': {
489
487
  if (focusCheck(attackingTeam, attackingGotchi, target, rng)) {
490
- addStatusToGotchi(target, attackEffect.status)
491
- targetActionEffect.statuses.push(attackEffect.status)
488
+ if (addStatusToGotchi(target, attackEffect.status)) {
489
+ targetActionEffect.statuses.push(attackEffect.status)
490
+ }
492
491
  }
493
492
  break
494
493
  }
495
494
  case 'gain_status': {
496
- addStatusToGotchi(attackingGotchi, attackEffect.status)
497
- targetAdditionalEffects.push({
498
- target: attackingGotchi.id,
499
- status: attackEffect.status,
500
- outcome: 'success'
501
- })
495
+ if (addStatusToGotchi(attackingGotchi, attackEffect.status)) {
496
+ targetAdditionalEffects.push({
497
+ target: attackingGotchi.id,
498
+ status: attackEffect.status,
499
+ outcome: 'success'
500
+ })
501
+ }
502
502
  break
503
503
  }
504
504
  case 'remove_buff': {
@@ -638,18 +638,21 @@ const handleSpecialEffects = (attackingTeam, attackingGotchi, target, specialEff
638
638
  case 'status': {
639
639
  // Focus/resistance check if target is not on the same team as the attacking gotchi
640
640
  if (focusCheck(attackingTeam, attackingGotchi, target, rng)) {
641
- addStatusToGotchi(target, specialEffect.status)
642
- actionEffect.statuses.push(specialEffect.status)
643
- actionEffect.outcome = 'success'
641
+ if (addStatusToGotchi(target, specialEffect.status)) {
642
+ actionEffect.statuses.push(specialEffect.status)
643
+ actionEffect.outcome = 'success'
644
+ } else {
645
+ // There's already a maximum of 3 of the same status
646
+ actionEffect.outcome = 'failed'
647
+ }
644
648
  } else {
645
649
  actionEffect.outcome = 'resisted'
646
650
  }
647
651
  break
648
652
  }
649
653
  case 'heal': {
650
- const amountToHeal = getHealFromMultiplier(target, specialEffect.actionMultiplier)
651
- target.health += amountToHeal
652
-
654
+ const amountToHeal = getHealFromMultiplier(attackingGotchi, target, specialEffect.actionMultiplier)
655
+
653
656
  // Add another effect for the healing
654
657
  additionalEffects.push({
655
658
  target: target.id,
@@ -658,9 +661,8 @@ const handleSpecialEffects = (attackingTeam, attackingGotchi, target, specialEff
658
661
  outcome: 'success'
659
662
  })
660
663
 
661
- // Handle stats
662
- attackingGotchi.stats.healGiven += amountToHeal
663
- target.stats.healReceived += amountToHeal
664
+ target.health += amountToHeal
665
+
664
666
  break
665
667
  }
666
668
  case 'remove_buff': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gotchi-battler-game-logic",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "mocha \"tests/**/*.test.js\"",