Implemented Repels

pull/544/head
Sophie Kujo 2024-05-06 04:37:48 -04:00
parent 6011794732
commit a3b3691084
5 changed files with 174 additions and 164 deletions

View File

@ -1,2 +1,2 @@
VITE_BYPASS_LOGIN=1 VITE_BYPASS_LOGIN=1
VITE_BYPASS_TUTORIAL=0 VITE_BYPASS_TUTORIAL=1

38
package-lock.json generated
View File

@ -2565,33 +2565,6 @@
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==",
"dev": true "dev": true
}, },
"node_modules/happy-dom": {
"version": "14.3.9",
"resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-14.3.9.tgz",
"integrity": "sha512-0kPQchwthekcYpYN8CvCiq+/z5bqFYDLbTxZ+yDLwT8AFRVJDFadShHRxp3VAZRy7a5isOZ1j/LzsU1dtAIZMQ==",
"dev": true,
"optional": true,
"peer": true,
"dependencies": {
"entities": "^4.5.0",
"webidl-conversions": "^7.0.0",
"whatwg-mimetype": "^3.0.0"
},
"engines": {
"node": ">=16.0.0"
}
},
"node_modules/happy-dom/node_modules/webidl-conversions": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
"integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",
"dev": true,
"optional": true,
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/has-flag": { "node_modules/has-flag": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@ -5802,17 +5775,6 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/whatwg-mimetype": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz",
"integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==",
"dev": true,
"optional": true,
"peer": true,
"engines": {
"node": ">=12"
}
},
"node_modules/whatwg-url": { "node_modules/whatwg-url": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",

View File

@ -4,7 +4,7 @@ import { NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, MessagePh
import Pokemon, { PlayerPokemon, EnemyPokemon } from './field/pokemon'; import Pokemon, { PlayerPokemon, EnemyPokemon } from './field/pokemon';
import PokemonSpecies, { PokemonSpeciesFilter, allSpecies, getPokemonSpecies, initSpecies, speciesStarters } from './data/pokemon-species'; import PokemonSpecies, { PokemonSpeciesFilter, allSpecies, getPokemonSpecies, initSpecies, speciesStarters } from './data/pokemon-species';
import * as Utils from './utils'; import * as Utils from './utils';
import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ModifierPredicate, DoubleBattleChanceBoosterModifier, FusePokemonModifier, PokemonFormChangeItemModifier, TerastallizeModifier } from './modifier/modifier'; import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ModifierPredicate, DoubleBattleChanceBoosterModifier, FusePokemonModifier, PokemonFormChangeItemModifier, TerastallizeModifier, DoubleBattleChancePreventerModifier } from './modifier/modifier';
import { PokeballType } from './data/pokeball'; import { PokeballType } from './data/pokeball';
import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets, populateAnims } from './data/battle-anims'; import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets, populateAnims } from './data/battle-anims';
import { Phase } from './phase'; import { Phase } from './phase';
@ -870,6 +870,9 @@ export default class BattleScene extends SceneBase {
} }
newBattle(waveIndex?: integer, battleType?: BattleType, trainerData?: TrainerData, double?: boolean): Battle { newBattle(waveIndex?: integer, battleType?: BattleType, trainerData?: TrainerData, double?: boolean): Battle {
if (this.getModifiers(DoubleBattleChancePreventerModifier) != null) {
double = false;
}
let newWaveIndex = waveIndex || ((this.currentBattle?.waveIndex || (startingWave - 1)) + 1); let newWaveIndex = waveIndex || ((this.currentBattle?.waveIndex || (startingWave - 1)) + 1);
let newDouble: boolean; let newDouble: boolean;
let newBattleType: BattleType; let newBattleType: BattleType;

View File

@ -332,6 +332,17 @@ export class DoubleBattleChanceBoosterModifierType extends ModifierType {
} }
} }
export class DoubleBattleChancePreventerModifierType extends ModifierType {
public battleCount: integer;
constructor(name: string, battleCount: integer) {
super(name, `Prevents the chance of an encounter being a double battle for ${battleCount} battles`, (_type, _args) => new Modifiers.DoubleBattleChancePreventerModifier(this, this.battleCount),
null, 'repel');
this.battleCount = battleCount;
}
}
export class TempBattleStatBoosterModifierType extends ModifierType implements GeneratedPersistentModifierType { export class TempBattleStatBoosterModifierType extends ModifierType implements GeneratedPersistentModifierType {
public tempBattleStat: TempBattleStat; public tempBattleStat: TempBattleStat;
@ -804,9 +815,9 @@ export const modifierTypes = {
PP_UP: () => new PokemonPpUpModifierType('PP Up', 1), PP_UP: () => new PokemonPpUpModifierType('PP Up', 1),
PP_MAX: () => new PokemonPpUpModifierType('PP Max', 3), PP_MAX: () => new PokemonPpUpModifierType('PP Max', 3),
/*REPEL: () => new DoubleBattleChanceBoosterModifierType('Repel', 5), REPEL: () => new DoubleBattleChancePreventerModifierType('Repel', 5),
SUPER_REPEL: () => new DoubleBattleChanceBoosterModifierType('Super Repel', 10), SUPER_REPEL: () => new DoubleBattleChancePreventerModifierType('Super Repel', 10),
MAX_REPEL: () => new DoubleBattleChanceBoosterModifierType('Max Repel', 25),*/ MAX_REPEL: () => new DoubleBattleChancePreventerModifierType('Max Repel', 25),
LURE: () => new DoubleBattleChanceBoosterModifierType('Lure', 5), LURE: () => new DoubleBattleChanceBoosterModifierType('Lure', 5),
SUPER_LURE: () => new DoubleBattleChanceBoosterModifierType('Super Lure', 10), SUPER_LURE: () => new DoubleBattleChanceBoosterModifierType('Super Lure', 10),
@ -983,7 +994,14 @@ const modifierPool: ModifierPool = {
const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && p.getMoveset().filter(m => (m.getMove().pp - m.ppUsed) <= 5).length).length, 3); const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && p.getMoveset().filter(m => (m.getMove().pp - m.ppUsed) <= 5).length).length, 3);
return thresholdPartyMemberCount; return thresholdPartyMemberCount;
}, 3), }, 3),
new WeightedModifierType(modifierTypes.LURE, 2), new WeightedModifierType(modifierTypes.REPEL, (party: Pokemon[]) => {
const existingItem = party[0].scene.findModifier(m => m.type instanceof DoubleBattleChancePreventerModifierType || m.type instanceof DoubleBattleChanceBoosterModifierType);
return existingItem ? 0 : 2;
}),
new WeightedModifierType(modifierTypes.LURE, (party: Pokemon[]) => {
const existingItem = party[0].scene.findModifier(m => m.type instanceof DoubleBattleChancePreventerModifierType || m.type instanceof DoubleBattleChanceBoosterModifierType);
return existingItem ? 0 : 2;
}),
new WeightedModifierType(modifierTypes.TEMP_STAT_BOOSTER, 4), new WeightedModifierType(modifierTypes.TEMP_STAT_BOOSTER, 4),
new WeightedModifierType(modifierTypes.BERRY, 2), new WeightedModifierType(modifierTypes.BERRY, 2),
new WeightedModifierType(modifierTypes.TM_COMMON, 1), new WeightedModifierType(modifierTypes.TM_COMMON, 1),
@ -1256,6 +1274,7 @@ export function regenerateModifierPoolThresholds(party: Pokemon[], poolType: Mod
pool[t].reduce((total: integer, modifierType: WeightedModifierType) => { pool[t].reduce((total: integer, modifierType: WeightedModifierType) => {
const weightedModifierType = modifierType as WeightedModifierType; const weightedModifierType = modifierType as WeightedModifierType;
const existingModifiers = party[0].scene.findModifiers(m => (m.type.generatorId || m.type.id) === weightedModifierType.modifierType.id, poolType === ModifierPoolType.PLAYER); const existingModifiers = party[0].scene.findModifiers(m => (m.type.generatorId || m.type.id) === weightedModifierType.modifierType.id, poolType === ModifierPoolType.PLAYER);
existingModifiers.forEach(m => console.log(m.type.name))
const itemModifierType = weightedModifierType.modifierType instanceof ModifierTypeGenerator const itemModifierType = weightedModifierType.modifierType instanceof ModifierTypeGenerator
? weightedModifierType.modifierType.generateType(party) ? weightedModifierType.modifierType.generateType(party)
: weightedModifierType.modifierType; : weightedModifierType.modifierType;

View File

@ -310,6 +310,32 @@ export class DoubleBattleChanceBoosterModifier extends LapsingPersistentModifier
} }
} }
export class DoubleBattleChancePreventerModifier extends LapsingPersistentModifier {
constructor(type: ModifierTypes.DoubleBattleChancePreventerModifierType, battlesLeft: integer, stackCount?: integer) {
super(type, battlesLeft, stackCount);
}
match(modifier: Modifier): boolean {
if (modifier instanceof DoubleBattleChancePreventerModifier)
return (modifier as DoubleBattleChancePreventerModifier).battlesLeft === this.battlesLeft;
return false;
}
clone(): DoubleBattleChancePreventerModifier {
return new DoubleBattleChancePreventerModifier(this.type as ModifierTypes.DoubleBattleChancePreventerModifierType, this.battlesLeft, this.stackCount);
}
getArgs(): any[] {
return [ this.battlesLeft ];
}
apply(args: any[]): boolean {
const doubleBattleChance = args[0] as Utils.NumberHolder;
doubleBattleChance.value = 0;
return true;
}
}
export class TempBattleStatBoosterModifier extends LapsingPersistentModifier { export class TempBattleStatBoosterModifier extends LapsingPersistentModifier {
private tempBattleStat: TempBattleStat; private tempBattleStat: TempBattleStat;