summaryrefslogtreecommitdiff
path: root/resources/js/classes/utility/TechniqueEffect.js
blob: 10e9399c9d8d8956c2de0377932e665c5644fd69 (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
class TechniqueEffect {
  /**
   * @type {string}
   */
  type = '';

  /**
   * @type {(('user' | 'target')|Monster)}
   */
  recipient = null;

  /**
   * @type {('give' | 'remove')}
   */
  application = '';

  /**
   * @type {StatusEffectType}
   */
  statusEffect = null;

  /**
   * @type {Monster}
   */
  user = null;

  /**
   * @type {Monster}
   */
  target = null;

  /**
   * @param {string} effectCode
   */
  constructor (effectCode) {
    if (effectCode.includes('status_')) {
      this.type = 'status';

      this.recipient = effectCode.split(',')[1];
      this.application = effectCode.split(' ')[0];
      this.statusEffect = effectCode.split(',')[0].split(' ')[1].split('_')[1];
    }

    else if (effectCode.includes('healing')) {
      this.type = 'healing';

      this.recipient = effectCode.split(' ')[1];
    }

    else {
      this.type = effectCode;
    }
  }

  /**
   * @type {Monster}
   */
  setUser (user) {
    if (this.recipient === 'user') {
      this.recipient = user;
    }
  }

  /**
   * @type {Monster}
   */
  setTarget (target) {
    if (this.recipient === 'target') {
      this.recipient = target;
    }
  }
}