Add mini black hole item

pull/1/head
Flashfyre 2023-04-21 15:45:48 -04:00
parent 4b89794ab3
commit 355bfc76bf
9 changed files with 1088 additions and 1012 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

View File

@ -5,7 +5,7 @@ import { allMoves, applyMoveAttrs, BypassSleepAttr, ChargeAttr, ConditionalMoveA
import { Mode } from './ui/ui';
import { Command } from "./ui/command-ui-handler";
import { Stat } from "./data/pokemon-stat";
import { BerryModifier, ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, HealingBoosterModifier, HitHealModifier, PokemonExpBoosterModifier, PokemonHeldItemModifier, TempBattleStatBoosterModifier, TurnHealModifier } from "./modifier/modifier";
import { BerryModifier, ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, HealingBoosterModifier, HeldItemTransferModifier, HitHealModifier, PokemonExpBoosterModifier, PokemonHeldItemModifier, TempBattleStatBoosterModifier, TurnHealModifier } from "./modifier/modifier";
import PartyUiHandler, { PartyOption, PartyUiMode } from "./ui/party-ui-handler";
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, PokeballType } from "./data/pokeball";
import { CommonAnim, CommonBattleAnim, MoveAnim, initMoveAnim, loadMoveAnimAssets } from "./data/battle-anims";
@ -16,7 +16,7 @@ import { EvolutionPhase } from "./evolution-phase";
import { BattlePhase } from "./battle-phase";
import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } from "./data/battle-stat";
import { Biome, biomeLinks } from "./data/biome";
import { ModifierTypeOption, PokemonModifierType, PokemonMoveModifierType, getEnemyModifierTypesForWave, getPlayerModifierTypeOptionsForWave, regenerateModifierPoolThresholds } from "./modifier/modifier-type";
import { ModifierTypeOption, PokemonModifierType, PokemonMoveModifierType, getPlayerModifierTypeOptionsForWave, regenerateModifierPoolThresholds } from "./modifier/modifier-type";
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import { BattleTagLapseType, BattleTagType, HideSpriteTag as HiddenTag } from "./data/battle-tag";
import { getPokemonMessage } from "./messages";
@ -293,6 +293,8 @@ export class SummonPhase extends BattlePhase {
const playerPokemon = this.scene.getPlayerPokemon();
this.scene.applyModifiers(HeldItemTransferModifier, true, this.scene);
pokeball.setVisible(true);
this.scene.tweens.add({
targets: pokeball,
@ -860,8 +862,6 @@ abstract class MoveEffectPhase extends PokemonPhase {
const overridden = new Utils.BooleanHolder(false);
console.log(this.move.getName());
applyMoveAttrs(OverrideMoveEffectAttr, user, target, this.move.getMove(), overridden).then(() => {
if (overridden.value) {
@ -1845,28 +1845,14 @@ export class SelectModifierPhase extends BattlePhase {
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).pokemonId === party[fromSlotIndex].id) as PokemonHeldItemModifier[];
const itemModifier = itemModifiers[itemIndex];
const newItemModifier = itemModifier.clone() as PokemonHeldItemModifier;
newItemModifier.pokemonId = party[toSlotIndex].id;
const matchingModifier = party[toSlotIndex].scene.findModifier(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).matchType(itemModifier)) as PokemonHeldItemModifier;
let removeOld = true;
if (matchingModifier) {
const newStackCount = matchingModifier.stackCount + itemModifier.stackCount;
const maxStackCount = matchingModifier.getMaxStackCount();
if (newStackCount > maxStackCount) {
itemModifier.stackCount = newStackCount - maxStackCount;
newItemModifier.stackCount = maxStackCount;
removeOld = !itemModifier.stackCount;
}
}
if (!removeOld || this.scene.removeModifier(itemModifier)) {
this.scene.addModifier(newItemModifier, true).then(() => super.end());
this.scene.tryTransferHeldItemModifier(itemModifier, party[toSlotIndex], true).then(success => {
if (success) {
this.scene.ui.clearText();
this.scene.ui.setMode(Mode.MESSAGE);
return;
}
}
} else
this.scene.ui.setMode(Mode.MODIFIER_SELECT, typeOptions, modifierSelectCallback);
});
}
}, PartyUiHandler.FilterItemMaxStacks);
return;
}

View File

@ -1,6 +1,6 @@
import Phaser from 'phaser';
import { Biome } from './data/biome';
import UI from './ui/ui';
import UI, { Mode } from './ui/ui';
import { EncounterPhase, SummonPhase, CommandPhase, NextEncounterPhase, NewBiomeEncounterPhase, SelectBiomePhase, SelectStarterPhase, MessagePhase } from './battle-phases';
import Pokemon, { PlayerPokemon, EnemyPokemon } from './pokemon';
import PokemonSpecies, { allSpecies, getPokemonSpecies } from './data/pokemon-species';
@ -662,6 +662,34 @@ export default class BattleScene extends Phaser.Scene {
});
}
tryTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, playSound: boolean): Promise<boolean> {
return new Promise(resolve => {
const newItemModifier = itemModifier.clone() as PokemonHeldItemModifier;
newItemModifier.pokemonId = target.id;
const matchingModifier = target.scene.findModifier(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).matchType(itemModifier)) as PokemonHeldItemModifier;
let removeOld = true;
if (matchingModifier) {
const maxStackCount = matchingModifier.getMaxStackCount();
if (matchingModifier.stackCount >= maxStackCount) {
resolve(false);
return;
}
const newStackCount = matchingModifier.stackCount + itemModifier.stackCount;
if (newStackCount > maxStackCount) {
itemModifier.stackCount = newStackCount - maxStackCount;
newItemModifier.stackCount = maxStackCount;
removeOld = !itemModifier.stackCount;
}
}
if (!removeOld || this.removeModifier(itemModifier)) {
this.addModifier(newItemModifier, playSound).then(() => resolve(true));
return;
}
resolve(false);
});
}
removePartyMemberModifiers(partyMemberIndex: integer): Promise<void> {
return new Promise(resolve => {
const pokemonId = this.getParty()[partyMemberIndex].id;

View File

@ -281,7 +281,6 @@ export class ProtectedTag extends BattleTag {
}
lapse(pokemon: Pokemon, lapseType: BattleTagLapseType): boolean {
console.log(pokemon, BattleTagLapseType[lapseType]);
if (lapseType === BattleTagLapseType.CUSTOM) {
new CommonBattleAnim(CommonAnim.PROTECT, pokemon).play(pokemon.scene);
pokemon.scene.unshiftPhase(new MessagePhase(pokemon.scene, getPokemonMessage(pokemon, '\nprotected itself!')));

View File

@ -425,6 +425,12 @@ class EvolutionItemModifierTypeGenerator extends ModifierTypeGenerator {
}
}
class HeldItemTransferModifierType extends ModifierType {
constructor(name: string, iconImage?: string, group?: string, soundName?: string) {
super(name, 'All held items in your party are transferred to a POKéMON on summon', (type, _args) => new Modifiers.HeldItemTransferModifier(type), iconImage, group, soundName);
}
}
class WeightedModifierType {
public modifierType: ModifierType;
public weight: integer | Function;
@ -522,6 +528,8 @@ const modifierTypes = {
SHINY_CHARM: new ModifierType('SHINY CHARM', 'Dramatically increases the chance of a wild POKéMON being shiny', (type, _args) => new Modifiers.ShinyRateBoosterModifier(type)),
MINI_BLACK_HOLE: new HeldItemTransferModifierType('MINI BLACK HOLE'),
GOLDEN_POKEBALL: new ModifierType(`GOLDEN ${getPokeballName(PokeballType.POKEBALL)}`, 'Adds 1 extra item option at the end of every battle',
(type, _args) => new Modifiers.ExtraModifierModifier(type), 'pb_gold', null, 'pb_bounce_1'),
};
@ -600,8 +608,9 @@ const modifierPool = {
modifierTypes.EXP_BALANCE
].map(m => { m.setTier(ModifierTier.ULTRA); return m; }),
[ModifierTier.MASTER]: [
modifierTypes.MASTER_BALL,
new WeightedModifierType(modifierTypes.SHINY_CHARM, 2)
new WeightedModifierType(modifierTypes.MASTER_BALL, 3),
new WeightedModifierType(modifierTypes.SHINY_CHARM, 2),
modifierTypes.MINI_BLACK_HOLE
].map(m => { m.setTier(ModifierTier.MASTER); return m; }),
[ModifierTier.LUXURY]: [
modifierTypes.GOLDEN_EXP_CHARM,
@ -690,8 +699,8 @@ export function getEnemyModifierTypesForWave(waveIndex: integer, count: integer,
function getNewModifierTypeOption(party: Pokemon[], player?: boolean, tier?: ModifierTier, upgrade?: boolean): ModifierTypeOption {
if (player === undefined)
player = true;
const tierValue = Utils.randInt(256);
if (tier === undefined) {
const tierValue = Utils.randInt(256);
if (player) {
const partyShinyCount = party.filter(p => p.shiny).length;
const upgradeOdds = Math.floor(32 / Math.max((partyShinyCount * 2), 1));

View File

@ -833,6 +833,40 @@ export class ShinyRateBoosterModifier extends PersistentModifier {
}
}
export class HeldItemTransferModifier extends PersistentModifier {
constructor(type: ModifierType, stackCount?: integer) {
super(type, stackCount);
}
match(modifier: Modifier): boolean {
return modifier instanceof HeldItemTransferModifier;
}
clone(): HeldItemTransferModifier {
return new HeldItemTransferModifier(this.type, this.stackCount);
}
shouldApply(args: any[]): boolean {
return super.shouldApply(args) && args.length && args[0] instanceof BattleScene;
}
apply(args: any[]): boolean {
const scene = args[0] as BattleScene;
const targetPokemon = scene.getPlayerPokemon();
const itemModifiers = scene.findModifiers(m => m instanceof PokemonHeldItemModifier
&& (m as PokemonHeldItemModifier).pokemonId !== targetPokemon.id) as PokemonHeldItemModifier[];
for (let modifier of itemModifiers)
scene.tryTransferHeldItemModifier(modifier, targetPokemon, false);
return true;
}
getMaxStackCount(): integer {
return 1;
}
}
export class ExtraModifierModifier extends PersistentModifier {
constructor(type: ModifierType, stackCount?: integer) {
super(type, stackCount);

View File

@ -62,7 +62,6 @@ export default class ConfirmUiHandler extends UiHandler {
this.setCursor(1);
const handler = this.cursor ? this.noHander : this.yesHandler;
handler();
console.log(this.cursor ? this.noHander : this.yesHandler);
this.clear();
} else {
switch (button) {