-
Notifications
You must be signed in to change notification settings - Fork 134
/
FusionTest.ts
298 lines (247 loc) · 12.9 KB
/
FusionTest.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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
///<reference path="../data/Data5.ts"/>
///<reference path="../src/DataUtil.ts"/>
///<reference path="../src/FusionCalculator.ts"/>
///<reference path="../data/PersonaData.ts"/>
///<reference path="d.ts/mocha.d.ts"/>
///<reference path="d.ts/expect.js.d.ts"/>
const fullPersonaeByArcana : {[arcana: string]: PersonaData[]} = (() =>{
let personaeByArcana_ = {};
for (let i = 0; i < fullPersonaList.length; i++) {
let persona = fullPersonaList[i];
if (!personaeByArcana_[persona.arcana]) {
personaeByArcana_[persona.arcana] = [];
}
personaeByArcana_[persona.arcana].push(persona);
}
for (let key in personaeByArcana_) {
personaeByArcana_[key].sort((a,b) => a.level - b.level);
}
return personaeByArcana_;
})();
let calc = new FusionCalculator(fullPersonaeByArcana);
function fuseTestWrapper(persona1Name: string, persona2Name: string): PersonaData {
return calc.fuse(personaMap[persona1Name], personaMap[persona2Name]);
}
function containAll(recipe: Recipe, personaNames: string[]): boolean {
return personaNames.map(a => personaMap[a])
.every(val => recipe.sources.indexOf(val) !== -1);
}
describe('FusionCalculator', () => {
describe('#fuse()', () => {
describe('same arcana fusion', () => {
it('should return null when fusing 2 lowest rank persona', () => {
expect(fuseTestWrapper("Obariyon", "Arsene")).to.equal(null);
});
it('should return correct persona when fusing 2 highest rank persona', () => {
expect(fuseTestWrapper("Beelzebub", "Belial")).to.equal(personaMap["Nebiros"]);
});
it('should return correct persona when have to skip special persona below 2 ingredients', () => {
expect(fuseTestWrapper("Ananta", "Kaiwan")).to.equal(personaMap["Fuu-Ki"]);
});
it('should return correct persona when have to skip rare persona below 2 ingredients', () => {
expect(fuseTestWrapper("Moloch", "Hecatoncheires")).to.equal(personaMap["Take-Minakata"]);
});
it('should return correct persona when have to skip rare and special personae below 2 ingredients', () => {
expect(fuseTestWrapper("Dionysus", "Black Frost")).to.equal(personaMap["Ose"]);
});
it('should return correct persona when result level is midway of 2 ingredients, and right on level', () => {
expect(fuseTestWrapper("Shiki-Ouji", "Slime")).to.equal(personaMap["Shiisaa"]);
});
it('should return correct persona when result level is midway of 2 ingredients, and have to go down', () => {
expect(fuseTestWrapper("Shiki-Ouji", "Slime")).to.equal(personaMap["Shiisaa"]);
});
it('should return correct persona when have to skip rare midway and skip ingredient when fusing 2 persona', () => {
expect(fuseTestWrapper("Take-Minakata", "Hecatoncheires")).to.equal(personaMap["Orthrus"]);
});
it('should return null when have to skip special midway, then skip ingredient, and ingredient is lowest in arcana rank', () => {
expect(fuseTestWrapper("Messiah", "Anubis")).to.equal(null);
});
});
describe('different arcana fusion', function () {
it('should return null when result level is higher than the highest level persona in the resulting arcana ' +
'(tower 79 + fool 83 -> empress 81 -> null)', () => {
expect(fuseTestWrapper("Vishnu", "Yoshitsune")).to.equal(null);
});
it('should return correct persona when result is the highest ranked persona in the resulting arcana ' +
'(judgement 92 + hierophant 63 -> empress 80)', () => {
expect(fuseTestWrapper("Satan", "Forneus")).to.equal(personaMap["Mother Harlot"]);
});
it('should return correct persona when fusing 2 persona, one highest rank and one lowest rank ' +
'(star 93 + temperance 7 -> sun 53)', () => {
expect(fuseTestWrapper("Lucifer", "Genbu")).to.equal(personaMap["Ganesha"]);
});
it('should return correct persona when fusing 2 rare persona', () => {
expect(fuseTestWrapper("Crystal Skull", "Regent")).to.equal(personaMap["Mithra"]);
});
});
describe('special fusion', function () {
it('should return Alice when fusing Nebiros and Belial', () => {
expect(fuseTestWrapper("Nebiros", "Belial")).to.equal(personaMap["Alice"]);
});
it('should return Shiva when fusing Rangda and Barong', () => {
expect(fuseTestWrapper("Rangda", "Barong")).to.equal(personaMap["Shiva"]);
});
it('should return Ardha when fusing Parvati and Shiva', () => {
expect(fuseTestWrapper("Parvati", "Shiva")).to.equal(personaMap["Ardha"]);
});
});
describe('rare fusion', function () {
it('should return correct persona when go down one', () => {
expect(fuseTestWrapper("Regent", "Obariyon")).to.equal(personaMap["Arsene"]);
});
it('should return correct persona when go up two', () => {
expect(fuseTestWrapper("Stone of Scone", "Nekomata")).to.equal(personaMap["Choronzon"]);
});
it('should return correct persona when go up one and skip special', () => {
expect(fuseTestWrapper("Orlov", "Fuu-Ki")).to.equal(personaMap["Kaiwan"]);
});
it('should return correct persona when go up one and have special persona as ingredient', () => {
expect(fuseTestWrapper("Orlov", "Neko Shogun")).to.equal(personaMap["Kaiwan"]);
});
});
describe('impossible fusions with Judgement', function () {
it('should return null when fusing Judgement + Death', () => {
expect(fuseTestWrapper("Messiah", "Mandrake")).to.equal(null);
expect(fuseTestWrapper("Trumpeter", "Hell Biker")).to.equal(null);
});
it('should return null when fusing Judgement + Chariot', () => {
expect(fuseTestWrapper("Messiah", "Agathion")).to.equal(null);
});
it('should return null when fusing Judgement + Strength', () => {
expect(fuseTestWrapper("Messiah Picaro", "Kelpie")).to.equal(null);
});
it('should return null when fusing Judgement + Justice', () => {
expect(fuseTestWrapper("Messiah Picaro", "Angel")).to.equal(null);
expect(fuseTestWrapper("Power", "Anubis")).to.equal(null);
});
});
});
describe('#getRecipes()', () => {
describe('special fusions', function () {
it('should return correct recipe for Ardha', () => {
let recipes = calc.getRecipes(personaMap["Ardha"]);
expect(recipes).to.have.length(1);
expect(recipes[0].sources).to.have.length(2);
expect(containAll(recipes[0], ['Parvati', 'Shiva'])).to.be(true);
});
it('should return correct recipe for Alice', () => {
let recipes = calc.getRecipes(personaMap["Alice"]);
expect(recipes).to.have.length(1);
expect(recipes[0].sources).to.have.length(2);
expect(containAll(recipes[0], ['Belial', 'Nebiros'])).to.be(true);
});
it('should return correct recipe for Ongyo-Ki', () => {
let recipes = calc.getRecipes(personaMap["Ongyo-Ki"]);
expect(recipes).to.have.length(1);
expect(recipes[0].sources).to.have.length(3);
expect(containAll(recipes[0], ['Kin-Ki', 'Sui-Ki', 'Fuu-Ki'])).to.be(true);
});
it('should return correct recipe for Kohryu', () => {
let recipes = calc.getRecipes(personaMap["Kohryu"]);
expect(recipes).to.have.length(1);
expect(recipes[0].sources).to.have.length(4);
expect(containAll(recipes[0], ['Genbu', 'Seiryu', 'Suzaku', 'Byakko'])).to.be(true);
});
it('should return correct recipe for Sraosha', () => {
let recipes = calc.getRecipes(personaMap["Sraosha"]);
expect(recipes).to.have.length(1);
expect(recipes[0].sources).to.have.length(5);
expect(containAll(recipes[0], ['Mithra', 'Mithras', 'Melchizedek', 'Lilith', 'Gabriel'])).to.be(true);
});
it('should return correct recipe for Satanael', () => {
let recipes = calc.getRecipes(personaMap["Satanael"]);
expect(recipes).to.have.length(1);
expect(recipes[0].sources).to.have.length(6);
expect(containAll(recipes[0], ['Arsene', 'Anzu', 'Ishtar', 'Satan', 'Lucifer', 'Michael'])).to.be(true);
});
});
describe('rare persona (cannot be fused)', function () {
it('should return empty recipe list for Regent', () => {
let recipes = calc.getRecipes(personaMap["Regent"]);
expect(recipes).to.have.length(0);
});
it('should return empty recipe list for Stone of Scone', () => {
let recipes = calc.getRecipes(personaMap["Stone of Scone"]);
expect(recipes).to.have.length(0);
});
it('should return empty recipe list for Orlov', () => {
let recipes = calc.getRecipes(personaMap["Orlov"]);
expect(recipes).to.have.length(0);
});
});
// note: these count the number of recipes and may not be correct
describe('normal fusion', function () {
it('should return correct number of recipe for Arsene', () => {
let recipes = calc.getRecipes(personaMap["Arsene"]);
expect(recipes).to.have.length(6);
});
it('should return correct number of recipe for Apsaras', () => {
let recipes = calc.getRecipes(personaMap["Apsaras"]);
expect(recipes).to.have.length(35);
});
it('should return correct number of recipe for Orthrus', () => {
let recipes = calc.getRecipes(personaMap["Orthrus"]);
expect(recipes).to.have.length(46);
});
it('should return correct number of recipe for Kikuri-Hime', () => {
let recipes = calc.getRecipes(personaMap["Kikuri-Hime"]);
expect(recipes).to.have.length(333);
});
it('should return correct number of recipe for Lilith', () => {
let recipes = calc.getRecipes(personaMap["Lilith"]);
expect(recipes).to.have.length(82);
});
it('should return correct number of recipe for Ishtar', () => {
let recipes = calc.getRecipes(personaMap["Ishtar"]);
expect(recipes).to.have.length(22);
});
});
});
});
describe('Data', () => {
it("all persona's skills should be in the skill list", () => {
expect(checkSkill()).to.equal(true);
});
it("all skills in SkillData should have valid persona in the persona list, and " +
"all skills in SkillData should have correct list of persona that learn that skill at the correct level", () => {
expect(checkSkillPersona()).to.equal(true);
});
});
function checkSkill() {
let isGood = true;
for (let i = 0; i < fullPersonaList.length; i++) {
for (let key in fullPersonaList[i].skills) {
if (fullPersonaList[i].skills.hasOwnProperty(key)) {
if (!skillMap[key]) {
isGood = false;
throw new Error("Skill not found: " + key);
}
}
}
}
return isGood;
}
function checkSkillPersona() {
let isGood = true;
for (let i = 0; i < skillList.length; i++) {
for (let key in skillList[i].personas) {
if (skillList[i].personas.hasOwnProperty(key)) {
if (!personaMap[key]) {
isGood = false;
throw new Error("Persona not found: " + key);
}
let skillLevelInPersonaMap = personaMap[key].skills[skillList[i].name];
let skillLevelInSkillMap = skillList[i].personas[key];
if (skillLevelInPersonaMap === undefined) {
isGood = false;
throw new Error(key + " doesn't learn " + skillList[i].name);
}
if (skillLevelInPersonaMap !== skillLevelInSkillMap) {
isGood = false;
throw new Error(key + " learns " + skillList[i].name + " at at mismatched level");
}
}
}
}
return isGood;
}