mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 07:22:19 +02:00
Add chance for double battles
This commit is contained in:
parent
3fad55d24b
commit
380ae3d29b
@ -9,7 +9,7 @@ import { BerryModifier, ContactHeldItemTransferChanceModifier, ExpBalanceModifie
|
|||||||
import PartyUiHandler, { PartyOption, PartyUiMode } from "./ui/party-ui-handler";
|
import PartyUiHandler, { PartyOption, PartyUiMode } from "./ui/party-ui-handler";
|
||||||
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballName, getPokeballTintColor, PokeballType } from "./data/pokeball";
|
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballName, getPokeballTintColor, PokeballType } from "./data/pokeball";
|
||||||
import { CommonAnim, CommonBattleAnim, MoveAnim, initMoveAnim, loadMoveAnimAssets } from "./data/battle-anims";
|
import { CommonAnim, CommonBattleAnim, MoveAnim, initMoveAnim, loadMoveAnimAssets } from "./data/battle-anims";
|
||||||
import { StatusEffect, getStatusEffectActivationText, getStatusEffectCatchRateMultiplier, getStatusEffectHealText, getStatusEffectObtainText, getStatusEffectOverlapText } from "./data/status-effect";
|
import { Status, StatusEffect, getStatusEffectActivationText, getStatusEffectCatchRateMultiplier, getStatusEffectHealText, getStatusEffectObtainText, getStatusEffectOverlapText } from "./data/status-effect";
|
||||||
import { SummaryUiMode } from "./ui/summary-ui-handler";
|
import { SummaryUiMode } from "./ui/summary-ui-handler";
|
||||||
import EvolutionSceneHandler from "./ui/evolution-scene-handler";
|
import EvolutionSceneHandler from "./ui/evolution-scene-handler";
|
||||||
import { EvolutionPhase } from "./evolution-phase";
|
import { EvolutionPhase } from "./evolution-phase";
|
||||||
@ -656,11 +656,13 @@ export class ToggleDoublePositionPhase extends BattlePhase {
|
|||||||
|
|
||||||
export class CheckSwitchPhase extends BattlePhase {
|
export class CheckSwitchPhase extends BattlePhase {
|
||||||
protected fieldIndex: integer;
|
protected fieldIndex: integer;
|
||||||
|
protected useName: boolean;
|
||||||
|
|
||||||
constructor(scene: BattleScene, fieldIndex: integer) {
|
constructor(scene: BattleScene, fieldIndex: integer, useName: boolean) {
|
||||||
super(scene);
|
super(scene);
|
||||||
|
|
||||||
this.fieldIndex = fieldIndex;
|
this.fieldIndex = fieldIndex;
|
||||||
|
this.useName = useName;
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
@ -684,7 +686,7 @@ export class CheckSwitchPhase extends BattlePhase {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.scene.ui.showText('Will you switch\nPOKéMON?', null, () => {
|
this.scene.ui.showText(`Will you switch\n${this.useName ? pokemon.name : 'POKéMON'}?`, null, () => {
|
||||||
this.scene.ui.setMode(Mode.CONFIRM, () => {
|
this.scene.ui.setMode(Mode.CONFIRM, () => {
|
||||||
this.scene.ui.setMode(Mode.MESSAGE);
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
this.scene.unshiftPhase(new SwitchPhase(this.scene, this.fieldIndex, false, true));
|
this.scene.unshiftPhase(new SwitchPhase(this.scene, this.fieldIndex, false, true));
|
||||||
@ -1828,7 +1830,7 @@ export class VictoryPhase extends PokemonPhase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.scene.currentBattle.enemyField.filter(p => p.isActive()).length) {
|
if (!this.scene.getEnemyField().filter(p => !p?.isFainted(true)).length) {
|
||||||
this.scene.pushPhase(new BattleEndPhase(this.scene));
|
this.scene.pushPhase(new BattleEndPhase(this.scene));
|
||||||
if (this.scene.currentBattle.waveIndex < this.scene.finalWave) {
|
if (this.scene.currentBattle.waveIndex < this.scene.finalWave) {
|
||||||
this.scene.pushPhase(new SelectModifierPhase(this.scene));
|
this.scene.pushPhase(new SelectModifierPhase(this.scene));
|
||||||
|
@ -19,7 +19,7 @@ import { TextStyle, addTextObject } from './ui/text';
|
|||||||
import { Moves, initMoves } from './data/move';
|
import { Moves, initMoves } from './data/move';
|
||||||
import { getDefaultModifierTypeForTier, getEnemyModifierTypesForWave } from './modifier/modifier-type';
|
import { getDefaultModifierTypeForTier, getEnemyModifierTypesForWave } from './modifier/modifier-type';
|
||||||
import AbilityBar from './ui/ability-bar';
|
import AbilityBar from './ui/ability-bar';
|
||||||
import { BlockItemTheftAbAttr, applyAbAttrs, initAbilities } from './data/ability';
|
import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, applyAbAttrs, initAbilities } from './data/ability';
|
||||||
import Battle from './battle';
|
import Battle from './battle';
|
||||||
|
|
||||||
const enableAuto = true;
|
const enableAuto = true;
|
||||||
@ -512,15 +512,19 @@ export default class BattleScene extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newBattle(waveIndex?: integer, double?: boolean): Battle {
|
newBattle(waveIndex?: integer, double?: boolean): Battle {
|
||||||
double = (waveIndex || ((this.currentBattle?.waveIndex || (startingWave - 1)) + 1)) % 2 === 0;
|
let newWaveIndex = waveIndex || ((this.currentBattle?.waveIndex || (startingWave - 1)) + 1);
|
||||||
|
let newDouble: boolean;
|
||||||
|
|
||||||
const isDouble = double === undefined || double;
|
if (double === undefined) {
|
||||||
|
const doubleChance = new Utils.IntegerHolder(newWaveIndex % 10 === 0 ? 32 : 8);
|
||||||
console.log(this.currentBattle?.waveIndex);
|
this.getPlayerField().forEach(p => applyAbAttrs(DoubleBattleChanceAbAttr, p, null, doubleChance));
|
||||||
|
newDouble = !Utils.randInt(doubleChance.value);
|
||||||
|
} else
|
||||||
|
newDouble = double;
|
||||||
|
|
||||||
const lastBattle = this.currentBattle;
|
const lastBattle = this.currentBattle;
|
||||||
|
|
||||||
this.currentBattle = new Battle(waveIndex || ((this.currentBattle?.waveIndex || (startingWave - 1)) + 1), isDouble);
|
this.currentBattle = new Battle(newWaveIndex, newDouble);
|
||||||
this.currentBattle.incrementTurn(this);
|
this.currentBattle.incrementTurn(this);
|
||||||
|
|
||||||
if (!waveIndex) {
|
if (!waveIndex) {
|
||||||
@ -542,9 +546,9 @@ export default class BattleScene extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((lastBattle?.double || false) !== isDouble) {
|
if ((lastBattle?.double || false) !== newDouble) {
|
||||||
const availablePartyMemberCount = this.getParty().filter(p => !p.isFainted()).length;
|
const availablePartyMemberCount = this.getParty().filter(p => !p.isFainted()).length;
|
||||||
if (isDouble) {
|
if (newDouble) {
|
||||||
this.pushPhase(new ToggleDoublePositionPhase(this, true));
|
this.pushPhase(new ToggleDoublePositionPhase(this, true));
|
||||||
if (availablePartyMemberCount > 1)
|
if (availablePartyMemberCount > 1)
|
||||||
this.pushPhase(new SummonPhase(this, 1));
|
this.pushPhase(new SummonPhase(this, 1));
|
||||||
@ -556,9 +560,9 @@ export default class BattleScene extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lastBattle) {
|
if (lastBattle) {
|
||||||
this.pushPhase(new CheckSwitchPhase(this, 0));
|
this.pushPhase(new CheckSwitchPhase(this, 0, newDouble));
|
||||||
if (lastBattle.double && isDouble)
|
if (newDouble)
|
||||||
this.pushPhase(new CheckSwitchPhase(this, 1));
|
this.pushPhase(new CheckSwitchPhase(this, 1, newDouble));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +83,18 @@ export class BlockRecoilDamageAttr extends AbAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class DoubleBattleChanceAbAttr extends AbAttr {
|
||||||
|
constructor() {
|
||||||
|
super(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
apply(pokemon: Pokemon, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||||
|
const doubleChance = (args[0] as Utils.IntegerHolder);
|
||||||
|
doubleChance.value = Math.max(doubleChance.value / 2, 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class PreDefendAbAttr extends AbAttr {
|
export class PreDefendAbAttr extends AbAttr {
|
||||||
applyPreDefend(pokemon: Pokemon, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
applyPreDefend(pokemon: Pokemon, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||||
return false;
|
return false;
|
||||||
@ -155,9 +167,10 @@ export class TypeImmunityHealAbAttr extends TypeImmunityAbAttr {
|
|||||||
applyPreDefend(pokemon: Pokemon, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
applyPreDefend(pokemon: Pokemon, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||||
const ret = super.applyPreDefend(pokemon, attacker, move, cancelled, args);
|
const ret = super.applyPreDefend(pokemon, attacker, move, cancelled, args);
|
||||||
|
|
||||||
if (ret && pokemon.getHpRatio() < 1) {
|
if (ret) {
|
||||||
const scene = pokemon.scene;
|
if (pokemon.getHpRatio() < 1)
|
||||||
scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), Math.max(Math.floor(pokemon.getMaxHp() / 4), 1), getPokemonMessage(pokemon, `'s ${pokemon.getAbility().name}\nrestored its HP a little!`), true));
|
pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, pokemon.getBattlerIndex(),
|
||||||
|
Math.max(Math.floor(pokemon.getMaxHp() / 4), 1), getPokemonMessage(pokemon, `'s ${pokemon.getAbility().name}\nrestored its HP a little!`), true));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,7 +708,6 @@ export function applyAbAttrs(attrType: { new(...args: any[]): AbAttr }, pokemon:
|
|||||||
|
|
||||||
const ability = pokemon.getAbility();
|
const ability = pokemon.getAbility();
|
||||||
const attrs = ability.getAttrs(attrType) as AbAttr[];
|
const attrs = ability.getAttrs(attrType) as AbAttr[];
|
||||||
console.log(attrs, ability);
|
|
||||||
for (let attr of attrs) {
|
for (let attr of attrs) {
|
||||||
if (!canApplyAttr(pokemon, attr))
|
if (!canApplyAttr(pokemon, attr))
|
||||||
continue;
|
continue;
|
||||||
@ -1220,7 +1232,8 @@ export function initAbilities() {
|
|||||||
new Ability(Abilities.HUSTLE, "Hustle (N)", "Boosts the ATTACK stat, but lowers accuracy.", 3),
|
new Ability(Abilities.HUSTLE, "Hustle (N)", "Boosts the ATTACK stat, but lowers accuracy.", 3),
|
||||||
new Ability(Abilities.HYPER_CUTTER, "Hyper Cutter", "Prevents other POKéMON from lowering ATTACK stat.", 3)
|
new Ability(Abilities.HYPER_CUTTER, "Hyper Cutter", "Prevents other POKéMON from lowering ATTACK stat.", 3)
|
||||||
.attr(ProtectStatAbAttr, BattleStat.ATK),
|
.attr(ProtectStatAbAttr, BattleStat.ATK),
|
||||||
new Ability(Abilities.ILLUMINATE, "Illuminate (N)", "Raises the likelihood of meeting wild POKéMON.", 3),
|
new Ability(Abilities.ILLUMINATE, "Illuminate", "Raises the likelihood of an encounter being a double battle.", 3)
|
||||||
|
.attr(DoubleBattleChanceAbAttr),
|
||||||
new Ability(Abilities.IMMUNITY, "Immunity", "Prevents the POKéMON from getting poisoned.", 3)
|
new Ability(Abilities.IMMUNITY, "Immunity", "Prevents the POKéMON from getting poisoned.", 3)
|
||||||
.attr(StatusEffectImmunityAbAttr, StatusEffect.POISON),
|
.attr(StatusEffectImmunityAbAttr, StatusEffect.POISON),
|
||||||
new Ability(Abilities.INNER_FOCUS, "Inner Focus", "The POKéMON is protected from flinching.", 3)
|
new Ability(Abilities.INNER_FOCUS, "Inner Focus", "The POKéMON is protected from flinching.", 3)
|
||||||
|
@ -98,6 +98,7 @@ export class EvolutionPhase extends BattlePhase {
|
|||||||
const levelMoves = pokemon.getLevelMoves(this.lastLevel + 1);
|
const levelMoves = pokemon.getLevelMoves(this.lastLevel + 1);
|
||||||
for (let lm of levelMoves)
|
for (let lm of levelMoves)
|
||||||
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm));
|
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, lm));
|
||||||
|
this.scene.unshiftPhase(new EndEvolutionPhase(this.scene));
|
||||||
|
|
||||||
this.scene.time.delayedCall(1000, () => {
|
this.scene.time.delayedCall(1000, () => {
|
||||||
const evolutionBgm = this.scene.sound.add('evolution');
|
const evolutionBgm = this.scene.sound.add('evolution');
|
||||||
@ -444,3 +445,11 @@ export class EvolutionPhase extends BattlePhase {
|
|||||||
updateParticle();
|
updateParticle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class EndEvolutionPhase extends BattlePhase {
|
||||||
|
start() {
|
||||||
|
super.start();
|
||||||
|
|
||||||
|
this.scene.ui.setModeForceTransition(Mode.MESSAGE).then(() => this.end());
|
||||||
|
}
|
||||||
|
}
|
@ -188,8 +188,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isFainted(): boolean {
|
isFainted(checkStatus?: boolean): boolean {
|
||||||
return !this.hp;
|
return !this.hp && (!checkStatus || this.status?.effect === StatusEffect.FAINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
isActive(): boolean {
|
isActive(): boolean {
|
||||||
|
Loading…
Reference in New Issue
Block a user