Updated to make tests work
This commit is contained in:
parent
9d8703bd56
commit
c62ddc2fe5
|
@ -168,10 +168,10 @@ export interface GeneratedPersistentModifierType {
|
||||||
|
|
||||||
export class AddPokeballModifierType extends ModifierType {
|
export class AddPokeballModifierType extends ModifierType {
|
||||||
private pokeballType: PokeballType;
|
private pokeballType: PokeballType;
|
||||||
private count: integer;
|
private count: number;
|
||||||
private scene: BattleScene;
|
private currentAmount: number;
|
||||||
|
|
||||||
constructor(iconImage: string, pokeballType: PokeballType, count: integer) {
|
constructor(iconImage: string, pokeballType: PokeballType, count: number) {
|
||||||
super("", iconImage, (_type, _args) => new Modifiers.AddPokeballModifier(this, pokeballType, count), "pb", "se/pb_bounce_1");
|
super("", iconImage, (_type, _args) => new Modifiers.AddPokeballModifier(this, pokeballType, count), "pb", "se/pb_bounce_1");
|
||||||
this.pokeballType = pokeballType;
|
this.pokeballType = pokeballType;
|
||||||
this.count = count;
|
this.count = count;
|
||||||
|
@ -181,12 +181,16 @@ export class AddPokeballModifierType extends ModifierType {
|
||||||
return i18next.t("modifierType:ModifierType.AddPokeballModifierType.name", {
|
return i18next.t("modifierType:ModifierType.AddPokeballModifierType.name", {
|
||||||
"modifierCount": this.count,
|
"modifierCount": this.count,
|
||||||
"pokeballName": getPokeballName(this.pokeballType),
|
"pokeballName": getPokeballName(this.pokeballType),
|
||||||
"pokeballAmount": `${this.scene.pokeballCounts[this.pokeballType]}`,
|
"pokeballAmount": `${this.currentAmount}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addScene(scene: BattleScene) {
|
addAmount(currentAmount: number) {
|
||||||
this.scene = scene;
|
this.currentAmount = currentAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
getPokeballType(): PokeballType {
|
||||||
|
return this.pokeballType as PokeballType;
|
||||||
}
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
|
@ -2153,13 +2157,13 @@ function getModifierTypeOptionWithRetry(existingOptions: ModifierTypeOption[], r
|
||||||
allowLuckUpgrades = allowLuckUpgrades ?? true;
|
allowLuckUpgrades = allowLuckUpgrades ?? true;
|
||||||
let candidate = getNewModifierTypeOption(party, ModifierPoolType.PLAYER, tier, undefined, 0, allowLuckUpgrades);
|
let candidate = getNewModifierTypeOption(party, ModifierPoolType.PLAYER, tier, undefined, 0, allowLuckUpgrades);
|
||||||
if (candidate?.type instanceof AddPokeballModifierType) {
|
if (candidate?.type instanceof AddPokeballModifierType) {
|
||||||
candidate.type.addScene(party[0].scene);
|
candidate.type.addAmount(party[0].scene.pokeballCounts[candidate.type.getPokeballType()]);
|
||||||
}
|
}
|
||||||
let r = 0;
|
let r = 0;
|
||||||
while (existingOptions.length && ++r < retryCount && existingOptions.filter(o => o.type.name === candidate?.type.name || o.type.group === candidate?.type.group).length) {
|
while (existingOptions.length && ++r < retryCount && existingOptions.filter(o => o.type.name === candidate?.type.name || o.type.group === candidate?.type.group).length) {
|
||||||
candidate = getNewModifierTypeOption(party, ModifierPoolType.PLAYER, candidate?.type.tier ?? tier, candidate?.upgradeCount, 0, allowLuckUpgrades);
|
candidate = getNewModifierTypeOption(party, ModifierPoolType.PLAYER, candidate?.type.tier ?? tier, candidate?.upgradeCount, 0, allowLuckUpgrades);
|
||||||
if (candidate?.type instanceof AddPokeballModifierType) {
|
if (candidate?.type instanceof AddPokeballModifierType) {
|
||||||
candidate.type.addScene(party[0].scene);
|
candidate.type.addAmount(party[0].scene.pokeballCounts[candidate.type.getPokeballType()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return candidate!;
|
return candidate!;
|
||||||
|
|
|
@ -214,7 +214,7 @@ describe("Field Trip - Mystery Encounter", () => {
|
||||||
expect(modifierSelectHandler.options.length).toEqual(5);
|
expect(modifierSelectHandler.options.length).toEqual(5);
|
||||||
expect(modifierSelectHandler.options[0].modifierTypeOption.type.name).toBe("X Accuracy");
|
expect(modifierSelectHandler.options[0].modifierTypeOption.type.name).toBe("X Accuracy");
|
||||||
expect(modifierSelectHandler.options[1].modifierTypeOption.type.name).toBe("X Speed");
|
expect(modifierSelectHandler.options[1].modifierTypeOption.type.name).toBe("X Speed");
|
||||||
expect(modifierSelectHandler.options[2].modifierTypeOption.type.name).toBe("5x Great Ball");
|
expect(modifierSelectHandler.options[2].modifierTypeOption.type.name).toBe("Great Ball x5\nInventory: 0");
|
||||||
expect(modifierSelectHandler.options[3].modifierTypeOption.type.name).toBe("IV Scanner");
|
expect(modifierSelectHandler.options[3].modifierTypeOption.type.name).toBe("IV Scanner");
|
||||||
expect(modifierSelectHandler.options[4].modifierTypeOption.type.name).toBe("Rarer Candy");
|
expect(modifierSelectHandler.options[4].modifierTypeOption.type.name).toBe("Rarer Candy");
|
||||||
});
|
});
|
||||||
|
|
|
@ -678,7 +678,7 @@ class ModifierOption extends Phaser.GameObjects.Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.modifierTypeOption.type instanceof AddPokeballModifierType) {
|
if (this.modifierTypeOption.type instanceof AddPokeballModifierType) {
|
||||||
this.modifierTypeOption.type.addScene(this.scene as BattleScene);
|
this.modifierTypeOption.type.addAmount((this.scene as BattleScene).pokeballCounts[this.modifierTypeOption.type.getPokeballType()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.itemText = addTextObject(this.scene, 0, 35, this.modifierTypeOption.type?.name!, TextStyle.PARTY, { align: "center" }); // TODO: is this bang correct?
|
this.itemText = addTextObject(this.scene, 0, 35, this.modifierTypeOption.type?.name!, TextStyle.PARTY, { align: "center" }); // TODO: is this bang correct?
|
||||||
|
|
Loading…
Reference in New Issue