mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-03 23:12:20 +02:00
Merge 10166daef5
into 9926a6e799
This commit is contained in:
commit
72932c7e0a
@ -12,28 +12,39 @@ export enum VoucherType {
|
|||||||
GOLDEN,
|
GOLDEN,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const VoucherTypeNames: Record<VoucherType, string> = {
|
||||||
|
[VoucherType.REGULAR]: "voucher:eggVoucher",
|
||||||
|
[VoucherType.PLUS]: "voucher:eggVoucherPlus",
|
||||||
|
[VoucherType.PREMIUM]: "voucher:eggVoucherPremium",
|
||||||
|
[VoucherType.GOLDEN]: "voucher:eggVoucherGold",
|
||||||
|
};
|
||||||
|
|
||||||
|
const VoucherTypeIcons: Record<VoucherType, string> = {
|
||||||
|
[VoucherType.REGULAR]: "coupon",
|
||||||
|
[VoucherType.PLUS]: "pair_of_tickets",
|
||||||
|
[VoucherType.PREMIUM]: "mystic_ticket",
|
||||||
|
[VoucherType.GOLDEN]: "golden_mystic_ticket",
|
||||||
|
};
|
||||||
|
|
||||||
|
const VoucherTiers: Record<VoucherType, AchvTier> = {
|
||||||
|
[VoucherType.REGULAR]: AchvTier.COMMON,
|
||||||
|
[VoucherType.PLUS]: AchvTier.GREAT,
|
||||||
|
[VoucherType.PREMIUM]: AchvTier.ULTRA,
|
||||||
|
[VoucherType.GOLDEN]: AchvTier.ROGUE,
|
||||||
|
};
|
||||||
|
|
||||||
export class Voucher {
|
export class Voucher {
|
||||||
public id: string;
|
public id = "";
|
||||||
public voucherType: VoucherType;
|
constructor(
|
||||||
public description: string;
|
public voucherType: VoucherType,
|
||||||
|
public description: string,
|
||||||
private conditionFunc: ConditionFn | undefined;
|
private conditionFunc?: ConditionFn,
|
||||||
|
) {}
|
||||||
constructor(voucherType: VoucherType, description: string, conditionFunc?: ConditionFn) {
|
|
||||||
this.description = description;
|
|
||||||
this.voucherType = voucherType;
|
|
||||||
this.conditionFunc = conditionFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
validate(args?: any[]): boolean {
|
validate(args?: any[]): boolean {
|
||||||
return !this.conditionFunc || this.conditionFunc(args);
|
return !this.conditionFunc || this.conditionFunc(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the name of the voucher
|
|
||||||
* @param _playerGender - this is ignored here. It's only there to match the signature of the function in the Achv class
|
|
||||||
* @returns the name of the voucher
|
|
||||||
*/
|
|
||||||
getName(_playerGender: PlayerGender): string {
|
getName(_playerGender: PlayerGender): string {
|
||||||
return getVoucherTypeName(this.voucherType);
|
return getVoucherTypeName(this.voucherType);
|
||||||
}
|
}
|
||||||
@ -43,43 +54,16 @@ export class Voucher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTier(): AchvTier {
|
getTier(): AchvTier {
|
||||||
switch (this.voucherType) {
|
return VoucherTiers[this.voucherType];
|
||||||
case VoucherType.REGULAR:
|
|
||||||
return AchvTier.COMMON;
|
|
||||||
case VoucherType.PLUS:
|
|
||||||
return AchvTier.GREAT;
|
|
||||||
case VoucherType.PREMIUM:
|
|
||||||
return AchvTier.ULTRA;
|
|
||||||
case VoucherType.GOLDEN:
|
|
||||||
return AchvTier.ROGUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getVoucherTypeName(voucherType: VoucherType): string {
|
export function getVoucherTypeName(voucherType: VoucherType): string {
|
||||||
switch (voucherType) {
|
return i18next.t(VoucherTypeNames[voucherType]);
|
||||||
case VoucherType.REGULAR:
|
|
||||||
return i18next.t("voucher:eggVoucher");
|
|
||||||
case VoucherType.PLUS:
|
|
||||||
return i18next.t("voucher:eggVoucherPlus");
|
|
||||||
case VoucherType.PREMIUM:
|
|
||||||
return i18next.t("voucher:eggVoucherPremium");
|
|
||||||
case VoucherType.GOLDEN:
|
|
||||||
return i18next.t("voucher:eggVoucherGold");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getVoucherTypeIcon(voucherType: VoucherType): string {
|
export function getVoucherTypeIcon(voucherType: VoucherType): string {
|
||||||
switch (voucherType) {
|
return VoucherTypeIcons[voucherType];
|
||||||
case VoucherType.REGULAR:
|
|
||||||
return "coupon";
|
|
||||||
case VoucherType.PLUS:
|
|
||||||
return "pair_of_tickets";
|
|
||||||
case VoucherType.PREMIUM:
|
|
||||||
return "mystic_ticket";
|
|
||||||
case VoucherType.GOLDEN:
|
|
||||||
return "golden_mystic_ticket";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Vouchers {
|
export interface Vouchers {
|
||||||
@ -89,35 +73,34 @@ export interface Vouchers {
|
|||||||
export const vouchers: Vouchers = {};
|
export const vouchers: Vouchers = {};
|
||||||
|
|
||||||
export function initVouchers() {
|
export function initVouchers() {
|
||||||
for (const achv of [achvs.CLASSIC_VICTORY]) {
|
const getVoucherTypeByScore = (score: number): VoucherType => {
|
||||||
const voucherType =
|
if (score >= 150) return VoucherType.GOLDEN;
|
||||||
achv.score >= 150
|
if (score >= 100) return VoucherType.PREMIUM;
|
||||||
? VoucherType.GOLDEN
|
if (score >= 75) return VoucherType.PLUS;
|
||||||
: achv.score >= 100
|
return VoucherType.REGULAR;
|
||||||
? VoucherType.PREMIUM
|
};
|
||||||
: achv.score >= 75
|
|
||||||
? VoucherType.PLUS
|
|
||||||
: VoucherType.REGULAR;
|
|
||||||
vouchers[achv.id] = new Voucher(voucherType, getAchievementDescription(achv.localizationKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
const bossTrainerTypes = Object.keys(trainerConfigs).filter(
|
vouchers[achvs.CLASSIC_VICTORY.id] = new Voucher(
|
||||||
tt =>
|
getVoucherTypeByScore(achvs.CLASSIC_VICTORY.score),
|
||||||
trainerConfigs[tt].isBoss &&
|
getAchievementDescription(achvs.CLASSIC_VICTORY.localizationKey),
|
||||||
trainerConfigs[tt].getDerivedType() !== TrainerType.RIVAL &&
|
|
||||||
trainerConfigs[tt].hasVoucher,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const trainerType of bossTrainerTypes) {
|
for (const [key, config] of Object.entries(trainerConfigs)) {
|
||||||
const voucherType = trainerConfigs[trainerType].moneyMultiplier < 10 ? VoucherType.PLUS : VoucherType.PREMIUM;
|
if (
|
||||||
const key = TrainerType[trainerType];
|
config.isBoss &&
|
||||||
const trainerName = trainerConfigs[trainerType].name;
|
config.getDerivedType() !== TrainerType.RIVAL &&
|
||||||
const trainer = trainerConfigs[trainerType];
|
config.hasVoucher
|
||||||
const title = trainer.title ? ` (${trainer.title})` : "";
|
) {
|
||||||
vouchers[key] = new Voucher(voucherType, `${i18next.t("voucher:defeatTrainer", { trainerName })} ${title}`);
|
const voucherType = config.moneyMultiplier < 10 ? VoucherType.PLUS : VoucherType.PREMIUM;
|
||||||
|
const title = config.title ? ` (${config.title})` : "";
|
||||||
|
vouchers[TrainerType[key as keyof typeof TrainerType]] = new Voucher(
|
||||||
|
voucherType,
|
||||||
|
`${i18next.t("voucher:defeatTrainer", { trainerName: config.name })}${title}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const voucherKeys = Object.keys(vouchers);
|
}
|
||||||
for (const k of voucherKeys) {
|
|
||||||
vouchers[k].id = k;
|
for (const [key, voucher] of Object.entries(vouchers)) {
|
||||||
|
voucher.id = key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user