summaryrefslogtreecommitdiff
path: root/resources/js/classes/Technique.js
blob: 39028be486d8b49c875f022afdeb130bd7270a30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
class Technique {
  #accuracy = 0;
  #potency = 0;
  #power = 0;

  turnLastUse = 0;

  constructor (slug) {
    this.slug = slug;

    this.resetStats();

    this.turnLastUse = -this.rechargeLength;
  }

  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 rechargeLength () {
    return DB.techniques[this.slug].recharge;
  }

  isRecharging () {
    if (this.turnLastUse >= Game.turn) {
      return false;
    }

    return this.rechargeLength > Game.turn - this.turnLastUse;
  }

  use () {
    this.turnLastUse = Game.turn;
  }

  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;
  }
}