Re-implement mini black hole item
parent
70cd42b934
commit
7c291ce0cf
|
@ -18,7 +18,7 @@ import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } fr
|
||||||
import { Biome, biomeLinks } from "./data/biome";
|
import { Biome, biomeLinks } from "./data/biome";
|
||||||
import { ModifierTypeOption, PokemonModifierType, PokemonMoveModifierType, 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 SoundFade from "phaser3-rex-plugins/plugins/soundfade";
|
||||||
import { BattlerTagLapseType, BattlerTagType, HideSpriteTag as HiddenTag, DamagingTrapTag, TrappedTag as TrapTag } from "./data/battler-tag";
|
import { BattlerTagLapseType, BattlerTagType, HideSpriteTag as HiddenTag, TrappedTag as TrapTag } from "./data/battler-tag";
|
||||||
import { getPokemonMessage } from "./messages";
|
import { getPokemonMessage } from "./messages";
|
||||||
import { Starter } from "./ui/starter-select-ui-handler";
|
import { Starter } from "./ui/starter-select-ui-handler";
|
||||||
import { Gender } from "./data/gender";
|
import { Gender } from "./data/gender";
|
||||||
|
@ -93,7 +93,7 @@ export class EncounterPhase extends BattlePhase {
|
||||||
}
|
}
|
||||||
|
|
||||||
doEncounter() {
|
doEncounter() {
|
||||||
if (startingWave > 10) {
|
if (startingWave > 10 && startingLevel < 100) {
|
||||||
for (let m = 0; m < Math.floor(startingWave / 10); m++)
|
for (let m = 0; m < Math.floor(startingWave / 10); m++)
|
||||||
this.scene.addModifier(getPlayerModifierTypeOptionsForWave((m + 1) * 10, 1, this.scene.getParty())[0].type.newModifier());
|
this.scene.addModifier(getPlayerModifierTypeOptionsForWave((m + 1) * 10, 1, this.scene.getParty())[0].type.newModifier());
|
||||||
}
|
}
|
||||||
|
@ -293,8 +293,6 @@ export class SummonPhase extends BattlePhase {
|
||||||
|
|
||||||
const playerPokemon = this.scene.getPlayerPokemon();
|
const playerPokemon = this.scene.getPlayerPokemon();
|
||||||
|
|
||||||
this.scene.applyModifiers(HeldItemTransferModifier, true, this.scene);
|
|
||||||
|
|
||||||
pokeball.setVisible(true);
|
pokeball.setVisible(true);
|
||||||
this.scene.tweens.add({
|
this.scene.tweens.add({
|
||||||
targets: pokeball,
|
targets: pokeball,
|
||||||
|
@ -627,6 +625,8 @@ export class TurnEndPhase extends BattlePhase {
|
||||||
|
|
||||||
this.scene.applyModifiers(TurnHealModifier, pokemon.isPlayer(), pokemon);
|
this.scene.applyModifiers(TurnHealModifier, pokemon.isPlayer(), pokemon);
|
||||||
|
|
||||||
|
this.scene.applyModifiers(HeldItemTransferModifier, pokemon.isPlayer(), pokemon);
|
||||||
|
|
||||||
pokemon.battleSummonData.turnCount++;
|
pokemon.battleSummonData.turnCount++;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -902,11 +902,13 @@ abstract class MoveEffectPhase extends PokemonPhase {
|
||||||
const result = !isProtected ? target.apply(user, this.move) : MoveResult.NO_EFFECT;
|
const result = !isProtected ? target.apply(user, this.move) : MoveResult.NO_EFFECT;
|
||||||
++user.turnData.hitCount;
|
++user.turnData.hitCount;
|
||||||
user.getMoveHistory().push({ move: this.move.moveId, result: result, virtual: this.move.virtual });
|
user.getMoveHistory().push({ move: this.move.moveId, result: result, virtual: this.move.virtual });
|
||||||
|
if (result !== MoveResult.NO_EFFECT && result !== MoveResult.FAILED) {
|
||||||
applyMoveAttrs(MoveEffectAttr, user, target, this.move.getMove());
|
applyMoveAttrs(MoveEffectAttr, user, target, this.move.getMove());
|
||||||
// Charge attribute with charge effect takes all effect attributes and applies them to charge stage, so ignore them if this is present
|
// Charge attribute with charge effect takes all effect attributes and applies them to charge stage, so ignore them if this is present
|
||||||
if (!isProtected && target.hp && !this.move.getMove().getAttrs(ChargeAttr).filter(ca => (ca as ChargeAttr).chargeEffect).length)
|
if (!isProtected && target.hp && !this.move.getMove().getAttrs(ChargeAttr).filter(ca => (ca as ChargeAttr).chargeEffect).length)
|
||||||
applyMoveAttrs(MoveHitEffectAttr, user, target, this.move.getMove());
|
applyMoveAttrs(MoveHitEffectAttr, user, target, this.move.getMove());
|
||||||
this.end();
|
this.end();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1732,7 +1734,7 @@ export class AttemptCapturePhase extends BattlePhase {
|
||||||
this.scene.sound.play('pb_catch');
|
this.scene.sound.play('pb_catch');
|
||||||
this.scene.time.delayedCall(17, () => this.pokeball.setTexture('pb', `${pokeballAtlasKey}`));
|
this.scene.time.delayedCall(17, () => this.pokeball.setTexture('pb', `${pokeballAtlasKey}`));
|
||||||
|
|
||||||
const doShake = this.pokeballType !== PokeballType.MASTER_BALL ? () => {
|
const doShake = pokeballMultiplier > -1 ? () => {
|
||||||
let shakeCount = 0;
|
let shakeCount = 0;
|
||||||
const pbX = this.pokeball.x;
|
const pbX = this.pokeball.x;
|
||||||
const shakeCounter = this.scene.tweens.addCounter({
|
const shakeCounter = this.scene.tweens.addCounter({
|
||||||
|
@ -1885,10 +1887,11 @@ export class SelectModifierPhase extends BattlePhase {
|
||||||
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
||||||
&& (m as PokemonHeldItemModifier).pokemonId === party[fromSlotIndex].id) as PokemonHeldItemModifier[];
|
&& (m as PokemonHeldItemModifier).pokemonId === party[fromSlotIndex].id) as PokemonHeldItemModifier[];
|
||||||
const itemModifier = itemModifiers[itemIndex];
|
const itemModifier = itemModifiers[itemIndex];
|
||||||
this.scene.tryTransferHeldItemModifier(itemModifier, party[toSlotIndex], true).then(success => {
|
this.scene.tryTransferHeldItemModifier(itemModifier, party[toSlotIndex], true, true).then(success => {
|
||||||
if (success) {
|
if (success) {
|
||||||
this.scene.ui.clearText();
|
this.scene.ui.clearText();
|
||||||
this.scene.ui.setMode(Mode.MESSAGE);
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
|
super.end();
|
||||||
} else
|
} else
|
||||||
this.scene.ui.setMode(Mode.MODIFIER_SELECT, typeOptions, modifierSelectCallback);
|
this.scene.ui.setMode(Mode.MODIFIER_SELECT, typeOptions, modifierSelectCallback);
|
||||||
});
|
});
|
||||||
|
@ -1910,9 +1913,9 @@ export class SelectModifierPhase extends BattlePhase {
|
||||||
const modifier = !isMoveModifier
|
const modifier = !isMoveModifier
|
||||||
? modifierType.newModifier(party[slotIndex])
|
? modifierType.newModifier(party[slotIndex])
|
||||||
: modifierType.newModifier(party[slotIndex], option - PartyOption.MOVE_1);
|
: modifierType.newModifier(party[slotIndex], option - PartyOption.MOVE_1);
|
||||||
this.scene.addModifier(modifier, true).then(() => super.end());
|
|
||||||
this.scene.ui.clearText();
|
this.scene.ui.clearText();
|
||||||
this.scene.ui.setMode(Mode.MESSAGE);
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
|
this.scene.addModifier(modifier, true).then(() => super.end());
|
||||||
});
|
});
|
||||||
} else
|
} else
|
||||||
this.scene.ui.setMode(Mode.MODIFIER_SELECT, typeOptions, modifierSelectCallback);
|
this.scene.ui.setMode(Mode.MODIFIER_SELECT, typeOptions, modifierSelectCallback);
|
||||||
|
|
|
@ -702,12 +702,20 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
tryTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, playSound: boolean): Promise<boolean> {
|
addEnemyModifier(itemModifier: PokemonHeldItemModifier): Promise<void> {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
itemModifier.add(this.enemyModifiers, false);
|
||||||
|
this.updateModifiers(false).then(() => resolve());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
tryTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, transferStack: boolean, playSound: boolean): Promise<boolean> {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const newItemModifier = itemModifier.clone() as PokemonHeldItemModifier;
|
const newItemModifier = itemModifier.clone() as PokemonHeldItemModifier;
|
||||||
|
const source = itemModifier.getPokemon(target.scene);
|
||||||
newItemModifier.pokemonId = target.id;
|
newItemModifier.pokemonId = target.id;
|
||||||
const matchingModifier = target.scene.findModifier(m => m instanceof PokemonHeldItemModifier
|
const matchingModifier = target.scene.findModifier(m => m instanceof PokemonHeldItemModifier
|
||||||
&& (m as PokemonHeldItemModifier).matchType(itemModifier)) as PokemonHeldItemModifier;
|
&& (m as PokemonHeldItemModifier).matchType(itemModifier), target.isPlayer()) as PokemonHeldItemModifier;
|
||||||
let removeOld = true;
|
let removeOld = true;
|
||||||
if (matchingModifier) {
|
if (matchingModifier) {
|
||||||
const maxStackCount = matchingModifier.getMaxStackCount();
|
const maxStackCount = matchingModifier.getMaxStackCount();
|
||||||
|
@ -715,15 +723,25 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const newStackCount = matchingModifier.stackCount + itemModifier.stackCount;
|
const newStackCount = matchingModifier.stackCount + (transferStack ? itemModifier.stackCount : 1);
|
||||||
if (newStackCount > maxStackCount) {
|
if (newStackCount > maxStackCount) {
|
||||||
itemModifier.stackCount = newStackCount - maxStackCount;
|
itemModifier.stackCount = newStackCount - maxStackCount;
|
||||||
newItemModifier.stackCount = maxStackCount;
|
newItemModifier.stackCount = maxStackCount;
|
||||||
removeOld = !itemModifier.stackCount;
|
removeOld = !itemModifier.stackCount;
|
||||||
}
|
}
|
||||||
}
|
} else if (!transferStack)
|
||||||
if (!removeOld || this.removeModifier(itemModifier)) {
|
removeOld = !(--itemModifier.stackCount);
|
||||||
|
if (!removeOld || this.removeModifier(itemModifier, !source.isPlayer())) {
|
||||||
|
const addModifier = () => {
|
||||||
|
if (target.isPlayer())
|
||||||
this.addModifier(newItemModifier, playSound).then(() => resolve(true));
|
this.addModifier(newItemModifier, playSound).then(() => resolve(true));
|
||||||
|
else
|
||||||
|
this.addEnemyModifier(newItemModifier).then(() => resolve(true));
|
||||||
|
};
|
||||||
|
if (source.isPlayer() !== target.isPlayer())
|
||||||
|
this.updateModifiers(source.isPlayer()).then(() => addModifier());
|
||||||
|
else
|
||||||
|
addModifier();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resolve(false);
|
resolve(false);
|
||||||
|
|
|
@ -55,7 +55,7 @@ export function getPokeballCatchMultiplier(type: PokeballType): number {
|
||||||
case PokeballType.ULTRA_BALL:
|
case PokeballType.ULTRA_BALL:
|
||||||
return 2;
|
return 2;
|
||||||
case PokeballType.MASTER_BALL:
|
case PokeballType.MASTER_BALL:
|
||||||
return -1;
|
return 10;
|
||||||
case PokeballType.LUXURY_BALL:
|
case PokeballType.LUXURY_BALL:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,17 +425,19 @@ class EvolutionItemModifierTypeGenerator extends ModifierTypeGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HeldItemTransferModifierType extends ModifierType {
|
class HeldItemTransferModifierType extends PokemonHeldItemModifierType {
|
||||||
constructor(name: string, iconImage?: string, group?: string, soundName?: string) {
|
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);
|
super(name, 'Every turn, the holder acquires one held item from the foe POKéMON', (type, args) => new Modifiers.HeldItemTransferModifier(type, (args[0] as Pokemon).id), iconImage, group, soundName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WeightedModifierTypeWeightFunc = (party: Pokemon[]) => integer;
|
||||||
|
|
||||||
class WeightedModifierType {
|
class WeightedModifierType {
|
||||||
public modifierType: ModifierType;
|
public modifierType: ModifierType;
|
||||||
public weight: integer | Function;
|
public weight: integer | WeightedModifierTypeWeightFunc;
|
||||||
|
|
||||||
constructor(modifierType: ModifierType, weight: integer | Function) {
|
constructor(modifierType: ModifierType, weight: integer | WeightedModifierTypeWeightFunc) {
|
||||||
this.modifierType = modifierType;
|
this.modifierType = modifierType;
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
}
|
}
|
||||||
|
@ -591,46 +593,48 @@ const modifierPool = {
|
||||||
return thresholdPartyMemberCount;
|
return thresholdPartyMemberCount;
|
||||||
}),
|
}),
|
||||||
new WeightedModifierType(modifierTypes.TM, 2),
|
new WeightedModifierType(modifierTypes.TM, 2),
|
||||||
modifierTypes.EXP_SHARE,
|
new WeightedModifierType(modifierTypes.EXP_SHARE, (party: Pokemon[]) => party.filter(p => p.level < 100).length ? 1 : 0),
|
||||||
new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3)
|
new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3)
|
||||||
].map(m => { m.setTier(ModifierTier.GREAT); return m; }),
|
].map(m => { m.setTier(ModifierTier.GREAT); return m; }),
|
||||||
[ModifierTier.ULTRA]: [
|
[ModifierTier.ULTRA]: [
|
||||||
new WeightedModifierType(modifierTypes.ULTRA_BALL, 8),
|
new WeightedModifierType(modifierTypes.ULTRA_BALL, 8),
|
||||||
new WeightedModifierType(modifierTypes.EVOLUTION_ITEM, 12),
|
new WeightedModifierType(modifierTypes.EVOLUTION_ITEM, 12),
|
||||||
new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 5),
|
new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 5),
|
||||||
modifierTypes.OVAL_CHARM,
|
new WeightedModifierType(modifierTypes.OVAL_CHARM, 1),
|
||||||
modifierTypes.HEALING_CHARM,
|
new WeightedModifierType(modifierTypes.HEALING_CHARM, 1),
|
||||||
new WeightedModifierType(modifierTypes.LEFTOVERS, 2),
|
new WeightedModifierType(modifierTypes.LEFTOVERS, 2),
|
||||||
new WeightedModifierType(modifierTypes.SHELL_BELL, 2),
|
new WeightedModifierType(modifierTypes.SHELL_BELL, 2),
|
||||||
new WeightedModifierType(modifierTypes.EXP_CHARM, 4),
|
|
||||||
new WeightedModifierType(modifierTypes.LUCKY_EGG, 3),
|
|
||||||
new WeightedModifierType(modifierTypes.BERRY_POUCH, 3),
|
new WeightedModifierType(modifierTypes.BERRY_POUCH, 3),
|
||||||
modifierTypes.EXP_BALANCE
|
new WeightedModifierType(modifierTypes.EXP_CHARM, (party: Pokemon[]) => party.filter(p => p.level < 100).length ? 4 : 0),
|
||||||
|
new WeightedModifierType(modifierTypes.LUCKY_EGG, (party: Pokemon[]) => party.filter(p => p.level < 100).length ? 3 : 0),
|
||||||
|
new WeightedModifierType(modifierTypes.EXP_BALANCE, (party: Pokemon[]) => party.filter(p => p.level < 100).length ? 1 : 0)
|
||||||
].map(m => { m.setTier(ModifierTier.ULTRA); return m; }),
|
].map(m => { m.setTier(ModifierTier.ULTRA); return m; }),
|
||||||
[ModifierTier.MASTER]: [
|
[ModifierTier.MASTER]: [
|
||||||
new WeightedModifierType(modifierTypes.MASTER_BALL, 3),
|
new WeightedModifierType(modifierTypes.MASTER_BALL, 3),
|
||||||
new WeightedModifierType(modifierTypes.SHINY_CHARM, 2),
|
new WeightedModifierType(modifierTypes.SHINY_CHARM, 2),
|
||||||
modifierTypes.MINI_BLACK_HOLE
|
new WeightedModifierType(modifierTypes.MINI_BLACK_HOLE, 1)
|
||||||
].map(m => { m.setTier(ModifierTier.MASTER); return m; }),
|
].map(m => { m.setTier(ModifierTier.MASTER); return m; }),
|
||||||
[ModifierTier.LUXURY]: [
|
[ModifierTier.LUXURY]: [
|
||||||
modifierTypes.GOLDEN_EXP_CHARM,
|
new WeightedModifierType(modifierTypes.GOLDEN_EXP_CHARM, (party: Pokemon[]) => party.filter(p => p.level < 100).length ? 1 : 0),
|
||||||
modifierTypes.GOLDEN_POKEBALL
|
new WeightedModifierType(modifierTypes.GOLDEN_POKEBALL, 1)
|
||||||
].map(m => { m.setTier(ModifierTier.LUXURY); return m; }),
|
].map(m => { m.setTier(ModifierTier.LUXURY); return m; }),
|
||||||
};
|
};
|
||||||
|
|
||||||
const enemyModifierPool = {
|
const enemyModifierPool = {
|
||||||
[ModifierTier.COMMON]: [
|
[ModifierTier.COMMON]: [
|
||||||
modifierTypes.BERRY
|
new WeightedModifierType(modifierTypes.BERRY, 1)
|
||||||
].map(m => { m.setTier(ModifierTier.COMMON); return m; }),
|
].map(m => { m.setTier(ModifierTier.COMMON); return m; }),
|
||||||
[ModifierTier.GREAT]: [
|
[ModifierTier.GREAT]: [
|
||||||
modifierTypes.BASE_STAT_BOOSTER
|
new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 1)
|
||||||
].map(m => { m.setTier(ModifierTier.GREAT); return m; }),
|
].map(m => { m.setTier(ModifierTier.GREAT); return m; }),
|
||||||
[ModifierTier.ULTRA]: [
|
[ModifierTier.ULTRA]: [
|
||||||
new WeightedModifierType(new AttackTypeBoosterModifierTypeGenerator(), 5),
|
new WeightedModifierType(new AttackTypeBoosterModifierTypeGenerator(), 5),
|
||||||
new WeightedModifierType(modifierTypes.LUCKY_EGG, 2),
|
new WeightedModifierType(modifierTypes.LUCKY_EGG, 2),
|
||||||
].map(m => { m.setTier(ModifierTier.ULTRA); return m; }),
|
].map(m => { m.setTier(ModifierTier.ULTRA); return m; }),
|
||||||
[ModifierTier.MASTER]: [
|
[ModifierTier.MASTER]: [
|
||||||
new WeightedModifierType(modifierTypes.SHELL_BELL, 1)
|
new WeightedModifierType(modifierTypes.LEFTOVERS, 4),
|
||||||
|
new WeightedModifierType(modifierTypes.SHELL_BELL, 4),
|
||||||
|
new WeightedModifierType(modifierTypes.MINI_BLACK_HOLE, 1)
|
||||||
].map(m => { m.setTier(ModifierTier.MASTER); return m; })
|
].map(m => { m.setTier(ModifierTier.MASTER); return m; })
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -649,8 +653,7 @@ export function regenerateModifierPoolThresholds(party: Pokemon[], player?: bool
|
||||||
ignoredIndexes[t] = [];
|
ignoredIndexes[t] = [];
|
||||||
const thresholds = new Map();
|
const thresholds = new Map();
|
||||||
let i = 0;
|
let i = 0;
|
||||||
pool[t].reduce((total: integer, modifierType: ModifierType | WeightedModifierType) => {
|
pool[t].reduce((total: integer, modifierType: WeightedModifierType) => {
|
||||||
if (modifierType instanceof WeightedModifierType) {
|
|
||||||
const weightedModifierType = modifierType as WeightedModifierType;
|
const weightedModifierType = modifierType as WeightedModifierType;
|
||||||
const weight = weightedModifierType.weight instanceof Function
|
const weight = weightedModifierType.weight instanceof Function
|
||||||
? (weightedModifierType.weight as Function)(party)
|
? (weightedModifierType.weight as Function)(party)
|
||||||
|
@ -661,8 +664,6 @@ export function regenerateModifierPoolThresholds(party: Pokemon[], player?: bool
|
||||||
ignoredIndexes[t].push(i++);
|
ignoredIndexes[t].push(i++);
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
total++;
|
|
||||||
thresholds.set(total, i++);
|
thresholds.set(total, i++);
|
||||||
return total;
|
return total;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
@ -679,7 +680,7 @@ export function regenerateModifierPoolThresholds(party: Pokemon[], player?: bool
|
||||||
|
|
||||||
export function getPlayerModifierTypeOptionsForWave(waveIndex: integer, count: integer, party: PlayerPokemon[]): ModifierTypeOption[] {
|
export function getPlayerModifierTypeOptionsForWave(waveIndex: integer, count: integer, party: PlayerPokemon[]): ModifierTypeOption[] {
|
||||||
if (waveIndex % 10 === 0)
|
if (waveIndex % 10 === 0)
|
||||||
return modifierPool[ModifierTier.LUXURY].map(m => new ModifierTypeOption(m, false));
|
return modifierPool[ModifierTier.LUXURY].filter(m => !(m.weight instanceof Function) || m.weight(party)).map(m => new ModifierTypeOption(m.modifierType, false));
|
||||||
const options: ModifierTypeOption[] = [];
|
const options: ModifierTypeOption[] = [];
|
||||||
const retryCount = Math.min(count * 5, 50);
|
const retryCount = Math.min(count * 5, 50);
|
||||||
new Array(count).fill(0).map(() => {
|
new Array(count).fill(0).map(() => {
|
||||||
|
@ -724,9 +725,7 @@ function getNewModifierTypeOption(party: Pokemon[], player?: boolean, tier?: Mod
|
||||||
|
|
||||||
if (player)
|
if (player)
|
||||||
console.log(index, ignoredPoolIndexes[tier].filter(i => i <= index).length, ignoredPoolIndexes[tier])
|
console.log(index, ignoredPoolIndexes[tier].filter(i => i <= index).length, ignoredPoolIndexes[tier])
|
||||||
let modifierType: ModifierType | WeightedModifierType = (player ? modifierPool : enemyModifierPool)[tier][index];
|
let modifierType: ModifierType = ((player ? modifierPool : enemyModifierPool)[tier][index]).modifierType;
|
||||||
if (modifierType instanceof WeightedModifierType)
|
|
||||||
modifierType = (modifierType as WeightedModifierType).modifierType;
|
|
||||||
if (modifierType instanceof ModifierTypeGenerator) {
|
if (modifierType instanceof ModifierTypeGenerator) {
|
||||||
modifierType = (modifierType as ModifierTypeGenerator).generateType(party);
|
modifierType = (modifierType as ModifierTypeGenerator).generateType(party);
|
||||||
if (modifierType === null) {
|
if (modifierType === null) {
|
||||||
|
|
|
@ -364,7 +364,7 @@ export class TurnHealModifier extends PokemonHeldItemModifier {
|
||||||
|
|
||||||
if (pokemon.getHpRatio() < 1) {
|
if (pokemon.getHpRatio() < 1) {
|
||||||
const scene = pokemon.scene;
|
const scene = pokemon.scene;
|
||||||
scene.unshiftPhase(new PokemonHealPhase(scene, true, Math.max(Math.floor(pokemon.getMaxHp() / 16) * this.stackCount, 1), getPokemonMessage(pokemon, `'s ${this.type.name}\nrestored its HP a little!`), true));
|
scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.isPlayer(), Math.max(Math.floor(pokemon.getMaxHp() / 16) * this.stackCount, 1), getPokemonMessage(pokemon, `'s ${this.type.name}\nrestored its HP a little!`), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -393,7 +393,7 @@ export class HitHealModifier extends PokemonHeldItemModifier {
|
||||||
|
|
||||||
if (pokemon.turnData.damageDealt && pokemon.getHpRatio() < 1) {
|
if (pokemon.turnData.damageDealt && pokemon.getHpRatio() < 1) {
|
||||||
const scene = pokemon.scene;
|
const scene = pokemon.scene;
|
||||||
scene.unshiftPhase(new PokemonHealPhase(scene, true, Math.max(Math.floor(pokemon.turnData.damageDealt / 8) * this.stackCount, 1), getPokemonMessage(pokemon, `'s ${this.type.name}\nrestored its HP a little!`), true));
|
scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.isPlayer(), Math.max(Math.floor(pokemon.turnData.damageDealt / 8) * this.stackCount, 1), getPokemonMessage(pokemon, `'s ${this.type.name}\nrestored its HP a little!`), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -828,41 +828,46 @@ export class ShinyRateBoosterModifier extends PersistentModifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
getMaxStackCount(): integer {
|
getMaxStackCount(): integer {
|
||||||
return 5;
|
return 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HeldItemTransferModifier extends PersistentModifier {
|
export class HeldItemTransferModifier extends PokemonHeldItemModifier {
|
||||||
constructor(type: ModifierType, stackCount?: integer) {
|
constructor(type: ModifierType, pokemonId: integer, stackCount?: integer) {
|
||||||
super(type, stackCount);
|
super(type, pokemonId, stackCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
match(modifier: Modifier): boolean {
|
matchType(modifier: Modifier): boolean {
|
||||||
return modifier instanceof HeldItemTransferModifier;
|
return modifier instanceof HeldItemTransferModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
clone(): HeldItemTransferModifier {
|
clone(): HeldItemTransferModifier {
|
||||||
return new HeldItemTransferModifier(this.type, this.stackCount);
|
return new HeldItemTransferModifier(this.type, this.pokemonId, this.stackCount);
|
||||||
}
|
|
||||||
|
|
||||||
shouldApply(args: any[]): boolean {
|
|
||||||
return super.shouldApply(args) && args.length && args[0] instanceof BattleScene;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(args: any[]): boolean {
|
apply(args: any[]): boolean {
|
||||||
const scene = args[0] as BattleScene;
|
const pokemon = args[0] as Pokemon;
|
||||||
const targetPokemon = scene.getPlayerPokemon();
|
const targetPokemon = pokemon.isPlayer() ? pokemon.scene.getEnemyPokemon() : pokemon.scene.getPlayerPokemon();
|
||||||
|
|
||||||
const itemModifiers = scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
const transferredModifierTypes: ModifierTypes.ModifierType[] = [];
|
||||||
&& (m as PokemonHeldItemModifier).pokemonId !== targetPokemon.id) as PokemonHeldItemModifier[];
|
const itemModifiers = pokemon.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
||||||
for (let modifier of itemModifiers)
|
&& (m as PokemonHeldItemModifier).pokemonId === targetPokemon.id, targetPokemon.isPlayer()) as PokemonHeldItemModifier[];
|
||||||
scene.tryTransferHeldItemModifier(modifier, targetPokemon, false);
|
|
||||||
|
|
||||||
return true;
|
for (let i = 0; i < this.getStackCount(); i++) {
|
||||||
|
if (!itemModifiers.length)
|
||||||
|
break;
|
||||||
|
const randItemIndex = Utils.randInt(itemModifiers.length);
|
||||||
|
const randItem = itemModifiers[randItemIndex];
|
||||||
|
if (pokemon.scene.tryTransferHeldItemModifier(randItem, pokemon, false, false)) {
|
||||||
|
transferredModifierTypes.push(randItem.type);
|
||||||
|
itemModifiers.splice(randItemIndex, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getMaxStackCount(): integer {
|
for (let mt of transferredModifierTypes)
|
||||||
return 1;
|
pokemon.scene.queueMessage(getPokemonMessage(targetPokemon, `'s ${mt.name} was absorbed\nby ${pokemon.name}'s MINI BLACK HOLE!`));
|
||||||
|
|
||||||
|
return !!transferredModifierTypes.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue