From 91d048ef0f994446aaee91e3afcbd99788e439d7 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Fri, 18 Aug 2023 23:19:13 +0200 Subject: item effects,conditions --- resources/js/classes/utility/ItemEffect.js | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 resources/js/classes/utility/ItemEffect.js (limited to 'resources/js/classes/utility/ItemEffect.js') diff --git a/resources/js/classes/utility/ItemEffect.js b/resources/js/classes/utility/ItemEffect.js new file mode 100644 index 0000000..aa1c1df --- /dev/null +++ b/resources/js/classes/utility/ItemEffect.js @@ -0,0 +1,51 @@ +class ItemEffect { + /** + * @type {string} + */ + type = ''; + + /** + * @type {('increase')} + */ + application = ''; + + /** + * @type {number} + */ + amount = 0; + + /** + * @param {string} effectCode + */ + constructor (effectCode) { + if (effectCode.startsWith('heal')) { + this.type = 'heal'; + + this.amount = parseInt(effectCode.split(' ')[1]); + } + + else if (effectCode.startsWith('revive')) { + this.type = 'revive'; + + this.amount = effectCode.split(' ')[1]; + } + + else if (effectCode.startsWith('learn_')) { + this.type = effectCode.split(' ')[0]; + + this.what = effectCode.split(' ')[1]; + } + + else if (Object.values(StatType).includes(effectCode.split(' ')[1] || '')) { + this.type = 'stat'; + + this.application = effectCode.split(' ')[0]; + this.what = effectCode.split(' ')[1].split(',')[0]; + this.amount = effectCode.split(' ')[1].split(',')[1]; + } + + else { + this.type = effectCode; + } + } +} -- cgit v1.2.3