summaryrefslogtreecommitdiff
path: root/resources/js/classes/StatusEffect.js
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-08-17 02:53:14 +0200
committerDaniel Weipert <code@drogueronin.de>2023-08-17 17:42:15 +0200
commitcc685bfe02b42b592987117fa008a4461785f53c (patch)
tree625c1c9573b178e574bb70cac042c35da4036cf1 /resources/js/classes/StatusEffect.js
parent717fde1c48c7221da986ac02d2b806b2fee6f2d5 (diff)
refactorrefactor
Diffstat (limited to 'resources/js/classes/StatusEffect.js')
-rw-r--r--resources/js/classes/StatusEffect.js55
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;
+ }
+}