forked from AlphaKretin/carby-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
monster.ts
241 lines (229 loc) · 7 KB
/
monster.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
interface IRawMonster {
name: string;
rpge_name: string;
level: number;
exp: number;
hp: number;
gil: number;
mp: number;
speed: number;
atk: number;
mag_power: number;
atk_m: number;
mag_m: number;
evade: number;
mag_evade: number;
def: number;
mag_def: number;
elem_immunity: string[];
status_immunity: string[];
elem_absorb: string[];
auto_hit: string[];
weakness: string[];
creature_type: string[];
immunity: string[];
init_status: string[];
specialty: ISpecialty;
spells: string[];
control: string[];
blue: string[];
catch: string;
drop: IDrop;
steal: IDrop;
ai: string[];
}
interface ISpecialty {
name: string;
effects: string[];
}
interface IDrop {
always: string;
rare: string;
}
export class Monster {
private static negativeStatus = [
"Darkness",
"Poison",
"Mini",
"Toad",
"Stone",
"Dead",
"Mute",
"Berserk",
"Charm",
"Paralyze",
"Sleep",
"Aging",
"Slow",
"Stop"
];
public name: string;
public rpgeName: string;
public level: number;
public exp: number;
public hp: number;
public gil: number;
public mp: number;
public speed: number;
public atk: number;
public magPower: number;
public atkM: number;
public magM: number;
public evade: number;
public magEvade: number;
public def: number;
public magDef: number;
public elemImmunity: string[];
public statusImmunity: string[];
public elemAbsorb: string[];
public autoHit: string[];
public weakness: string[];
public creatureType: string[];
public immunity: string[];
public initStatus: string[];
public specialty: ISpecialty;
public spells: string[];
public control: string[];
public blue: string[];
public catch: string;
public drop: IDrop;
public steal: IDrop;
private rawAi: string[];
constructor(raw: IRawMonster) {
this.name = raw.name;
this.rpgeName = raw.rpge_name;
this.level = raw.level;
this.exp = raw.exp;
this.hp = raw.hp;
this.gil = raw.gil;
this.mp = raw.mp;
this.speed = raw.speed;
this.atk = raw.atk;
this.magPower = raw.mag_power;
this.atkM = raw.atk_m;
this.magM = raw.mag_m;
this.evade = raw.evade;
this.magEvade = raw.mag_evade;
this.def = raw.def;
this.magDef = raw.mag_def;
this.elemImmunity = raw.elem_immunity;
this.statusImmunity = raw.status_immunity;
this.elemAbsorb = raw.elem_absorb;
this.autoHit = raw.auto_hit;
this.weakness = raw.weakness;
this.creatureType = raw.creature_type;
this.immunity = raw.immunity;
this.initStatus = raw.init_status;
this.specialty = raw.specialty;
this.spells = raw.spells;
this.control = raw.control;
this.blue = raw.blue;
this.catch = raw.catch;
this.drop = raw.drop;
this.steal = raw.steal;
this.rawAi = raw.ai;
}
private get statusWeakness(): string[] {
return Monster.negativeStatus.filter(s => !this.statusImmunity.includes(s));
}
private nameString(): string {
let out: string;
out = "__**" + this.name;
if (this.rpgeName !== this.name) {
out += " (" + this.rpgeName + ")";
}
out += "**__";
return out;
}
private statsProfile(): string {
let out = "**Level**: " + this.level + " **EXP**: " + this.exp + " **Gil**: " + this.gil + "\n";
out += "**HP**: " + this.hp + " **MP**: " + this.mp + " **Speed**: " + this.speed + "\n";
out += `**Attack**: ${this.atk} (${this.atkM} M) **Magic Power**: ${this.magPower} (${this.magM} M)\n`;
out += `**Defense**: ${this.def} (${this.evade} Evade) **Magic Defense**: ${this.magDef} (${
this.magEvade
} Evade)`;
return out;
}
private weakProfile(): string | undefined {
const out: string[] = [];
if (this.elemAbsorb.length > 0) {
out.push("**Elemental Absorptions**: " + this.elemAbsorb.join(", "));
}
if (this.elemImmunity.length > 0) {
out.push("**Elemental Immunities**: " + this.elemImmunity.join(", "));
}
if (this.weakness.length > 0) {
out.push("**Elemental Weaknesses**: " + this.weakness.join(", "));
}
if (this.statusImmunity.length > 0) {
out.push("**Status Immunities**: " + this.statusImmunity.join(", "));
}
if (this.statusWeakness.length > 0) {
out.push("**Status Vulnerabilities**: " + this.statusWeakness.join(", "));
}
if (this.initStatus.length > 0) {
out.push("**Initial Status**: " + this.initStatus.join(", "));
}
if (this.immunity.length > 0) {
out.push("**Misc. Immunities**: " + this.immunity.join(", "));
}
if (this.creatureType.length > 0) {
out.push("**Creature Types**: " + this.creatureType.join(", "));
}
if (this.autoHit.length > 0) {
out.push("**Auto-Hit Types**: " + this.autoHit.join(", "));
}
if (out.length > 0) {
return out.join("\n");
}
}
private abilityProfile(): string {
let out = "**Specialty**: " + this.specialty.name;
if (this.specialty.effects.length > 0) {
out += " (" + this.specialty.effects.join(", ") + ")";
}
out += "\n**Catch**: " + this.catch + " **Control**: " + this.control.join(", ");
const extras: string[] = [];
if (this.spells.length > 0) {
extras.push("**Spells**: " + this.spells.join(", "));
}
if (this.blue.length > 0) {
extras.push("**Blue Magic**: " + this.blue.join(", "));
}
if (extras.length > 0) {
out += "\n" + extras.join("\n");
}
return out;
}
private lootProfile(): string {
return `**Drop**: ${this.drop.always} / ${this.drop.rare} (Rare) **Steal**: ${this.steal.always} / ${
this.steal.rare
} (Rare)`;
}
get profile(): string {
let out: string = this.nameString();
out += "\n" + this.statsProfile();
const weak = this.weakProfile();
if (weak) {
out += "\n" + weak;
}
out += "\n" + this.abilityProfile();
out += "\n" + this.lootProfile();
return out;
}
get stats(): string {
return this.nameString() + "\n" + this.statsProfile();
}
get weak(): string {
return this.nameString() + "\n" + this.weakProfile();
}
get ability(): string {
return this.nameString() + "\n" + this.abilityProfile();
}
get loot(): string {
return this.nameString() + "\n" + this.lootProfile();
}
get ai(): string {
return this.nameString() + "\n```css\n" + this.rawAi.join("\n") + "```";
}
}