/
Ability.ts
197 lines (188 loc) · 4.93 KB
/
Ability.ts
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import {elements} from "./utils";
export enum ability_types {
HEALING = "healing",
EFFECT_ONLY = "effect_only",
ADDED_DAMAGE = "added_damage",
MULTIPLIER = "multiplier",
BASE_DAMAGE = "base_damage",
SUMMON = "summon",
UTILITY = "utility",
DIRECT_DAMAGE = "direct_damage",
}
export enum ability_msg_types {
CAST = "cast",
ATTACK = "attack",
USE = "use",
SUMMON = "summon",
UNLEASH = "unleash",
DEFEND = "defend",
ITEM_UNLEASH = "item_unleash",
SET_DJINN = "set_djinn",
NO_MSG = "no_msg",
}
export enum ability_target_types {
NO_TARGET = "no_target",
ALLY = "ally",
ENEMY = "enemy",
USER = "user",
}
export enum ability_categories {
PSYNERGY = "psynergy",
DJINN = "djinn",
SUMMON = "summon",
ITEM = "item",
WEAPON_UNLEASH = "weapon_unleash",
NORMAL = "normal",
SKILL = "skill",
}
export enum ability_ranges {
ONE = 1,
THREE = 3,
FIVE = 5,
SEVEN = 7,
NINE = 9,
ELEVEN = 11,
ALL = "all",
}
export const diminishing_ratios = {
ALL: {
11: 1,
9: 1,
7: 1,
5: 1,
3: 1,
1: 1,
},
STANDARD: {
11: 0.1,
9: 0.2,
7: 0.4,
5: 0.6,
3: 0.8,
1: 1,
},
SUMMON: {
11: 0.1,
9: 0.2,
7: 0.3,
5: 0.4,
3: 0.7,
1: 1,
},
DIMINISH: {
11: 0.1,
9: 0.1,
7: 0.1,
5: 0.3,
3: 0.5,
1: 1,
},
STATUS: {
11: 0.3,
9: 0.3,
7: 0.3,
5: 0.3,
3: 0.6,
1: 1,
},
};
export class Ability {
public key_name: string;
public name: string;
public description: string;
public type: ability_types;
public element: elements;
public battle_target: string;
public range: ability_ranges;
public pp_cost: number;
public ability_power: number;
public effects_outside_battle: boolean;
public is_battle_ability: boolean;
public is_field_psynergy: boolean;
public effects: any;
public ability_category: ability_categories;
public battle_animation_key: string;
public priority_move: boolean;
public has_critical: boolean;
public crit_mult_factor: number;
public can_switch_to_unleash: boolean;
public can_be_evaded: boolean;
public use_diminishing_ratio: boolean;
public msg_type: ability_msg_types;
public affects_pp: boolean;
public has_animation_variation: boolean;
public can_be_mirrored: boolean;
public affects_downed: boolean;
constructor(
key_name,
name,
description,
type,
element,
battle_target,
range,
pp_cost,
ability_power,
effects_outside_battle,
is_battle_ability,
is_field_psynergy,
effects,
ability_category,
battle_animation_key,
priority_move,
has_critical,
crit_mult_factor,
can_switch_to_unleash,
can_be_evaded,
use_diminishing_ratio,
msg_type,
affects_pp,
has_animation_variation,
can_be_mirrored,
affects_downed
) {
this.key_name = key_name;
this.name = name;
this.description = description;
this.type = type;
this.element = element;
this.battle_target = battle_target;
this.range = range;
this.pp_cost = pp_cost;
this.ability_power = ability_power;
this.effects_outside_battle = effects_outside_battle;
this.is_battle_ability = is_battle_ability;
this.is_field_psynergy = is_field_psynergy;
this.effects = effects;
this.ability_category = ability_category;
this.battle_animation_key = battle_animation_key;
this.priority_move = priority_move ?? false;
this.has_critical = has_critical ?? false;
this.crit_mult_factor = crit_mult_factor ?? 1;
this.can_switch_to_unleash = can_switch_to_unleash ?? false;
this.can_be_evaded = can_be_evaded ?? false;
this.use_diminishing_ratio = use_diminishing_ratio ?? false;
this.msg_type = msg_type ?? ability_msg_types.CAST;
this.affects_pp = affects_pp ?? false;
this.has_animation_variation = has_animation_variation ?? false;
this.can_be_mirrored = can_be_mirrored ?? false;
this.affects_downed = affects_downed ?? false;
}
static get_diminishing_ratios(
ability_type: ability_types,
ability_range: ability_ranges,
use_diminishing_ratio: boolean
) {
if (use_diminishing_ratio) {
return diminishing_ratios.DIMINISH;
} else if (ability_range === ability_ranges.ALL) {
return diminishing_ratios.ALL;
}
switch (ability_type) {
case ability_types.SUMMON:
return diminishing_ratios.SUMMON;
default:
return diminishing_ratios.STANDARD;
}
}
}