diff options
Diffstat (limited to 'resources/js/classes/StatusEffect.js')
-rw-r--r-- | resources/js/classes/StatusEffect.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/resources/js/classes/StatusEffect.js b/resources/js/classes/StatusEffect.js new file mode 100644 index 0000000..ac6ae54 --- /dev/null +++ b/resources/js/classes/StatusEffect.js @@ -0,0 +1,55 @@ +class StatusEffect { + turnsLeft = 0; + onRemove = null; + + /** + * @type {Monster} + */ + issuer = null; + + constructor (slug) { + this.slug = slug; + + if (['recover', 'lifeleech'].includes(this.slug)) { + this.turnsLeft = 1; + } + else if (['charging'].includes(this.slug)) { + this.turnsLeft = 2; + } + else if (this.category === 'positive') { + this.turnsLeft = Math.ceil(Math.random() * 6) + 4; + } + else if (this.category === 'negative') { + this.turnsLeft = Math.ceil(Math.random() * 3) + 2; + } + else { + this.turnsLeft = Math.ceil(Math.random() * 3) + 2; + } + } + + /** + * @returns {string[]} + */ + get effects () { + return DB.statusEffects[this.slug].effects; + } + + get category () { + return DB.statusEffects[this.slug].category; + } + + get name () { + return slugToName(this.slug); + } + + get stats () { + const stats = {}; + + const statsChangeKeys = Object.keys(DB.statusEffects[this.slug]).filter((key) => key.startsWith('stat')); + for (const statChangeKey of statsChangeKeys) { + stats[statChangeKey.replace('stat', '')] = DB.statusEffects[this.slug][statChangeKey]; + } + + return stats; + } +} |