Index: ps/trunk/binaries/data/mods/public/simulation/components/StatusEffectsReceiver.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/StatusEffectsReceiver.js +++ ps/trunk/binaries/data/mods/public/simulation/components/StatusEffectsReceiver.js @@ -142,7 +142,7 @@ return; if (status.Damage || status.Capture) - Attacking.HandleAttackEffects(statusName, status, this.entity, status.source.entity, status.source.owner); + Attacking.HandleAttackEffects(this.entity, statusName, status, status.source.entity, status.source.owner); if (!status.Duration) return; Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_StatusEffectsReceiver.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_StatusEffectsReceiver.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_StatusEffectsReceiver.js @@ -19,7 +19,7 @@ let statusName; let Attacking = { - "HandleAttackEffects": (_, attackData) => { + "HandleAttackEffects": (_, __, attackData) => { for (let type in attackData.Damage) dealtDamage += attackData.Damage[type]; } Index: ps/trunk/binaries/data/mods/public/simulation/helpers/Attacking.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/helpers/Attacking.js +++ ps/trunk/binaries/data/mods/public/simulation/helpers/Attacking.js @@ -170,7 +170,7 @@ * * @param {number} target - The target of the attack. * @param {Object} effectData - The effects calculate the effect for. - * @param {string} effectType - The type of effect to apply (e.g. Damage, Capture or StatusEffect). + * @param {string} effectType - The type of effect to apply (e.g. Damage, Capture or ApplyStatus). * @param {number} bonusMultiplier - The factor to multiply the total effect with. * @param {Object} cmpResistance - Optionally the resistance component of the target. * @@ -196,7 +196,7 @@ if (cmpHealth) total /= 0.1 + 0.9 * cmpHealth.GetHitpoints() / cmpHealth.GetMaxHitpoints(); } - else if (effectType == "StatusEffect") + else if (effectType == "ApplyStatus") return effectData[effectType]; return total * bonusMultiplier; Index: ps/trunk/binaries/data/mods/public/simulation/helpers/tests/test_Attacking.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/helpers/tests/test_Attacking.js +++ ps/trunk/binaries/data/mods/public/simulation/helpers/tests/test_Attacking.js @@ -3,6 +3,7 @@ Engine.LoadComponentScript("interfaces/Health.js"); Engine.LoadComponentScript("interfaces/Promotion.js"); Engine.LoadComponentScript("interfaces/Resistance.js"); +Engine.LoadComponentScript("interfaces/StatusEffectsReceiver.js"); // Unit tests for the Attacking helper. // TODO: Some of it is tested in components/test_Damage.js, which should be spliced and moved. @@ -14,7 +15,10 @@ this.attackData = { "Damage": "1", - "Capture": "2" + "Capture": "2", + "ApplyStatus": { + "statusName": {} + } }; } @@ -90,6 +94,21 @@ } /** + * Regression test that StatusEffects are handled correctly. + */ + testStatusEffects() { + let cmpStatusEffectsReceiver = AddMock(this.TESTED_ENTITY_ID, IID_StatusEffectsReceiver, { + "ApplyStatus": (effectData, __, ___) => { + TS_ASSERT_UNEVAL_EQUALS(effectData, this.attackData.ApplyStatus); + } + }); + let spy = new Spy(cmpStatusEffectsReceiver, "ApplyStatus"); + + Attacking.HandleAttackEffects(this.TESTED_ENTITY_ID, "Test", this.attackData, INVALID_ENTITY, INVALID_PLAYER, 2); + TS_ASSERT_EQUALS(spy._called, 1); + } + + /** * Regression test that bonus multiplier is handled correctly. */ testBonusMultiplier() { @@ -113,4 +132,5 @@ new testHandleAttackEffects().testMultipleEffects(); new testHandleAttackEffects().testSkippedEffect(); new testHandleAttackEffects().testAttackedMessage(); +new testHandleAttackEffects().testStatusEffects(); new testHandleAttackEffects().testBonusMultiplier();