mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-16 13:22:18 +02:00
Random Pokemon Starter Teams
- Ability to generate random pokemon starter meeting point criteria - Randomize button located in starter-select-ui bottom left hand side of screen
This commit is contained in:
parent
8c21bdc0a1
commit
452004f8dc
@ -40,5 +40,6 @@ export const starterSelectUiHandler: SimpleTranslationEntries = {
|
|||||||
"disablePassive": "Passiv-Skill deaktivieren",
|
"disablePassive": "Passiv-Skill deaktivieren",
|
||||||
"locked": "Gesperrt",
|
"locked": "Gesperrt",
|
||||||
"disabled": "Deaktiviert",
|
"disabled": "Deaktiviert",
|
||||||
"uncaught": "Ungefangen"
|
"uncaught": "Ungefangen",
|
||||||
|
"randomize": "Zufällig!",
|
||||||
}
|
}
|
||||||
|
@ -40,5 +40,6 @@ export const starterSelectUiHandler: SimpleTranslationEntries = {
|
|||||||
"disablePassive": "Disable Passive",
|
"disablePassive": "Disable Passive",
|
||||||
"locked": "Locked",
|
"locked": "Locked",
|
||||||
"disabled": "Disabled",
|
"disabled": "Disabled",
|
||||||
"uncaught": "Uncaught"
|
"uncaught": "Uncaught",
|
||||||
|
"randomize": "Randomize!",
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
private statsContainer: StatsContainer;
|
private statsContainer: StatsContainer;
|
||||||
private pokemonFormText: Phaser.GameObjects.Text;
|
private pokemonFormText: Phaser.GameObjects.Text;
|
||||||
|
|
||||||
|
private starterRandomizeText: Phaser.GameObjects.Text;
|
||||||
|
|
||||||
private genMode: boolean;
|
private genMode: boolean;
|
||||||
|
private randomizeMode: boolean;
|
||||||
private statsMode: boolean;
|
private statsMode: boolean;
|
||||||
private dexAttrCursor: bigint = 0n;
|
private dexAttrCursor: bigint = 0n;
|
||||||
private abilityCursor: integer = -1;
|
private abilityCursor: integer = -1;
|
||||||
@ -175,6 +178,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
private assetLoadCancelled: Utils.BooleanHolder;
|
private assetLoadCancelled: Utils.BooleanHolder;
|
||||||
private cursorObj: Phaser.GameObjects.Image;
|
private cursorObj: Phaser.GameObjects.Image;
|
||||||
private starterCursorObjs: Phaser.GameObjects.Image[];
|
private starterCursorObjs: Phaser.GameObjects.Image[];
|
||||||
|
private starterRandomizeCursorObj: Phaser.GameObjects.NineSlice;
|
||||||
private pokerusCursorObjs: Phaser.GameObjects.Image[];
|
private pokerusCursorObjs: Phaser.GameObjects.Image[];
|
||||||
private starterIcons: Phaser.GameObjects.Sprite[];
|
private starterIcons: Phaser.GameObjects.Sprite[];
|
||||||
private genCursorObj: Phaser.GameObjects.Image;
|
private genCursorObj: Phaser.GameObjects.Image;
|
||||||
@ -222,11 +226,21 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
this.starterSelectContainer.add(addWindow(this.scene, 107, 1, 34, 58));
|
this.starterSelectContainer.add(addWindow(this.scene, 107, 1, 34, 58));
|
||||||
this.starterSelectContainer.add(addWindow(this.scene, 107, 59, 34, 91));
|
this.starterSelectContainer.add(addWindow(this.scene, 107, 59, 34, 91));
|
||||||
this.starterSelectContainer.add(addWindow(this.scene, 107, 145, 34, 34, true));
|
this.starterSelectContainer.add(addWindow(this.scene, 107, 145, 34, 34, true));
|
||||||
|
this.starterSelectContainer.add(addWindow(this.scene, 20, 158, 70, 20));
|
||||||
this.starterSelectContainer.add(starterContainerWindow);
|
this.starterSelectContainer.add(starterContainerWindow);
|
||||||
|
|
||||||
if (!this.scene.uiTheme)
|
if (!this.scene.uiTheme)
|
||||||
starterContainerWindow.setVisible(false);
|
starterContainerWindow.setVisible(false);
|
||||||
|
|
||||||
|
this.starterRandomizeText = addTextObject(this.scene, 55, 163, i18next.t("starterSelectUiHandler:randomize"), TextStyle.TOOLTIP_CONTENT);
|
||||||
|
this.starterRandomizeText.setOrigin(0.5, 0);
|
||||||
|
this.starterSelectContainer.add(this.starterRandomizeText);
|
||||||
|
|
||||||
|
this.starterRandomizeCursorObj = this.scene.add.nineslice(30, 162, 'select_cursor', null, 50, 12, 6, 6, 6, 6);
|
||||||
|
this.starterRandomizeCursorObj.setVisible(false);
|
||||||
|
this.starterRandomizeCursorObj.setOrigin(0, 0);
|
||||||
|
this.starterSelectContainer.add(this.starterRandomizeCursorObj);
|
||||||
|
|
||||||
this.iconAnimHandler = new PokemonIconAnimHandler();
|
this.iconAnimHandler = new PokemonIconAnimHandler();
|
||||||
this.iconAnimHandler.setup(this.scene);
|
this.iconAnimHandler.setup(this.scene);
|
||||||
|
|
||||||
@ -772,8 +786,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
break;
|
break;
|
||||||
case Button.LEFT:
|
case Button.LEFT:
|
||||||
this.startCursorObj.setVisible(false);
|
this.startCursorObj.setVisible(false);
|
||||||
|
this.setRandomizeMode(true);
|
||||||
this.setGenMode(false);
|
this.setGenMode(false);
|
||||||
this.setCursor(this.cursor + 8);
|
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
case Button.RIGHT:
|
case Button.RIGHT:
|
||||||
@ -805,6 +819,43 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
success = this.setGenMode(false);
|
success = this.setGenMode(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (this.randomizeMode){
|
||||||
|
switch (button){
|
||||||
|
// Going up, down, left, or right, will take it back to start
|
||||||
|
case Button.UP:
|
||||||
|
this.startCursorObj.setVisible(false);
|
||||||
|
this.setGenMode(true);
|
||||||
|
this.setRandomizeMode(false);
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
|
// case Button.DOWN:
|
||||||
|
// this.startCursorObj.setVisible(false);
|
||||||
|
// this.setGenMode(true);
|
||||||
|
// this.setRandomizeMode(false);
|
||||||
|
// success = true;
|
||||||
|
// break;
|
||||||
|
case Button.LEFT:
|
||||||
|
this.startCursorObj.setVisible(false);
|
||||||
|
this.setGenMode(false);
|
||||||
|
this.setRandomizeMode(false);
|
||||||
|
this.setCursor(this.cursor + 8);
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
|
case Button.RIGHT:
|
||||||
|
this.startCursorObj.setVisible(true);
|
||||||
|
this.setGenMode(false);
|
||||||
|
this.setRandomizeMode(false);
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
|
case Button.ACTION:
|
||||||
|
this.generateRandomStarterTeam();
|
||||||
|
// if (this.tryStart(true))
|
||||||
|
// success = true;
|
||||||
|
// else
|
||||||
|
// error = true;
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (button === Button.ACTION) {
|
if (button === Button.ACTION) {
|
||||||
if (!this.speciesStarterDexEntry?.caughtAttr)
|
if (!this.speciesStarterDexEntry?.caughtAttr)
|
||||||
@ -815,6 +866,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
label: i18next.t("starterSelectUiHandler:addToParty"),
|
label: i18next.t("starterSelectUiHandler:addToParty"),
|
||||||
handler: () => {
|
handler: () => {
|
||||||
ui.setMode(Mode.STARTER_SELECT);
|
ui.setMode(Mode.STARTER_SELECT);
|
||||||
|
|
||||||
|
// this.generateRandomStarter();
|
||||||
let isDupe = false;
|
let isDupe = false;
|
||||||
for (let s = 0; s < this.starterCursors.length; s++) {
|
for (let s = 0; s < this.starterCursors.length; s++) {
|
||||||
if (this.starterGens[s] === this.getGenCursorWithScroll() && this.starterCursors[s] === this.cursor) {
|
if (this.starterGens[s] === this.getGenCursorWithScroll() && this.starterCursors[s] === this.cursor) {
|
||||||
@ -822,6 +875,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const species = this.genSpecies[this.getGenCursorWithScroll()][this.cursor];
|
const species = this.genSpecies[this.getGenCursorWithScroll()][this.cursor];
|
||||||
if (!isDupe && this.tryUpdateValue(this.scene.gameData.getSpeciesStarterValue(species.speciesId))) {
|
if (!isDupe && this.tryUpdateValue(this.scene.gameData.getSpeciesStarterValue(species.speciesId))) {
|
||||||
const cursorObj = this.starterCursorObjs[this.starterCursors.length];
|
const cursorObj = this.starterCursorObjs[this.starterCursors.length];
|
||||||
@ -1275,7 +1330,17 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
this.hiddenAbilityIcons[s].setVisible(slotVisible && !!this.scene.gameData.dexData[speciesId].caughtAttr && !!(this.scene.gameData.starterData[speciesId].abilityAttr & 4));
|
this.hiddenAbilityIcons[s].setVisible(slotVisible && !!this.scene.gameData.dexData[speciesId].caughtAttr && !!(this.scene.gameData.starterData[speciesId].abilityAttr & 4));
|
||||||
this.classicWinIcons[s].setVisible(slotVisible && this.scene.gameData.starterData[speciesId].classicWinCount > 0);
|
this.classicWinIcons[s].setVisible(slotVisible && this.scene.gameData.starterData[speciesId].classicWinCount > 0);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else if (this.randomizeMode){
|
||||||
|
changed = super.setCursor(cursor);
|
||||||
|
|
||||||
|
// this.cursorObj.setPosition(54, 160);
|
||||||
|
|
||||||
|
// this.setSpecies(this.randomSpecies[cursor]);
|
||||||
|
|
||||||
|
this.updateInstructions();
|
||||||
|
}
|
||||||
|
else {
|
||||||
changed = super.setCursor(cursor);
|
changed = super.setCursor(cursor);
|
||||||
|
|
||||||
this.cursorObj.setPosition(150 + 18 * (cursor % 9), 10 + 18 * Math.floor(cursor / 9));
|
this.cursorObj.setPosition(150 + 18 * (cursor % 9), 10 + 18 * Math.floor(cursor / 9));
|
||||||
@ -1289,6 +1354,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getGenCursorWithScroll(): integer {
|
getGenCursorWithScroll(): integer {
|
||||||
|
// return this.genCursor + this.genScrollCursor;
|
||||||
return this.genCursor !== undefined
|
return this.genCursor !== undefined
|
||||||
? this.genCursor + this.genScrollCursor
|
? this.genCursor + this.genScrollCursor
|
||||||
: undefined;
|
: undefined;
|
||||||
@ -1309,9 +1375,25 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
this.genOptionsText.setText(text);
|
this.genOptionsText.setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setRandomizeMode(randomizeMode: boolean): boolean {
|
||||||
|
this.starterRandomizeCursorObj.setVisible(randomizeMode);
|
||||||
|
this.cursorObj.setVisible(!randomizeMode && !this.startCursorObj.visible && !this.genCursorObj.visible);
|
||||||
|
|
||||||
|
if (randomizeMode !== this.randomizeMode) {
|
||||||
|
this.randomizeMode = randomizeMode;
|
||||||
|
|
||||||
|
// this.setCursor(this.cursor);
|
||||||
|
|
||||||
|
if (randomizeMode)
|
||||||
|
this.setSpecies(null);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setGenMode(genMode: boolean): boolean {
|
setGenMode(genMode: boolean): boolean {
|
||||||
this.genCursorObj.setVisible(genMode && !this.startCursorObj.visible);
|
this.genCursorObj.setVisible(genMode && !this.startCursorObj.visible);
|
||||||
this.cursorObj.setVisible(!genMode && !this.startCursorObj.visible);
|
this.cursorObj.setVisible(!genMode && !this.startCursorObj.visible && !this.starterRandomizeCursorObj.visible);
|
||||||
|
|
||||||
if (genMode !== this.genMode) {
|
if (genMode !== this.genMode) {
|
||||||
this.genMode = genMode;
|
this.genMode = genMode;
|
||||||
@ -1781,6 +1863,105 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearCurrentStarterTeam(): void {
|
||||||
|
this.starterGens = [];
|
||||||
|
this.starterCursors = [];
|
||||||
|
this.starterAttr = [];
|
||||||
|
this.starterAbilityIndexes = [];
|
||||||
|
this.starterNatures = [];
|
||||||
|
this.starterMovesets = [];
|
||||||
|
this.starterCursorObjs.forEach(cursor => cursor.setVisible(false));
|
||||||
|
this.starterIcons.forEach(icon => icon.setTexture('pokemon_icons_0').setFrame('unknown'));
|
||||||
|
this.value = 0;
|
||||||
|
this.tryUpdateValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
generateRandomStarterTeam(): void {
|
||||||
|
this.clearCurrentStarterTeam();
|
||||||
|
while (this.generateRandomStarter());
|
||||||
|
}
|
||||||
|
|
||||||
|
generateRandomStarter(): boolean {
|
||||||
|
var generatedValidPokemon:boolean = false;
|
||||||
|
var hasValidPokemon:boolean = false;
|
||||||
|
|
||||||
|
// Checking if there are still valid pokemon to generate
|
||||||
|
for (let g = 0; g < this.genSpecies.length; g++) {
|
||||||
|
for (let s = 0; s < this.genSpecies[g].length; s++){
|
||||||
|
if (this.isValidStarter(this.genSpecies[g][s])){
|
||||||
|
if (this.value + this.scene.gameData.getSpeciesStarterValue(this.genSpecies[g][s].speciesId) <= this.getValueLimit()){
|
||||||
|
hasValidPokemon = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasValidPokemon){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasValidPokemon){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!generatedValidPokemon) {
|
||||||
|
// Create a random number for gens 0 - 8
|
||||||
|
const gen = Utils.randInt(8, 0);
|
||||||
|
// const gen = 3;
|
||||||
|
// Create a random pokemon id based off of how many pokemon are in the gen
|
||||||
|
const speciesId = Utils.randInt(this.genSpecies[gen].length - 1, 0);
|
||||||
|
// const speciesId = 2;
|
||||||
|
const species = this.genSpecies[gen][speciesId];
|
||||||
|
|
||||||
|
// Ownership check
|
||||||
|
if (!this.isValidStarter(species)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Dupe check
|
||||||
|
var isDupe = false;
|
||||||
|
for (let s = 0; s < this.starterCursors.length; s++) {
|
||||||
|
if (this.starterGens[s] === gen && this.starterCursors[s] === speciesId) {
|
||||||
|
isDupe = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Update value
|
||||||
|
if (!isDupe && this.tryUpdateValue(this.scene.gameData.getSpeciesStarterValue(species.speciesId))){
|
||||||
|
// < 6 pokemon and the value is less than the limit check
|
||||||
|
if (this.starterGens.length < 6 && this.value <= this.getValueLimit()) {
|
||||||
|
this.speciesStarterDexEntry = species ? this.scene.gameData.dexData[species.speciesId] : null;
|
||||||
|
this.dexAttrCursor = species ? this.scene.gameData.getSpeciesDefaultDexAttr(species, false, true) : 0n;
|
||||||
|
this.abilityCursor = species ? this.scene.gameData.getStarterSpeciesDefaultAbilityIndex(species) : 0;
|
||||||
|
this.natureCursor = species ? this.scene.gameData.getSpeciesDefaultNature(species) : 0;
|
||||||
|
|
||||||
|
const props = this.scene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor);
|
||||||
|
|
||||||
|
this.starterAttr.push(this.dexAttrCursor);
|
||||||
|
this.starterAbilityIndexes.push(this.abilityCursor);
|
||||||
|
this.starterNatures.push(this.natureCursor as unknown as Nature);
|
||||||
|
this.starterMovesets.push(this.starterMoveset.slice(0) as StarterMoveset);
|
||||||
|
|
||||||
|
this.starterIcons[this.starterCursors.length].setTexture(species.getIconAtlasKey(props.formIndex, props.shiny, props.variant));
|
||||||
|
this.starterIcons[this.starterCursors.length].setFrame(species.getIconId(props.female, props.formIndex, props.shiny, props.variant));
|
||||||
|
|
||||||
|
this.starterGens.push(gen);
|
||||||
|
this.starterCursors.push(speciesId);
|
||||||
|
|
||||||
|
generatedValidPokemon = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
isValidStarter(species): bigint {
|
||||||
|
return this.scene.gameData.dexData[species.speciesId].caughtAttr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
tryStart(manualTrigger: boolean = false): boolean {
|
tryStart(manualTrigger: boolean = false): boolean {
|
||||||
if (!this.starterGens.length)
|
if (!this.starterGens.length)
|
||||||
return false;
|
return false;
|
||||||
@ -1797,6 +1978,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
ui.showText(i18next.t("starterSelectUiHandler:confirmStartTeam"), null, () => {
|
ui.showText(i18next.t("starterSelectUiHandler:confirmStartTeam"), null, () => {
|
||||||
ui.setModeWithoutClear(Mode.CONFIRM, () => {
|
ui.setModeWithoutClear(Mode.CONFIRM, () => {
|
||||||
const startRun = (gameMode: GameModes) => {
|
const startRun = (gameMode: GameModes) => {
|
||||||
|
// const dexEntry = this.scene.gameData.dexData[species.speciesId];
|
||||||
|
|
||||||
|
// this.starterCursors = [10];
|
||||||
|
// this.starterGens = [1];
|
||||||
this.scene.gameMode = gameModes[gameMode];
|
this.scene.gameMode = gameModes[gameMode];
|
||||||
this.scene.money = this.scene.gameMode.getStartingMoney();
|
this.scene.money = this.scene.gameMode.getStartingMoney();
|
||||||
ui.setMode(Mode.STARTER_SELECT);
|
ui.setMode(Mode.STARTER_SELECT);
|
||||||
|
Loading…
Reference in New Issue
Block a user