More updates to Endless Battle Clause

- Gen 1 PP overflow makes a Pokemon stale
- Staleness warnings now specify the staleness source
- Half-staleness also warns, if another pokemon is already stale

Warning on half-staleness helps remind people who seem to think
they've beaten Endless Battle Clause after 5-ish turns, when it
takes 10-20 turns for some staleness verdics, especially if
there's a lot of switching going on.
This commit is contained in:
Guangcong Luo 2015-07-22 19:45:33 -04:00
parent af53f4f989
commit 5d3cd8263c
3 changed files with 75 additions and 11 deletions

View File

@ -1119,7 +1119,10 @@ BattlePokemon = (function () {
BattlePokemon.prototype.setItem = function (item, source, effect) {
if (!this.hp || !this.isActive) return false;
item = this.battle.getItem(item);
if (item.id === 'leppaberry') this.isStale = 2;
if (item.id === 'leppaberry') {
this.isStale = 2;
this.isStaleSource = 'getleppa';
}
this.lastItem = this.item;
this.item = item.id;
this.itemData = {id: item.id, target: this};
@ -2838,6 +2841,7 @@ Battle = (function () {
for (var i = 0; i < side.foe.active.length; i++) {
if (side.foe.active[i].isStale >= 2) {
oldActive.isStaleCon++;
oldActive.isStaleSource = 'drag';
break;
}
}
@ -2912,19 +2916,43 @@ Battle = (function () {
if (pokemon.fainted) continue;
if (pokemon.isStale < 2) {
if (pokemon.isStaleCon >= 2) {
if (pokemon.hp >= pokemon.isStaleHP - pokemon.maxhp / 100) pokemon.isStale++;
if (pokemon.hp >= pokemon.isStaleHP - pokemon.maxhp / 100) {
pokemon.isStale++;
if (this.firstStaleWarned && pokemon.isStale < 2) {
switch (pokemon.isStaleSource) {
case 'struggle':
this.add('html', '<div class="broadcast-red">' + this.escapeHTML(pokemon.name) + ' isn\'t losing HP from Struggle. If this continues, it will be classified as being in an endless loop.</div>');
break;
case 'drag':
this.add('html', '<div class="broadcast-red">' + this.escapeHTML(pokemon.name) + ' isn\'t losing PP or HP from being forced to switch. If this continues, it will be classified as being in an endless loop.</div>');
break;
case 'switch':
this.add('html', '<div class="broadcast-red">' + this.escapeHTML(pokemon.name) + ' isn\'t losing PP or HP from repeatedly switching. If this continues, it will be classified as being in an endless loop.</div>');
break;
}
}
}
pokemon.isStaleCon = 0;
pokemon.isStalePPTurns = 0;
pokemon.isStaleHP = pokemon.hp;
}
if (pokemon.isStalePPTurns >= 5) {
if (pokemon.hp >= pokemon.isStaleHP - pokemon.maxhp / 100) pokemon.isStale++;
if (pokemon.hp >= pokemon.isStaleHP - pokemon.maxhp / 100) {
pokemon.isStale++;
pokemon.isStaleSource = 'ppstall';
if (this.firstStaleWarned && pokemon.isStale < 2) {
this.add('html', '<div class="broadcast-red">' + this.escapeHTML(pokemon.name) + ' isn\'t losing PP or HP. If it keeps on not losing PP or HP, it will be classified as being in an endless loop.</div>');
}
}
pokemon.isStaleCon = 0;
pokemon.isStalePPTurns = 0;
pokemon.isStaleHP = pokemon.hp;
}
}
pokemon.isStaleCon += (pokemon.getMoves().length === 0 ? 1 : 0);
if (pokemon.getMoves().length === 0) {
pokemon.isStaleCon++;
pokemon.isStaleSource = 'struggle';
}
if (pokemon.isStale < 2) {
allStale = false;
} else if (pokemon.isStale && !pokemon.staleWarned) {
@ -2942,15 +2970,45 @@ Battle = (function () {
this.sides[i].faintedLastTurn = this.sides[i].faintedThisTurn;
this.sides[i].faintedThisTurn = false;
}
this.add('turn', this.turn);
var banlistTable = this.getFormat().banlistTable;
if (banlistTable && 'Rule:endlessbattleclause' in banlistTable) {
if (oneStale) {
var activationWarning = '<br />If all active Pok&eacute;mon go in an endless loop, Endless Battle Clause will activate.';
if (allStale) activationWarning = '';
var loopReason = '';
switch (oneStale.isStaleSource) {
case 'struggle':
loopReason = ": it isn't losing HP from Struggle";
break;
case 'drag':
loopReason = ": it isn't losing PP or HP from being forced to switch";
break;
case 'switch':
loopReason = ": it isn't losing PP or HP from repeatedly switching";
break;
case 'getleppa':
loopReason = ": it got a Leppa Berry it didn't start with";
break;
case 'useleppa':
loopReason = ": it used a Leppa Berry it didn't start with";
break;
case 'ppstall':
loopReason = ": it isn't losing PP or HP";
break;
case 'ppoverflow':
loopReason = ": its PP overflowed";
break;
}
this.add('html', '<div class="broadcast-red">' + this.escapeHTML(oneStale.name) + ' is in an endless loop' + loopReason + '.' + activationWarning + '</div>');
oneStale.staleWarned = true;
this.firstStaleWarned = true;
}
if (allStale) {
this.add('message', "All active Pok\u00e9mon are in an endless loop. Endless Battle Clause activated!");
var leppaPokemon = null;
for (var i = 0; i < this.sides.length; i++) {
for (var j = 0; j < this.sides[i].active.length; j++) {
var pokemon = this.sides[i].active[j];
for (var j = 0; j < this.sides[i].pokemon.length; j++) {
var pokemon = this.sides[i].pokemon[j];
if (toId(pokemon.set.item) === 'leppaberry') {
if (leppaPokemon) {
leppaPokemon = null; // both sides have Leppa
@ -2969,9 +3027,6 @@ Battle = (function () {
}
this.win();
return;
} else if (oneStale) {
this.add('html', '<div class="broadcast-red">' + this.escapeHTML(oneStale.name) + ' is in an endless loop. If all active Pok&eacute;mon go in an endless loop, Endless Battle Clause will activate.</div>');
oneStale.staleWarned = true;
}
} else {
if (allStale && !this.staleWarned) {
@ -2983,6 +3038,8 @@ Battle = (function () {
}
}
this.add('turn', this.turn);
if (this.gameType === 'triples' && this.sides.map('pokemonLeft').count(1) === this.sides.length) {
// If both sides have one Pokemon left in triples and they are not adjacent, they are both moved to the center.
var center = false;
@ -3874,6 +3931,7 @@ Battle = (function () {
for (var i = 0; i < foeActive.length; i++) {
if (foeActive[i].isStale >= 2) {
decision.pokemon.isStaleCon++;
decision.pokemon.isStaleSource = 'switch';
break;
}
}
@ -3899,6 +3957,7 @@ Battle = (function () {
for (var i = 0; i < foeActive.length; i++) {
if (foeActive[i].isStale >= 2) {
decision.pokemon.isStaleCon++;
decision.pokemon.isStaleSource = 'switch';
break;
}
}

View File

@ -2327,7 +2327,10 @@ exports.BattleItems = {
move.pp += 10;
if (move.pp > move.maxpp) move.pp = move.maxpp;
this.add('-activate', pokemon, 'item: Leppa Berry', move.move);
if (pokemon.item === 'leppaberry') pokemon.isStale = 2;
if (pokemon.item === 'leppaberry') {
pokemon.isStale = 2;
pokemon.isStaleSource = 'useleppa';
}
},
num: 154,
gen: 3,

View File

@ -142,6 +142,8 @@ exports.BattleScripts = {
if (usedMovePos > -1 && pokemon.moveset[usedMovePos].pp === 0) {
// If we were on the middle of the 0 PP sequence, the PPs get reset to 63.
pokemon.moveset[usedMovePos].pp = 63;
pokemon.isStale = 2;
pokemon.isStaleSource = 'ppoverflow';
}
}
}