Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/globalscripts/AttackEffects.js
Show All 18 Lines | for (let filename of Engine.ListDirectoryFiles("simulation/data/attack_effects", "*.json", false)) | ||||
error("Encountered two effect types with the code " + data.name + "."); | error("Encountered two effect types with the code " + data.name + "."); | ||||
continue; | continue; | ||||
} | } | ||||
effectsDataObj[data.code] = data; | effectsDataObj[data.code] = data; | ||||
this.effectReceivers.push({ | this.effectReceivers.push({ | ||||
"type": data.code, | "type": data.code, | ||||
"cmp": data.cmp, | |||||
"IID": data.IID, | "IID": data.IID, | ||||
"method": data.method | "method": data.method, | ||||
"getRelativeEffectMethod": data.getRelativeEffectMethod | |||||
}); | }); | ||||
} | } | ||||
let effDataSort = (a, b) => a.order < b.order ? -1 : a.order > b.order ? 1 : 0; | let effDataSort = (a, b) => a.order < b.order ? -1 : a.order > b.order ? 1 : 0; | ||||
let effSort = (a, b) => effDataSort( | let effSort = (a, b) => effDataSort( | ||||
effectsDataObj[a.type], | effectsDataObj[a.type], | ||||
effectsDataObj[b.type] | effectsDataObj[b.type] | ||||
); | ); | ||||
this.effectReceivers.sort(effSort); | this.effectReceivers.sort(effSort); | ||||
this.effectCodes = this.effectReceivers.map(receiver => receiver.type); | |||||
deepfreeze(this.effectReceivers); | deepfreeze(this.effectReceivers); | ||||
deepfreeze(this.effectCodes); | |||||
} | } | ||||
/** | /** | ||||
* @return {Object[]} - The effects possible with their data. | * @return {Object[]} - The effects possible with their data. | ||||
*/ | */ | ||||
Receivers() | Receivers() | ||||
{ | { | ||||
return this.effectReceivers; | return this.effectReceivers; | ||||
} | } | ||||
/** | |||||
* @return {string[]} - List of the possible effect codes. | |||||
*/ | |||||
Codes() | |||||
{ | |||||
return this.effectCodes; | |||||
} | |||||
/** | |||||
* @return {Object} - Get the data from the given effect data. | |||||
*/ | |||||
GetReceiverFromCode(type) | |||||
{ | |||||
return this.effectReceivers.find(receiver => receiver.type == type); | |||||
} | |||||
} | } |
Wildfire Games · Phabricator