gotchi-battler-game-logic 4.0.6 → 4.0.7

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.
@@ -379,10 +379,20 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
379
379
 
380
380
  const actionMultipler = isSpecial ? attackingGotchi.specialExpanded.actionMultiplier : 1
381
381
 
382
+ const specialEffects = isSpecial ? (attackingGotchi.specialExpanded.effects || []) : []
383
+
382
384
  const actionEffects = []
383
385
  const additionalEffects = []
384
386
  const statusesExpired = []
387
+
388
+ // repeat_attack is a meta-effect: roll once per special use (not once per target)
389
+ const repeatAttackEffect = isSpecial ? specialEffects.find(e => e.effectType === 'repeat_attack') : null
390
+ const nonRepeatSpecialEffects = isSpecial ? specialEffects.filter(e => e.effectType !== 'repeat_attack') : []
391
+
385
392
  let repeatAttack = false
393
+ if (isSpecial && repeatAttackEffect) {
394
+ repeatAttack = rng() <= repeatAttackEffect.chance
395
+ }
386
396
 
387
397
  targets.forEach((target) => {
388
398
  // The effect for the main action of the attack
@@ -438,7 +448,7 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
438
448
 
439
449
  // If it's a special attack then handle the special effects with target 'same_as_attack'
440
450
  if (isSpecial) {
441
- attackingGotchi.specialExpanded.effects.forEach((specialEffect) => {
451
+ nonRepeatSpecialEffects.forEach((specialEffect) => {
442
452
  // Only handle special effects here that have a target code of 'same_as_attack'
443
453
  // Handle the rest after the action is done
444
454
  // This is to ensure that these effects are not applied multiple times
@@ -464,10 +474,6 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
464
474
  targetAdditionalEffects.push(...specialEffectResults.additionalEffects)
465
475
 
466
476
  statusesExpired.push(...specialEffectResults.statusesExpired)
467
-
468
- if (specialEffectResults.repeatAttack) {
469
- repeatAttack = true
470
- }
471
477
  }
472
478
  })
473
479
  } else {
@@ -585,7 +591,7 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
585
591
 
586
592
  // Handle specialEffects that are not 'same_as_attack'
587
593
  if (isSpecial) {
588
- attackingGotchi.specialExpanded.effects.forEach((specialEffect) => {
594
+ nonRepeatSpecialEffects.forEach((specialEffect) => {
589
595
  if (specialEffect.target !== 'same_as_attack') {
590
596
  const targets = getTargetsFromCode(specialEffect.target, attackingGotchi, attackingTeam, defendingTeam, rng)
591
597
 
@@ -597,10 +603,6 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
597
603
  additionalEffects.push(...specialEffectResults.additionalEffects)
598
604
 
599
605
  statusesExpired.push(...specialEffectResults.statusesExpired)
600
-
601
- if (specialEffectResults.repeatAttack) {
602
- repeatAttack = true
603
- }
604
606
  })
605
607
  }
606
608
  })
@@ -623,15 +625,13 @@ const handleSpecialEffects = (attackingTeam, attackingGotchi, target, specialEff
623
625
 
624
626
  const additionalEffects = []
625
627
  const statusesExpired = []
626
- let repeatAttack = false
627
628
 
628
629
  // Check for chance of the special effect
629
630
  if (specialEffect.chance && specialEffect.chance < 1 && rng() > specialEffect.chance) {
630
631
  return {
631
632
  actionEffect,
632
633
  additionalEffects,
633
- statusesExpired,
634
- repeatAttack
634
+ statusesExpired
635
635
  }
636
636
  }
637
637
 
@@ -757,10 +757,6 @@ const handleSpecialEffects = (attackingTeam, attackingGotchi, target, specialEff
757
757
 
758
758
  break
759
759
  }
760
- case 'repeat_attack': {
761
- repeatAttack = true
762
- break
763
- }
764
760
  default:
765
761
  throw new Error(`Invalid special effect type: ${specialEffect.effectType}`)
766
762
  }
@@ -768,8 +764,7 @@ const handleSpecialEffects = (attackingTeam, attackingGotchi, target, specialEff
768
764
  return {
769
765
  actionEffect,
770
766
  additionalEffects,
771
- statusesExpired,
772
- repeatAttack
767
+ statusesExpired
773
768
  }
774
769
  }
775
770
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gotchi-battler-game-logic",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "mocha \"tests/**/*.test.js\"",