Remove team bonus when the source player is defeated. Reviewed by wraitii.

Differential Revision: https://code.wildfiregames.com/D12
This was SVN commit r19093.
This commit is contained in:
fatherbushido
2017-01-01 17:23:29 +00:00
parent feb22d7626
commit 6d318d0869
2 changed files with 14 additions and 2 deletions
@@ -86,7 +86,7 @@ Auras.prototype.CalculateAffectedPlayers = function(name)
var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player);
if (!cmpPlayer)
cmpPlayer = QueryOwnerInterface(this.entity);
if (!cmpPlayer)
if (!cmpPlayer || cmpPlayer.GetState() == "defeated")
return;
var numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetNumPlayers();
@@ -426,4 +426,9 @@ Auras.prototype.OnGlobalResearchFinished = function(msg)
}
};
Auras.prototype.OnPlayerDefeated = function(msg)
{
this.Clean();
};
Engine.RegisterComponentType(IID_Auras, "Auras", Auras);
@@ -8,6 +8,7 @@ Engine.LoadComponentScript("AuraManager.js");
let playerID = [0, 1, 2];
let playerEnt = [10, 11, 12];
let playerState = "active";
let giverEnt = 20;
let targetEnt = 30;
let auraRange = 40;
@@ -51,7 +52,8 @@ function testAuras(name, test_function)
AddMock(playerEnt[1], IID_Player, {
"IsAlly": id => id == 1,
"IsEnemy": id => id != 1,
"GetPlayerID": () => playerID[1]
"GetPlayerID": () => playerID[1],
"GetState": () => playerState
});
AddMock(targetEnt, IID_Identity, {
@@ -123,3 +125,8 @@ testAuras("formation", (name, cmpAuras) => {
cmpAuras.RemoveFormationBonus([targetEnt]);
TS_ASSERT_EQUALS(ApplyValueModificationsToEntity("Component/Value", 5, targetEnt), 5);
});
playerState = "defeated";
testAuras("global", (name, cmpAuras) => {
TS_ASSERT_EQUALS(ApplyValueModificationsToTemplate("Component/Value", 5, playerID[1], template), 5);
});