initVouchers correctly (#1940)
This commit is contained in:
parent
bf5b6e3f6b
commit
9c97e37c27
|
@ -20,6 +20,7 @@ import {initAchievements} from "#app/system/achv";
|
||||||
import {initTrainerTypeDialogue} from "#app/data/dialogue";
|
import {initTrainerTypeDialogue} from "#app/data/dialogue";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { initStatsKeys } from "./ui/game-stats-ui-handler";
|
import { initStatsKeys } from "./ui/game-stats-ui-handler";
|
||||||
|
import { initVouchers } from "./system/voucher";
|
||||||
|
|
||||||
export class LoadingScene extends SceneBase {
|
export class LoadingScene extends SceneBase {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -329,6 +330,7 @@ export class LoadingScene extends SceneBase {
|
||||||
|
|
||||||
this.loadLoadingScreen();
|
this.loadLoadingScreen();
|
||||||
|
|
||||||
|
initVouchers();
|
||||||
initAchievements();
|
initAchievements();
|
||||||
initStatsKeys();
|
initStatsKeys();
|
||||||
initPokemonPrevolutions();
|
initPokemonPrevolutions();
|
||||||
|
|
|
@ -83,42 +83,40 @@ export const vouchers: Vouchers = {};
|
||||||
|
|
||||||
const voucherAchvs: Achv[] = [ achvs.CLASSIC_VICTORY ];
|
const voucherAchvs: Achv[] = [ achvs.CLASSIC_VICTORY ];
|
||||||
|
|
||||||
{
|
export function initVouchers() {
|
||||||
(function() {
|
import("../data/trainer-config").then(tc => {
|
||||||
import("../data/trainer-config").then(tc => {
|
const trainerConfigs = tc.trainerConfigs;
|
||||||
const trainerConfigs = tc.trainerConfigs;
|
|
||||||
|
|
||||||
for (const achv of voucherAchvs) {
|
for (const achv of voucherAchvs) {
|
||||||
const voucherType = achv.score >= 150
|
const voucherType = achv.score >= 150
|
||||||
? VoucherType.GOLDEN
|
? VoucherType.GOLDEN
|
||||||
: achv.score >= 100
|
: achv.score >= 100
|
||||||
? VoucherType.PREMIUM
|
? VoucherType.PREMIUM
|
||||||
: achv.score >= 75
|
: achv.score >= 75
|
||||||
? VoucherType.PLUS
|
? VoucherType.PLUS
|
||||||
: VoucherType.REGULAR;
|
: VoucherType.REGULAR;
|
||||||
vouchers[achv.id] = new Voucher(voucherType, getAchievementDescription(achv.localizationKey));
|
vouchers[achv.id] = new Voucher(voucherType, getAchievementDescription(achv.localizationKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
const bossTrainerTypes = Object.keys(trainerConfigs)
|
const bossTrainerTypes = Object.keys(trainerConfigs)
|
||||||
.filter(tt => trainerConfigs[tt].isBoss && trainerConfigs[tt].getDerivedType() !== TrainerType.RIVAL);
|
.filter(tt => trainerConfigs[tt].isBoss && trainerConfigs[tt].getDerivedType() !== TrainerType.RIVAL);
|
||||||
|
|
||||||
for (const trainerType of bossTrainerTypes) {
|
for (const trainerType of bossTrainerTypes) {
|
||||||
const voucherType = trainerConfigs[trainerType].moneyMultiplier < 10
|
const voucherType = trainerConfigs[trainerType].moneyMultiplier < 10
|
||||||
? VoucherType.PLUS
|
? VoucherType.PLUS
|
||||||
: VoucherType.PREMIUM;
|
: VoucherType.PREMIUM;
|
||||||
const key = TrainerType[trainerType];
|
const key = TrainerType[trainerType];
|
||||||
const trainerName = trainerConfigs[trainerType].name;
|
const trainerName = trainerConfigs[trainerType].name;
|
||||||
const trainer = trainerConfigs[trainerType];
|
const trainer = trainerConfigs[trainerType];
|
||||||
const title = trainer.title ? ` (${trainer.title})` : "";
|
const title = trainer.title ? ` (${trainer.title})` : "";
|
||||||
vouchers[key] = new Voucher(
|
vouchers[key] = new Voucher(
|
||||||
voucherType,
|
voucherType,
|
||||||
`${i18next.t("voucher:defeatTrainer", { trainerName })} ${title}`,
|
`${i18next.t("voucher:defeatTrainer", { trainerName })} ${title}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const voucherKeys = Object.keys(vouchers);
|
const voucherKeys = Object.keys(vouchers);
|
||||||
for (const k of voucherKeys) {
|
for (const k of voucherKeys) {
|
||||||
vouchers[k].id = k;
|
vouchers[k].id = k;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,9 @@ import {initSpecies} from "#app/data/pokemon-species";
|
||||||
import {initMoves} from "#app/data/move";
|
import {initMoves} from "#app/data/move";
|
||||||
import {initAbilities} from "#app/data/ability";
|
import {initAbilities} from "#app/data/ability";
|
||||||
import {initAchievements} from "#app/system/achv.js";
|
import {initAchievements} from "#app/system/achv.js";
|
||||||
|
import { initVouchers } from "#app/system/voucher.js";
|
||||||
|
|
||||||
|
initVouchers();
|
||||||
initAchievements();
|
initAchievements();
|
||||||
initStatsKeys();
|
initStatsKeys();
|
||||||
initPokemonPrevolutions();
|
initPokemonPrevolutions();
|
||||||
|
|
Loading…
Reference in New Issue