From cc685bfe02b42b592987117fa008a4461785f53c Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 17 Aug 2023 02:53:14 +0200 Subject: refactor --- resources/js/classes/Technique.js | 77 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 resources/js/classes/Technique.js (limited to 'resources/js/classes/Technique.js') diff --git a/resources/js/classes/Technique.js b/resources/js/classes/Technique.js new file mode 100644 index 0000000..a24e094 --- /dev/null +++ b/resources/js/classes/Technique.js @@ -0,0 +1,77 @@ +class Technique { + #accuracy = 0; + #potency = 0; + #power = 0; + + constructor (slug) { + this.slug = slug; + + this.resetStats(); + } + + get name () { + return slugToName(this.slug); + } + + get types () { + return DB.techniques[this.slug].types; + } + + get range () { + return DB.techniques[this.slug].range; + } + + get animation () { + return DB.techniques[this.slug].animation; + } + + get sfx () { + return DB.techniques[this.slug].sfx; + } + + /** + * @returns {string[]} + */ + get effects () { + return DB.techniques[this.slug].effects; + } + + get accuracy () { + return this.#accuracy; + } + set accuracy (accuracy) { + this.#accuracy = accuracy; + } + + get potency () { + return this.#potency; + } + set potency (potency) { + this.#potency = potency; + } + + get power () { + return this.#power; + } + set power (power) { + this.#power = power; + } + + get stats () { + const accuracy = DB.techniques[this.slug].accuracy; + const potency = DB.techniques[this.slug].potency; + const power = DB.techniques[this.slug].power; + + return { + accuracy, + potency, + power, + }; + } + + resetStats () { + this.accuracy = this.stats.accuracy; + this.potency = this.stats.potency; + this.power = this.stats.power; + } +} -- cgit v1.2.3