Skip to content

Commit

Permalink
Fixed a bug with the text for effects that run out
Browse files Browse the repository at this point in the history
This fixes #203.
  • Loading branch information
varkor committed Feb 27, 2016
1 parent 868f4e3 commit 8ae712d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions battle/scripts/data/Moves.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,9 @@ const Moves = {
targets : Move.targets.opposingSide,
effects : {
constant : function (self, target) {
if (!self.battler.battle.hasEffectOnSide(Moves._("Heal Block"), target)) {
if (!self.battler.battle.hasEffectOnSide("Heal Block", target)) {
if (!self.battler.battle.process) Textbox.state(self.name() + " put a Heal Block into effect.");
self.battler.battle.bringIntoEffect(Moves._("Heal Block"), Battles.when.afterFiveTurns, target);
self.battler.battle.bringIntoEffect("Heal Block", Moves._("Heal Block"), Battles.when.afterFiveTurns, target);
} else {
return {
failed : true
Expand Down
18 changes: 11 additions & 7 deletions battle/scripts/objects/general/BattleContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -2142,15 +2142,18 @@ function BattleContext (client) {
endTurn : function () {
if (!battleContext.active || battleContext.finished)
return;
foreach(battleContext.effects.near, function (effect, i, deletion) {
if (battleContext.turns >= Math.floor(effect.expiration)) {
if (!battleContext.process) Textbox.state(battleContext.alliedTrainers[0].possessivePronoun(true) + " " + effect.type + " ran out.");
deletion.push(i);
}
foreach([battleContext.effects.near, battleContext.effects.far], side => {
foreach(side, function (effect, i, deletion) {
if (battleContext.turns >= Math.floor(effect.expiration)) {
if (!battleContext.process) Textbox.state((battleContext.isWildBattle() ? "The wild Pokémon's" : battleContext.alliedTrainers[0].possessivePronoun(true)) + " " + effect.name + " ran out.");
deletion.push(i);
}
});
});

foreach(battleContext.effects.far, function (effect, i, deletion) {
if (battleContext.turns >= Math.floor(effect.expiration)) {
if (!battleContext.process) Textbox.state(battleContext.opposingTrainers[0].possessivePronoun(true) + " " + effect.type + " ran out.");
if (!battleContext.process) Textbox.state((battleContext.isWildBattle() ? "The wild Pokémon's" : battleContext.alliedTrainers[0].possessivePronoun(true)) + " " + effect.name + " ran out.");
deletion.push(i);
}
});
Expand Down Expand Up @@ -3231,7 +3234,7 @@ function BattleContext (client) {
});
return !maxedOut;
},
bringIntoEffect : function (effect, duration, side) {
bringIntoEffect : function (name, effect, duration, side) {
var effectSide = (side === Battles.side.near ? battleContext.effects.near : battleContext.effects.far);
if (!foreach(effectSide, function (which) {
if (which.type === effect) {
Expand All @@ -3240,6 +3243,7 @@ function BattleContext (client) {
}
}))
effectSide.push({
name,
type : effect,
expiration : battleContext.turns + duration
});
Expand Down

0 comments on commit 8ae712d

Please sign in to comment.