gotchi-battler-game-logic 4.0.3 → 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.
@@ -448,6 +448,9 @@ const addLeaderToTeam = (team, addStatuses) => {
448
448
  const addStatusToGotchi = (gotchi, status, count) => {
449
449
  if (!count) count = 1
450
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
+
451
454
  for (let i = 0; i < count; i++) {
452
455
  gotchi.statuses.push(status)
453
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,
@@ -483,18 +485,20 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
483
485
  switch (attackEffect.type) {
484
486
  case 'apply_status': {
485
487
  if (focusCheck(attackingTeam, attackingGotchi, target, rng)) {
486
- addStatusToGotchi(target, attackEffect.status)
487
- targetActionEffect.statuses.push(attackEffect.status)
488
+ if (addStatusToGotchi(target, attackEffect.status)) {
489
+ targetActionEffect.statuses.push(attackEffect.status)
490
+ }
488
491
  }
489
492
  break
490
493
  }
491
494
  case 'gain_status': {
492
- addStatusToGotchi(attackingGotchi, attackEffect.status)
493
- targetAdditionalEffects.push({
494
- target: attackingGotchi.id,
495
- status: attackEffect.status,
496
- outcome: 'success'
497
- })
495
+ if (addStatusToGotchi(attackingGotchi, attackEffect.status)) {
496
+ targetAdditionalEffects.push({
497
+ target: attackingGotchi.id,
498
+ status: attackEffect.status,
499
+ outcome: 'success'
500
+ })
501
+ }
498
502
  break
499
503
  }
500
504
  case 'remove_buff': {
@@ -634,9 +638,13 @@ const handleSpecialEffects = (attackingTeam, attackingGotchi, target, specialEff
634
638
  case 'status': {
635
639
  // Focus/resistance check if target is not on the same team as the attacking gotchi
636
640
  if (focusCheck(attackingTeam, attackingGotchi, target, rng)) {
637
- addStatusToGotchi(target, specialEffect.status)
638
- actionEffect.statuses.push(specialEffect.status)
639
- 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
+ }
640
648
  } else {
641
649
  actionEffect.outcome = 'resisted'
642
650
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gotchi-battler-game-logic",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "mocha \"tests/**/*.test.js\"",