mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
* Brave the Elements - Fixed not working choose color effect.
This commit is contained in:
parent
643b7a5ad8
commit
28ed7f1b63
4 changed files with 95 additions and 104 deletions
|
@ -28,9 +28,12 @@
|
||||||
package mage.sets.onslaught;
|
package mage.sets.onslaught;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
|
import mage.abilities.effects.ContinuousEffect;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.continious.GainAbilityAllEffect;
|
||||||
import mage.abilities.keyword.CyclingAbility;
|
import mage.abilities.keyword.CyclingAbility;
|
||||||
import mage.abilities.keyword.ProtectionAbility;
|
import mage.abilities.keyword.ProtectionAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
@ -40,6 +43,7 @@ import mage.constants.Duration;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.filter.FilterCard;
|
import mage.filter.FilterCard;
|
||||||
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
@ -57,7 +61,7 @@ public class AkromasBlessing extends CardImpl {
|
||||||
this.color.setWhite(true);
|
this.color.setWhite(true);
|
||||||
|
|
||||||
// Choose a color. Creatures you control gain protection from the chosen color until end of turn.
|
// Choose a color. Creatures you control gain protection from the chosen color until end of turn.
|
||||||
this.getSpellAbility().addEffect(new AcromasBlessingEffect());
|
this.getSpellAbility().addEffect(new AkromasBlessingChooseColorEffect());
|
||||||
// Cycling {W}
|
// Cycling {W}
|
||||||
this.addAbility(new CyclingAbility(new ManaCostsImpl("{W}")));
|
this.addAbility(new CyclingAbility(new ManaCostsImpl("{W}")));
|
||||||
}
|
}
|
||||||
|
@ -72,44 +76,45 @@ public class AkromasBlessing extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AkromasBlessingChooseColorEffect extends OneShotEffect {
|
||||||
|
|
||||||
class AcromasBlessingEffect extends GainAbilityControlledEffect {
|
public AkromasBlessingChooseColorEffect() {
|
||||||
|
super(Outcome.Benefit);
|
||||||
private final FilterCard filter2;
|
this.staticText = "Choose a color. Creatures you control gain protection from the chosen color until end of turn";
|
||||||
|
|
||||||
public AcromasBlessingEffect() {
|
|
||||||
super(new ProtectionAbility(new FilterCard()), Duration.EndOfTurn);
|
|
||||||
filter2 = (FilterCard)((ProtectionAbility)getFirstAbility()).getFilter();
|
|
||||||
staticText = "Choose a color. Creatures you control gain protection from the chosen color until end of turn";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AcromasBlessingEffect(final AcromasBlessingEffect effect) {
|
public AkromasBlessingChooseColorEffect(final AkromasBlessingChooseColorEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.filter2 = effect.filter2.copy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AcromasBlessingEffect copy() {
|
public AkromasBlessingChooseColorEffect copy() {
|
||||||
return new AcromasBlessingEffect(this);
|
return new AkromasBlessingChooseColorEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null) {
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
|
if (sourceObject != null && controller != null) {
|
||||||
ChoiceColor choice = new ChoiceColor();
|
ChoiceColor choice = new ChoiceColor();
|
||||||
while (!choice.isChosen()) {
|
while (!choice.isChosen()) {
|
||||||
controller.choose(Outcome.Protect, choice, game);
|
controller.choose(outcome, choice, game);
|
||||||
if (!controller.isInGame()) {
|
if (!controller.isInGame()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filter2.add(new ColorPredicate(choice.getColor()));
|
if (choice.getColor() == null) {
|
||||||
filter2.setMessage(choice.getChoice());
|
return false;
|
||||||
setAbility(new ProtectionAbility(new FilterCard(filter2)));
|
}
|
||||||
return super.apply(game, source);
|
game.informPlayers(sourceObject.getName() + ": " + controller.getName() + " 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,21 +28,25 @@
|
||||||
|
|
||||||
package mage.sets.zendikar;
|
package mage.sets.zendikar;
|
||||||
|
|
||||||
import mage.constants.CardType;
|
import java.util.UUID;
|
||||||
import mage.constants.Duration;
|
import mage.MageObject;
|
||||||
import mage.constants.Rarity;
|
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.effects.ContinuousEffect;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.continious.GainAbilityAllEffect;
|
||||||
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
|
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
|
||||||
import mage.abilities.keyword.ProtectionAbility;
|
import mage.abilities.keyword.ProtectionAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.choices.ChoiceColor;
|
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.FilterCard;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +61,7 @@ public class BraveTheElements extends CardImpl {
|
||||||
this.color.setWhite(true);
|
this.color.setWhite(true);
|
||||||
|
|
||||||
// Choose a color. White creatures you control gain protection from the chosen color until end of turn.
|
// Choose a color. White creatures you control gain protection from the chosen color until end of turn.
|
||||||
this.getSpellAbility().addEffect(new BraveTheElementsEffect());
|
this.getSpellAbility().addEffect(new BraveTheElementsChooseColorEffect());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BraveTheElements(final BraveTheElements card) {
|
public BraveTheElements(final BraveTheElements card) {
|
||||||
|
@ -71,36 +75,34 @@ public class BraveTheElements extends CardImpl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class BraveTheElementsEffect extends GainAbilityControlledEffect {
|
|
||||||
|
|
||||||
private static final FilterCreaturePermanent filter1 = new FilterCreaturePermanent();
|
class BraveTheElementsChooseColorEffect extends OneShotEffect {
|
||||||
|
|
||||||
|
private static final FilterControlledCreaturePermanent filter1 = new FilterControlledCreaturePermanent();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter1.add(new ColorPredicate(ObjectColor.WHITE));
|
filter1.add(new ColorPredicate(ObjectColor.WHITE));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final FilterCard filter2;
|
public BraveTheElementsChooseColorEffect() {
|
||||||
|
super(Outcome.Benefit);
|
||||||
public BraveTheElementsEffect() {
|
this.staticText = "Choose a color. White creatures you control gain protection from the chosen color until end of turn";
|
||||||
super(new ProtectionAbility(new FilterCard()), Duration.EndOfTurn, filter1);
|
|
||||||
filter2 = (FilterCard)((ProtectionAbility)getFirstAbility()).getFilter();
|
|
||||||
staticText = "Choose a color. White creatures you control gain protection from the chosen color until end of turn";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BraveTheElementsEffect(final BraveTheElementsEffect effect) {
|
public BraveTheElementsChooseColorEffect(final BraveTheElementsChooseColorEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.filter2 = effect.filter2.copy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BraveTheElementsEffect copy() {
|
public BraveTheElementsChooseColorEffect copy() {
|
||||||
return new BraveTheElementsEffect(this);
|
return new BraveTheElementsChooseColorEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getFirstTarget());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null) {
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
|
if (sourceObject != null && controller != null) {
|
||||||
ChoiceColor choice = new ChoiceColor();
|
ChoiceColor choice = new ChoiceColor();
|
||||||
while (!choice.isChosen()) {
|
while (!choice.isChosen()) {
|
||||||
controller.choose(outcome, choice, game);
|
controller.choose(outcome, choice, game);
|
||||||
|
@ -111,12 +113,14 @@ class BraveTheElementsEffect extends GainAbilityControlledEffect {
|
||||||
if (choice.getColor() == null) {
|
if (choice.getColor() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
filter2.add(new ColorPredicate(choice.getColor()));
|
game.informPlayers(sourceObject.getName() + ": " + controller.getName() + " has chosen " + choice.getChoice());
|
||||||
filter2.setMessage(choice.getChoice());
|
FilterCard filterColor = new FilterCard();
|
||||||
setAbility(new ProtectionAbility(new FilterCard(filter2)));
|
filterColor.add(new ColorPredicate(choice.getColor()));
|
||||||
return super.apply(game, source);
|
filterColor.setMessage(choice.getChoice());
|
||||||
|
ContinuousEffect effect = new GainAbilityAllEffect(new ProtectionAbility(new FilterCard(filterColor)), Duration.EndOfTurn, filter1);
|
||||||
|
game.addEffect(effect, source);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -29,11 +29,11 @@ package mage.sets.zendikar;
|
||||||
|
|
||||||
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.EntersBattlefieldControlledTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
|
||||||
|
import mage.abilities.effects.ContinuousEffect;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
|
import mage.abilities.effects.common.continious.GainAbilityAllEffect;
|
||||||
import mage.abilities.keyword.ProtectionAbility;
|
import mage.abilities.keyword.ProtectionAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.choices.ChoiceColor;
|
import mage.choices.ChoiceColor;
|
||||||
|
@ -72,13 +72,13 @@ public class KabiraEvangel extends CardImpl {
|
||||||
this.power = new MageInt(2);
|
this.power = new MageInt(2);
|
||||||
this.toughness = new MageInt(3);
|
this.toughness = new MageInt(3);
|
||||||
|
|
||||||
FilterPermanent filter = new FilterPermanent("Kabira Evangel or another Ally");
|
FilterPermanent filter = new FilterPermanent(getName() + " or another Ally");
|
||||||
filter.add(Predicates.or(
|
filter.add(Predicates.or(
|
||||||
new CardIdPredicate(this.getId()),
|
new CardIdPredicate(this.getId()),
|
||||||
new SubtypePredicate("Ally")));
|
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.
|
// 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 ChooseColorEffect(), filter, true));
|
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(Zone.BATTLEFIELD, new KabiraEvangelChooseColorEffect(), filter, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KabiraEvangel(final KabiraEvangel card) {
|
public KabiraEvangel(final KabiraEvangel card) {
|
||||||
|
@ -91,39 +91,9 @@ public class KabiraEvangel extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChooseColorEffect extends OneShotEffect {
|
|
||||||
|
|
||||||
public ChooseColorEffect() {
|
|
||||||
super(Outcome.Benefit);
|
|
||||||
staticText = "choose a color. All Allies you control gain protection from the chosen color until end of turn";
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChooseColorEffect(final ChooseColorEffect effect) {
|
class KabiraEvangelChooseColorEffect extends OneShotEffect {
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
|
||||||
Permanent perm = game.getPermanent(source.getSourceId());
|
|
||||||
if (player != null && perm != null) {
|
|
||||||
ChoiceColor colorChoice = new ChoiceColor();
|
|
||||||
if (player.choose(Outcome.Benefit, colorChoice, game)) {
|
|
||||||
game.informPlayers(perm.getName() + ": " + player.getName() + " has chosen " + colorChoice.getChoice());
|
|
||||||
game.addEffect(new GainProtectionFromChosenColorEffect(colorChoice.getColor()), source);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChooseColorEffect copy() {
|
|
||||||
return new ChooseColorEffect(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class GainProtectionFromChosenColorEffect extends GainAbilityControlledEffect {
|
|
||||||
|
|
||||||
private static final FilterCreaturePermanent filter1 = new FilterCreaturePermanent();
|
private static final FilterCreaturePermanent filter1 = new FilterCreaturePermanent();
|
||||||
|
|
||||||
|
@ -131,31 +101,44 @@ class GainProtectionFromChosenColorEffect extends GainAbilityControlledEffect {
|
||||||
filter1.add(new ControllerPredicate(TargetController.YOU));
|
filter1.add(new ControllerPredicate(TargetController.YOU));
|
||||||
filter1.add(new SubtypePredicate("Ally"));
|
filter1.add(new SubtypePredicate("Ally"));
|
||||||
}
|
}
|
||||||
private final FilterCard filter2;
|
|
||||||
private final ObjectColor chosenColor;
|
|
||||||
|
|
||||||
public GainProtectionFromChosenColorEffect(ObjectColor chosenColor) {
|
public KabiraEvangelChooseColorEffect() {
|
||||||
super(new ProtectionAbility(new FilterCard()), Duration.EndOfTurn, filter1);
|
super(Outcome.Benefit);
|
||||||
filter2 = (FilterCard) ((ProtectionAbility) getFirstAbility()).getFilter();
|
staticText = "choose a color. All Allies you control gain protection from the chosen color until end of turn";
|
||||||
this.chosenColor = chosenColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GainProtectionFromChosenColorEffect(final GainProtectionFromChosenColorEffect effect) {
|
public KabiraEvangelChooseColorEffect(final KabiraEvangelChooseColorEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.filter2 = effect.filter2.copy();
|
|
||||||
this.chosenColor = effect.chosenColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GainProtectionFromChosenColorEffect copy() {
|
|
||||||
return new GainProtectionFromChosenColorEffect(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
filter2.add(new ColorPredicate(chosenColor));
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
filter2.setMessage(chosenColor.getDescription());
|
Permanent sourceObject = game.getPermanent(source.getSourceId());
|
||||||
setAbility(new ProtectionAbility(new FilterCard(filter2)));
|
if (sourceObject != null && controller != null) {
|
||||||
return super.apply(game, source);
|
ChoiceColor choice = new ChoiceColor();
|
||||||
|
while (!choice.isChosen()) {
|
||||||
|
controller.choose(outcome, choice, game);
|
||||||
|
if (!controller.isInGame()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (choice.getColor() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
game.informPlayers(sourceObject.getName() + ": " + controller.getName() + " 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package mage.abilities;
|
package mage.abilities;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,9 +15,7 @@ public class CompoundAbility extends AbilitiesImpl<Ability> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundAbility(String ruleText, Ability... abilities) {
|
public CompoundAbility(String ruleText, Ability... abilities) {
|
||||||
for (Ability ability : abilities) {
|
addAll(Arrays.asList(abilities));
|
||||||
add(ability);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundAbility(final CompoundAbility compoundAbility) {
|
public CompoundAbility(final CompoundAbility compoundAbility) {
|
||||||
|
|
Loading…
Reference in a new issue