mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-14 20:32:17 +02:00
Added comments, added (what i think is TSDoc) to functions and classes. Removed empty lines i introduced
This commit is contained in:
parent
6d55533493
commit
d9a154220d
@ -747,16 +747,26 @@ export class SacrificialAttr extends MoveEffectAttr {
|
||||
super(true, MoveEffectTrigger.PRE_APPLY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the sacrificial effect to the user
|
||||
* @param user Pokemon that used the move
|
||||
* @param target The target of the move
|
||||
* @param move Move with this attribute
|
||||
* @param args N/A
|
||||
*/
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
|
||||
|
||||
|
||||
user.damageAndUpdate(user.hp, HitResult.OTHER, false, true, true);
|
||||
user.turnData.damageTaken += user.hp;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user Pokemon that used the move
|
||||
* @param target The target of the move
|
||||
* @param move Move with this attribute
|
||||
*/
|
||||
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||
if (user.isBoss())
|
||||
return -20;
|
||||
@ -766,15 +776,23 @@ export class SacrificialAttr extends MoveEffectAttr {
|
||||
|
||||
|
||||
/**
|
||||
* Attribute used for moves which self KO the user but only if the move hits a target
|
||||
* * Attribute used for moves which self KO the user but only if the move hits a target
|
||||
*/
|
||||
export class SacrificialAttrOnHit extends MoveEffectAttr {
|
||||
constructor() {
|
||||
super(true, MoveEffectTrigger.PRE_APPLY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the sacrificial effect to the user
|
||||
* @param user Pokemon that used the move
|
||||
* @param target The target of the move
|
||||
* @param move Move with this attribute
|
||||
* @param args N/A
|
||||
*/
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
|
||||
// If the move hits a target, the user will self KO
|
||||
if (!super.apply(user, target, move, args))
|
||||
return false;
|
||||
|
||||
@ -784,6 +802,12 @@ export class SacrificialAttrOnHit extends MoveEffectAttr {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user Pokemon that used the move
|
||||
* @param target The target of the move
|
||||
* @param move Move with this attribute
|
||||
*/
|
||||
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||
if (user.isBoss())
|
||||
return -20;
|
||||
|
@ -2295,13 +2295,12 @@ export class MovePhase extends BattlePhase {
|
||||
return this.end();
|
||||
}
|
||||
|
||||
// Check if the move has no valid targets (because they are flying, etc.) - if the used move is sacrificial it does not need a target so we add the user as a target so the move does not fail
|
||||
if (targets.length === 0 && this.move.getMove().getAttrs(SacrificialAttr).length) {
|
||||
// Add the user as a target if the move is sacrificial
|
||||
targets.push(this.pokemon);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!moveQueue.length || !moveQueue.shift().ignorePP) // using .shift here clears out two turn moves once they've been used
|
||||
this.move.usePp(ppUsed);
|
||||
|
||||
@ -2465,13 +2464,14 @@ export class MoveEffectPhase extends PokemonPhase {
|
||||
|
||||
// Move animation only needs one target
|
||||
new MoveAnim(this.move.getMove().id as Moves, user, this.getTarget()?.getBattlerIndex()).play(this.scene, () => {
|
||||
// Check if the user is in the targets list for sacrificial moves
|
||||
// Check if the user is in the targets list for sacrificial moves, if not add them
|
||||
if (this.move.getMove().getAttrs(SacrificialAttr).length && !targets.includes(user)) {
|
||||
targets.push(user);
|
||||
targetHitChecks[user.getBattlerIndex()] = true;
|
||||
}
|
||||
for (let target of targets) {
|
||||
if (!targetHitChecks[target.getBattlerIndex()]) {
|
||||
// If we have a sacrifical move, and the target isnt the user - it should not "miss". So we skip the miss check
|
||||
if (this.move.getMove().getAttrs(SacrificialAttr).length && target !== user) {
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user