Commit 145efbf2 authored by Clement Brizard's avatar Clement Brizard
Browse files

feat: ComponentDamage getters and setters + mutate function

parent 9360f99d
...@@ -8,11 +8,40 @@ class ComponentDamage { ...@@ -8,11 +8,40 @@ class ComponentDamage {
* @param {Number} climateChange - The damage value on Climate Change. * @param {Number} climateChange - The damage value on Climate Change.
* @param {Number} resources - The damage value on Resources. * @param {Number} resources - The damage value on Resources.
*/ */
constructor (humanHealth, ecosystemQuality, climateChange, resources) { constructor ({ humanHealth = 0, ecosystemQuality = 0, climateChange = 0, resources = 0 } = {}) {
this.humanHealth = humanHealth this._humanHealth = humanHealth
this.ecosystemQuality = ecosystemQuality this._ecosystemQuality = ecosystemQuality
this.climateChange = climateChange this._climateChange = climateChange
this.resources = resources this._resources = resources
}
get humanHealth () {
return this._humanHealth
}
get ecosystemQuality () {
return this._ecosystemQuality
}
get climateChange () {
return this._climateChange
}
get resources () {
return this._resources
}
/**
* Apply the given function on the four
* damage values.
* @param {Function} mutation - The function to apply.
*/
mutate (mutation) {
Object.values(this).map(categoryDamage => {
categoryDamage = mutation(categoryDamage)
})
return this
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment