Add starter values with limit and add generated fusion names

pull/12/head
Flashfyre 2023-12-01 17:23:26 -05:00
parent b2d7895c7b
commit ab344cd82a
9 changed files with 531 additions and 72 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -270,7 +270,7 @@ export class EncounterPhase extends BattlePhase {
loadEnemyAssets.push(enemyPokemon.loadAssets());
console.log(enemyPokemon.species.name, enemyPokemon.species.speciesId, enemyPokemon.stats);
console.log(enemyPokemon.name, enemyPokemon.species.speciesId, enemyPokemon.stats);
});
if (battle.battleType === BattleType.TRAINER)

View File

@ -1,11 +1,10 @@
import { Abilities, Ability } from './ability';
import { Abilities } from './ability';
import BattleScene, { AnySound } from '../battle-scene';
import { GrowthRate } from './exp';
import { SpeciesWildEvolutionDelay, pokemonEvolutions, pokemonPrevolutions } from './pokemon-evolutions';
import { Species } from './species';
import { Type } from './type';
import * as Utils from '../utils';
import { TrainerType, trainerConfigs } from './trainer-type';
import { LevelMoves, pokemonFormLevelMoves as pokemonSpeciesFormLevelMoves, pokemonSpeciesLevelMoves } from './pokemon-level-moves';
export function getPokemonSpecies(species: Species): PokemonSpecies {
@ -14,6 +13,41 @@ export function getPokemonSpecies(species: Species): PokemonSpecies {
return allSpecies[species - 1];
}
export function getFusedSpeciesName(speciesAName: string, speciesBName: string): string {
const fragAPattern = /([a-z]{2}.*?[aeiou(?:y$)\-\']+)(.*?)$/i;
const fragBPattern = /([a-z]{2}.*?[aeiou(?:y$)\-\'])(.*?)$/i;
const splitNameA = speciesAName.split(/ /g);
const splitNameB = speciesBName.split(/ /g);
let fragAMatch = fragAPattern.exec(speciesAName);
let fragBMatch = fragBPattern.exec(speciesBName);
let fragA: string;
let fragB: string;
fragA = splitNameA.length === 1
? fragAMatch ? fragAMatch[1] : speciesAName
: splitNameA[splitNameA.length - 1];
if (splitNameB.length === 1) {
if (fragBMatch) {
const lastCharA = fragA.slice(fragA.length - 1);
const prevCharB = fragBMatch[1].slice(fragBMatch.length - 1);
fragB = (/[\-']/.test(prevCharB) || /[aeiou]/i.test(lastCharA) ? prevCharB : '') + fragBMatch[2] || prevCharB;
if (lastCharA === fragB[0] && /[aiu]/.test(lastCharA))
fragB = fragB.slice(1);
} else
fragB = speciesBName;
} else
fragB = splitNameB[splitNameB.length - 1];
if (splitNameA.length > 1)
fragA = `${splitNameA.slice(0, splitNameA.length - 1).join(' ')} ${fragA}`;
return `${fragA}${fragB}`;
}
export type PokemonSpeciesFilter = (species: PokemonSpecies) => boolean;
export abstract class PokemonSpeciesForm {
@ -1193,6 +1227,343 @@ export function initSpecies() {
);
}
export const speciesStarters = {
[Species.BULBASAUR]: 3,
[Species.CHARMANDER]: 3,
[Species.SQUIRTLE]: 3,
[Species.CATERPIE]: 1,
[Species.WEEDLE]: 1,
[Species.PIDGEY]: 2,
[Species.RATTATA]: 1,
[Species.SPEAROW]: 2,
[Species.EKANS]: 2,
[Species.PIKACHU]: 4,
[Species.SANDSHREW]: 2,
[Species.NIDORAN_F]: 3,
[Species.NIDORAN_M]: 3,
[Species.VULPIX]: 3,
[Species.ZUBAT]: 2,
[Species.ODDISH]: 2,
[Species.PARAS]: 1,
[Species.VENONAT]: 2,
[Species.DIGLETT]: 3,
[Species.MEOWTH]: 4,
[Species.PSYDUCK]: 2,
[Species.MANKEY]: 4,
[Species.GROWLITHE]: 4,
[Species.POLIWAG]: 3,
[Species.ABRA]: 3,
[Species.MACHOP]: 3,
[Species.BELLSPROUT]: 3,
[Species.TENTACOOL]: 3,
[Species.GEODUDE]: 3,
[Species.PONYTA]: 3,
[Species.SLOWPOKE]: 3,
[Species.MAGNEMITE]: 3,
[Species.FARFETCHD]: 4,
[Species.DODUO]: 4,
[Species.SEEL]: 3,
[Species.GRIMER]: 3,
[Species.SHELLDER]: 4,
[Species.GASTLY]: 3,
[Species.ONIX]: 4,
[Species.DROWZEE]: 3,
[Species.KRABBY]: 2,
[Species.VOLTORB]: 2,
[Species.EXEGGCUTE]: 4,
[Species.CUBONE]: 3,
[Species.LICKITUNG]: 5,
[Species.KOFFING]: 3,
[Species.RHYHORN]: 3,
[Species.TANGELA]: 3,
[Species.KANGASKHAN]: 5,
[Species.HORSEA]: 4,
[Species.GOLDEEN]: 3,
[Species.STARYU]: 4,
[Species.SCYTHER]: 5,
[Species.PINSIR]: 4,
[Species.TAUROS]: 5,
[Species.MAGIKARP]: 3,
[Species.LAPRAS]: 5,
[Species.DITTO]: 2,
[Species.EEVEE]: 4,
[Species.PORYGON]: 4,
[Species.OMANYTE]: 3,
[Species.KABUTO]: 3,
[Species.AERODACTYL]: 5,
[Species.ARTICUNO]: 6,
[Species.ZAPDOS]: 6,
[Species.MOLTRES]: 6,
[Species.DRATINI]: 4,
[Species.MEWTWO]: 8,
[Species.MEW]: 7,
[Species.CHIKORITA]: 3,
[Species.CYNDAQUIL]: 3,
[Species.TOTODILE]: 3,
[Species.SENTRET]: 1,
[Species.HOOTHOOT]: 1,
[Species.LEDYBA]: 1,
[Species.SPINARAK]: 1,
[Species.CHINCHOU]: 3,
[Species.PICHU]: 3,
[Species.CLEFFA]: 3,
[Species.IGGLYBUFF]: 3,
[Species.TOGEPI]: 3,
[Species.NATU]: 2,
[Species.MAREEP]: 3,
[Species.HOPPIP]: 1,
[Species.AIPOM]: 3,
[Species.SUNKERN]: 1,
[Species.YANMA]: 3,
[Species.WOOPER]: 2,
[Species.MURKROW]: 4,
[Species.MISDREAVUS]: 3,
[Species.UNOWN]: 1,
[Species.GIRAFARIG]: 4,
[Species.PINECO]: 2,
[Species.DUNSPARCE]: 4,
[Species.GLIGAR]: 4,
[Species.SNUBBULL]: 3,
[Species.QWILFISH]: 3,
[Species.SHUCKLE]: 4,
[Species.HERACROSS]: 5,
[Species.SNEASEL]: 4,
[Species.TEDDIURSA]: 4,
[Species.SLUGMA]: 2,
[Species.SWINUB]: 3,
[Species.CORSOLA]: 3,
[Species.REMORAID]: 3,
[Species.DELIBIRD]: 3,
[Species.SKARMORY]: 5,
[Species.HOUNDOUR]: 4,
[Species.PHANPY]: 3,
[Species.STANTLER]: 4,
[Species.SMEARGLE]: 3,
[Species.TYROGUE]: 4,
[Species.SMOOCHUM]: 3,
[Species.ELEKID]: 4,
[Species.MAGBY]: 4,
[Species.MILTANK]: 5,
[Species.RAIKOU]: 6,
[Species.ENTEI]: 6,
[Species.SUICUNE]: 6,
[Species.LARVITAR]: 4,
[Species.LUGIA]: 8,
[Species.HO_OH]: 8,
[Species.CELEBI]: 7,
[Species.TREECKO]: 3,
[Species.TORCHIC]: 3,
[Species.MUDKIP]: 3,
[Species.POOCHYENA]: 2,
[Species.ZIGZAGOON]: 2,
[Species.WURMPLE]: 1,
[Species.LOTAD]: 3,
[Species.SEEDOT]: 3,
[Species.TAILLOW]: 3,
[Species.WINGULL]: 3,
[Species.RALTS]: 3,
[Species.SURSKIT]: 2,
[Species.SHROOMISH]: 3,
[Species.SLAKOTH]: 4,
[Species.NINCADA]: 4,
[Species.WHISMUR]: 2,
[Species.MAKUHITA]: 3,
[Species.AZURILL]: 3,
[Species.NOSEPASS]: 3,
[Species.SKITTY]: 3,
[Species.SABLEYE]: 3,
[Species.MAWILE]: 5,
[Species.ARON]: 3,
[Species.MEDITITE]: 4,
[Species.ELECTRIKE]: 3,
[Species.PLUSLE]: 2,
[Species.MINUN]: 2,
[Species.VOLBEAT]: 2,
[Species.ILLUMISE]: 2,
[Species.GULPIN]: 3,
[Species.CARVANHA]: 3,
[Species.WAILMER]: 3,
[Species.NUMEL]: 3,
[Species.TORKOAL]: 4,
[Species.SPOINK]: 3,
[Species.SPINDA]: 2,
[Species.TRAPINCH]: 4,
[Species.CACNEA]: 3,
[Species.SWABLU]: 3,
[Species.ZANGOOSE]: 5,
[Species.SEVIPER]: 4,
[Species.LUNATONE]: 4,
[Species.SOLROCK]: 4,
[Species.BARBOACH]: 3,
[Species.CORPHISH]: 3,
[Species.BALTOY]: 3,
[Species.LILEEP]: 3,
[Species.ANORITH]: 3,
[Species.FEEBAS]: 4,
[Species.CASTFORM]: 2,
[Species.KECLEON]: 4,
[Species.SHUPPET]: 3,
[Species.DUSKULL]: 3,
[Species.TROPIUS]: 5,
[Species.ABSOL]: 5,
[Species.WYNAUT]: 3,
[Species.SNORUNT]: 3,
[Species.SPHEAL]: 3,
[Species.CLAMPERL]: 3,
[Species.RELICANTH]: 4,
[Species.LUVDISC]: 2,
[Species.BAGON]: 4,
[Species.BELDUM]: 4,
[Species.REGIROCK]: 6,
[Species.REGICE]: 6,
[Species.REGISTEEL]: 6,
[Species.LATIAS]: 7,
[Species.LATIOS]: 7,
[Species.KYOGRE]: 8,
[Species.GROUDON]: 8,
[Species.RAYQUAZA]: 8,
[Species.JIRACHI]: 7,
[Species.DEOXYS]: 8,
[Species.TURTWIG]: 3,
[Species.CHIMCHAR]: 3,
[Species.PIPLUP]: 3,
[Species.STARLY]: 3,
[Species.BIDOOF]: 2,
[Species.KRICKETOT]: 1,
[Species.SHINX]: 3,
[Species.BUDEW]: 3,
[Species.CRANIDOS]: 3,
[Species.SHIELDON]: 3,
[Species.BURMY]: 1,
[Species.COMBEE]: 2,
[Species.PACHIRISU]: 3,
[Species.BUIZEL]: 3,
[Species.CHERUBI]: 3,
[Species.SHELLOS]: 3,
[Species.DRIFLOON]: 3,
[Species.BUNEARY]: 3,
[Species.GLAMEOW]: 3,
[Species.CHINGLING]: 3,
[Species.STUNKY]: 3,
[Species.BRONZOR]: 3,
[Species.BONSLY]: 3,
[Species.MIME_JR]: 3,
[Species.HAPPINY]: 4,
[Species.CHATOT]: 4,
[Species.SPIRITOMB]: 5,
[Species.GIBLE]: 4,
[Species.MUNCHLAX]: 4,
[Species.RIOLU]: 5,
[Species.HIPPOPOTAS]: 3,
[Species.SKORUPI]: 3,
[Species.CROAGUNK]: 3,
[Species.CARNIVINE]: 4,
[Species.FINNEON]: 3,
[Species.MANTYKE]: 3,
[Species.SNOVER]: 3,
[Species.ROTOM]: 5,
[Species.UXIE]: 7,
[Species.MESPRIT]: 7,
[Species.AZELF]: 7,
[Species.DIALGA]: 8,
[Species.PALKIA]: 8,
[Species.HEATRAN]: 7,
[Species.REGIGIGAS]: 8,
[Species.GIRATINA]: 8,
[Species.CRESSELIA]: 7,
[Species.PHIONE]: 5,
[Species.MANAPHY]: 7,
[Species.DARKRAI]: 7,
[Species.SHAYMIN]: 7,
[Species.ARCEUS]: 9,
[Species.VICTINI]: 8,
[Species.SNIVY]: 3,
[Species.TEPIG]: 3,
[Species.OSHAWOTT]: 3,
[Species.PATRAT]: 2,
[Species.LILLIPUP]: 3,
[Species.PURRLOIN]: 3,
[Species.PANSAGE]: 3,
[Species.PANSEAR]: 3,
[Species.PANPOUR]: 3,
[Species.MUNNA]: 3,
[Species.PIDOVE]: 2,
[Species.BLITZLE]: 3,
[Species.ROGGENROLA]: 3,
[Species.WOOBAT]: 3,
[Species.DRILBUR]: 4,
[Species.AUDINO]: 4,
[Species.TIMBURR]: 3,
[Species.TYMPOLE]: 3,
[Species.THROH]: 5,
[Species.SAWK]: 5,
[Species.SEWADDLE]: 3,
[Species.VENIPEDE]: 3,
[Species.COTTONEE]: 3,
[Species.PETILIL]: 3,
[Species.BASCULIN]: 4,
[Species.SANDILE]: 3,
[Species.DARUMAKA]: 4,
[Species.MARACTUS]: 4,
[Species.DWEBBLE]: 3,
[Species.SCRAGGY]: 3,
[Species.SIGILYPH]: 5,
[Species.YAMASK]: 3,
[Species.TIRTOUGA]: 4,
[Species.ARCHEN]: 4,
[Species.TRUBBISH]: 3,
[Species.ZORUA]: 3,
[Species.MINCCINO]: 3,
[Species.GOTHITA]: 3,
[Species.SOLOSIS]: 3,
[Species.DUCKLETT]: 3,
[Species.VANILLITE]: 3,
[Species.DEERLING]: 3,
[Species.EMOLGA]: 4,
[Species.KARRABLAST]: 3,
[Species.FOONGUS]: 3,
[Species.FRILLISH]: 3,
[Species.ALOMOMOLA]: 4,
[Species.JOLTIK]: 3,
[Species.FERROSEED]: 3,
[Species.KLINK]: 3,
[Species.TYNAMO]: 3,
[Species.ELGYEM]: 3,
[Species.LITWICK]: 3,
[Species.AXEW]: 4,
[Species.CUBCHOO]: 3,
[Species.CRYOGONAL]: 5,
[Species.SHELMET]: 3,
[Species.STUNFISK]: 4,
[Species.MIENFOO]: 3,
[Species.DRUDDIGON]: 5,
[Species.GOLETT]: 3,
[Species.PAWNIARD]: 4,
[Species.BOUFFALANT]: 5,
[Species.RUFFLET]: 3,
[Species.VULLABY]: 3,
[Species.HEATMOR]: 5,
[Species.DURANT]: 5,
[Species.DEINO]: 4,
[Species.LARVESTA]: 4,
[Species.COBALION]: 6,
[Species.TERRAKION]: 6,
[Species.VIRIZION]: 6,
[Species.TORNADUS]: 7,
[Species.THUNDURUS]: 7,
[Species.RESHIRAM]: 8,
[Species.ZEKROM]: 8,
[Species.LANDORUS]: 7,
[Species.KYUREM]: 8,
[Species.KELDEO]: 7,
[Species.MELOETTA]: 7,
[Species.GENESECT]: 8
};
// TODO: Remove
{
//setTimeout(() => {

View File

@ -2,7 +2,7 @@ import Phaser from 'phaser';
import BattleScene, { AnySound } from './battle-scene';
import BattleInfo, { PlayerBattleInfo, EnemyBattleInfo } from './ui/battle-info';
import Move, { HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariablePowerAttr, Moves, allMoves, MoveCategory, TypelessAttr, CritOnlyAttr, getMoveTargets, AttackMove, AddBattlerTagAttr, OneHitKOAttr } from "./data/move";
import { default as PokemonSpecies, PokemonSpeciesForm, getPokemonSpecies } from './data/pokemon-species';
import { default as PokemonSpecies, PokemonSpeciesForm, getFusedSpeciesName, getPokemonSpecies } from './data/pokemon-species';
import * as Utils from './utils';
import { Type, TypeDamageMultiplier, getTypeDamageMultiplier } from './data/type';
import { getLevelTotalExp } from './data/exp';
@ -98,7 +98,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
const hasHiddenAbility = !Utils.randSeedInt(hiddenAbilityChance.value);
const randAbilityIndex = Utils.randSeedInt(2);
this.name = species.name;
this.species = species;
this.battleInfo = this.isPlayer()
? new PlayerBattleInfo(scene)
@ -162,6 +161,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.generateFusionSpecies();
}
this.generateName();
if (!species.isObtainable())
this.shiny = false;
@ -233,6 +234,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return ret;
}
generateName(): void {
if (!this.fusionSpecies) {
this.name = this.species.name;
return;
}
this.name = getFusedSpeciesName(this.species.name, this.fusionSpecies.name);
}
abstract isPlayer(): boolean;
abstract hasTrainer(): boolean;
@ -1679,7 +1688,7 @@ export class PlayerPokemon extends Pokemon {
return new Promise(resolve => {
this.handleSpecialEvolutions(evolution);
this.species = getPokemonSpecies(evolution.speciesId);
this.name = this.species.name;
this.generateName();
const abilityCount = this.getSpeciesForm().getAbilityCount();
if (this.abilityIndex >= abilityCount) // Shouldn't happen
this.abilityIndex = abilityCount - 1;
@ -1732,6 +1741,7 @@ export class PlayerPokemon extends Pokemon {
this.scene.validateAchv(achvs.SPLICE);
this.generateName();
this.calculateStats();
this.generateCompatibleTms();
this.updateInfo(true).then(() => {
@ -1760,6 +1770,7 @@ export class PlayerPokemon extends Pokemon {
this.fusionShiny = false;
this.fusionGender = 0;
this.generateName();
this.calculateStats();
this.generateCompatibleTms();
this.updateInfo(true).then(() => resolve());

View File

@ -1,7 +1,7 @@
import BattleScene, { PokeballCounts } from "../battle-scene";
import Pokemon, { EnemyPokemon, PlayerPokemon } from "../pokemon";
import { pokemonPrevolutions } from "../data/pokemon-evolutions";
import PokemonSpecies, { allSpecies, getPokemonSpecies } from "../data/pokemon-species";
import PokemonSpecies, { allSpecies, getPokemonSpecies, speciesStarters } from "../data/pokemon-species";
import { Species } from "../data/species";
import * as Utils from "../utils";
import PokemonData from "./pokemon-data";
@ -376,17 +376,19 @@ export class GameData {
const hasPrevolution = pokemonPrevolutions.hasOwnProperty(species.speciesId);
const newCatch = !caughtAttr;
if (newCatch && !hasPrevolution) {
this.scene.playSoundWithoutBgm('level_up_fanfare', 1500);
this.scene.ui.showText(`${species.name} has been\nadded as a starter!`, null, () => resolve(), null, true);
return;
}
const checkPrevolution = () => {
if (hasPrevolution) {
const prevolutionSpecies = pokemonPrevolutions[species.speciesId];
return this.setPokemonSpeciesCaught(pokemon, getPokemonSpecies(prevolutionSpecies)).then(() => resolve());
} else
resolve();
};
if (hasPrevolution) {
const prevolutionSpecies = pokemonPrevolutions[species.speciesId];
return this.setPokemonSpeciesCaught(pokemon, getPokemonSpecies(prevolutionSpecies)).then(() => resolve());
if (newCatch && speciesStarters.hasOwnProperty(species.speciesId)) {
this.scene.playSoundWithoutBgm('level_up_fanfare', 1500);
this.scene.ui.showText(`${species.name} has been\nadded as a starter!`, null, () => checkPrevolution(), null, true);
} else
resolve();
checkPrevolution();
});
}

View File

@ -194,7 +194,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
return;
}
if (this.lastName !== pokemon.species.name) {
if (this.lastName !== pokemon.name) {
this.nameText.setText(pokemon.name);
this.lastName = pokemon.name;

View File

@ -340,7 +340,7 @@ export default class PartyUiHandler extends MessageUiHandler {
break;
case Button.RIGHT:
const battlerCount = this.scene.currentBattle.getBattlerCount();
if (this.cursor < battlerCount)
if (slotCount && this.cursor < battlerCount)
success = this.setCursor(this.lastCursor < 6 ? this.lastCursor || battlerCount : battlerCount);
break;
}

View File

@ -1,11 +1,10 @@
import BattleScene, { Button } from "../battle-scene";
import PokemonSpecies, { allSpecies, getPokemonSpecies } from "../data/pokemon-species";
import PokemonSpecies, { allSpecies, getPokemonSpecies, speciesStarters as speciesStarterValues } from "../data/pokemon-species";
import { Species } from "../data/species";
import { TextStyle, addTextObject, getTextColor } from "./text";
import { Mode } from "./ui";
import MessageUiHandler from "./message-ui-handler";
import { Gender, getGenderColor, getGenderSymbol } from "../data/gender";
import { pokemonPrevolutions } from "../data/pokemon-evolutions";
import { abilities } from "../data/ability";
import { GameMode } from "../game-mode";
import { Unlockables } from "../system/unlockables";
@ -62,6 +61,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
private canCycleForm: boolean;
private canCycleGender: boolean;
private canCycleAbility: boolean;
private value: integer = 0;
private assetLoadCancelled: Utils.BooleanHolder;
private cursorObj: Phaser.GameObjects.Image;
@ -70,6 +70,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
private starterIcons: Phaser.GameObjects.Sprite[];
private genCursorObj: Phaser.GameObjects.Image;
private genCursorHighlightObj: Phaser.GameObjects.Image;
private valueLimitLabel: Phaser.GameObjects.Text;
private startCursorObj: Phaser.GameObjects.NineSlice;
private starterValueLabels: Phaser.GameObjects.Text[];
private shinyIcons: Phaser.GameObjects.Image[];
private starterSelectCallback: StarterSelectCallback;
@ -163,6 +166,19 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.genCursorObj.setVisible(false);
this.genCursorObj.setOrigin(0, 0);
this.starterSelectContainer.add(this.genCursorObj);
this.valueLimitLabel = addTextObject(this.scene, 124, 150, '0/10', TextStyle.TOOLTIP_CONTENT);
this.valueLimitLabel.setOrigin(0.5, 0);
this.starterSelectContainer.add(this.valueLimitLabel);
const startLabel = addTextObject(this.scene, 124, 162, 'Start', TextStyle.TOOLTIP_CONTENT);
startLabel.setOrigin(0.5, 0);
this.starterSelectContainer.add(startLabel);
this.startCursorObj = this.scene.add.nineslice(111, 160, 'starter_select_cursor', null, 26, 15, 1, 1, 1, 1);
this.startCursorObj.setVisible(false);
this.startCursorObj.setOrigin(0, 0);
this.starterSelectContainer.add(this.startCursorObj);
const starterSpecies: Species[] = [];
@ -173,7 +189,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
for (let species of allSpecies) {
if (species.generation > 5)
break;
if (pokemonPrevolutions.hasOwnProperty(species.speciesId) || species.generation !== g + 1)
if (!speciesStarterValues.hasOwnProperty(species.speciesId) || species.generation !== g + 1)
continue;
starterSpecies.push(species.speciesId);
this.speciesLoaded.set(species.speciesId, false);
@ -209,6 +225,17 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
return icon;
});
this.starterValueLabels = new Array(81).fill(null).map((_, i) => {
const x = (i % 9) * 18;
const y = Math.floor(i / 9) * 18;
const ret = addTextObject(this.scene, x + 150, y + 11, '0', TextStyle.WINDOW, { fontSize: '32px' });
ret.setShadowOffset(2, 2);
ret.setOrigin(0, 0);
ret.setVisible(false);
this.starterSelectContainer.add(ret);
return ret;
});
this.shinyIcons = new Array(81).fill(null).map((_, i) => {
const x = (i % 9) * 18;
const y = Math.floor(i / 9) * 18;
@ -354,7 +381,26 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
let success = false;
let error = false;
if (this.genMode) {
if (this.startCursorObj.visible) {
switch (button) {
case Button.ACTION:
if (this.tryStart())
success = true;
else
error = true;
break;
case Button.UP:
this.startCursorObj.setVisible(false);
this.setGenMode(true);
success = true;
break;
case Button.RIGHT:
this.startCursorObj.setVisible(false);
this.setGenMode(false);
success = true;
break;
}
} else if (this.genMode) {
switch (button) {
case Button.UP:
if (this.genCursor)
@ -363,6 +409,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
case Button.DOWN:
if (this.genCursor < 4)
success = this.setCursor(this.genCursor + 1);
else {
this.startCursorObj.setVisible(true);
this.setGenMode(true);
success = true;
}
break;
case Button.RIGHT:
success = this.setGenMode(false);
@ -382,11 +433,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
break;
}
}
if (!isDupe) {
const species = this.genSpecies[this.genCursor][this.cursor];
if (!isDupe && this.tryUpdateValue(speciesStarterValues[species.speciesId])) {
const cursorObj = this.starterCursorObjs[this.starterCursors.length];
cursorObj.setVisible(true);
cursorObj.setPosition(this.cursorObj.x, this.cursorObj.y);
const species = this.genSpecies[this.genCursor][this.cursor];
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species);
const defaultProps = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
this.starterIcons[this.starterCursors.length].play(species.getIconKey(defaultProps.female, defaultProps.formIndex));
@ -395,37 +446,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.starterAttr.push(this.dexAttrCursor);
if (this.speciesLoaded.get(species.speciesId))
species.cry(this.scene);
if (this.starterCursors.length === 3) {
const cancel = () => {
ui.setMode(Mode.STARTER_SELECT);
this.popStarter();
this.clearText();
};
ui.showText('Begin with these Pokémon?', null, () => {
ui.setModeWithoutClear(Mode.CONFIRM, () => {
const startRun = (gameMode: GameMode) => {
this.scene.gameMode = gameMode;
ui.setMode(Mode.STARTER_SELECT);
const thisObj = this;
const originalStarterSelectCallback = this.starterSelectCallback;
this.starterSelectCallback = null;
originalStarterSelectCallback(new Array(3).fill(0).map(function (_, i) {
const starterSpecies = thisObj.genSpecies[thisObj.starterGens[i]][thisObj.starterCursors[i]];
return {
species: starterSpecies,
dexAttr: thisObj.starterAttr[i],
pokerus: !![ 0, 1, 2 ].filter(n => thisObj.pokerusGens[n] === starterSpecies.generation - 1 && thisObj.pokerusCursors[n] === thisObj.genSpecies[starterSpecies.generation - 1].indexOf(starterSpecies)).length
};
}));
};
if (this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) {
ui.setMode(Mode.STARTER_SELECT);
ui.showText('Select a game mode.', null, () => ui.setModeWithoutClear(Mode.GAME_MODE_SELECT, startRun, cancel));
} else
startRun(GameMode.CLASSIC);
}, cancel);
});
}
if (this.starterCursors.length === 3)
this.tryStart();
this.updateInstructions();
ui.playSelect();
} else
@ -511,8 +533,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
case Button.LEFT:
if (this.cursor % 9)
success = this.setCursor(this.cursor - 1);
else
else {
if (row >= Math.min(5, rows - 1))
this.startCursorObj.setVisible(true);
success = this.setGenMode(true);
}
break;
case Button.RIGHT:
if (this.cursor % 9 < (row < rows - 1 ? 8 : (genStarters - 1) % 9))
@ -582,8 +607,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokerusCursorObjs[s].setVisible(this.pokerusGens[s] === cursor);
const genLimit = this.genSpecies[this.genCursor].length;
for (let s = 0; s < 81; s++)
this.shinyIcons[s].setVisible(s < genLimit && !!(this.scene.gameData.dexData[this.genSpecies[this.genCursor][s].speciesId].caughtAttr & DexAttr.SHINY));
for (let s = 0; s < 81; s++) {
const slotVisible = s < genLimit && !!(this.scene.gameData.dexData[this.genSpecies[this.genCursor][s].speciesId].caughtAttr);
this.starterValueLabels[s].setText(slotVisible ? speciesStarterValues[this.genSpecies[this.genCursor][s].speciesId] : 0);
this.starterValueLabels[s].setVisible(slotVisible);
this.shinyIcons[s].setVisible(slotVisible && !!(this.scene.gameData.dexData[this.genSpecies[this.genCursor][s].speciesId].caughtAttr & DexAttr.SHINY));
}
} else {
changed = super.setCursor(cursor);
@ -598,12 +627,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
}
setGenMode(genMode: boolean): boolean {
this.genCursorObj.setVisible(genMode && !this.startCursorObj.visible);
this.cursorObj.setVisible(!genMode && !this.startCursorObj.visible);
if (genMode !== this.genMode) {
this.genMode = genMode;
this.genCursorObj.setVisible(genMode);
this.cursorObj.setVisible(!genMode);
this.setCursor(genMode ? this.genCursor : this.cursor);
if (genMode)
this.setSpecies(null);
@ -746,6 +775,62 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.starterAttr.pop();
this.starterCursorObjs[this.starterCursors.length].setVisible(false);
this.starterIcons[this.starterCursors.length].play('pkmn_icon__000');
this.tryUpdateValue();
}
tryUpdateValue(add?: integer): boolean {
const value = this.starterGens.reduce((total: integer, gen: integer, i: integer) => total += speciesStarterValues[this.genSpecies[gen][this.starterCursors[i]].speciesId], 0);
const newValue = value + (add || 0);
const overLimit = newValue > 10;
this.valueLimitLabel.setText(`${newValue}/10`);
this.valueLimitLabel.setColor(getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_RED));
this.valueLimitLabel.setShadowColor(getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_RED, true));
if (overLimit) {
this.scene.time.delayedCall(Utils.fixedInt(500), () => this.tryUpdateValue());
return false;
}
this.value = newValue;
return true;
}
tryStart(): boolean {
if (!this.starterGens.length)
return false;
const ui = this.getUi();
const cancel = () => {
ui.setMode(Mode.STARTER_SELECT);
this.popStarter();
this.clearText();
};
ui.showText('Begin with these Pokémon?', null, () => {
ui.setModeWithoutClear(Mode.CONFIRM, () => {
const startRun = (gameMode: GameMode) => {
this.scene.gameMode = gameMode;
ui.setMode(Mode.STARTER_SELECT);
const thisObj = this;
const originalStarterSelectCallback = this.starterSelectCallback;
this.starterSelectCallback = null;
originalStarterSelectCallback(new Array(this.starterGens.length).fill(0).map(function (_, i) {
const starterSpecies = thisObj.genSpecies[thisObj.starterGens[i]][thisObj.starterCursors[i]];
return {
species: starterSpecies,
dexAttr: thisObj.starterAttr[i],
pokerus: !![ 0, 1, 2 ].filter(n => thisObj.pokerusGens[n] === starterSpecies.generation - 1 && thisObj.pokerusCursors[n] === thisObj.genSpecies[starterSpecies.generation - 1].indexOf(starterSpecies)).length
};
}));
};
if (this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) {
ui.setMode(Mode.STARTER_SELECT);
ui.showText('Select a game mode.', null, () => ui.setModeWithoutClear(Mode.GAME_MODE_SELECT, startRun, cancel));
} else
startRun(GameMode.CLASSIC);
}, cancel);
});
return true;
}
toggleStatsMode(on?: boolean): void {

View File

@ -10,7 +10,6 @@ import { getPokeballAtlasKey } from "../data/pokeball";
import { getGenderColor, getGenderSymbol } from "../data/gender";
import { getLevelTotalExp } from "../data/exp";
import { Stat, getStatName } from "../data/pokemon-stat";
import { abilities } from "../data/ability";
import { PokemonHeldItemModifier } from "../modifier/modifier";
import { StatusEffect } from "../data/status-effect";
@ -206,16 +205,7 @@ export default class SummaryUiHandler extends UiHandler {
});
this.pokemon.cry();
let nameLabel = this.pokemon.name;
if (this.pokemon.fusionSpecies)
nameLabel += `/\n ${this.pokemon.fusionSpecies.name}`;
this.nameText.setText(nameLabel);
this.nameText.setFontSize(`${!this.pokemon.fusionSpecies ? '96px' : '72px'}`);
const nameShadowSize = !this.pokemon.fusionSpecies ? 6 : 4.5;
this.nameText.setShadowOffset(nameShadowSize, nameShadowSize);
this.nameText.setLineSpacing(!this.pokemon.fusionSpecies ? 5 : 0);
this.nameText.setText(this.pokemon.name);
this.pokeball.setFrame(getPokeballAtlasKey(this.pokemon.pokeball));
this.levelText.setText(this.pokemon.level.toString());