Initially lock Mini Black Hole item

This commit is contained in:
Flashfyre 2023-04-29 01:40:24 -04:00
parent 16fbe971f6
commit 842ea5af40
9 changed files with 92 additions and 11 deletions

View File

@ -4,6 +4,7 @@
"module": "ES2020",
"moduleResolution": "node",
"checkJs": true,
"esModuleInterop": true
"esModuleInterop": true,
"strictNullChecks": false
}
}

View File

@ -26,6 +26,7 @@ import { Weather, WeatherType, getRandomWeatherType, getWeatherDamageMessage, ge
import { TempBattleStat } from "./data/temp-battle-stat";
import { ArenaTrapTag, TrickRoomTag } from "./data/arena-tag";
import { PostWeatherLapseAbAttr, PreWeatherDamageAbAttr, ProtectStatAttr, SuppressWeatherEffectAbAttr, applyPostWeatherLapseAbAttrs, applyPreStatChangeAbAttrs, applyPreWeatherEffectAbAttrs } from "./data/ability";
import { Unlockables, getUnlockableName } from "./system/unlockables";
export class CheckLoadPhase extends BattlePhase {
private loaded: boolean;
@ -1602,6 +1603,39 @@ export class GameOverPhase extends BattlePhase {
});
});
}
end(): void {
if (!this.scene.gameData.unlocks[Unlockables.MINI_BLACK_HOLE])
this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.MINI_BLACK_HOLE));
super.end();
}
}
export class UnlockPhase extends BattlePhase {
private unlockable: Unlockables;
constructor(scene: BattleScene, unlockable: Unlockables) {
super(scene);
this.unlockable = unlockable;
}
start(): void {
this.scene.time.delayedCall(2000, () => {
this.scene.gameData.unlocks[this.unlockable] = true;
this.scene.gameData.saveSystem();
this.scene.sound.play('level_up_fanfare');
this.scene.ui.setMode(Mode.MESSAGE);
this.scene.arenaBg.setVisible(false);
this.scene.ui.fadeIn(250).then(() => {
this.scene.ui.showText(`${getUnlockableName(this.unlockable)}\nhas been unlocked.`, null, () => {
this.scene.time.delayedCall(1500, () => this.scene.arenaBg.setVisible(true));
this.end();
}, null, true, 1500);
});
});
}
}
export class SwitchPhase extends BattlePhase {

View File

@ -17,7 +17,7 @@ const expLevels = [
];
export function getLevelTotalExp(level: integer, growthRate: integer) {
return expLevels[growthRate][Math.min(level, 100) - 1];
return expLevels[growthRate][level - 1];
};
export function getLevelRelExp(level: integer, growthRate: integer) {

View File

@ -168,7 +168,7 @@ export class EvolutionPhase extends BattlePhase {
this.scene.time.delayedCall(1250, () => {
this.scene.sound.play('evolution_fanfare');
this.scene.ui.showText(`Congratulations! Your ${preName}\nevolved into ${pokemon.name}!`, null, () => this.end(), null, true, 3000);
this.scene.time.delayedCall(4250, () => this.scene.playBgm());
this.scene.time.delayedCall(new Utils.FixedInt(4250) as unknown as integer, () => this.scene.playBgm());
});
});
}

View File

@ -10,6 +10,7 @@ import PartyUiHandler, { PokemonMoveSelectFilter, PokemonSelectFilter } from '..
import * as Utils from '../utils';
import { TempBattleStat, getTempBattleStatBoosterItemName, getTempBattleStatName } from '../data/temp-battle-stat';
import { BerryType, getBerryEffectDescription, getBerryName } from '../data/berry';
import { Unlockables } from '../system/unlockables';
type Modifier = Modifiers.Modifier;
@ -702,7 +703,7 @@ const modifierPool = {
[ModifierTier.MASTER]: [
new WeightedModifierType(modifierTypes.MASTER_BALL, 3),
new WeightedModifierType(modifierTypes.SHINY_CHARM, 2),
new WeightedModifierType(modifierTypes.MINI_BLACK_HOLE, 1)
new WeightedModifierType(modifierTypes.MINI_BLACK_HOLE, (party: Pokemon[]) => party[0].scene.gameData.unlocks[Unlockables.MINI_BLACK_HOLE] ? 1 : 0)
].map(m => { m.setTier(ModifierTier.MASTER); return m; }),
[ModifierTier.LUXURY]: [
new WeightedModifierType(modifierTypes.GOLDEN_EXP_CHARM, (party: Pokemon[]) => party.filter(p => p.level < 100).length ? 1 : 0),

View File

@ -1010,10 +1010,12 @@ export class HeldItemTransferModifier extends PokemonHeldItemModifier {
apply(args: any[]): boolean {
const pokemon = args[0] as Pokemon;
const targetPokemon = pokemon.isPlayer() ? pokemon.scene.getEnemyPokemon() : pokemon.scene.getPlayerPokemon();
if (!targetPokemon)
return false;
const transferredModifierTypes: ModifierTypes.ModifierType[] = [];
const itemModifiers = pokemon.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).pokemonId === targetPokemon.id, targetPokemon.isPlayer()) as PokemonHeldItemModifier[];
&& (m as PokemonHeldItemModifier).pokemonId === targetPokemon.id && !m.matchType(this), targetPokemon.isPlayer()) as PokemonHeldItemModifier[];
for (let i = 0; i < this.getStackCount(); i++) {
if (!itemModifiers.length)

View File

@ -402,6 +402,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
console.log(this.species.speciesId, 'ERROR')
return;
}
for (let m = 0; m < allLevelMoves.length; m++) {
const levelMove = allLevelMoves[m];
if (this.level < levelMove[0])
@ -974,6 +975,22 @@ export class EnemyPokemon extends Pokemon {
this.aiType = AiType.SMART_RANDOM;
}
generateAndPopulateMoveset(): void {
switch (true) {
case (this.species.speciesId === Species.ETERNATUS):
this.moveset = [
new PokemonMove(Moves.DYNAMAX_CANNON),
new PokemonMove(Moves.CROSS_POISON),
new PokemonMove(Moves.DRAGON_DANCE),
new PokemonMove(Moves.RECOVER)
];
break;
default:
super.generateAndPopulateMoveset();
break;
}
}
getNextMove(): PokemonMove {
const queuedMove = this.getMoveQueue().length
? this.moveset.find(m => m.moveId === this.getMoveQueue()[0].move)
@ -1116,7 +1133,7 @@ export enum AiType {
RANDOM,
SMART_RANDOM,
SMART
};
}
export enum MoveResult {
EFFECTIVE = 1,
@ -1127,7 +1144,7 @@ export enum MoveResult {
FAILED,
MISSED,
OTHER
};
}
export type DamageResult = MoveResult.EFFECTIVE | MoveResult.SUPER_EFFECTIVE | MoveResult.NOT_VERY_EFFECTIVE | MoveResult.OTHER;

View File

@ -6,17 +6,16 @@ import PokemonSpecies, { allSpecies, getPokemonSpecies } from "../data/pokemon-s
import { Species } from "../data/species";
import * as Utils from "../utils";
import PokemonData from "./pokemon-data";
import { Weather } from "../data/weather";
import PersistentModifierData from "./modifier-data";
import { Biome } from "../data/biome";
import { PokemonHeldItemModifier } from "../modifier/modifier";
import { ArenaTag } from "../data/arena-tag";
import ArenaData from "./arena-data";
import { Unlockables } from "./unlockables";
interface SystemSaveData {
trainerId: integer;
secretId: integer;
dexData: DexData;
unlocks: Unlocks;
timestamp: integer;
}
@ -31,6 +30,10 @@ interface SessionSaveData {
timestamp: integer;
}
interface Unlocks {
[key: integer]: boolean;
}
export interface DexData {
[key: integer]: DexData | DexEntry
}
@ -65,15 +68,20 @@ export class GameData {
public dexData: DexData;
public unlocks: Unlocks;
constructor(scene: BattleScene) {
this.scene = scene;
this.trainerId = Utils.randInt(65536);
this.secretId = Utils.randInt(65536);
this.unlocks = {
[Unlockables.MINI_BLACK_HOLE]: false
};
this.initDexData();
this.loadSystem();
}
private saveSystem(): boolean {
public saveSystem(): boolean {
if (this.scene.quickStart)
return false;
@ -81,6 +89,7 @@ export class GameData {
trainerId: this.trainerId,
secretId: this.secretId,
dexData: this.dexData,
unlocks: this.unlocks,
timestamp: new Date().getTime()
};
@ -99,6 +108,13 @@ export class GameData {
this.trainerId = data.trainerId;
this.secretId = data.secretId;
if (data.unlocks) {
for (let key of Object.keys(data.unlocks)) {
if (this.unlocks.hasOwnProperty(key))
this.unlocks[key] = data.unlocks[key];
}
}
if (data.timestamp === undefined)
this.convertDexData(data.dexData);

10
src/system/unlockables.ts Normal file
View File

@ -0,0 +1,10 @@
export enum Unlockables {
MINI_BLACK_HOLE
}
export function getUnlockableName(unlockable: Unlockables) {
switch (unlockable) {
case Unlockables.MINI_BLACK_HOLE:
return 'MINI BLACK HOLE';
}
}