Skip to content

Commit

Permalink
Fixed a couple of bugs with battle forfeiting
Browse files Browse the repository at this point in the history
Should work both locally and online now.
  • Loading branch information
varkor committed Jan 5, 2016
1 parent f57bed3 commit 53fd7d1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions battle/scripts/objects/general/BattleContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ function BattleContext (client) {
}
if (!requireProperty(action, "trainer") || !requireProperty(action, "action")) // The `trainer` parameter is effectively guaranteed because Supervisor adds it itself, so we don't need to check that they all match up
return true;
if (action.action === "forfeit") {
if (action.action === "forfeit" && battleContext.state.for === "command") {
if (!battleContext.isCompetitiveBattle()) {
issues.push("The player tried to forfeit a non-PvP battle.");
return true; // Can only forfeit in certain situations
Expand Down Expand Up @@ -1679,12 +1679,18 @@ function BattleContext (client) {
};
} else {
if (!battleContext.process) {
Textbox.state("Everyone forfeited the battel!");
Textbox.state("Everyone forfeited the battle!");
}
endBattleFlags = {
"outcome" : "draw"
};
}
if (battleContext.state.kind === "waiting") {
battleContext.state = {
kind : "running"
};
if (!battleContext.process) Textbox.update();
}
battleContext.endingFlags = endBattleFlags;
battleContext.finish();
battleContext.endDelay();
Expand Down Expand Up @@ -2732,7 +2738,7 @@ function BattleContext (client) {
action : "forfeit"
});
battleContext.flushInputs();
battleContext.waitForActions("command", () => Textbox.state(null));
battleContext.waitForActions("command", () => Textbox.stateUntil("", () => battleContext.state.kind !== "waiting" && Textbox.dialogue.length > 1));
},
attemptCapture : function (poke, ball, character) {
if (arguments.length < 3)
Expand Down

0 comments on commit 53fd7d1

Please sign in to comment.