Changeset View
Standalone View
binaries/data/mods/public/simulation/helpers/Attacking.js
/** | /** | ||||
* Provides attack and damage-related helpers under the Attacking umbrella (to avoid name ambiguity with the component). | * Provides attack and damage-related helpers under the Attacking umbrella (to avoid name ambiguity with the component). | ||||
*/ | */ | ||||
function Attacking() {} | function Attacking() {} | ||||
const DirectEffectsSchema = | const DirectEffectsSchema = | ||||
"<element name='Damage'>" + | "<element name='Damage'>" + | ||||
"<oneOrMore>" + | "<oneOrMore>" + | ||||
"<element a:help='One or more elements describing damage types'>" + | "<element a:help='One or more elements describing damage types'>" + | ||||
Nescio: For comparison.
(Also full stop is missing.) | |||||
"<anyName>" + | "<anyName>" + | ||||
// Armour requires Foundation to not be a damage type. | // Armour requires Foundation to not be a damage type. | ||||
"<except><name>Foundation</name></except>" + | "<except><name>Foundation</name></except>" + | ||||
"</anyName>" + | "</anyName>" + | ||||
"<ref name='nonNegativeDecimal' />" + | "<ref name='nonNegativeDecimal' />" + | ||||
"</element>" + | "</element>" + | ||||
"</oneOrMore>" + | "</oneOrMore>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='Capture' a:help='Capture points value'>" + | "<element name='Capture' a:help='Capture points value'>" + | ||||
"<ref name='nonNegativeDecimal'/>" + | "<ref name='nonNegativeDecimal'/>" + | ||||
"</element>"; | "</element>"; | ||||
const StatusEffectsSchema = | const StatusEffectsSchema = | ||||
"<element name='ApplyStatus' a:help='Effects like poisoning or burning a unit.'>" + | "<element name='ApplyStatus' a:help='Effects like poisoning or burning a unit.'>" + | ||||
"<oneOrMore>" + | "<oneOrMore>" + | ||||
"<element>" + | "<element>" + | ||||
"<anyName/>" + | "<anyName/>" + | ||||
"<interleave>" + | "<interleave>" + | ||||
"<element name='Name'><text/></element>" + | "<element name='Name'><text/></element>" + | ||||
"<element name='Stackability' a:help='Defines how this status effect stacks, i.e. how subsequent status effects of the same kind are handled. Choices are: “Ignore”, which means a new one is ignored, “Extend”, which means the duration of a new one is added to the already active status effect, “Replace”, which means the currently active status effect is removed and the new one is put in place and “Stack”, which means that the status effect can be added multiple times.'>" + | |||||
Done Inline ActionsDefines how this status ..., currently it starts like question :) @Nescio thoughts ? Silier: Defines how this status ..., currently it starts like question :)
\"Ignore\" means, that… | |||||
Done Inline ActionsAuras can be stackable too; how is it done there? Nescio: Auras can be stackable too; how is it done there?
Also, you can use proper opening and closing… | |||||
Done Inline Actionsthats defined in json so not documented in component or elsewhere Silier: thats defined in json so not documented in component or elsewhere | |||||
Done Inline ActionsIs this string something that shows up in game and is translated? Nescio: Is this string something that shows up in game and is translated? | |||||
Done Inline Actionsno, this is just for dev documentation, maybe some ide would show that, dont know Silier: no, this is just for dev documentation, maybe some ide would show that, dont know | |||||
Done Inline ActionsThen the exact formulation isn't terribly important. For comparison, simulation/components/Market.js has line 4: "<element name='TradeType' a:help='Specifies the type of possible trade route (land or naval).'>" + Is there a default choice? Is this element optional? Nescio: Then the exact formulation isn't terribly important. For comparison… | |||||
Done Inline ActionsTrue/False is not really an options, since there are four, mutually exclusive, choices. Freagarach: True/False is not really an options, since there are four, mutually exclusive, choices. | |||||
"<choice>" + | |||||
"<value>Ignore</value>" + | |||||
"<value>Extend</value>" + | |||||
"<value>Replace</value>" + | |||||
"<value>Stack</value>" + | |||||
"</choice>" + | |||||
"</element>" + | |||||
"<optional>" + | "<optional>" + | ||||
"<element name='Icon' a:help='Icon for the status effect.'><text/></element>" + | "<element name='Icon' a:help='Icon for the status effect.'><text/></element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='Tooltip'><text/></element>" + | "<element name='Tooltip'><text/></element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='Duration' a:help='The duration of the status while the effect occurs.'><ref name='nonNegativeDecimal'/></element>" + | "<element name='Duration' a:help='The duration of the status while the effect occurs.'><ref name='nonNegativeDecimal'/></element>" + | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | let applyMods = damageType => | ||||
ApplyValueModificationsToEntity(valueModifRoot + "/Damage/" + damageType, +(template.Damage[damageType] || 0), entity); | ApplyValueModificationsToEntity(valueModifRoot + "/Damage/" + damageType, +(template.Damage[damageType] || 0), entity); | ||||
for (let damageType in template.Damage) | for (let damageType in template.Damage) | ||||
ret.Damage[damageType] = applyMods(damageType); | ret.Damage[damageType] = applyMods(damageType); | ||||
} | } | ||||
if (template.Capture) | if (template.Capture) | ||||
ret.Capture = ApplyValueModificationsToEntity(valueModifRoot + "/Capture", +(template.Capture || 0), entity); | ret.Capture = ApplyValueModificationsToEntity(valueModifRoot + "/Capture", +(template.Capture || 0), entity); | ||||
if (template.ApplyStatus) | if (template.ApplyStatus) | ||||
ret.ApplyStatus = template.ApplyStatus; | { | ||||
ret.ApplyStatus = {}; | |||||
for (let effect in template.ApplyStatus) | |||||
{ | |||||
let statusTemplate = template.ApplyStatus[effect]; | |||||
ret.ApplyStatus[effect] = { | |||||
"Name": statusTemplate.Name, | |||||
"Tooltip": statusTemplate.Tooltip, | |||||
"Duration": ApplyValueModificationsToEntity(valueModifRoot + "/ApplyStatus/" + effect + "/Duration", +(statusTemplate.Duration || 0), entity), | |||||
"Interval": ApplyValueModificationsToEntity(valueModifRoot + "/ApplyStatus/" + effect + "/Interval", +(statusTemplate.Interval || 0), entity), | |||||
Done Inline Actions1000 looks here like random number, StatusEffectReceiver has DefaultInterval property, that one should be used else this need to be kept in sync with it what is not good also, does this mean that Interval will always exist ? making // With neither an interval nor a duration, there is no point in starting a timer. if (!status.Duration && !status.Interval) return; and // We want an interval to update the GUI to show how much time of the status effect // is left even if the status effect itself has no interval. if (!status.Interval) status._interval = this.DefaultInterval; useless ? Silier: 1000 looks here like random number, StatusEffectReceiver has DefaultInterval property, that one… | |||||
"Stackability": statusTemplate.Stackability | |||||
}; | |||||
Object.assign(ret.ApplyStatus[effect], this.GetAttackEffectsData(valueModifRoot + "/ApplyStatus" + effect, statusTemplate, entity)); | |||||
if (statusTemplate.Modifiers) | |||||
{ | |||||
let modifiers = {}; | |||||
for (let modifier in statusTemplate.Modifiers) | |||||
Done Inline Actionslet someVariable = template.ApplyStatus[effect].Modifiers[modifier] and use it in next lines so it become a bit cleaner or try to for of Silier: let someVariable = template.ApplyStatus[effect].Modifiers[modifier] and use it in next lines so… | |||||
{ | |||||
let modifierTemplate = statusTemplate.Modifiers[modifier]; | |||||
modifiers[modifier] = { | |||||
"Paths": modifierTemplate.Paths, | |||||
"Affects": modifierTemplate.Affects | |||||
}; | |||||
if (modifierTemplate.Add !== undefined) | |||||
Done Inline Actionswhat if Add == 0 and author wants to increase it later with techs ? Silier: what if Add == 0 and author wants to increase it later with techs ? | |||||
modifiers[modifier].Add = ApplyValueModificationsToEntity(valueModifRoot + "/ApplyStatus/" + effect + "/Modifiers/" + modifier + "/Add", +modifierTemplate.Add, entity); | |||||
Done Inline Actions|| 0 is not needed because if check above, so if here, that do exist Silier: `|| 0` is not needed because if check above, so if here, that do exist | |||||
Done Inline Actionscorrectly should be 1 to make it mathematicly neutral Silier: correctly should be 1 to make it mathematicly neutral | |||||
if (modifierTemplate.Multiply !== undefined) | |||||
modifiers[modifier].Multiply = ApplyValueModificationsToEntity(valueModifRoot + "/ApplyStatus/" + effect + "/Modifiers/" + modifier + "/Multiply", +modifierTemplate.Multiply, entity); | |||||
Done Inline Actionssame Silier: same | |||||
if (modifierTemplate.Replace !== undefined) | |||||
modifiers[modifier].Replace = modifierTemplate.Replace; | |||||
} | |||||
ret.ApplyStatus[effect].Modifiers = modifiers; | |||||
wraitiiUnsubmitted Done Inline ActionsThat modifier-only bit seems like it should be moved elsewhere wraitii: That modifier-only bit seems like it should be moved elsewhere | |||||
} | |||||
} | |||||
} | |||||
if (template.Bonuses) | if (template.Bonuses) | ||||
ret.Bonuses = template.Bonuses; | ret.Bonuses = template.Bonuses; | ||||
return ret; | return ret; | ||||
}; | }; | ||||
Attacking.prototype.GetTotalAttackEffects = function(effectData, effectType, cmpResistance) | Attacking.prototype.GetTotalAttackEffects = function(effectData, effectType, cmpResistance) | ||||
▲ Show 20 Lines • Show All 235 Lines • Show Last 20 Lines |
For comparison.
(Also full stop is missing.)