Add egg gacha system and various minor changes

Add egg gacha system; remove certain mythical Pokemon from the wild pool as egg exclusive; add egg vouchers with UI; rework Shiny Charm odds; fix trainer Pokemon shiny odds not properly ignoring Shiny Charm modifier
This commit is contained in:
Flashfyre committed 2023-12-19 23:51:48 -05:00
1 parent 50d4858caa
commit aa94e044ab
71 files changed
+4303 -2241

No files matched your search

+93 -1
View File
@@ -1,4 +1,9 @@
import { ModifierTier } from "../modifier/modifier-type";
import { Type } from "./type";
import * as Utils from "../utils";
import BattleScene from "../battle-scene";
import { Species } from "./species";
import { getPokemonSpecies, speciesStarters } from "./pokemon-species";
export const EGG_SEED = 1073741824;
@@ -12,12 +17,99 @@ export class Egg {
public id: integer;
public tier: ModifierTier;
public gachaType: GachaType;
public hatchWaves: integer;
public timestamp: integer;
constructor(id: integer, gachaType: GachaType, timestamp: integer) {
constructor(id: integer, gachaType: GachaType, hatchWaves: integer, timestamp: integer) {
this.id = id;
this.tier = Math.floor(id / EGG_SEED);
this.gachaType = gachaType;
this.hatchWaves = hatchWaves;
this.timestamp = timestamp;
}
isManaphyEgg(): boolean {
return this.tier === ModifierTier.COMMON && !(this.id % 255);
}
getKey(): string {
if (this.isManaphyEgg())
return 'manaphy';
return this.tier.toString();
}
}
export function getEggTierDefaultHatchWaves(tier: ModifierTier): integer {
switch (tier) {
case ModifierTier.COMMON:
return 10;
case ModifierTier.GREAT:
return 25;
case ModifierTier.ULTRA:
return 50;
}
return 100;
}
export function getEggDescriptor(egg: Egg): string {
if (egg.isManaphyEgg())
return 'Manaphy';
switch (egg.tier) {
case ModifierTier.GREAT:
return 'Rare';
case ModifierTier.ULTRA:
return 'Epic';
case ModifierTier.MASTER:
return 'Legendary';
default:
return 'Common';
}
}
export function getEggHatchWavesMessage(hatchWaves: integer): string {
if (hatchWaves <= 5)
return 'Sounds can be heard coming from inside! It will hatch soon!';
if (hatchWaves <= 15)
return 'It appears to move occasionally. It may be close to hatching.';
if (hatchWaves <= 50)
return 'What will hatch from this? It doesn\'t seem close to hatching.';
return 'It looks like this Egg will take a long time to hatch.';
}
export function getEggGachaTypeDescriptor(scene: BattleScene, egg: Egg): string {
if (egg.isManaphyEgg())
return '';
switch (egg.gachaType) {
case GachaType.LEGENDARY:
return `Legendary Rate Up (${getPokemonSpecies(getLegendaryGachaSpeciesForTimestamp(scene, egg.timestamp)).getName()})`;
case GachaType.TYPE:
return `Type Rate Up (${Utils.toReadableString(Type[getTypeGachaTypeForTimestamp(scene, egg.timestamp)])})`;
case GachaType.SHINY:
return 'Shiny Rate Up';
}
}
export function getLegendaryGachaSpeciesForTimestamp(scene: BattleScene, timestamp: integer): Species {
const legendarySpecies = Object.entries(speciesStarters)
.filter(s => s[1] >= 8 && s[1] <= 9)
.map(s => parseInt(s[0]));
let ret: Species;
scene.executeWithSeedOffset(() => {
ret = Phaser.Math.RND.pick(legendarySpecies);
}, Utils.getSunday(new Date(timestamp)).getTime(), EGG_SEED.toString());
return ret;
}
export function getTypeGachaTypeForTimestamp(scene: BattleScene, timestamp: integer): Type {
const types = Utils.getEnumValues(Type);
let ret: Type;
scene.executeWithSeedOffset(() => {
ret = Phaser.Math.RND.pick(types);
}, Utils.getSunday(new Date(timestamp)).getTime(), EGG_SEED.toString());
return ret;
}