2023-12-20 04:51:48 +00:00
|
|
|
import { Type } from "./type";
|
|
|
|
import * as Utils from "../utils";
|
|
|
|
import BattleScene from "../battle-scene";
|
2024-01-13 17:24:24 +00:00
|
|
|
import { Species } from "./enums/species";
|
2023-12-20 04:51:48 +00:00
|
|
|
import { getPokemonSpecies, speciesStarters } from "./pokemon-species";
|
2024-02-29 04:13:05 +00:00
|
|
|
import { EggTier } from "./enums/egg-type";
|
2023-12-16 04:07:32 +00:00
|
|
|
|
|
|
|
export const EGG_SEED = 1073741824;
|
|
|
|
|
|
|
|
export enum GachaType {
|
2024-03-04 02:30:11 +00:00
|
|
|
MOVE,
|
2024-02-19 15:42:17 +00:00
|
|
|
LEGENDARY,
|
2023-12-16 04:07:32 +00:00
|
|
|
SHINY
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Egg {
|
|
|
|
public id: integer;
|
2024-02-29 04:13:05 +00:00
|
|
|
public tier: EggTier;
|
2023-12-16 04:07:32 +00:00
|
|
|
public gachaType: GachaType;
|
2023-12-20 04:51:48 +00:00
|
|
|
public hatchWaves: integer;
|
2023-12-16 04:07:32 +00:00
|
|
|
public timestamp: integer;
|
|
|
|
|
2023-12-20 04:51:48 +00:00
|
|
|
constructor(id: integer, gachaType: GachaType, hatchWaves: integer, timestamp: integer) {
|
2023-12-16 04:07:32 +00:00
|
|
|
this.id = id;
|
|
|
|
this.tier = Math.floor(id / EGG_SEED);
|
|
|
|
this.gachaType = gachaType;
|
2023-12-20 04:51:48 +00:00
|
|
|
this.hatchWaves = hatchWaves;
|
2023-12-16 04:07:32 +00:00
|
|
|
this.timestamp = timestamp;
|
|
|
|
}
|
2023-12-20 04:51:48 +00:00
|
|
|
|
|
|
|
isManaphyEgg(): boolean {
|
2024-02-29 04:13:05 +00:00
|
|
|
return this.tier === EggTier.COMMON && !(this.id % 255);
|
2023-12-20 04:51:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getKey(): string {
|
|
|
|
if (this.isManaphyEgg())
|
|
|
|
return 'manaphy';
|
|
|
|
return this.tier.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-29 04:13:05 +00:00
|
|
|
export function getEggTierDefaultHatchWaves(tier: EggTier): integer {
|
2023-12-20 04:51:48 +00:00
|
|
|
switch (tier) {
|
2024-02-29 04:13:05 +00:00
|
|
|
case EggTier.COMMON:
|
2023-12-20 04:51:48 +00:00
|
|
|
return 10;
|
2024-02-29 04:13:05 +00:00
|
|
|
case EggTier.GREAT:
|
2023-12-20 04:51:48 +00:00
|
|
|
return 25;
|
2024-02-29 04:13:05 +00:00
|
|
|
case EggTier.ULTRA:
|
2023-12-20 04:51:48 +00:00
|
|
|
return 50;
|
|
|
|
}
|
|
|
|
return 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getEggDescriptor(egg: Egg): string {
|
|
|
|
if (egg.isManaphyEgg())
|
|
|
|
return 'Manaphy';
|
|
|
|
switch (egg.tier) {
|
2024-02-29 04:13:05 +00:00
|
|
|
case EggTier.GREAT:
|
2023-12-20 04:51:48 +00:00
|
|
|
return 'Rare';
|
2024-02-29 04:13:05 +00:00
|
|
|
case EggTier.ULTRA:
|
2023-12-20 04:51:48 +00:00
|
|
|
return 'Epic';
|
2024-02-29 04:13:05 +00:00
|
|
|
case EggTier.MASTER:
|
2023-12-20 04:51:48 +00:00
|
|
|
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()})`;
|
2024-03-04 02:30:11 +00:00
|
|
|
case GachaType.MOVE:
|
|
|
|
return 'Rare Egg Move Rate Up';
|
2023-12-20 04:51:48 +00:00
|
|
|
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)
|
2023-12-30 20:58:41 +00:00
|
|
|
.map(s => parseInt(s[0]))
|
|
|
|
.filter(s => getPokemonSpecies(s).isObtainable());
|
2023-12-20 04:51:48 +00:00
|
|
|
|
|
|
|
let ret: Species;
|
|
|
|
|
|
|
|
scene.executeWithSeedOffset(() => {
|
2024-02-17 05:40:03 +00:00
|
|
|
ret = Utils.randSeedItem(legendarySpecies);
|
2023-12-20 04:51:48 +00:00
|
|
|
}, Utils.getSunday(new Date(timestamp)).getTime(), EGG_SEED.toString());
|
|
|
|
|
|
|
|
return ret;
|
2023-12-16 04:07:32 +00:00
|
|
|
}
|