Differential D179 Diff 987 ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Player.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Player.js
Engine.LoadHelperScript("ValueModification.js"); | Engine.LoadHelperScript("ValueModification.js"); | ||||
Engine.LoadComponentScript("interfaces/Player.js"); | Engine.LoadComponentScript("interfaces/Player.js"); | ||||
Engine.LoadComponentScript("interfaces/TechnologyManager.js"); | Engine.LoadComponentScript("interfaces/TechnologyManager.js"); | ||||
Engine.LoadComponentScript("Player.js"); | Engine.LoadComponentScript("Player.js"); | ||||
Resources = { | Resources = { | ||||
"GetCodes": () => ["food", "metal", "stone", "wood"], | "GetCodes": () => ["food", "metal", "stone", "wood"], | ||||
"GetResource": () => ({}), | "GetResource": () => ({}), | ||||
}; | }; | ||||
var cmpPlayer = ConstructComponent(10, "Player"); | var cmpPlayer = ConstructComponent(10, "Player", { | ||||
"SpyCostMultiplier": 1 | |||||
}); | |||||
TS_ASSERT_EQUALS(cmpPlayer.GetPopulationCount(), 0); | TS_ASSERT_EQUALS(cmpPlayer.GetPopulationCount(), 0); | ||||
TS_ASSERT_EQUALS(cmpPlayer.GetPopulationLimit(), 0); | TS_ASSERT_EQUALS(cmpPlayer.GetPopulationLimit(), 0); | ||||
cmpPlayer.SetDiplomacy([-1, 1, 0, 1, -1]); | cmpPlayer.SetDiplomacy([-1, 1, 0, 1, -1]); | ||||
TS_ASSERT_UNEVAL_EQUALS(cmpPlayer.GetAllies(), [1, 3]); | TS_ASSERT_UNEVAL_EQUALS(cmpPlayer.GetAllies(), [1, 3]); | ||||
TS_ASSERT_UNEVAL_EQUALS(cmpPlayer.GetEnemies(), [0, 4]); | TS_ASSERT_UNEVAL_EQUALS(cmpPlayer.GetEnemies(), [0, 4]); | ||||
var diplo = cmpPlayer.GetDiplomacy(); | var diplo = cmpPlayer.GetDiplomacy(); | ||||
diplo[0] = 1; | diplo[0] = 1; | ||||
TS_ASSERT(cmpPlayer.IsEnemy(0)); | TS_ASSERT(cmpPlayer.IsEnemy(0)); | ||||
diplo = [1, 1, 0]; | diplo = [1, 1, 0]; | ||||
cmpPlayer.SetDiplomacy(diplo); | cmpPlayer.SetDiplomacy(diplo); | ||||
diplo[1] = -1; | diplo[1] = -1; | ||||
TS_ASSERT(cmpPlayer.IsAlly(1)); | TS_ASSERT(cmpPlayer.IsAlly(1)); | ||||
TS_ASSERT_EQUALS(cmpPlayer.GetSpyCostMultiplier(), 1); |
Wildfire Games · Phabricator