Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/AIInterface.js
Show First 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | for (let valName of msg.valueNames) | ||||
if (item !== undefined && item[str] !== undefined) | if (item !== undefined && item[str] !== undefined) | ||||
item = item[str]; | item = item[str]; | ||||
else | else | ||||
ended = false; | ended = false; | ||||
} | } | ||||
if (!ended) | if (!ended) | ||||
continue; | continue; | ||||
// item now contains the template value for this. | // item now contains the template value for this. | ||||
let oldValue = +item; | let oldValue = +item == item ? +item : item; | ||||
Stan: Is that necessary ? | |||||
Done Inline ActionsAs I recall it was. There'd probably be other ways to do this cleanly. wraitii: As I recall it was. There'd probably be other ways to do this cleanly. | |||||
Not Done Inline Actionstypeof number maybe? dunno Stan: typeof number maybe? dunno | |||||
Done Inline Actionswouldn't work, since if it was a number we wouldn't need to '+' it. wraitii: wouldn't work, since if it was a number we wouldn't need to '+' it. | |||||
let newValue = ApplyValueModificationsToTemplate(valName, oldValue, msg.player, template); | let newValue = ApplyValueModificationsToTemplate(valName, oldValue, msg.player, template); | ||||
// Apply the same roundings as in the components | // Apply the same roundings as in the components | ||||
if (valName === "Player/MaxPopulation" || valName === "Cost/Population" || | if (valName === "Player/MaxPopulation" || valName === "Cost/Population" || | ||||
valName === "Cost/PopulationBonus") | valName === "Cost/PopulationBonus") | ||||
newValue = Math.round(newValue); | newValue = Math.round(newValue); | ||||
// TODO in some cases, we can have two opposite changes which bring us to the old value, | // TODO in some cases, we can have two opposite changes which bring us to the old value, | ||||
// and we should keep it. But how to distinguish it ? | // and we should keep it. But how to distinguish it ? | ||||
if(newValue == oldValue) | if(newValue == oldValue) | ||||
Show All 31 Lines | for (let valName of msg.valueNames) | ||||
if (item !== undefined && item[str] !== undefined) | if (item !== undefined && item[str] !== undefined) | ||||
item = item[str]; | item = item[str]; | ||||
else | else | ||||
ended = false; | ended = false; | ||||
} | } | ||||
if (!ended) | if (!ended) | ||||
continue; | continue; | ||||
// "item" now contains the unmodified template value for this. | // "item" now contains the unmodified template value for this. | ||||
let oldValue = +item; | let oldValue = +item == item ? +item : item; | ||||
let newValue = ApplyValueModificationsToEntity(valName, oldValue, ent); | let newValue = ApplyValueModificationsToEntity(valName, oldValue, ent); | ||||
// Apply the same roundings as in the components | // Apply the same roundings as in the components | ||||
if (valName === "Player/MaxPopulation" || valName === "Cost/Population" || | if (valName === "Player/MaxPopulation" || valName === "Cost/Population" || | ||||
valName === "Cost/PopulationBonus") | valName === "Cost/PopulationBonus") | ||||
newValue = Math.round(newValue); | newValue = Math.round(newValue); | ||||
// TODO in some cases, we can have two opposite changes which bring us to the old value, | // TODO in some cases, we can have two opposite changes which bring us to the old value, | ||||
// and we should keep it. But how to distinguish it ? | // and we should keep it. But how to distinguish it ? | ||||
if (newValue == oldValue) | if (newValue == oldValue) | ||||
Show All 10 Lines |
Wildfire Games · Phabricator
Is that necessary ?