mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-19 23:03:56 -07:00
Patch By: Freagarach Comments By: elexis, Stan`, Nescio Reviewed By: wraitii, Angen Fixes #4370 Differential Revision: https://code.wildfiregames.com/D1846 This was SVN commit r22970.
68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
Resources = {
|
|
"GetCodes": () => ["food", "metal", "stone", "wood"],
|
|
"GetTradableCodes": () => ["food", "metal", "stone", "wood"],
|
|
"GetBarterableCodes": () => ["food", "metal", "stone", "wood"],
|
|
"GetResource": () => ({}),
|
|
"BuildSchema": (type) => {
|
|
let schema = "";
|
|
for (let res of Resources.GetCodes())
|
|
schema +=
|
|
"<optional>" +
|
|
"<element name='" + res + "'>" +
|
|
"<ref name='" + type + "'/>" +
|
|
"</element>" +
|
|
"</optional>";
|
|
return "<interleave>" + schema + "</interleave>";
|
|
}
|
|
};
|
|
|
|
Engine.LoadHelperScript("ValueModification.js");
|
|
Engine.LoadComponentScript("interfaces/Player.js");
|
|
Engine.LoadComponentScript("interfaces/ModifiersManager.js");
|
|
Engine.LoadComponentScript("Player.js");
|
|
|
|
var cmpPlayer = ConstructComponent(10, "Player", {
|
|
"SpyCostMultiplier": 1,
|
|
"BarterMultiplier": {
|
|
"Buy": {
|
|
"wood": 1.0,
|
|
"stone": 1.0,
|
|
"metal": 1.0
|
|
},
|
|
"Sell": {
|
|
"wood": 1.0,
|
|
"stone": 1.0,
|
|
"metal": 1.0
|
|
}
|
|
},
|
|
});
|
|
|
|
TS_ASSERT_EQUALS(cmpPlayer.GetPopulationCount(), 0);
|
|
TS_ASSERT_EQUALS(cmpPlayer.GetPopulationLimit(), 0);
|
|
|
|
cmpPlayer.SetDiplomacy([-1, 1, 0, 1, -1]);
|
|
TS_ASSERT_UNEVAL_EQUALS(cmpPlayer.GetAllies(), [1, 3]);
|
|
TS_ASSERT_UNEVAL_EQUALS(cmpPlayer.GetEnemies(), [0, 4]);
|
|
|
|
var diplo = cmpPlayer.GetDiplomacy();
|
|
diplo[0] = 1;
|
|
TS_ASSERT(cmpPlayer.IsEnemy(0));
|
|
|
|
diplo = [1, 1, 0];
|
|
cmpPlayer.SetDiplomacy(diplo);
|
|
diplo[1] = -1;
|
|
TS_ASSERT(cmpPlayer.IsAlly(1));
|
|
|
|
TS_ASSERT_EQUALS(cmpPlayer.GetSpyCostMultiplier(), 1);
|
|
TS_ASSERT_UNEVAL_EQUALS(cmpPlayer.GetBarterMultiplier(), {
|
|
"buy": {
|
|
"wood": 1.0,
|
|
"stone": 1.0,
|
|
"metal": 1.0
|
|
},
|
|
"sell": {
|
|
"wood": 1.0,
|
|
"stone": 1.0,
|
|
"metal": 1.0
|
|
}
|
|
});
|