Add money items

This commit is contained in:
Flashfyre 2024-01-18 17:22:18 -05:00
parent 84fe12d83a
commit 80095a64fc
6 changed files with 61 additions and 9 deletions

View File

@ -2733,10 +2733,7 @@ export class MoneyRewardPhase extends BattlePhase {
} }
start() { start() {
const waveIndex = this.scene.currentBattle.waveIndex; const moneyAmount = new Utils.IntegerHolder(this.scene.getMoneyAmountForWave(this.moneyMultiplier));
const waveSetIndex = Math.ceil(waveIndex / 10) - 1;
const moneyValue = Math.pow((waveSetIndex + 1 + (0.75 + (((waveIndex - 1) % 10) + 1) / 10)) * 100, 1 + 0.005 * waveSetIndex) * this.moneyMultiplier;
const moneyAmount = new Utils.IntegerHolder(Math.floor(moneyValue / 10) * 10);
this.scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount); this.scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount);

View File

@ -1437,6 +1437,13 @@ export default class BattleScene extends Phaser.Scene {
this.phaseQueue.push(new TurnInitPhase(this)); this.phaseQueue.push(new TurnInitPhase(this));
} }
getMoneyAmountForWave(moneyMultiplier: number): integer {
const waveIndex = this.currentBattle.waveIndex;
const waveSetIndex = Math.ceil(waveIndex / 10) - 1;
const moneyValue = Math.pow((waveSetIndex + 1 + (0.75 + (((waveIndex - 1) % 10) + 1) / 10)) * 100, 1 + 0.005 * waveSetIndex) * moneyMultiplier;
return Math.floor(moneyValue / 10) * 10;
}
addModifier(modifier: Modifier, ignoreUpdate?: boolean, playSound?: boolean, virtual?: boolean, instant?: boolean): Promise<void> { addModifier(modifier: Modifier, ignoreUpdate?: boolean, playSound?: boolean, virtual?: boolean, instant?: boolean): Promise<void> {
return new Promise(resolve => { return new Promise(resolve => {
const soundName = modifier.type.soundName; const soundName = modifier.type.soundName;

View File

@ -35,7 +35,7 @@ export class ModifierType {
public id: string; public id: string;
public generatorId: string; public generatorId: string;
public name: string; public name: string;
public description: string; protected description: string;
public iconImage: string; public iconImage: string;
public group: string; public group: string;
public soundName: string; public soundName: string;
@ -51,6 +51,10 @@ export class ModifierType {
this.newModifierFunc = newModifierFunc; this.newModifierFunc = newModifierFunc;
} }
getDescription(scene: BattleScene): string {
return this.description;
}
setTier(tier: ModifierTier): void { setTier(tier: ModifierTier): void {
this.tier = tier; this.tier = tier;
} }
@ -403,6 +407,20 @@ class AllPokemonFullReviveModifierType extends AllPokemonFullHpRestoreModifierTy
} }
} }
export class MoneyRewardModifierType extends ModifierType {
private moneyMultiplier: number;
constructor(name: string, moneyMultiplier: number, moneyMultiplierDescriptor: string, iconImage?: string) {
super(name, `Grants a ${moneyMultiplierDescriptor} amount of money (₽{AMOUNT})`, (_type, _args) => new Modifiers.MoneyRewardModifier(this, moneyMultiplier), iconImage, 'money', 'buy');
this.moneyMultiplier = moneyMultiplier;
}
getDescription(scene: BattleScene): string {
return this.description.replace('{AMOUNT}', scene.getMoneyAmountForWave(this.moneyMultiplier).toLocaleString('en-US'));
}
}
export class ExpBoosterModifierType extends ModifierType { export class ExpBoosterModifierType extends ModifierType {
constructor(name: string, boostPercent: integer, iconImage?: string) { constructor(name: string, boostPercent: integer, iconImage?: string) {
super(name, `Increases gain of EXP. Points by ${boostPercent}%`, () => new Modifiers.ExpBoosterModifier(this, boostPercent), iconImage); super(name, `Increases gain of EXP. Points by ${boostPercent}%`, () => new Modifiers.ExpBoosterModifier(this, boostPercent), iconImage);
@ -738,6 +756,10 @@ export const modifierTypes = {
SOUL_DEW: () => new PokemonHeldItemModifierType('Soul Dew', 'Increases the influence of a Pokémon\'s nature on its stats by 5% (additive)', (type, args) => new Modifiers.PokemonNatureWeightModifier(type, (args[0] as Pokemon).id)), SOUL_DEW: () => new PokemonHeldItemModifierType('Soul Dew', 'Increases the influence of a Pokémon\'s nature on its stats by 5% (additive)', (type, args) => new Modifiers.PokemonNatureWeightModifier(type, (args[0] as Pokemon).id)),
NUGGET: () => new MoneyRewardModifierType('Nugget', 1, 'small'),
BIG_NUGGET: () => new MoneyRewardModifierType('Big Nugget', 2.5, 'moderate'),
RELIC_GOLD: () => new MoneyRewardModifierType('Relic Gold', 10, 'large'),
AMULET_COIN: () => new ModifierType('Amulet Coin', 'Increases money rewards by 20%', (type, _args) => new Modifiers.MoneyMultiplierModifier(type)), AMULET_COIN: () => new ModifierType('Amulet Coin', 'Increases money rewards by 20%', (type, _args) => new Modifiers.MoneyMultiplierModifier(type)),
GOLDEN_PUNCH: () => new PokemonHeldItemModifierType('Golden Punch', 'Grants 20% of damage inflicted as money', (type, args) => new Modifiers.DamageMoneyRewardModifier(type, (args[0] as Pokemon).id)), GOLDEN_PUNCH: () => new PokemonHeldItemModifierType('Golden Punch', 'Grants 20% of damage inflicted as money', (type, args) => new Modifiers.DamageMoneyRewardModifier(type, (args[0] as Pokemon).id)),
COIN_CASE: () => new ModifierType('Coin Case', 'After every 10th battle, receive 10% of your money in interest', (type, _args) => new Modifiers.MoneyInterestModifier(type)), COIN_CASE: () => new ModifierType('Coin Case', 'After every 10th battle, receive 10% of your money in interest', (type, _args) => new Modifiers.MoneyInterestModifier(type)),
@ -856,6 +878,8 @@ const modifierPool = {
return thresholdPartyMemberCount; return thresholdPartyMemberCount;
}), }),
new WeightedModifierType(modifierTypes.SUPER_LURE, 4), new WeightedModifierType(modifierTypes.SUPER_LURE, 4),
new WeightedModifierType(modifierTypes.NUGGET, 5),
new WeightedModifierType(modifierTypes.BIG_NUGGET, 1),
new WeightedModifierType(modifierTypes.MAP, (party: Pokemon[]) => party[0].scene.gameMode === GameMode.CLASSIC ? 1 : 0), new WeightedModifierType(modifierTypes.MAP, (party: Pokemon[]) => party[0].scene.gameMode === GameMode.CLASSIC ? 1 : 0),
new WeightedModifierType(modifierTypes.TM_GREAT, 2), new WeightedModifierType(modifierTypes.TM_GREAT, 2),
new WeightedModifierType(modifierTypes.EXP_SHARE, 1), new WeightedModifierType(modifierTypes.EXP_SHARE, 1),
@ -868,6 +892,7 @@ const modifierPool = {
[ModifierTier.ULTRA]: [ [ModifierTier.ULTRA]: [
new WeightedModifierType(modifierTypes.ULTRA_BALL, 8), new WeightedModifierType(modifierTypes.ULTRA_BALL, 8),
new WeightedModifierType(modifierTypes.MAX_LURE, 4), new WeightedModifierType(modifierTypes.MAX_LURE, 4),
new WeightedModifierType(modifierTypes.RELIC_GOLD, 3),
new WeightedModifierType(modifierTypes.PP_UP, 6), new WeightedModifierType(modifierTypes.PP_UP, 6),
new WeightedModifierType(modifierTypes.PP_MAX, 2), new WeightedModifierType(modifierTypes.PP_MAX, 2),
new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 4), new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 4),

View File

@ -57,7 +57,7 @@ export class ModifierBar extends Phaser.GameObjects.Container {
this.setModifierIconPosition(icon, visibleIconModifiers.length); this.setModifierIconPosition(icon, visibleIconModifiers.length);
icon.setInteractive(new Phaser.Geom.Rectangle(0, 0, 32, 32), Phaser.Geom.Rectangle.Contains); icon.setInteractive(new Phaser.Geom.Rectangle(0, 0, 32, 32), Phaser.Geom.Rectangle.Contains);
icon.on('pointerover', () => { icon.on('pointerover', () => {
(this.scene as BattleScene).ui.showTooltip(modifier.type.name, modifier.type.description); (this.scene as BattleScene).ui.showTooltip(modifier.type.name, modifier.type.getDescription(this.scene as BattleScene));
if (this.modifierCache && this.modifierCache.length > iconOverflowIndex) if (this.modifierCache && this.modifierCache.length > iconOverflowIndex)
thisArg.updateModifierOverflowVisibility(true); thisArg.updateModifierOverflowVisibility(true);
}); });
@ -1312,6 +1312,29 @@ export class PokemonFormChangeItemModifier extends PokemonHeldItemModifier {
} }
} }
export class MoneyRewardModifier extends ConsumableModifier {
private moneyMultiplier: number;
constructor(type: ModifierType, moneyMultiplier: number) {
super(type);
this.moneyMultiplier = moneyMultiplier;
}
apply(args: any[]): boolean {
const scene = args[0] as BattleScene;
const moneyAmount = new Utils.IntegerHolder(scene.getMoneyAmountForWave(this.moneyMultiplier));
scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount);
scene.money += moneyAmount.value;
scene.updateMoneyText();
scene.validateAchvs(MoneyAchv);
return true;
}
}
export class MoneyMultiplierModifier extends PersistentModifier { export class MoneyMultiplierModifier extends PersistentModifier {
constructor(type: ModifierType, stackCount?: integer) { constructor(type: ModifierType, stackCount?: integer) {
super(type, stackCount); super(type, stackCount);

View File

@ -218,7 +218,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
if (cursor < this.options.length) { if (cursor < this.options.length) {
const sliceWidth = (this.scene.game.canvas.width / 6) / (this.options.length + 2); const sliceWidth = (this.scene.game.canvas.width / 6) / (this.options.length + 2);
this.cursorObj.setPosition(sliceWidth * (cursor + 1) + (sliceWidth * 0.5) - 20, -this.scene.game.canvas.height / 12 - 20); this.cursorObj.setPosition(sliceWidth * (cursor + 1) + (sliceWidth * 0.5) - 20, -this.scene.game.canvas.height / 12 - 20);
ui.showText(this.options[this.cursor].modifierTypeOption.type.description); ui.showText(this.options[this.cursor].modifierTypeOption.type.getDescription(this.scene));
} else if (cursor === this.options.length) { } else if (cursor === this.options.length) {
this.cursorObj.setPosition(6, -60); this.cursorObj.setPosition(6, -60);
ui.showText('Spend money to reroll your item options'); ui.showText('Spend money to reroll your item options');

View File

@ -578,7 +578,7 @@ export default class SummaryUiHandler extends UiHandler {
statsContainer.add(icon); statsContainer.add(icon);
icon.setInteractive(new Phaser.Geom.Rectangle(0, 0, 32, 32), Phaser.Geom.Rectangle.Contains); icon.setInteractive(new Phaser.Geom.Rectangle(0, 0, 32, 32), Phaser.Geom.Rectangle.Contains);
icon.on('pointerover', () => (this.scene as BattleScene).ui.showTooltip(item.type.name, item.type.description, true)); icon.on('pointerover', () => (this.scene as BattleScene).ui.showTooltip(item.type.name, item.type.getDescription(this.scene), true));
icon.on('pointerout', () => (this.scene as BattleScene).ui.hideTooltip()); icon.on('pointerout', () => (this.scene as BattleScene).ui.hideTooltip());
}); });