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

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

  /**
   * @type {Monster[]}
   */
  recipients = [];

  /**
   * @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 (['user', 'both'].includes(this.recipient)) {
      this.recipients.push(user);
    }
  }

  /**
   * @type {Monster}
   */
  setTarget (target) {
    if (['target', 'both'].includes(this.recipient)) {
      this.recipients.push(target);
    }
  }
}