sekai-calculator 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +21 -9
- package/dist/index.mjs +21 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -227,7 +227,8 @@ class CardPowerCalculator {
|
|
|
227
227
|
const cardEpisodes = p[0];
|
|
228
228
|
const masterLessons = p[1];
|
|
229
229
|
const ret = [0, 0, 0];
|
|
230
|
-
const cardParameters = card.cardParameters
|
|
230
|
+
const cardParameters = card.cardParameters
|
|
231
|
+
.filter(it => it.cardLevel === userCard.level);
|
|
231
232
|
const params = ['param1', 'param2', 'param3'];
|
|
232
233
|
params.forEach((param, i) => {
|
|
233
234
|
ret[i] = findOrThrow(cardParameters, it => it.cardParameterType === param).power;
|
|
@@ -261,20 +262,31 @@ class CardPowerCalculator {
|
|
|
261
262
|
(it.targetGameCharacterId === undefined || it.targetGameCharacterId === characterId));
|
|
262
263
|
const areaItemBonus = [0, 0, 0];
|
|
263
264
|
for (const areaItem of usedAreaItems) {
|
|
264
|
-
const allMatch = (areaItem.targetUnit !== 'any' && sameUnit) ||
|
|
265
|
-
|
|
266
|
-
areaItemBonus[
|
|
267
|
-
|
|
265
|
+
const allMatch = (areaItem.targetUnit !== 'any' && sameUnit) ||
|
|
266
|
+
(areaItem.targetCardAttr !== 'any' && sameAttr);
|
|
267
|
+
areaItemBonus[0] = Math.fround(areaItemBonus[0] +
|
|
268
|
+
Math.fround(allMatch ? areaItem.power1AllMatchBonusRate : areaItem.power1BonusRate));
|
|
269
|
+
areaItemBonus[1] = Math.fround(areaItemBonus[1] +
|
|
270
|
+
Math.fround(allMatch ? areaItem.power2AllMatchBonusRate : areaItem.power2BonusRate));
|
|
271
|
+
areaItemBonus[2] = Math.fround(areaItemBonus[2] +
|
|
272
|
+
Math.fround(allMatch ? areaItem.power3AllMatchBonusRate : areaItem.power3BonusRate));
|
|
268
273
|
}
|
|
269
|
-
return basePower
|
|
274
|
+
return basePower
|
|
275
|
+
.reduce((v, it, i) => v + Math.floor(Math.fround(it * areaItemBonus[i] / 100)), 0);
|
|
270
276
|
}
|
|
271
277
|
async getCharacterBonusPower(basePower, characterId) {
|
|
272
278
|
const characterRanks = await this.dataProvider.getMasterData('characterRanks');
|
|
273
279
|
const userCharacters = await this.dataProvider.getUserData('userCharacters');
|
|
274
280
|
const userCharacter = findOrThrow(userCharacters, it => it.characterId === characterId);
|
|
275
|
-
const characterRank = findOrThrow(characterRanks, it => it.characterId === userCharacter.characterId &&
|
|
276
|
-
|
|
277
|
-
|
|
281
|
+
const characterRank = findOrThrow(characterRanks, it => it.characterId === userCharacter.characterId &&
|
|
282
|
+
it.characterRank === userCharacter.characterRank);
|
|
283
|
+
const rates = [
|
|
284
|
+
Math.fround(characterRank.power1BonusRate),
|
|
285
|
+
Math.fround(characterRank.power2BonusRate),
|
|
286
|
+
Math.fround(characterRank.power3BonusRate)
|
|
287
|
+
];
|
|
288
|
+
return rates
|
|
289
|
+
.reduce((v, it, i) => v + Math.floor(Math.fround(basePower[i] * it / 100)), 0);
|
|
278
290
|
}
|
|
279
291
|
}
|
|
280
292
|
|
package/dist/index.mjs
CHANGED
|
@@ -225,7 +225,8 @@ class CardPowerCalculator {
|
|
|
225
225
|
const cardEpisodes = p[0];
|
|
226
226
|
const masterLessons = p[1];
|
|
227
227
|
const ret = [0, 0, 0];
|
|
228
|
-
const cardParameters = card.cardParameters
|
|
228
|
+
const cardParameters = card.cardParameters
|
|
229
|
+
.filter(it => it.cardLevel === userCard.level);
|
|
229
230
|
const params = ['param1', 'param2', 'param3'];
|
|
230
231
|
params.forEach((param, i) => {
|
|
231
232
|
ret[i] = findOrThrow(cardParameters, it => it.cardParameterType === param).power;
|
|
@@ -259,20 +260,31 @@ class CardPowerCalculator {
|
|
|
259
260
|
(it.targetGameCharacterId === undefined || it.targetGameCharacterId === characterId));
|
|
260
261
|
const areaItemBonus = [0, 0, 0];
|
|
261
262
|
for (const areaItem of usedAreaItems) {
|
|
262
|
-
const allMatch = (areaItem.targetUnit !== 'any' && sameUnit) ||
|
|
263
|
-
|
|
264
|
-
areaItemBonus[
|
|
265
|
-
|
|
263
|
+
const allMatch = (areaItem.targetUnit !== 'any' && sameUnit) ||
|
|
264
|
+
(areaItem.targetCardAttr !== 'any' && sameAttr);
|
|
265
|
+
areaItemBonus[0] = Math.fround(areaItemBonus[0] +
|
|
266
|
+
Math.fround(allMatch ? areaItem.power1AllMatchBonusRate : areaItem.power1BonusRate));
|
|
267
|
+
areaItemBonus[1] = Math.fround(areaItemBonus[1] +
|
|
268
|
+
Math.fround(allMatch ? areaItem.power2AllMatchBonusRate : areaItem.power2BonusRate));
|
|
269
|
+
areaItemBonus[2] = Math.fround(areaItemBonus[2] +
|
|
270
|
+
Math.fround(allMatch ? areaItem.power3AllMatchBonusRate : areaItem.power3BonusRate));
|
|
266
271
|
}
|
|
267
|
-
return basePower
|
|
272
|
+
return basePower
|
|
273
|
+
.reduce((v, it, i) => v + Math.floor(Math.fround(it * areaItemBonus[i] / 100)), 0);
|
|
268
274
|
}
|
|
269
275
|
async getCharacterBonusPower(basePower, characterId) {
|
|
270
276
|
const characterRanks = await this.dataProvider.getMasterData('characterRanks');
|
|
271
277
|
const userCharacters = await this.dataProvider.getUserData('userCharacters');
|
|
272
278
|
const userCharacter = findOrThrow(userCharacters, it => it.characterId === characterId);
|
|
273
|
-
const characterRank = findOrThrow(characterRanks, it => it.characterId === userCharacter.characterId &&
|
|
274
|
-
|
|
275
|
-
|
|
279
|
+
const characterRank = findOrThrow(characterRanks, it => it.characterId === userCharacter.characterId &&
|
|
280
|
+
it.characterRank === userCharacter.characterRank);
|
|
281
|
+
const rates = [
|
|
282
|
+
Math.fround(characterRank.power1BonusRate),
|
|
283
|
+
Math.fround(characterRank.power2BonusRate),
|
|
284
|
+
Math.fround(characterRank.power3BonusRate)
|
|
285
|
+
];
|
|
286
|
+
return rates
|
|
287
|
+
.reduce((v, it, i) => v + Math.floor(Math.fround(basePower[i] * it / 100)), 0);
|
|
276
288
|
}
|
|
277
289
|
}
|
|
278
290
|
|