Add biome flow
parent
1bf0456511
commit
4c892c2c40
|
@ -8,7 +8,6 @@
|
||||||
- Get starters from save data caught Pokemon
|
- Get starters from save data caught Pokemon
|
||||||
- Moves
|
- Moves
|
||||||
- Move logic
|
- Move logic
|
||||||
- Can't use when PP consumed
|
|
||||||
- Abilities
|
- Abilities
|
||||||
- Ability logic
|
- Ability logic
|
||||||
- Ability activation indicator (?)
|
- Ability activation indicator (?)
|
||||||
|
@ -26,7 +25,6 @@
|
||||||
- Status effect indicator
|
- Status effect indicator
|
||||||
- Modifiers
|
- Modifiers
|
||||||
- PP Up
|
- PP Up
|
||||||
- Ether/elixir
|
|
||||||
- Type enhancers
|
- Type enhancers
|
||||||
- Evolution items
|
- Evolution items
|
||||||
- Various mainline game items for various enhancements
|
- Various mainline game items for various enhancements
|
||||||
|
@ -38,6 +36,5 @@
|
||||||
- Custom art
|
- Custom art
|
||||||
- Battle bases and backgrounds
|
- Battle bases and backgrounds
|
||||||
- Game sequence
|
- Game sequence
|
||||||
- Biome sequence (random?)
|
|
||||||
- Endgame?
|
- Endgame?
|
||||||
- Endless mode?
|
- Endless mode?
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 336 B |
Binary file not shown.
After Width: | Height: | Size: 359 B |
|
@ -15,6 +15,7 @@ import EvolutionSceneHandler from "./ui/evolution-scene-handler";
|
||||||
import { EvolutionPhase } from "./evolution-phase";
|
import { EvolutionPhase } from "./evolution-phase";
|
||||||
import { BattlePhase } from "./battle-phase";
|
import { BattlePhase } from "./battle-phase";
|
||||||
import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } from "./battle-stat";
|
import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } from "./battle-stat";
|
||||||
|
import { Biome, biomeLinks } from "./biome";
|
||||||
|
|
||||||
export class SelectStarterPhase extends BattlePhase {
|
export class SelectStarterPhase extends BattlePhase {
|
||||||
constructor(scene: BattleScene) {
|
constructor(scene: BattleScene) {
|
||||||
|
@ -132,7 +133,7 @@ export class NewBiomeEncounterPhase extends NextEncounterPhase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SwitchBiomePhase extends BattlePhase {
|
export class SelectBiomePhase extends BattlePhase {
|
||||||
constructor(scene: BattleScene) {
|
constructor(scene: BattleScene) {
|
||||||
super(scene);
|
super(scene);
|
||||||
}
|
}
|
||||||
|
@ -142,6 +143,35 @@ export class SwitchBiomePhase extends BattlePhase {
|
||||||
|
|
||||||
this.scene.arena.fadeOutBgm(2000);
|
this.scene.arena.fadeOutBgm(2000);
|
||||||
|
|
||||||
|
const currentBiome = this.scene.arena.biomeType;
|
||||||
|
|
||||||
|
const setNextBiome = (nextBiome: Biome) => {
|
||||||
|
this.scene.unshiftPhase(new SwitchBiomePhase(this.scene, nextBiome));
|
||||||
|
this.end();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Array.isArray(biomeLinks[currentBiome]))
|
||||||
|
this.scene.ui.setMode(Mode.BIOME_SELECT, currentBiome, (biomeIndex: integer) => {
|
||||||
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
|
setNextBiome((biomeLinks[currentBiome] as Biome[])[biomeIndex]);
|
||||||
|
});
|
||||||
|
else
|
||||||
|
setNextBiome(biomeLinks[currentBiome] as Biome)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SwitchBiomePhase extends BattlePhase {
|
||||||
|
private nextBiome: Biome;
|
||||||
|
|
||||||
|
constructor(scene: BattleScene, nextBiome: Biome) {
|
||||||
|
super(scene);
|
||||||
|
|
||||||
|
this.nextBiome = nextBiome;
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
super.start();
|
||||||
|
|
||||||
this.scene.tweens.add({
|
this.scene.tweens.add({
|
||||||
targets: this.scene.arenaEnemy,
|
targets: this.scene.arenaEnemy,
|
||||||
x: '+=300',
|
x: '+=300',
|
||||||
|
@ -149,7 +179,7 @@ export class SwitchBiomePhase extends BattlePhase {
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
this.scene.arenaEnemy.setX(this.scene.arenaEnemy.x - 600);
|
this.scene.arenaEnemy.setX(this.scene.arenaEnemy.x - 600);
|
||||||
|
|
||||||
this.scene.newBiome();
|
this.scene.newBiome(this.nextBiome);
|
||||||
|
|
||||||
const biomeKey = this.scene.arena.getBiomeKey();
|
const biomeKey = this.scene.arena.getBiomeKey();
|
||||||
const bgTexture = `${biomeKey}_bg`;
|
const bgTexture = `${biomeKey}_bg`;
|
||||||
|
@ -380,6 +410,7 @@ export class CommandPhase extends BattlePhase {
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
const enemyMove = enemyPokemon.getNextMove();
|
const enemyMove = enemyPokemon.getNextMove();
|
||||||
const enemyPhase = new EnemyMovePhase(this.scene, enemyPokemon, enemyMove);
|
const enemyPhase = new EnemyMovePhase(this.scene, enemyPokemon, enemyMove);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Phaser from 'phaser';
|
import Phaser from 'phaser';
|
||||||
import { Biome, BiomeArena } from './biome';
|
import { Biome, BiomeArena } from './biome';
|
||||||
import UI from './ui/ui';
|
import UI from './ui/ui';
|
||||||
import { EncounterPhase, SummonPhase, CommandPhase, NextEncounterPhase, SwitchBiomePhase, NewBiomeEncounterPhase } from './battle-phases';
|
import { EncounterPhase, SummonPhase, CommandPhase, NextEncounterPhase, SwitchBiomePhase, NewBiomeEncounterPhase, SelectBiomePhase } from './battle-phases';
|
||||||
import { PlayerPokemon, EnemyPokemon } from './pokemon';
|
import { PlayerPokemon, EnemyPokemon } from './pokemon';
|
||||||
import PokemonSpecies, { allSpecies, getPokemonSpecies } from './pokemon-species';
|
import PokemonSpecies, { allSpecies, getPokemonSpecies } from './pokemon-species';
|
||||||
import * as Utils from './utils';
|
import * as Utils from './utils';
|
||||||
|
@ -153,6 +153,9 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
this.loadImage('summary_moves_overlay_pp', 'ui');
|
this.loadImage('summary_moves_overlay_pp', 'ui');
|
||||||
this.loadAtlas('summary_moves_cursor', 'ui');
|
this.loadAtlas('summary_moves_cursor', 'ui');
|
||||||
|
|
||||||
|
this.loadImage('biome_select_window_2', 'ui');
|
||||||
|
this.loadImage('biome_select_window_3', 'ui');
|
||||||
|
|
||||||
// Load arena images
|
// Load arena images
|
||||||
Utils.getEnumValues(Biome).map(at => {
|
Utils.getEnumValues(Biome).map(at => {
|
||||||
const atKey = Biome[at].toLowerCase();
|
const atKey = Biome[at].toLowerCase();
|
||||||
|
@ -238,25 +241,6 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
|
|
||||||
this.field = field;
|
this.field = field;
|
||||||
|
|
||||||
this.newBiome();
|
|
||||||
|
|
||||||
const biomeKey = this.arena.getBiomeKey();
|
|
||||||
this.arenaBg = this.add.sprite(0, 0, `${biomeKey}_bg`);
|
|
||||||
this.arenaBgTransition = this.add.sprite(0, 0, `${biomeKey}_bg`);
|
|
||||||
this.arenaPlayer = this.add.sprite(340, 20, `${biomeKey}_a`);
|
|
||||||
this.arenaPlayerTransition = this.add.sprite(40, 20, `${biomeKey}_a`);
|
|
||||||
this.arenaEnemy = this.add.sprite(-240, 13, `${biomeKey}_b`);
|
|
||||||
this.arenaNextEnemy = this.add.sprite(-240, 13, `${biomeKey}_b`);
|
|
||||||
|
|
||||||
this.arenaBgTransition.setVisible(false);
|
|
||||||
this.arenaPlayerTransition.setVisible(false);
|
|
||||||
|
|
||||||
[this.arenaBg, this.arenaBgTransition, this.arenaPlayer, this.arenaPlayerTransition, this.arenaEnemy, this.arenaNextEnemy].forEach(a => {
|
|
||||||
a.setOrigin(0, 0);
|
|
||||||
field.add(a);
|
|
||||||
});
|
|
||||||
this.arena.playBgm();
|
|
||||||
|
|
||||||
const fieldUI = this.add.container(0, this.game.canvas.height);
|
const fieldUI = this.add.container(0, this.game.canvas.height);
|
||||||
fieldUI.setDepth(1);
|
fieldUI.setDepth(1);
|
||||||
fieldUI.setScale(6);
|
fieldUI.setScale(6);
|
||||||
|
@ -281,6 +265,29 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
|
|
||||||
const isRandom = this.isButtonPressed(Button.RANDOM); // For testing purposes
|
const isRandom = this.isButtonPressed(Button.RANDOM); // For testing purposes
|
||||||
|
|
||||||
|
if (isRandom) {
|
||||||
|
const biomes = Utils.getEnumValues(Biome);
|
||||||
|
this.newBiome(biomes[Utils.randInt(biomes.length)]);
|
||||||
|
} else
|
||||||
|
this.newBiome(Biome.PLAINS);
|
||||||
|
|
||||||
|
const biomeKey = this.arena.getBiomeKey();
|
||||||
|
this.arenaBg = this.add.sprite(0, 0, `${biomeKey}_bg`);
|
||||||
|
this.arenaBgTransition = this.add.sprite(0, 0, `${biomeKey}_bg`);
|
||||||
|
this.arenaPlayer = this.add.sprite(340, 20, `${biomeKey}_a`);
|
||||||
|
this.arenaPlayerTransition = this.add.sprite(40, 20, `${biomeKey}_a`);
|
||||||
|
this.arenaEnemy = this.add.sprite(-240, 13, `${biomeKey}_b`);
|
||||||
|
this.arenaNextEnemy = this.add.sprite(-240, 13, `${biomeKey}_b`);
|
||||||
|
|
||||||
|
this.arenaBgTransition.setVisible(false);
|
||||||
|
this.arenaPlayerTransition.setVisible(false);
|
||||||
|
|
||||||
|
[this.arenaBg, this.arenaBgTransition, this.arenaPlayer, this.arenaPlayerTransition, this.arenaEnemy, this.arenaNextEnemy].forEach(a => {
|
||||||
|
a.setOrigin(0, 0);
|
||||||
|
field.add(a);
|
||||||
|
});
|
||||||
|
this.arena.playBgm();
|
||||||
|
|
||||||
for (let s = 0; s < 3; s++) {
|
for (let s = 0; s < 3; s++) {
|
||||||
const playerSpecies = !isRandom ? getPokemonSpecies(s === 0 ? Species.TORCHIC : s === 1 ? Species.TREECKO : Species.MUDKIP) : this.randomSpecies(5);
|
const playerSpecies = !isRandom ? getPokemonSpecies(s === 0 ? Species.TORCHIC : s === 1 ? Species.TREECKO : Species.MUDKIP) : this.randomSpecies(5);
|
||||||
const playerPokemon = new PlayerPokemon(this, playerSpecies, 5);
|
const playerPokemon = new PlayerPokemon(this, playerSpecies, 5);
|
||||||
|
@ -378,7 +385,7 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
if (this.currentBattle.waveIndex % 10)
|
if (this.currentBattle.waveIndex % 10)
|
||||||
this.unshiftPhase(new NextEncounterPhase(this));
|
this.unshiftPhase(new NextEncounterPhase(this));
|
||||||
else {
|
else {
|
||||||
this.unshiftPhase(new SwitchBiomePhase(this));
|
this.unshiftPhase(new SelectBiomePhase(this));
|
||||||
this.unshiftPhase(new NewBiomeEncounterPhase(this));
|
this.unshiftPhase(new NewBiomeEncounterPhase(this));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -391,8 +398,7 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
return this.currentBattle;
|
return this.currentBattle;
|
||||||
}
|
}
|
||||||
|
|
||||||
newBiome(): BiomeArena {
|
newBiome(biome: Biome): BiomeArena {
|
||||||
const biome = this.currentBattle ? Utils.randInt(20) as Biome : Biome.PLAINS;
|
|
||||||
this.arena = new BiomeArena(this, biome, Biome[biome].toLowerCase());
|
this.arena = new BiomeArena(this, biome, Biome[biome].toLowerCase());
|
||||||
return this.arena;
|
return this.arena;
|
||||||
}
|
}
|
||||||
|
|
70
src/biome.ts
70
src/biome.ts
|
@ -1,7 +1,7 @@
|
||||||
import BattleScene from "./battle-scene";
|
import BattleScene from "./battle-scene";
|
||||||
import SoundFade from "phaser3-rex-plugins/plugins/soundfade.js";
|
import SoundFade from "phaser3-rex-plugins/plugins/soundfade.js";
|
||||||
import { pokemonEvolutions, SpeciesEvolution } from "./pokemon-evolutions";
|
import { pokemonEvolutions, SpeciesEvolution } from "./pokemon-evolutions";
|
||||||
import { default as PokemonSpecies, allSpecies, getPokemonSpecies } from "./pokemon-species";
|
import { default as PokemonSpecies, getPokemonSpecies } from "./pokemon-species";
|
||||||
import { Species } from "./species";
|
import { Species } from "./species";
|
||||||
import { Type } from './type';
|
import { Type } from './type';
|
||||||
import * as Utils from './utils';
|
import * as Utils from './utils';
|
||||||
|
@ -35,6 +35,54 @@ export enum Biome {
|
||||||
SPACE
|
SPACE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function getBiomeName(biome: Biome) {
|
||||||
|
switch (biome) {
|
||||||
|
case Biome.PLAINS:
|
||||||
|
return 'STARTER PLAINS';
|
||||||
|
case Biome.GRASS:
|
||||||
|
return 'GRASSY FIELD';
|
||||||
|
case Biome.RUINS:
|
||||||
|
return 'ANCIENT RUINS';
|
||||||
|
case Biome.ABYSS:
|
||||||
|
return 'THE ABYSS';
|
||||||
|
case Biome.SPACE:
|
||||||
|
return 'STRATOSPHERE';
|
||||||
|
default:
|
||||||
|
return Biome[biome].replace(/\_/g, ' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BiomeLinks {
|
||||||
|
[key: integer]: Biome | Biome[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const biomeLinks: BiomeLinks = {
|
||||||
|
[Biome.PLAINS]: Biome.GRASS,
|
||||||
|
[Biome.GRASS]: [ Biome.TALL_GRASS, Biome.CITY, Biome.LAKE ],
|
||||||
|
[Biome.TALL_GRASS]: [ Biome.FOREST, Biome.CAVE ],
|
||||||
|
[Biome.CITY]: [ Biome.DOJO, Biome.POWER_PLANT ],
|
||||||
|
[Biome.FOREST]: Biome.MEADOW,
|
||||||
|
[Biome.SEA]: [ Biome.SEABED, Biome.ICE_CAVE ],
|
||||||
|
[Biome.SWAMP]: [ Biome.GRAVEYARD, Biome.TALL_GRASS ],
|
||||||
|
[Biome.BEACH]: Biome.SEA,
|
||||||
|
[Biome.LAKE]: [ Biome.BEACH, Biome.SWAMP ],
|
||||||
|
[Biome.SEABED]: Biome.CAVE,
|
||||||
|
[Biome.MOUNTAIN]: [ Biome.WASTELAND, Biome.VOLCANO ],
|
||||||
|
[Biome.LAND]: [ Biome.DESERT, Biome.MOUNTAIN ],
|
||||||
|
[Biome.CAVE]: [ Biome.LAND, Biome.BEACH ],
|
||||||
|
[Biome.DESERT]: Biome.RUINS,
|
||||||
|
[Biome.ICE_CAVE]: Biome.LAKE,
|
||||||
|
[Biome.MEADOW]: Biome.GRASS,
|
||||||
|
[Biome.POWER_PLANT]: Biome.GRASS,
|
||||||
|
[Biome.VOLCANO]: Biome.ICE_CAVE,
|
||||||
|
[Biome.GRAVEYARD]: Biome.ABYSS,
|
||||||
|
[Biome.DOJO]: Biome.GRASS,
|
||||||
|
[Biome.RUINS]: Biome.FOREST,
|
||||||
|
[Biome.WASTELAND]: Biome.LAND,
|
||||||
|
[Biome.ABYSS]: Biome.SPACE,
|
||||||
|
[Biome.SPACE]: Biome.RUINS
|
||||||
|
};
|
||||||
|
|
||||||
enum PoolTier {
|
enum PoolTier {
|
||||||
COMMON,
|
COMMON,
|
||||||
UNCOMMON,
|
UNCOMMON,
|
||||||
|
@ -47,12 +95,24 @@ enum PoolTier {
|
||||||
BOSS_ULTRA_RARE
|
BOSS_ULTRA_RARE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface SpeciesTree {
|
||||||
|
[key: integer]: Species[]
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BiomeTierPools {
|
||||||
|
[key: integer]: Array<Species | SpeciesTree>
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BiomePools {
|
||||||
|
[key: integer]: BiomeTierPools
|
||||||
|
}
|
||||||
|
|
||||||
export class BiomeArena {
|
export class BiomeArena {
|
||||||
private scene: BattleScene;
|
private scene: BattleScene;
|
||||||
public biomeType: integer;
|
public biomeType: integer;
|
||||||
private bgm: string;
|
private bgm: string;
|
||||||
|
|
||||||
private pokemonPool: PokemonSpecies[][];
|
private pokemonPool: BiomeTierPools;
|
||||||
|
|
||||||
constructor(scene: BattleScene, biome: integer, bgm: string) {
|
constructor(scene: BattleScene, biome: integer, bgm: string) {
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
|
@ -140,7 +200,7 @@ export class BiomeArena {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const biomePools = {
|
const biomePools: BiomePools = {
|
||||||
[Biome.PLAINS]: {
|
[Biome.PLAINS]: {
|
||||||
[PoolTier.COMMON]: [
|
[PoolTier.COMMON]: [
|
||||||
{ 1: [ Species.CATERPIE ], 7: [ Species.METAPOD ] },
|
{ 1: [ Species.CATERPIE ], 7: [ Species.METAPOD ] },
|
||||||
|
@ -3805,8 +3865,10 @@ const biomePools = {
|
||||||
let treeIndex = -1;
|
let treeIndex = -1;
|
||||||
let arrayIndex = 0;
|
let arrayIndex = 0;
|
||||||
|
|
||||||
|
// Not sure why this works but let's just leave it alone until we need it again
|
||||||
|
|
||||||
for (let t = 0; t < biomeTierPool.length; t++) {
|
for (let t = 0; t < biomeTierPool.length; t++) {
|
||||||
const existingSpeciesIds = biomeTierPool[t] as Species[];
|
const existingSpeciesIds = biomeTierPool[t] as SpeciesTree;
|
||||||
for (let es = 0; es < existingSpeciesIds.length; es++) {
|
for (let es = 0; es < existingSpeciesIds.length; es++) {
|
||||||
const existingSpeciesId = existingSpeciesIds[es];
|
const existingSpeciesId = existingSpeciesIds[es];
|
||||||
if (pokemonEvolutions.hasOwnProperty(existingSpeciesId) && (pokemonEvolutions[existingSpeciesId] as SpeciesEvolution[]).find(ese => ese.speciesId === speciesId)) {
|
if (pokemonEvolutions.hasOwnProperty(existingSpeciesId) && (pokemonEvolutions[existingSpeciesId] as SpeciesEvolution[]).find(ese => ese.speciesId === speciesId)) {
|
||||||
|
|
|
@ -766,7 +766,7 @@ const modifierPool = {
|
||||||
const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed)).length;
|
const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed)).length;
|
||||||
return thresholdPartyMemberCount;
|
return thresholdPartyMemberCount;
|
||||||
}),
|
}),
|
||||||
new WeightedModifierType(new PokemonPpRestoreModifierType('MAX ETHER', 100), (party: PlayerPokemon[]) => {
|
new WeightedModifierType(new PokemonPpRestoreModifierType('MAX ETHER', -1), (party: PlayerPokemon[]) => {
|
||||||
const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed > 10)).length;
|
const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed > 10)).length;
|
||||||
return Math.ceil(thresholdPartyMemberCount / 3);
|
return Math.ceil(thresholdPartyMemberCount / 3);
|
||||||
})
|
})
|
||||||
|
@ -793,7 +793,7 @@ const modifierPool = {
|
||||||
const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed)).length;
|
const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed)).length;
|
||||||
return thresholdPartyMemberCount;
|
return thresholdPartyMemberCount;
|
||||||
}),
|
}),
|
||||||
new WeightedModifierType(new PokemonAllMovePpRestoreModifierType('MAX ELIXIR', 100), (party: PlayerPokemon[]) => {
|
new WeightedModifierType(new PokemonAllMovePpRestoreModifierType('MAX ELIXIR', -1), (party: PlayerPokemon[]) => {
|
||||||
const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed > 10)).length;
|
const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed > 10)).length;
|
||||||
return Math.ceil(thresholdPartyMemberCount / 3);
|
return Math.ceil(thresholdPartyMemberCount / 3);
|
||||||
}),
|
}),
|
||||||
|
@ -863,16 +863,13 @@ export function regenerateModifierPoolThresholds(party: PlayerPokemon[]) {
|
||||||
console.log(modifierPoolThresholds)
|
console.log(modifierPoolThresholds)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getModifierTypesForWave(waveIndex: integer, count: integer, party: PlayerPokemon[]): Array<ModifierType> {
|
export function getModifierTypesForWave(waveIndex: integer, count: integer, party: PlayerPokemon[]): ModifierType[] {
|
||||||
if (waveIndex % 10 === 0)
|
if (waveIndex % 10 === 0)
|
||||||
return modifierPool[ModifierTier.LUXURY];
|
return modifierPool[ModifierTier.LUXURY];
|
||||||
const ret = [];
|
return new Array(count).fill(0).map(() => getNewModifierType(party));
|
||||||
for (let m = 0; m < count; m++)
|
|
||||||
ret.push(getNewModifierType(party));
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNewModifierType(party: PlayerPokemon[]) {
|
function getNewModifierType(party: PlayerPokemon[]): ModifierType {
|
||||||
const tierValue = Utils.randInt(256);
|
const tierValue = Utils.randInt(256);
|
||||||
const tier = tierValue >= 52 ? ModifierTier.COMMON : tierValue >= 8 ? ModifierTier.GREAT : tierValue >= 1 ? ModifierTier.ULTRA : ModifierTier.MASTER;
|
const tier = tierValue >= 52 ? ModifierTier.COMMON : tierValue >= 8 ? ModifierTier.GREAT : tierValue >= 1 ? ModifierTier.ULTRA : ModifierTier.MASTER;
|
||||||
const thresholds = Object.keys(modifierPoolThresholds[tier]);
|
const thresholds = Object.keys(modifierPoolThresholds[tier]);
|
||||||
|
@ -892,5 +889,5 @@ function getNewModifierType(party: PlayerPokemon[]) {
|
||||||
modifierType = (modifierType as WeightedModifierType).modifierType;
|
modifierType = (modifierType as WeightedModifierType).modifierType;
|
||||||
if (modifierType instanceof ModifierTypeGenerator)
|
if (modifierType instanceof ModifierTypeGenerator)
|
||||||
modifierType = (modifierType as ModifierTypeGenerator).generateType(party);
|
modifierType = (modifierType as ModifierTypeGenerator).generateType(party);
|
||||||
return modifierType;
|
return modifierType as ModifierType;
|
||||||
}
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
import BattleScene, { Button } from "../battle-scene";
|
||||||
|
import { Biome, biomeLinks, getBiomeName } from "../biome";
|
||||||
|
import { addTextObject, TextStyle } from "../text";
|
||||||
|
import { Mode } from "./ui";
|
||||||
|
import UiHandler from "./uiHandler";
|
||||||
|
|
||||||
|
export default class BiomeSelectUiHandler extends UiHandler {
|
||||||
|
private biomeSelectContainer: Phaser.GameObjects.Container;
|
||||||
|
private biomeSelectBg: Phaser.GameObjects.Image;
|
||||||
|
private biomesText: Phaser.GameObjects.Text;
|
||||||
|
private biomeChoices: Biome[];
|
||||||
|
|
||||||
|
private cursorObj: Phaser.GameObjects.Image;
|
||||||
|
|
||||||
|
private biomeSelectHandler: Function;
|
||||||
|
|
||||||
|
constructor(scene: BattleScene) {
|
||||||
|
super(scene, Mode.BIOME_SELECT);
|
||||||
|
}
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
const ui = this.getUi();
|
||||||
|
|
||||||
|
this.biomeSelectContainer = this.scene.add.container((this.scene.game.canvas.width / 6) - 97, -49);
|
||||||
|
this.biomeSelectContainer.setVisible(false);
|
||||||
|
ui.add(this.biomeSelectContainer);
|
||||||
|
|
||||||
|
this.biomeSelectBg = this.scene.add.image(0, 0, 'biome_select_window_2');
|
||||||
|
this.biomeSelectBg.setOrigin(0, 1);
|
||||||
|
this.biomeSelectContainer.add(this.biomeSelectBg);
|
||||||
|
|
||||||
|
this.biomesText = addTextObject(this.scene, 0, 0, '', TextStyle.WINDOW, { maxLines: 3 });
|
||||||
|
this.biomesText.setLineSpacing(12);
|
||||||
|
this.biomeSelectContainer.add(this.biomesText);
|
||||||
|
}
|
||||||
|
|
||||||
|
show(args: any[]) {
|
||||||
|
if (args.length >= 2 && typeof(args[0]) === 'number' && args[1] instanceof Function) {
|
||||||
|
super.show(args);
|
||||||
|
|
||||||
|
if (!Array.isArray(biomeLinks[args[0]]))
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.biomeChoices = biomeLinks[args[0]] as Biome[];
|
||||||
|
this.biomeSelectBg.setTexture(`biome_select_window_${this.biomeChoices.length}`)
|
||||||
|
this.biomesText.setText(this.biomeChoices.map(b => getBiomeName(b)).join('\n'));
|
||||||
|
this.biomesText.setPositionRelative(this.biomeSelectBg, 16, 9);
|
||||||
|
this.biomeSelectHandler = args[1] as Function;
|
||||||
|
|
||||||
|
this.biomeSelectContainer.setVisible(true);
|
||||||
|
this.setCursor(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processInput(button: Button) {
|
||||||
|
const ui = this.getUi();
|
||||||
|
|
||||||
|
let success = false;
|
||||||
|
|
||||||
|
if (button === Button.ACTION || button === Button.CANCEL) {
|
||||||
|
success = true;
|
||||||
|
const originalBiomeSelectHandler = this.biomeSelectHandler;
|
||||||
|
this.biomeSelectHandler = null;
|
||||||
|
originalBiomeSelectHandler(this.cursor);
|
||||||
|
this.clear();
|
||||||
|
} else {
|
||||||
|
switch (button) {
|
||||||
|
case Button.UP:
|
||||||
|
if (this.cursor)
|
||||||
|
success = this.setCursor(this.cursor - 1);
|
||||||
|
break;
|
||||||
|
case Button.DOWN:
|
||||||
|
if (this.cursor < this.biomeChoices.length - 1)
|
||||||
|
success = this.setCursor(this.cursor + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
ui.playSelect();
|
||||||
|
}
|
||||||
|
|
||||||
|
setCursor(cursor: integer): boolean {
|
||||||
|
const ret = super.setCursor(cursor);
|
||||||
|
|
||||||
|
if (!this.cursorObj) {
|
||||||
|
this.cursorObj = this.scene.add.image(0, 0, 'cursor');
|
||||||
|
this.biomeSelectContainer.add(this.cursorObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.cursorObj.setPositionRelative(this.biomeSelectBg, 12, 17 + 16 * this.cursor);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
super.clear();
|
||||||
|
this.biomeSelectContainer.setVisible(false);
|
||||||
|
this.biomeSelectHandler = null;
|
||||||
|
this.eraseCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
eraseCursor() {
|
||||||
|
if (this.cursorObj)
|
||||||
|
this.cursorObj.destroy();
|
||||||
|
this.cursorObj = null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import BallUiHandler from './ball-ui-handler';
|
||||||
import SummaryUiHandler from './summary-ui-handler';
|
import SummaryUiHandler from './summary-ui-handler';
|
||||||
import StarterSelectUiHandler from './starter-select-ui-handler';
|
import StarterSelectUiHandler from './starter-select-ui-handler';
|
||||||
import EvolutionSceneHandler from './evolution-scene-handler';
|
import EvolutionSceneHandler from './evolution-scene-handler';
|
||||||
|
import BiomeSelectUiHandler from './biome-select-ui-handler';
|
||||||
|
|
||||||
export enum Mode {
|
export enum Mode {
|
||||||
MESSAGE = 0,
|
MESSAGE = 0,
|
||||||
|
@ -21,6 +22,7 @@ export enum Mode {
|
||||||
PARTY,
|
PARTY,
|
||||||
CONFIRM,
|
CONFIRM,
|
||||||
SUMMARY,
|
SUMMARY,
|
||||||
|
BIOME_SELECT,
|
||||||
STARTER_SELECT,
|
STARTER_SELECT,
|
||||||
EVOLUTION_SCENE
|
EVOLUTION_SCENE
|
||||||
};
|
};
|
||||||
|
@ -56,6 +58,7 @@ export default class UI extends Phaser.GameObjects.Container {
|
||||||
new PartyUiHandler(scene),
|
new PartyUiHandler(scene),
|
||||||
new ConfirmUiHandler(scene),
|
new ConfirmUiHandler(scene),
|
||||||
new SummaryUiHandler(scene),
|
new SummaryUiHandler(scene),
|
||||||
|
new BiomeSelectUiHandler(scene),
|
||||||
new StarterSelectUiHandler(scene),
|
new StarterSelectUiHandler(scene),
|
||||||
new EvolutionSceneHandler(scene)
|
new EvolutionSceneHandler(scene)
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue