Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/globalscripts/Technologies.js
Show All 38 Lines | function GetTechModifiedProperty(currentTechModifications, classes, propertyName, propertyValue) | ||||
// Note, some components pass non-numeric values (for which only the "replace" modification makes sense) | // Note, some components pass non-numeric values (for which only the "replace" modification makes sense) | ||||
if (typeof propertyValue == "number") | if (typeof propertyValue == "number") | ||||
return propertyValue * multiply + add; | return propertyValue * multiply + add; | ||||
return propertyValue; | return propertyValue; | ||||
} | } | ||||
/** | /** | ||||
* Derives modifications (to be applied to entities) from a given technology. | |||||
bb: . | |||||
* | |||||
* @param {Object} techTemplate - The technology template to derive the modifications from. | |||||
* @return {Object} containing the relevant modifications. | |||||
Done Inline ActionsImproper JsDocs, should be @param {Object} techTemplate The technology template to derive the modifications from. and @return {Object} containing the relevant modifications.. bb: Improper JsDocs, should be `@param {Object} techTemplate The technology template to derive the… | |||||
*/ | |||||
function DeriveModificationsFromTech(techTemplate) | |||||
{ | |||||
if (!techTemplate.modifications) | |||||
return {}; | |||||
let techMods = {}; | |||||
let techAffects = []; | |||||
if (techTemplate.affects && techTemplate.affects.length) | |||||
for (let affected of techTemplate.affects) | |||||
techAffects.push(affected.split(/\s+/)); | |||||
else | |||||
techAffects.push([]); | |||||
for (let mod of techTemplate.modifications) | |||||
{ | |||||
let affects = techAffects.slice(); | |||||
if (mod.affects) | |||||
{ | |||||
let specAffects = mod.affects.split(/\s+/); | |||||
for (let a in affects) | |||||
affects[a] = affects[a].concat(specAffects); | |||||
} | |||||
let newModifier = { "affects": affects }; | |||||
for (let idx in mod) | |||||
if (idx !== "value" && idx !== "affects") | |||||
Done Inline ActionsDoesn't need overline split but OK. bb: Doesn't need overline split but OK. | |||||
newModifier[idx] = mod[idx]; | |||||
Not Done Inline ActionsNewline bb: Newline | |||||
if (!techMods[mod.value]) | |||||
techMods[mod.value] = []; | |||||
techMods[mod.value].push(newModifier); | |||||
} | |||||
return techMods; | |||||
} | |||||
/** | |||||
* Returns whether the given modification applies to the entity containing the given class list | * Returns whether the given modification applies to the entity containing the given class list | ||||
*/ | */ | ||||
function DoesModificationApply(modification, classes) | function DoesModificationApply(modification, classes) | ||||
{ | { | ||||
return MatchesClassList(classes, modification.affects); | return MatchesClassList(classes, modification.affects); | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 233 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
.