Rename Attacking.js-helper to Attack.js and its global to AttackHelper.
16b452cf91#inline-4026 Differential revision: https://code.wildfiregames.com/D3858 Comment by: @wraitii This was SVN commit r25275.
This commit is contained in:
parent
3184a51787
commit
4329dd90ce
@ -109,7 +109,7 @@ Attack.prototype.Schema =
|
||||
"</optional>" +
|
||||
"<text/>" +
|
||||
"</element>" +
|
||||
Attacking.BuildAttackEffectsSchema() +
|
||||
AttackHelper.BuildAttackEffectsSchema() +
|
||||
"<element name='MaxRange' a:help='Maximum attack range (in metres)'><ref name='nonNegativeDecimal'/></element>" +
|
||||
"<optional>" +
|
||||
"<element name='MinRange' a:help='Minimum attack range (in metres). Defaults to 0.'><ref name='nonNegativeDecimal'/></element>" +
|
||||
@ -143,7 +143,7 @@ Attack.prototype.Schema =
|
||||
"<element name='Shape' a:help='Shape of the splash damage, can be circular or linear'><text/></element>" +
|
||||
"<element name='Range' a:help='Size of the area affected by the splash'><ref name='nonNegativeDecimal'/></element>" +
|
||||
"<element name='FriendlyFire' a:help='Whether the splash damage can hurt non enemy units'><data type='boolean'/></element>" +
|
||||
Attacking.BuildAttackEffectsSchema() +
|
||||
AttackHelper.BuildAttackEffectsSchema() +
|
||||
"</interleave>" +
|
||||
"</element>" +
|
||||
"</optional>" +
|
||||
@ -327,7 +327,7 @@ Attack.prototype.GetAttackEffectsData = function(type, splash)
|
||||
let template = this.template[type];
|
||||
if (splash)
|
||||
template = template.Splash;
|
||||
return Attacking.GetAttackEffectsData("Attack/" + type + (splash ? "/Splash" : ""), template, this.entity);
|
||||
return AttackHelper.GetAttackEffectsData("Attack/" + type + (splash ? "/Splash" : ""), template, this.entity);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -15,7 +15,7 @@ DeathDamage.prototype.Schema =
|
||||
"<element name='Shape' a:help='Shape of the splash damage, can be circular.'><text/></element>" +
|
||||
"<element name='Range' a:help='Size of the area affected by the splash.'><ref name='nonNegativeDecimal'/></element>" +
|
||||
"<element name='FriendlyFire' a:help='Whether the splash damage can hurt non enemy units.'><data type='boolean'/></element>" +
|
||||
Attacking.BuildAttackEffectsSchema();
|
||||
AttackHelper.BuildAttackEffectsSchema();
|
||||
|
||||
DeathDamage.prototype.Init = function()
|
||||
{
|
||||
@ -26,7 +26,7 @@ DeathDamage.prototype.Serialize = null;
|
||||
|
||||
DeathDamage.prototype.GetDeathDamageEffects = function()
|
||||
{
|
||||
return Attacking.GetAttackEffectsData("DeathDamage", this.template, this.entity);
|
||||
return AttackHelper.GetAttackEffectsData("DeathDamage", this.template, this.entity);
|
||||
};
|
||||
|
||||
DeathDamage.prototype.CauseDeathDamage = function()
|
||||
@ -41,7 +41,7 @@ DeathDamage.prototype.CauseDeathDamage = function()
|
||||
if (owner == INVALID_PLAYER)
|
||||
warn("Unit causing death damage does not have any owner.");
|
||||
|
||||
Attacking.CauseDamageOverArea({
|
||||
AttackHelper.CauseDamageOverArea({
|
||||
"type": "Death",
|
||||
"attackData": this.GetDeathDamageEffects(),
|
||||
"attacker": this.entity,
|
||||
|
@ -42,7 +42,7 @@ DelayedDamage.prototype.Hit = function(data, lateness)
|
||||
Engine.QueryInterface(SYSTEM_ENTITY, IID_SoundManager).PlaySoundGroupAtPosition(data.attackImpactSound, data.position);
|
||||
|
||||
if (data.splash)
|
||||
Attacking.CauseDamageOverArea({
|
||||
AttackHelper.CauseDamageOverArea({
|
||||
"type": data.type,
|
||||
"attackData": data.splash.attackData,
|
||||
"attacker": data.attacker,
|
||||
@ -62,7 +62,7 @@ DelayedDamage.prototype.Hit = function(data, lateness)
|
||||
|
||||
if (!data.projectileId)
|
||||
{
|
||||
Attacking.HandleAttackEffects(target, data);
|
||||
AttackHelper.HandleAttackEffects(target, data);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ DelayedDamage.prototype.Hit = function(data, lateness)
|
||||
// Deal direct damage if we hit the main target
|
||||
// and we could handle the attack.
|
||||
if (PositionHelper.TestCollision(target, data.position, lateness) &&
|
||||
Attacking.HandleAttackEffects(target, data))
|
||||
AttackHelper.HandleAttackEffects(target, data))
|
||||
{
|
||||
cmpProjectileManager.RemoveProjectile(data.projectileId);
|
||||
return;
|
||||
@ -79,12 +79,12 @@ DelayedDamage.prototype.Hit = function(data, lateness)
|
||||
|
||||
// If we didn't hit the main target look for nearby units.
|
||||
let ents = PositionHelper.EntitiesNearPoint(Vector2D.from3D(data.position), this.MISSILE_HIT_RADIUS,
|
||||
Attacking.GetPlayersToDamage(data.attackerOwner, data.friendlyFire));
|
||||
AttackHelper.GetPlayersToDamage(data.attackerOwner, data.friendlyFire));
|
||||
|
||||
for (let ent of ents)
|
||||
{
|
||||
if (!PositionHelper.TestCollision(ent, data.position, lateness) ||
|
||||
!Attacking.HandleAttackEffects(ent, data))
|
||||
!AttackHelper.HandleAttackEffects(ent, data))
|
||||
continue;
|
||||
|
||||
cmpProjectileManager.RemoveProjectile(data.projectileId);
|
||||
|
@ -145,7 +145,7 @@ StatusEffectsReceiver.prototype.ExecuteEffect = function(statusCode, lateness)
|
||||
return;
|
||||
|
||||
if (status.Damage || status.Capture)
|
||||
Attacking.HandleAttackEffects(this.entity, {
|
||||
AttackHelper.HandleAttackEffects(this.entity, {
|
||||
"type": statusCode,
|
||||
"attackData": status,
|
||||
"attacker": status.source.entity,
|
||||
|
@ -15,6 +15,6 @@ Engine.RegisterMessageType("InvulnerabilityChanged");
|
||||
* "capture": number,
|
||||
* "statusEffects": Object[],
|
||||
* "fromStatusEffect": boolean }
|
||||
* sent from Attacking.js-helper to the target entity, each time the target is damaged.
|
||||
* sent from Attack.js-helper to the target entity, each time the target is damaged.
|
||||
*/
|
||||
Engine.RegisterMessageType("Attacked");
|
||||
|
@ -21,7 +21,7 @@ AttackEffects = class AttackEffects
|
||||
}
|
||||
};
|
||||
|
||||
Engine.LoadHelperScript("Attacking.js");
|
||||
Engine.LoadHelperScript("Attack.js");
|
||||
Engine.LoadHelperScript("Player.js");
|
||||
Engine.LoadHelperScript("ValueModification.js");
|
||||
Engine.LoadComponentScript("interfaces/Auras.js");
|
||||
@ -280,7 +280,7 @@ for (let className of ["Infantry", "Cavalry"])
|
||||
|
||||
TS_ASSERT_EQUALS(cmpAttack.GetAttackEffectsData("Capture").Bonuses || null, null);
|
||||
|
||||
let getAttackBonus = (s, t, e, splash) => Attacking.GetAttackBonus(s, e, t, cmpAttack.GetAttackEffectsData(t, splash).Bonuses || null);
|
||||
let getAttackBonus = (s, t, e, splash) => AttackHelper.GetAttackBonus(s, e, t, cmpAttack.GetAttackEffectsData(t, splash).Bonuses || null);
|
||||
TS_ASSERT_UNEVAL_EQUALS(getAttackBonus(attacker, "Melee", defender), className == "Cavalry" ? 2 : 1);
|
||||
TS_ASSERT_UNEVAL_EQUALS(getAttackBonus(attacker, "Ranged", defender), 1);
|
||||
TS_ASSERT_UNEVAL_EQUALS(getAttackBonus(attacker, "Ranged", defender, true), className == "Cavalry" ? 3 : 1);
|
||||
|
@ -11,7 +11,7 @@ AttackEffects = class AttackEffects
|
||||
}
|
||||
};
|
||||
|
||||
Engine.LoadHelperScript("Attacking.js");
|
||||
Engine.LoadHelperScript("Attack.js");
|
||||
Engine.LoadHelperScript("Player.js");
|
||||
Engine.LoadHelperScript("Position.js");
|
||||
Engine.LoadHelperScript("ValueModification.js");
|
||||
@ -147,12 +147,12 @@ function Test_Generic()
|
||||
damageTaken = false;
|
||||
}
|
||||
|
||||
Attacking.HandleAttackEffects(target, data);
|
||||
AttackHelper.HandleAttackEffects(target, data);
|
||||
TestDamage();
|
||||
|
||||
data.type = "Ranged";
|
||||
type = data.type;
|
||||
Attacking.HandleAttackEffects(target, data);
|
||||
AttackHelper.HandleAttackEffects(target, data);
|
||||
TestDamage();
|
||||
|
||||
// Check for damage still being dealt if the attacker dies
|
||||
@ -164,8 +164,8 @@ function Test_Generic()
|
||||
AddMock(atkPlayerEntity, IID_Player, {
|
||||
"GetEnemies": () => [2, 3]
|
||||
});
|
||||
TS_ASSERT_UNEVAL_EQUALS(Attacking.GetPlayersToDamage(atkPlayerEntity, true), [0, 1, 2, 3, 4]);
|
||||
TS_ASSERT_UNEVAL_EQUALS(Attacking.GetPlayersToDamage(atkPlayerEntity, false), [2, 3]);
|
||||
TS_ASSERT_UNEVAL_EQUALS(AttackHelper.GetPlayersToDamage(atkPlayerEntity, true), [0, 1, 2, 3, 4]);
|
||||
TS_ASSERT_UNEVAL_EQUALS(AttackHelper.GetPlayersToDamage(atkPlayerEntity, false), [2, 3]);
|
||||
}
|
||||
|
||||
Test_Generic();
|
||||
@ -257,7 +257,7 @@ function TestLinearSplashDamage()
|
||||
}
|
||||
});
|
||||
|
||||
Attacking.CauseDamageOverArea(data);
|
||||
AttackHelper.CauseDamageOverArea(data);
|
||||
TS_ASSERT(hitEnts.has(60));
|
||||
TS_ASSERT(hitEnts.has(61));
|
||||
TS_ASSERT(hitEnts.has(62));
|
||||
@ -273,7 +273,7 @@ function TestLinearSplashDamage()
|
||||
}
|
||||
});
|
||||
|
||||
Attacking.CauseDamageOverArea(data);
|
||||
AttackHelper.CauseDamageOverArea(data);
|
||||
TS_ASSERT(hitEnts.has(60));
|
||||
TS_ASSERT(hitEnts.has(61));
|
||||
TS_ASSERT(hitEnts.has(62));
|
||||
@ -388,7 +388,7 @@ function TestCircularSplashDamage()
|
||||
});
|
||||
let spy65 = new Spy(cmpHealth65, "TakeDamage");
|
||||
|
||||
Attacking.CauseDamageOverArea({
|
||||
AttackHelper.CauseDamageOverArea({
|
||||
"type": "Ranged",
|
||||
"attackData": { "Damage": { "Hack": 100, "Pierce": 0, "Crush": 0 } },
|
||||
"attacker": 50,
|
||||
|
@ -2,7 +2,7 @@ AttackEffects = class AttackEffects
|
||||
{
|
||||
};
|
||||
|
||||
Engine.LoadHelperScript("Attacking.js");
|
||||
Engine.LoadHelperScript("Attack.js");
|
||||
Engine.LoadHelperScript("ValueModification.js");
|
||||
Engine.LoadComponentScript("interfaces/DeathDamage.js");
|
||||
Engine.LoadComponentScript("interfaces/ModifiersManager.js");
|
||||
@ -53,8 +53,8 @@ let result = {
|
||||
"friendlyFire": false
|
||||
};
|
||||
|
||||
Attacking.CauseDamageOverArea = data => TS_ASSERT_UNEVAL_EQUALS(data, result);
|
||||
Attacking.GetPlayersToDamage = () => playersToDamage;
|
||||
AttackHelper.CauseDamageOverArea = data => TS_ASSERT_UNEVAL_EQUALS(data, result);
|
||||
AttackHelper.GetPlayersToDamage = () => playersToDamage;
|
||||
|
||||
AddMock(deadEnt, IID_Position, {
|
||||
"GetPosition2D": () => pos,
|
||||
|
@ -21,7 +21,7 @@ AttackEffects = class AttackEffects
|
||||
}
|
||||
};
|
||||
|
||||
Engine.LoadHelperScript("Attacking.js");
|
||||
Engine.LoadHelperScript("Attack.js");
|
||||
Engine.LoadHelperScript("Player.js");
|
||||
Engine.LoadHelperScript("ValueModification.js");
|
||||
Engine.LoadComponentScript("interfaces/Capturable.js");
|
||||
@ -80,13 +80,13 @@ class testResistance
|
||||
"attackerOwner": this.EnemyID
|
||||
};
|
||||
|
||||
Attacking.HandleAttackEffects(this.EntityID, data);
|
||||
AttackHelper.HandleAttackEffects(this.EntityID, data);
|
||||
TS_ASSERT_EQUALS(spy._called, 1);
|
||||
|
||||
this.cmpResistance.SetInvulnerability(true);
|
||||
|
||||
TS_ASSERT(this.cmpResistance.IsInvulnerable());
|
||||
Attacking.HandleAttackEffects(this.EntityID, data);
|
||||
AttackHelper.HandleAttackEffects(this.EntityID, data);
|
||||
TS_ASSERT_EQUALS(spy._called, 1);
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ class testResistance
|
||||
});
|
||||
let spy = new Spy(cmpHealth, "TakeDamage");
|
||||
|
||||
Attacking.HandleAttackEffects(this.EntityID, {
|
||||
AttackHelper.HandleAttackEffects(this.EntityID, {
|
||||
"type": "Test",
|
||||
"attackData": attackData,
|
||||
"attacker": this.AttackerID,
|
||||
@ -154,7 +154,7 @@ class testResistance
|
||||
});
|
||||
let spy = new Spy(cmpHealth, "TakeDamage");
|
||||
|
||||
Attacking.HandleAttackEffects(this.EntityID, {
|
||||
AttackHelper.HandleAttackEffects(this.EntityID, {
|
||||
"type": "Test",
|
||||
"attackData": attackData,
|
||||
"attacker": this.AttackerID,
|
||||
@ -185,7 +185,7 @@ class testResistance
|
||||
});
|
||||
let spy = new Spy(cmpCapturable, "Capture");
|
||||
|
||||
Attacking.HandleAttackEffects(this.EntityID, {
|
||||
AttackHelper.HandleAttackEffects(this.EntityID, {
|
||||
"type": "Test",
|
||||
"attackData": attackData,
|
||||
"attacker": this.AttackerID,
|
||||
@ -226,7 +226,7 @@ class testResistance
|
||||
});
|
||||
let spy = new Spy(cmpStatusEffectsReceiver, "ApplyStatus");
|
||||
|
||||
Attacking.HandleAttackEffects(this.EntityID, {
|
||||
AttackHelper.HandleAttackEffects(this.EntityID, {
|
||||
"type": "Test",
|
||||
"attackData": attackData,
|
||||
"attacker": this.AttackerID,
|
||||
@ -253,7 +253,7 @@ class testResistance
|
||||
});
|
||||
spy = new Spy(cmpStatusEffectsReceiver, "ApplyStatus");
|
||||
|
||||
Attacking.HandleAttackEffects(this.EntityID, {
|
||||
AttackHelper.HandleAttackEffects(this.EntityID, {
|
||||
"type": "Test",
|
||||
"attackData": attackData,
|
||||
"attacker": this.AttackerID,
|
||||
@ -297,7 +297,7 @@ class testResistance
|
||||
});
|
||||
spy = new Spy(cmpStatusEffectsReceiver, "ApplyStatus");
|
||||
|
||||
Attacking.HandleAttackEffects(this.EntityID, {
|
||||
AttackHelper.HandleAttackEffects(this.EntityID, {
|
||||
"type": "Test",
|
||||
"attackData": attackData,
|
||||
"attacker": this.AttackerID,
|
||||
@ -344,7 +344,7 @@ class testResistance
|
||||
});
|
||||
let spy = new Spy(cmpHealth, "TakeDamage");
|
||||
|
||||
Attacking.HandleAttackEffects(this.EntityID, {
|
||||
AttackHelper.HandleAttackEffects(this.EntityID, {
|
||||
"type": "Test",
|
||||
"attackData": attackData,
|
||||
"attacker": this.AttackerID,
|
||||
@ -398,7 +398,7 @@ class testResistance
|
||||
let healthSpy = new Spy(cmpHealth, "TakeDamage");
|
||||
let captureSpy = new Spy(cmpCapturable, "Capture");
|
||||
|
||||
Attacking.HandleAttackEffects(this.EntityID, {
|
||||
AttackHelper.HandleAttackEffects(this.EntityID, {
|
||||
"type": "Test",
|
||||
"attackData": attackData,
|
||||
"attacker": this.AttackerID,
|
||||
|
@ -18,13 +18,13 @@ let enemyEntity = 4;
|
||||
let enemy = 2;
|
||||
let statusName;
|
||||
|
||||
let Attacking = {
|
||||
let AttackHelper = {
|
||||
"HandleAttackEffects": (_, data) => {
|
||||
for (let type in data.attackData.Damage)
|
||||
dealtDamage += data.attackData.Damage[type];
|
||||
}
|
||||
};
|
||||
Engine.RegisterGlobal("Attacking", Attacking);
|
||||
Engine.RegisterGlobal("AttackHelper", AttackHelper);
|
||||
|
||||
function reset()
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Provides attack and damage-related helpers under the Attacking umbrella (to avoid name ambiguity with the component).
|
||||
* Provides attack and damage-related helpers.
|
||||
*/
|
||||
function Attacking() {}
|
||||
function AttackHelper() {}
|
||||
|
||||
const DirectEffectsSchema =
|
||||
"<element name='Damage'>" +
|
||||
@ -58,7 +58,7 @@ const StatusEffectsSchema =
|
||||
*
|
||||
* @return {string} - RelaxNG schema string.
|
||||
*/
|
||||
Attacking.prototype.BuildAttackEffectsSchema = function()
|
||||
AttackHelper.prototype.BuildAttackEffectsSchema = function()
|
||||
{
|
||||
return "" +
|
||||
"<oneOrMore>" +
|
||||
@ -88,7 +88,7 @@ Attacking.prototype.BuildAttackEffectsSchema = function()
|
||||
/**
|
||||
* Returns a template-like object of attack effects.
|
||||
*/
|
||||
Attacking.prototype.GetAttackEffectsData = function(valueModifRoot, template, entity)
|
||||
AttackHelper.prototype.GetAttackEffectsData = function(valueModifRoot, template, entity)
|
||||
{
|
||||
let ret = {};
|
||||
|
||||
@ -112,7 +112,7 @@ Attacking.prototype.GetAttackEffectsData = function(valueModifRoot, template, en
|
||||
return ret;
|
||||
};
|
||||
|
||||
Attacking.prototype.GetStatusEffectsData = function(valueModifRoot, template, entity)
|
||||
AttackHelper.prototype.GetStatusEffectsData = function(valueModifRoot, template, entity)
|
||||
{
|
||||
let result = {};
|
||||
for (let effect in template)
|
||||
@ -130,7 +130,7 @@ Attacking.prototype.GetStatusEffectsData = function(valueModifRoot, template, en
|
||||
return result;
|
||||
};
|
||||
|
||||
Attacking.prototype.GetStatusEffectsModifications = function(valueModifRoot, template, entity, effect)
|
||||
AttackHelper.prototype.GetStatusEffectsModifications = function(valueModifRoot, template, entity, effect)
|
||||
{
|
||||
let modifiers = {};
|
||||
for (let modifier in template)
|
||||
@ -161,7 +161,7 @@ Attacking.prototype.GetStatusEffectsModifications = function(valueModifRoot, tem
|
||||
*
|
||||
* @return {number} - The total value of the effect.
|
||||
*/
|
||||
Attacking.prototype.GetTotalAttackEffects = function(target, effectData, effectType, bonusMultiplier, cmpResistance)
|
||||
AttackHelper.prototype.GetTotalAttackEffects = function(target, effectData, effectType, bonusMultiplier, cmpResistance)
|
||||
{
|
||||
let total = 0;
|
||||
if (!cmpResistance)
|
||||
@ -215,7 +215,7 @@ Attacking.prototype.GetTotalAttackEffects = function(target, effectData, effectT
|
||||
* @param {boolean} friendlyFire - A flag indicating if allied entities are also damaged.
|
||||
* @return {number[]} The ids of players need to be damaged.
|
||||
*/
|
||||
Attacking.prototype.GetPlayersToDamage = function(attackerOwner, friendlyFire)
|
||||
AttackHelper.prototype.GetPlayersToDamage = function(attackerOwner, friendlyFire)
|
||||
{
|
||||
if (!friendlyFire)
|
||||
return QueryPlayerIDInterface(attackerOwner).GetEnemies();
|
||||
@ -236,7 +236,7 @@ Attacking.prototype.GetPlayersToDamage = function(attackerOwner, friendlyFire)
|
||||
* @param {Vector3D} [data.direction] - The unit vector defining the direction. Needed for linear splash damage.
|
||||
* @param {boolean} data.friendlyFire - A flag indicating if allied entities also ought to be damaged.
|
||||
*/
|
||||
Attacking.prototype.CauseDamageOverArea = function(data)
|
||||
AttackHelper.prototype.CauseDamageOverArea = function(data)
|
||||
{
|
||||
let nearEnts = PositionHelper.EntitiesNearPoint(data.origin, data.radius,
|
||||
this.GetPlayersToDamage(data.attackerOwner, data.friendlyFire));
|
||||
@ -300,7 +300,7 @@ Attacking.prototype.CauseDamageOverArea = function(data)
|
||||
*
|
||||
* @return {boolean} - Whether we handled the attack.
|
||||
*/
|
||||
Attacking.prototype.HandleAttackEffects = function(target, data, bonusMultiplier = 1)
|
||||
AttackHelper.prototype.HandleAttackEffects = function(target, data, bonusMultiplier = 1)
|
||||
{
|
||||
let cmpResistance = Engine.QueryInterface(target, IID_Resistance);
|
||||
if (cmpResistance && cmpResistance.IsInvulnerable())
|
||||
@ -354,7 +354,7 @@ Attacking.prototype.HandleAttackEffects = function(target, data, bonusMultiplier
|
||||
* @param {Object} template - The bonus' template.
|
||||
* @return {number} - The source entity's attack bonus against the specified target.
|
||||
*/
|
||||
Attacking.prototype.GetAttackBonus = function(source, target, type, template)
|
||||
AttackHelper.prototype.GetAttackBonus = function(source, target, type, template)
|
||||
{
|
||||
let cmpIdentity = Engine.QueryInterface(target, IID_Identity);
|
||||
if (!cmpIdentity)
|
||||
@ -377,7 +377,5 @@ Attacking.prototype.GetAttackBonus = function(source, target, type, template)
|
||||
return attackBonus;
|
||||
};
|
||||
|
||||
var AttackingInstance = new Attacking();
|
||||
Engine.RegisterGlobal("Attacking", AttackingInstance);
|
||||
|
||||
Engine.RegisterGlobal("AttackHelper", new AttackHelper());
|
||||
Engine.RegisterGlobal("g_AttackEffects", new AttackEffects());
|
@ -21,14 +21,13 @@ AttackEffects = class AttackEffects
|
||||
}
|
||||
};
|
||||
|
||||
Engine.LoadHelperScript("Attacking.js");
|
||||
Engine.LoadHelperScript("Attack.js");
|
||||
Engine.LoadComponentScript("interfaces/Capturable.js");
|
||||
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.
|
||||
|
||||
class testHandleAttackEffects {
|
||||
@ -59,7 +58,7 @@ class testHandleAttackEffects {
|
||||
"Capture": x => { this.resultString += x; },
|
||||
});
|
||||
|
||||
Attacking.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
AttackHelper.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
"type": "Test",
|
||||
"attackData": this.attackData,
|
||||
"attacker": INVALID_ENTITY,
|
||||
@ -78,7 +77,7 @@ class testHandleAttackEffects {
|
||||
"Capture": x => { this.resultString += x; },
|
||||
});
|
||||
|
||||
Attacking.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
AttackHelper.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
"type": "Test",
|
||||
"attackData": this.attackData,
|
||||
"attacker": INVALID_ENTITY,
|
||||
@ -95,7 +94,7 @@ class testHandleAttackEffects {
|
||||
"GetMaxHitpoints": () => 1,
|
||||
});
|
||||
|
||||
Attacking.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
AttackHelper.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
"type": "Test",
|
||||
"attackData": this.attackData,
|
||||
"attacker": INVALID_ENTITY,
|
||||
@ -110,7 +109,7 @@ class testHandleAttackEffects {
|
||||
*/
|
||||
testAttackedMessage() {
|
||||
Engine.PostMessage = () => TS_ASSERT(false);
|
||||
Attacking.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
AttackHelper.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
"type": "Test",
|
||||
"attackData": this.attackData,
|
||||
"attacker": INVALID_ENTITY,
|
||||
@ -122,7 +121,7 @@ class testHandleAttackEffects {
|
||||
});
|
||||
let count = 0;
|
||||
Engine.PostMessage = () => count++;
|
||||
Attacking.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
AttackHelper.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
"type": "Test",
|
||||
"attackData": this.attackData,
|
||||
"attacker": INVALID_ENTITY,
|
||||
@ -137,7 +136,7 @@ class testHandleAttackEffects {
|
||||
});
|
||||
count = 0;
|
||||
Engine.PostMessage = () => count++;
|
||||
Attacking.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
AttackHelper.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
"type": "Test",
|
||||
"attackData": this.attackData,
|
||||
"attacker": INVALID_ENTITY,
|
||||
@ -157,7 +156,7 @@ class testHandleAttackEffects {
|
||||
});
|
||||
let spy = new Spy(cmpStatusEffectsReceiver, "ApplyStatus");
|
||||
|
||||
Attacking.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
AttackHelper.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
"type": "Test",
|
||||
"attackData": this.attackData,
|
||||
"attacker": INVALID_ENTITY,
|
||||
@ -183,7 +182,7 @@ class testHandleAttackEffects {
|
||||
},
|
||||
});
|
||||
|
||||
Attacking.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
AttackHelper.HandleAttackEffects(this.TESTED_ENTITY_ID, {
|
||||
"type": "Test",
|
||||
"attackData": this.attackData,
|
||||
"attacker": INVALID_ENTITY,
|
Loading…
Reference in New Issue
Block a user