* Fixed a problem that optional effects could produce IndexOutOfBoundsExceptions.

This commit is contained in:
LevelX2 2016-11-19 12:47:20 +01:00
parent 8e42660e33
commit ca25cc4679
5 changed files with 19 additions and 12 deletions

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.MageObject;
import mage.abilities.effects.Effect;
import mage.constants.AbilityType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -88,7 +89,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
MageObject object = game.getObject(getSourceId());
Player player = game.getPlayer(this.getControllerId());
if (player != null && object != null) {
if (!player.chooseUse(getEffects().get(0).getOutcome(), this.getRule(object.getLogName()), this, game)) {
if (!player.chooseUse(getEffects().isEmpty() ? Outcome.Detriment : getEffects().get(0).getOutcome(), this.getRule(object.getLogName()), this, game)) {
return false;
}
} else {