gotchi-battler-game-logic 4.0.1 → 4.0.3
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.
- package/game-logic/v2.0/helpers.js +10 -3
- package/game-logic/v2.0/index.js +40 -52
- package/package.json +1 -1
- package/scripts/data/yield_fields_1_2.json +2778 -0
- package/scripts/rerunBattle.js +24 -0
|
@@ -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
|
-
|
|
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
|
-
|
|
276
|
+
// Handle stats
|
|
277
|
+
healingGotchi.stats.healGiven += amountToHeal
|
|
278
|
+
target.stats.healReceived += amountToHeal
|
|
272
279
|
|
|
273
280
|
return amountToHeal
|
|
274
281
|
}
|
package/game-logic/v2.0/index.js
CHANGED
|
@@ -414,7 +414,7 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
|
|
|
414
414
|
target.stats.dmgReceived += damage
|
|
415
415
|
|
|
416
416
|
} else if (action === 'heal') {
|
|
417
|
-
const amountToHeal = getHealFromMultiplier(attackingGotchi, actionMultipler)
|
|
417
|
+
const amountToHeal = getHealFromMultiplier(attackingGotchi, target, actionMultipler)
|
|
418
418
|
|
|
419
419
|
targetActionEffect = {
|
|
420
420
|
target: target.id,
|
|
@@ -426,10 +426,6 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
|
|
|
426
426
|
// Handle healing
|
|
427
427
|
target.health += amountToHeal
|
|
428
428
|
|
|
429
|
-
// Handle stats
|
|
430
|
-
attackingGotchi.stats.healGiven += amountToHeal
|
|
431
|
-
target.stats.healReceived += amountToHeal
|
|
432
|
-
|
|
433
429
|
} else if (action === 'none') {
|
|
434
430
|
// Do nothing
|
|
435
431
|
} else {
|
|
@@ -449,32 +445,25 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
|
|
|
449
445
|
// Handle the effect
|
|
450
446
|
const specialEffectResults = handleSpecialEffects(attackingTeam, attackingGotchi, target, specialEffect, rng)
|
|
451
447
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
targetAdditionalEffects.push(specialEffectResults.actionEffect)
|
|
461
|
-
}
|
|
462
|
-
} else {
|
|
463
|
-
targetActionEffect = specialEffectResults.actionEffect
|
|
464
|
-
}
|
|
448
|
+
// Do we already have an action effect with attack damage or healing?
|
|
449
|
+
if (targetActionEffect) {
|
|
450
|
+
// If target is same as the actionEffect then just add statuses to the actionEffect
|
|
451
|
+
if (targetActionEffect.target && targetActionEffect.target === specialEffectResults.actionEffect.target) {
|
|
452
|
+
targetActionEffect.statuses.push(...specialEffectResults.actionEffect.statuses)
|
|
453
|
+
} else {
|
|
454
|
+
// If not then add to additionalEffects
|
|
455
|
+
targetAdditionalEffects.push(specialEffectResults.actionEffect)
|
|
465
456
|
}
|
|
457
|
+
} else {
|
|
458
|
+
targetActionEffect = specialEffectResults.actionEffect
|
|
459
|
+
}
|
|
466
460
|
|
|
467
|
-
|
|
468
|
-
targetAdditionalEffects.push(...specialEffectResults.additionalEffects)
|
|
469
|
-
}
|
|
461
|
+
targetAdditionalEffects.push(...specialEffectResults.additionalEffects)
|
|
470
462
|
|
|
471
|
-
|
|
472
|
-
statusesExpired.push(...specialEffectResults.statusesExpired)
|
|
473
|
-
}
|
|
463
|
+
statusesExpired.push(...specialEffectResults.statusesExpired)
|
|
474
464
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
465
|
+
if (specialEffectResults.repeatAttack) {
|
|
466
|
+
repeatAttack = true
|
|
478
467
|
}
|
|
479
468
|
}
|
|
480
469
|
})
|
|
@@ -598,22 +587,14 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
|
|
|
598
587
|
targets.forEach((target) => {
|
|
599
588
|
const specialEffectResults = handleSpecialEffects(attackingTeam, attackingGotchi, target, specialEffect, rng)
|
|
600
589
|
|
|
601
|
-
|
|
602
|
-
if (specialEffectResults.actionEffect) {
|
|
603
|
-
additionalEffects.push(specialEffectResults.actionEffect)
|
|
604
|
-
}
|
|
590
|
+
additionalEffects.push(specialEffectResults.actionEffect)
|
|
605
591
|
|
|
606
|
-
|
|
607
|
-
additionalEffects.push(...specialEffectResults.additionalEffects)
|
|
608
|
-
}
|
|
592
|
+
additionalEffects.push(...specialEffectResults.additionalEffects)
|
|
609
593
|
|
|
610
|
-
|
|
611
|
-
statusesExpired.push(...specialEffectResults.statusesExpired)
|
|
612
|
-
}
|
|
594
|
+
statusesExpired.push(...specialEffectResults.statusesExpired)
|
|
613
595
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
}
|
|
596
|
+
if (specialEffectResults.repeatAttack) {
|
|
597
|
+
repeatAttack = true
|
|
617
598
|
}
|
|
618
599
|
})
|
|
619
600
|
}
|
|
@@ -629,33 +610,41 @@ const attack = (attackingGotchi, attackingTeam, defendingTeam, rng, isSpecial =
|
|
|
629
610
|
}
|
|
630
611
|
|
|
631
612
|
const handleSpecialEffects = (attackingTeam, attackingGotchi, target, specialEffect, rng) => {
|
|
632
|
-
if (specialEffect.chance && specialEffect.chance < 1 && rng() > specialEffect.chance) {
|
|
633
|
-
return false
|
|
634
|
-
}
|
|
635
|
-
|
|
636
613
|
const actionEffect = {
|
|
637
614
|
target: target.id,
|
|
638
615
|
statuses: [],
|
|
639
|
-
outcome: '
|
|
616
|
+
outcome: 'failed'
|
|
640
617
|
}
|
|
641
|
-
|
|
618
|
+
|
|
642
619
|
const additionalEffects = []
|
|
643
620
|
const statusesExpired = []
|
|
644
621
|
let repeatAttack = false
|
|
645
622
|
|
|
623
|
+
// Check for chance of the special effect
|
|
624
|
+
if (specialEffect.chance && specialEffect.chance < 1 && rng() > specialEffect.chance) {
|
|
625
|
+
return {
|
|
626
|
+
actionEffect,
|
|
627
|
+
additionalEffects,
|
|
628
|
+
statusesExpired,
|
|
629
|
+
repeatAttack
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
646
633
|
switch (specialEffect.effectType) {
|
|
647
634
|
case 'status': {
|
|
648
635
|
// Focus/resistance check if target is not on the same team as the attacking gotchi
|
|
649
636
|
if (focusCheck(attackingTeam, attackingGotchi, target, rng)) {
|
|
650
637
|
addStatusToGotchi(target, specialEffect.status)
|
|
651
638
|
actionEffect.statuses.push(specialEffect.status)
|
|
639
|
+
actionEffect.outcome = 'success'
|
|
640
|
+
} else {
|
|
641
|
+
actionEffect.outcome = 'resisted'
|
|
652
642
|
}
|
|
653
643
|
break
|
|
654
644
|
}
|
|
655
645
|
case 'heal': {
|
|
656
|
-
const amountToHeal = getHealFromMultiplier(target, specialEffect.actionMultiplier)
|
|
657
|
-
|
|
658
|
-
|
|
646
|
+
const amountToHeal = getHealFromMultiplier(attackingGotchi, target, specialEffect.actionMultiplier)
|
|
647
|
+
|
|
659
648
|
// Add another effect for the healing
|
|
660
649
|
additionalEffects.push({
|
|
661
650
|
target: target.id,
|
|
@@ -664,9 +653,8 @@ const handleSpecialEffects = (attackingTeam, attackingGotchi, target, specialEff
|
|
|
664
653
|
outcome: 'success'
|
|
665
654
|
})
|
|
666
655
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
target.stats.healReceived += amountToHeal
|
|
656
|
+
target.health += amountToHeal
|
|
657
|
+
|
|
670
658
|
break
|
|
671
659
|
}
|
|
672
660
|
case 'remove_buff': {
|