finished Voice of All implementation

This commit is contained in:
mnapoleon 2015-04-22 15:21:48 -04:00
parent 52a52b950c
commit d99e81cf8f

View file

@ -29,15 +29,11 @@ package mage.sets.planeshift;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseColorEffect;
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
import mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.ProtectionAbility; import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -49,7 +45,6 @@ import mage.constants.Rarity;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
/** /**
@ -68,10 +63,8 @@ public class VoiceOfAll extends CardImpl {
// Flying // Flying
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// As Voice of All enters the battlefield, choose a color. // As Voice of All enters the battlefield, choose a color.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Protect)));
// Voice of All has protection from the chosen color. // Voice of All has protection from the chosen color.
this.getSpellAbility().addEffect(new VoiceOfAllEffect()); this.addAbility(new EntersBattlefieldAbility(new VoiceOfAllEffect()));
} }
public VoiceOfAll(final VoiceOfAll card) { public VoiceOfAll(final VoiceOfAll card) {
@ -88,7 +81,7 @@ class VoiceOfAllEffect extends OneShotEffect {
public VoiceOfAllEffect() { public VoiceOfAllEffect() {
super(Outcome.Protect); super(Outcome.Protect);
this.staticText = "{this} gains protection from the color of your choice until end of turn"; this.staticText = "{this} gains protection from the color of your choice";
} }
public VoiceOfAllEffect(final VoiceOfAllEffect effect) { public VoiceOfAllEffect(final VoiceOfAllEffect effect) {
@ -105,12 +98,11 @@ class VoiceOfAllEffect extends OneShotEffect {
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
choice.setMessage("Choose color to get protection from"); choice.setMessage("Choose color to get protection from");
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
if (controller != null && controller.choose(outcome, choice, game)) { if (controller != null && controller.choose(outcome, choice, game)) {
FilterCard protectionFilter = new FilterCard(); FilterCard protectionFilter = new FilterCard();
protectionFilter.add(new ColorPredicate(choice.getColor())); protectionFilter.add(new ColorPredicate(choice.getColor()));
protectionFilter.setMessage(choice.getChoice().toLowerCase()); protectionFilter.setMessage(choice.getChoice().toLowerCase());
ContinuousEffect effect = new GainAbilitySourceEffect(new ProtectionAbility(protectionFilter), Duration.EndOfTurn); ContinuousEffect effect = new GainAbilitySourceEffect(new ProtectionAbility(protectionFilter), Duration.WhileOnBattlefield);
game.addEffect(effect, source); game.addEffect(effect, source);
return true; return true;
} }