mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 21:02:08 -08:00
Add GainProtectionFromColorAllEffect and use it for existing cards. Implement card: Glory
This commit is contained in:
parent
a58a2a3215
commit
05342e5176
6 changed files with 255 additions and 189 deletions
54
Mage.Sets/src/mage/sets/judgment/Glory.java
Normal file
54
Mage.Sets/src/mage/sets/judgment/Glory.java
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.sets.judgment;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.Rarity;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class Glory extends mage.sets.prereleaseevents.Glory {
|
||||
|
||||
public Glory(UUID ownerId) {
|
||||
super(ownerId);
|
||||
this.cardNumber = 11;
|
||||
this.expansionSetCode = "JUD";
|
||||
this.rarity = Rarity.RARE;
|
||||
}
|
||||
|
||||
public Glory(final Glory card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Glory copy() {
|
||||
return new Glory(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -29,24 +29,15 @@ package mage.sets.onslaught;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
|
||||
import mage.abilities.effects.common.continuous.GainProtectionFromColorAllEffect;
|
||||
import mage.abilities.keyword.CyclingAbility;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -60,7 +51,7 @@ public class AkromasBlessing extends CardImpl {
|
|||
|
||||
|
||||
// Choose a color. Creatures you control gain protection from the chosen color until end of turn.
|
||||
this.getSpellAbility().addEffect(new AkromasBlessingChooseColorEffect());
|
||||
this.getSpellAbility().addEffect(new GainProtectionFromColorAllEffect(Duration.EndOfTurn, new FilterControlledCreaturePermanent("Creatures you control")));
|
||||
// Cycling {W}
|
||||
this.addAbility(new CyclingAbility(new ManaCostsImpl("{W}")));
|
||||
}
|
||||
|
|
@ -74,46 +65,3 @@ public class AkromasBlessing extends CardImpl {
|
|||
return new AkromasBlessing(this);
|
||||
}
|
||||
}
|
||||
|
||||
class AkromasBlessingChooseColorEffect extends OneShotEffect {
|
||||
|
||||
public AkromasBlessingChooseColorEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Choose a color. Creatures you control gain protection from the chosen color until end of turn";
|
||||
}
|
||||
|
||||
public AkromasBlessingChooseColorEffect(final AkromasBlessingChooseColorEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AkromasBlessingChooseColorEffect copy() {
|
||||
return new AkromasBlessingChooseColorEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (sourceObject != null && controller != null) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
while (!choice.isChosen()) {
|
||||
controller.choose(outcome, choice, game);
|
||||
if (!controller.canRespond()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (choice.getColor() == null) {
|
||||
return false;
|
||||
}
|
||||
game.informPlayers(sourceObject.getName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
|
||||
FilterCard filterColor = new FilterCard();
|
||||
filterColor.add(new ColorPredicate(choice.getColor()));
|
||||
filterColor.setMessage(choice.getChoice());
|
||||
ContinuousEffect effect = new GainAbilityAllEffect(new ProtectionAbility(new FilterCard(filterColor)), Duration.EndOfTurn, new FilterControlledCreaturePermanent());
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
73
Mage.Sets/src/mage/sets/prereleaseevents/Glory.java
Normal file
73
Mage.Sets/src/mage/sets/prereleaseevents/Glory.java
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.sets.prereleaseevents;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.continuous.GainProtectionFromColorAllEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class Glory extends CardImpl {
|
||||
|
||||
public Glory(UUID ownerId) {
|
||||
super(ownerId, 17, "Glory", Rarity.SPECIAL, new CardType[]{CardType.CREATURE}, "{3}{W}{W}");
|
||||
this.expansionSetCode = "PTC";
|
||||
this.subtype.add("Incarnation");
|
||||
this.power = new MageInt(3);
|
||||
this.toughness = new MageInt(3);
|
||||
|
||||
// Flying
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
// {2}{W}: Choose a color. Creatures you control gain protection from the chosen color until end of turn. Activate this ability only if Glory is in your graveyard.
|
||||
Effect effect = new GainProtectionFromColorAllEffect(Duration.EndOfTurn, new FilterControlledCreaturePermanent("Creatures you control"));
|
||||
effect.setText("Choose a color. Creatures you control gain protection from the chosen color until end of turn. Activate this ability only if {this} is in your graveyard.");
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.GRAVEYARD, effect, new ManaCostsImpl("{2}{W}")));
|
||||
}
|
||||
|
||||
public Glory(final Glory card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Glory copy() {
|
||||
return new Glory(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -31,23 +31,13 @@ package mage.sets.zendikar;
|
|||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
import mage.abilities.effects.common.continuous.GainProtectionFromColorAllEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -55,13 +45,19 @@ import mage.players.Player;
|
|||
*/
|
||||
public class BraveTheElements extends CardImpl {
|
||||
|
||||
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("White creatures you control");
|
||||
|
||||
static {
|
||||
filter.add(new ColorPredicate(ObjectColor.WHITE));
|
||||
}
|
||||
|
||||
public BraveTheElements(UUID ownerId) {
|
||||
super(ownerId, 4, "Brave the Elements", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{W}");
|
||||
this.expansionSetCode = "ZEN";
|
||||
|
||||
|
||||
// Choose a color. White creatures you control gain protection from the chosen color until end of turn.
|
||||
this.getSpellAbility().addEffect(new BraveTheElementsChooseColorEffect());
|
||||
this.getSpellAbility().addEffect(new GainProtectionFromColorAllEffect(Duration.EndOfTurn, filter));
|
||||
}
|
||||
|
||||
public BraveTheElements(final BraveTheElements card) {
|
||||
|
|
@ -74,53 +70,3 @@ public class BraveTheElements extends CardImpl {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class BraveTheElementsChooseColorEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterControlledCreaturePermanent filter1 = new FilterControlledCreaturePermanent();
|
||||
|
||||
static {
|
||||
filter1.add(new ColorPredicate(ObjectColor.WHITE));
|
||||
}
|
||||
|
||||
public BraveTheElementsChooseColorEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Choose a color. White creatures you control gain protection from the chosen color until end of turn";
|
||||
}
|
||||
|
||||
public BraveTheElementsChooseColorEffect(final BraveTheElementsChooseColorEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BraveTheElementsChooseColorEffect copy() {
|
||||
return new BraveTheElementsChooseColorEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (sourceObject != null && controller != null) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
while (!choice.isChosen()) {
|
||||
controller.choose(outcome, choice, game);
|
||||
if (!controller.canRespond()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (choice.getColor() == null) {
|
||||
return false;
|
||||
}
|
||||
game.informPlayers(sourceObject.getName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
|
||||
FilterCard filterColor = new FilterCard();
|
||||
filterColor.add(new ColorPredicate(choice.getColor()));
|
||||
filterColor.setMessage(choice.getChoice());
|
||||
ContinuousEffect effect = new GainAbilityAllEffect(new ProtectionAbility(new FilterCard(filterColor)), Duration.EndOfTurn, filter1);
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,31 +29,19 @@ package mage.sets.zendikar;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.continuous.GainProtectionFromColorAllEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardIdPredicate;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -61,6 +49,12 @@ import mage.players.Player;
|
|||
*/
|
||||
public class KabiraEvangel extends CardImpl {
|
||||
|
||||
private static final FilterControlledCreaturePermanent filter1 = new FilterControlledCreaturePermanent();
|
||||
|
||||
static {
|
||||
filter1.add(new SubtypePredicate("Ally"));
|
||||
}
|
||||
|
||||
public KabiraEvangel(UUID ownerId) {
|
||||
super(ownerId, 15, "Kabira Evangel", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{W}");
|
||||
this.expansionSetCode = "ZEN";
|
||||
|
|
@ -71,13 +65,13 @@ public class KabiraEvangel extends CardImpl {
|
|||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(3);
|
||||
|
||||
FilterPermanent filter = new FilterPermanent(getName() + " or another Ally");
|
||||
filter.add(Predicates.or(
|
||||
new CardIdPredicate(this.getId()),
|
||||
new SubtypePredicate("Ally")));
|
||||
FilterPermanent filter2 = new FilterPermanent(getName() + " or another Ally");
|
||||
filter2.add(Predicates.or(new CardIdPredicate(this.getId()), new SubtypePredicate("Ally")));
|
||||
|
||||
// Whenever Kabira Evangel or another Ally enters the battlefield under your control, you may choose a color. If you do, Allies you control gain protection from the chosen color until end of turn.
|
||||
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(Zone.BATTLEFIELD, new KabiraEvangelChooseColorEffect(), filter, true));
|
||||
Effect effect = new GainProtectionFromColorAllEffect(Duration.EndOfTurn, filter1);
|
||||
effect.setText("choose a color. If you do, Allies you control gain protection from the chosen color until end of turn.");
|
||||
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(Zone.BATTLEFIELD, effect, filter2, true));
|
||||
}
|
||||
|
||||
public KabiraEvangel(final KabiraEvangel card) {
|
||||
|
|
@ -89,55 +83,3 @@ public class KabiraEvangel extends CardImpl {
|
|||
return new KabiraEvangel(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class KabiraEvangelChooseColorEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterCreaturePermanent filter1 = new FilterCreaturePermanent();
|
||||
|
||||
static {
|
||||
filter1.add(new ControllerPredicate(TargetController.YOU));
|
||||
filter1.add(new SubtypePredicate("Ally"));
|
||||
}
|
||||
|
||||
public KabiraEvangelChooseColorEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "choose a color. All Allies you control gain protection from the chosen color until end of turn";
|
||||
}
|
||||
|
||||
public KabiraEvangelChooseColorEffect(final KabiraEvangelChooseColorEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent sourceObject = game.getPermanent(source.getSourceId());
|
||||
if (sourceObject != null && controller != null) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
while (!choice.isChosen()) {
|
||||
controller.choose(outcome, choice, game);
|
||||
if (!controller.canRespond()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (choice.getColor() == null) {
|
||||
return false;
|
||||
}
|
||||
game.informPlayers(sourceObject.getName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
|
||||
FilterCard filterColor = new FilterCard();
|
||||
filterColor.add(new ColorPredicate(choice.getColor()));
|
||||
filterColor.setMessage(choice.getChoice());
|
||||
ContinuousEffect effect = new GainAbilityAllEffect(new ProtectionAbility(new FilterCard(filterColor)), Duration.EndOfTurn, filter1);
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KabiraEvangelChooseColorEffect copy() {
|
||||
return new KabiraEvangelChooseColorEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class GainProtectionFromColorAllEffect extends GainAbilityAllEffect {
|
||||
|
||||
protected ChoiceColor choice;
|
||||
|
||||
public GainProtectionFromColorAllEffect(Duration duration, FilterPermanent filter) {
|
||||
super(new ProtectionAbility(new FilterCard()), duration, filter);
|
||||
choice = new ChoiceColor(true);
|
||||
}
|
||||
|
||||
public GainProtectionFromColorAllEffect(final GainProtectionFromColorAllEffect effect) {
|
||||
super(effect);
|
||||
choice = effect.choice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainProtectionFromColorAllEffect copy() {
|
||||
return new GainProtectionFromColorAllEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
FilterCard protectionFilter = (FilterCard)((ProtectionAbility)ability).getFilter();
|
||||
protectionFilter.add(new ColorPredicate(choice.getColor()));
|
||||
protectionFilter.setMessage(choice.getChoice());
|
||||
((ProtectionAbility)ability).setFilter(protectionFilter);
|
||||
return super.apply(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if(sourceObject != null && controller != null) {
|
||||
choice.clearChoice();
|
||||
while(!choice.isChosen()) {
|
||||
controller.choose(Outcome.Protect, choice, game);
|
||||
if(!controller.canRespond()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(choice.isChosen() && !game.isSimulation()) {
|
||||
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen protection from " + choice.getChoice()); }
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if(staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
|
||||
String text = "Choose a color. " + filter.getMessage() + " gain protection from the chosen color " + duration.toString();
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue