Update Feint move logic

This commit is contained in:
Flashfyre 2024-02-20 12:27:38 -05:00
parent be122f4f08
commit 00d985c9cf
2 changed files with 42 additions and 3 deletions

View File

@ -1518,7 +1518,7 @@ export class AddBattlerTagAttr extends MoveEffectAttr {
: null;
}
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
getTagTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
switch (this.tagType) {
case BattlerTagType.RECHARGING:
return -16;
@ -1566,12 +1566,19 @@ export class AddBattlerTagAttr extends MoveEffectAttr {
return 3;
}
}
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
let chance = this.getTagChance(user, target, move);
if (chance < 0)
chance = 100;
return Math.floor(this.getTagTargetBenefitScore(user, target, move) * (chance / 100));
}
}
export class LapseBattlerTagAttr extends MoveEffectAttr {
public tagTypes: BattlerTagType[];
constructor(tagTypes: BattlerTagType[], selfTarget?: boolean) {
constructor(tagTypes: BattlerTagType[], selfTarget: boolean = false) {
super(selfTarget);
this.tagTypes = tagTypes;
@ -1588,6 +1595,27 @@ export class LapseBattlerTagAttr extends MoveEffectAttr {
}
}
export class RemoveBattlerTagAttr extends MoveEffectAttr {
public tagTypes: BattlerTagType[];
constructor(tagTypes: BattlerTagType[], selfTarget: boolean = false) {
super(selfTarget);
this.tagTypes = tagTypes;
}
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if (!super.apply(user, target, move, args))
return false;
for (let tagType of this.tagTypes)
(this.selfTarget ? user : target).removeTag(tagType);
return true;
}
}
export class FlinchAttr extends AddBattlerTagAttr {
constructor() {
super(BattlerTagType.FLINCHED, false);
@ -3064,7 +3092,7 @@ export function initMoves() {
new AttackMove(Moves.NATURAL_GIFT, "Natural Gift (N)", Type.NORMAL, MoveCategory.PHYSICAL, -1, 100, 15, -1, "The user draws power to attack by using its held Berry. The Berry determines the move's type and power.", -1, 0, 4)
.makesContact(false),
new AttackMove(Moves.FEINT, "Feint", Type.NORMAL, MoveCategory.PHYSICAL, 30, 100, 10, -1, "This attack hits a target using a move such as Protect or Detect. This also lifts the effects of those moves.", -1, 2, 4)
.condition((user, target, move) => !!target.getTag(BattlerTagType.PROTECTED))
.attr(RemoveBattlerTagAttr, [ BattlerTagType.PROTECTED ])
.makesContact(false)
.ignoresProtect(),
new AttackMove(Moves.PLUCK, "Pluck (N)", Type.FLYING, MoveCategory.PHYSICAL, 60, 100, 20, -1, "The user pecks the target. If the target is holding a Berry, the user eats it and gains its effect.", -1, 0, 4),

View File

@ -1262,6 +1262,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
});
}
removeTag(tagType: BattlerTagType): boolean {
const tags = this.summonData.tags;
const tag = tags.find(t => t.tagType === tagType);
if (tag) {
tag.turnCount = 0;
tag.onRemove(this);
tags.splice(tags.indexOf(tag), 1);
}
return !!tag;
}
removeTagsBySourceId(sourceId: integer): void {
const tags = this.summonData.tags;
tags.filter(t => t.sourceId === sourceId).forEach(t => {