Download Ability Fix (#1119)
* Fixes Issue #993 by changing from base stats to include summonBattleStats * Added TODO with Substitute * Fix conflicts * Unsure why true was put through for passive, probably just a mistake on my end * !== fix * Conflict fix * Eslint Fix * Implement Double Battle average to take in stats from both Pkmn
This commit is contained in:
parent
91013cf8c4
commit
4695d0617d
|
@ -1573,18 +1573,41 @@ export class PostSummonClearAllyStatsAbAttr extends PostSummonAbAttr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download raises either the Attack stat or Special Attack stat by one stage depending on the foe's currently lowest defensive stat:
|
||||||
|
* it will raise Attack if the foe's current Defense is lower than its current Special Defense stat;
|
||||||
|
* otherwise, it will raise Special Attack.
|
||||||
|
* @extends PostSummonAbAttr
|
||||||
|
* @see {applyPostSummon}
|
||||||
|
*/
|
||||||
export class DownloadAbAttr extends PostSummonAbAttr {
|
export class DownloadAbAttr extends PostSummonAbAttr {
|
||||||
private enemyDef: integer;
|
private enemyDef: integer;
|
||||||
private enemySpDef: integer;
|
private enemySpDef: integer;
|
||||||
|
private enemyCountTally: integer;
|
||||||
private stats: BattleStat[];
|
private stats: BattleStat[];
|
||||||
|
|
||||||
|
// TODO: Implement the Substitute feature(s) once move is implemented.
|
||||||
|
/**
|
||||||
|
* Checks to see if it is the opening turn (starting a new game), if so, Download won't work. This is because Download takes into account
|
||||||
|
* vitamins and items, so it needs to use the BattleStat and the stat alone.
|
||||||
|
* @param {Pokemon} pokemon Pokemon that is using the move, as well as seeing the opposing pokemon.
|
||||||
|
* @param {boolean} passive N/A
|
||||||
|
* @param {any[]} args N/A
|
||||||
|
* @returns Returns true if ability is used successful, false if not.
|
||||||
|
*/
|
||||||
applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean {
|
applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean {
|
||||||
this.enemyDef = 0;
|
this.enemyDef = 0;
|
||||||
this.enemySpDef = 0;
|
this.enemySpDef = 0;
|
||||||
|
this.enemyCountTally = 0;
|
||||||
|
|
||||||
for (const opponent of pokemon.getOpponents()) {
|
if (pokemon.getOpponents()[0].summonData !== undefined) {
|
||||||
this.enemyDef += opponent.stats[BattleStat.DEF];
|
for (const opponent of pokemon.getOpponents()) {
|
||||||
this.enemySpDef += opponent.stats[BattleStat.SPDEF];
|
this.enemyCountTally++;
|
||||||
|
this.enemyDef += opponent.getBattleStat(Stat.DEF);
|
||||||
|
this.enemySpDef += opponent.getBattleStat(Stat.SPDEF);
|
||||||
|
}
|
||||||
|
this.enemyDef = Math.round(this.enemyDef / this.enemyCountTally);
|
||||||
|
this.enemySpDef = Math.round(this.enemySpDef / this.enemyCountTally);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.enemyDef < this.enemySpDef) {
|
if (this.enemyDef < this.enemySpDef) {
|
||||||
|
|
Loading…
Reference in New Issue