mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +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;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
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.ProtectionAbility;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -40,6 +43,7 @@ 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;
|
||||
|
@ -57,7 +61,7 @@ public class AkromasBlessing extends CardImpl {
|
|||
this.color.setWhite(true);
|
||||
|
||||
// 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}
|
||||
this.addAbility(new CyclingAbility(new ManaCostsImpl("{W}")));
|
||||
}
|
||||
|
@ -72,44 +76,45 @@ public class AkromasBlessing extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class AkromasBlessingChooseColorEffect extends OneShotEffect {
|
||||
|
||||
class AcromasBlessingEffect extends GainAbilityControlledEffect {
|
||||
|
||||
private final FilterCard filter2;
|
||||
|
||||
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 AkromasBlessingChooseColorEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.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);
|
||||
this.filter2 = effect.filter2.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AcromasBlessingEffect copy() {
|
||||
return new AcromasBlessingEffect(this);
|
||||
public AkromasBlessingChooseColorEffect copy() {
|
||||
return new AkromasBlessingChooseColorEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (sourceObject != null && controller != null) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
while (!choice.isChosen()) {
|
||||
controller.choose(Outcome.Protect, choice, game);
|
||||
controller.choose(outcome, choice, game);
|
||||
if (!controller.isInGame()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
filter2.add(new ColorPredicate(choice.getColor()));
|
||||
filter2.setMessage(choice.getChoice());
|
||||
setAbility(new ProtectionAbility(new FilterCard(filter2)));
|
||||
return super.apply(game, source);
|
||||
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, new FilterControlledCreaturePermanent());
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,21 +28,25 @@
|
|||
|
||||
package mage.sets.zendikar;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
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.continious.GainAbilityAllEffect;
|
||||
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
|
||||
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.FilterCreaturePermanent;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
|
@ -57,7 +61,7 @@ public class BraveTheElements extends CardImpl {
|
|||
this.color.setWhite(true);
|
||||
|
||||
// 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) {
|
||||
|
@ -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 {
|
||||
filter1.add(new ColorPredicate(ObjectColor.WHITE));
|
||||
}
|
||||
|
||||
private final FilterCard filter2;
|
||||
|
||||
public BraveTheElementsEffect() {
|
||||
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 BraveTheElementsChooseColorEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.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);
|
||||
this.filter2 = effect.filter2.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BraveTheElementsEffect copy() {
|
||||
return new BraveTheElementsEffect(this);
|
||||
public BraveTheElementsChooseColorEffect copy() {
|
||||
return new BraveTheElementsChooseColorEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getFirstTarget());
|
||||
if (controller != null) {
|
||||
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);
|
||||
|
@ -111,12 +113,14 @@ class BraveTheElementsEffect extends GainAbilityControlledEffect {
|
|||
if (choice.getColor() == null) {
|
||||
return false;
|
||||
}
|
||||
filter2.add(new ColorPredicate(choice.getColor()));
|
||||
filter2.setMessage(choice.getChoice());
|
||||
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, filter1);
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@ package mage.sets.zendikar;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
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.cards.CardImpl;
|
||||
import mage.choices.ChoiceColor;
|
||||
|
@ -72,13 +72,13 @@ public class KabiraEvangel extends CardImpl {
|
|||
this.power = new MageInt(2);
|
||||
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(
|
||||
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 ChooseColorEffect(), filter, true));
|
||||
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(Zone.BATTLEFIELD, new KabiraEvangelChooseColorEffect(), filter, true));
|
||||
}
|
||||
|
||||
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) {
|
||||
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 {
|
||||
class KabiraEvangelChooseColorEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterCreaturePermanent filter1 = new FilterCreaturePermanent();
|
||||
|
||||
|
@ -131,31 +101,44 @@ class GainProtectionFromChosenColorEffect extends GainAbilityControlledEffect {
|
|||
filter1.add(new ControllerPredicate(TargetController.YOU));
|
||||
filter1.add(new SubtypePredicate("Ally"));
|
||||
}
|
||||
private final FilterCard filter2;
|
||||
private final ObjectColor chosenColor;
|
||||
|
||||
public GainProtectionFromChosenColorEffect(ObjectColor chosenColor) {
|
||||
super(new ProtectionAbility(new FilterCard()), Duration.EndOfTurn, filter1);
|
||||
filter2 = (FilterCard) ((ProtectionAbility) getFirstAbility()).getFilter();
|
||||
this.chosenColor = chosenColor;
|
||||
public KabiraEvangelChooseColorEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "choose a color. All Allies you control gain protection from the chosen color until end of turn";
|
||||
}
|
||||
|
||||
public GainProtectionFromChosenColorEffect(final GainProtectionFromChosenColorEffect effect) {
|
||||
public KabiraEvangelChooseColorEffect(final KabiraEvangelChooseColorEffect effect) {
|
||||
super(effect);
|
||||
this.filter2 = effect.filter2.copy();
|
||||
this.chosenColor = effect.chosenColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainProtectionFromChosenColorEffect copy() {
|
||||
return new GainProtectionFromChosenColorEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
filter2.add(new ColorPredicate(chosenColor));
|
||||
filter2.setMessage(chosenColor.getDescription());
|
||||
setAbility(new ProtectionAbility(new FilterCard(filter2)));
|
||||
return super.apply(game, 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.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;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -14,9 +15,7 @@ public class CompoundAbility extends AbilitiesImpl<Ability> {
|
|||
}
|
||||
|
||||
public CompoundAbility(String ruleText, Ability... abilities) {
|
||||
for (Ability ability : abilities) {
|
||||
add(ability);
|
||||
}
|
||||
addAll(Arrays.asList(abilities));
|
||||
}
|
||||
|
||||
public CompoundAbility(final CompoundAbility compoundAbility) {
|
||||
|
|
Loading…
Reference in a new issue