mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Burning Cinder Fury of Crimson Chaos Fire - Fixed opponent slection.
This commit is contained in:
parent
e614b8573e
commit
9b46406c86
2 changed files with 38 additions and 31 deletions
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
package mage.cards.b;
|
package mage.cards.b;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -16,12 +17,15 @@ import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
|
import mage.filter.FilterPlayer;
|
||||||
|
import mage.filter.predicate.Predicates;
|
||||||
|
import mage.filter.predicate.other.PlayerIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.common.TargetOpponent;
|
import mage.target.TargetPlayer;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.Watcher;
|
||||||
|
|
||||||
|
@ -38,7 +42,7 @@ public final class BurningCinderFuryOfCrimsonChaosFire extends CardImpl {
|
||||||
this.addAbility(new BurningCinderFuryOfCrimsonChaosFireAbility());
|
this.addAbility(new BurningCinderFuryOfCrimsonChaosFireAbility());
|
||||||
|
|
||||||
// At the beginning of each player’s end step, if that player didn’t tap any nonland permanents that turn, Burning Cinder Fury of Crimson Chaos Fire deals 3 damage to that player.
|
// At the beginning of each player’s end step, if that player didn’t tap any nonland permanents that turn, Burning Cinder Fury of Crimson Chaos Fire deals 3 damage to that player.
|
||||||
this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new DamageTargetEffect(3).setText("{this} deals 3 damage to that player"),
|
this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new DamageTargetEffect(3).setText("{this} deals 3 damage to that player"),
|
||||||
TargetController.ANY, new BurningCinderFuryOfCrimsonChaosFireCondition(), false), new BurningCinderFuryOfCrimsonChaosFireWatcher());
|
TargetController.ANY, new BurningCinderFuryOfCrimsonChaosFireCondition(), false), new BurningCinderFuryOfCrimsonChaosFireWatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +76,8 @@ class BurningCinderFuryOfCrimsonChaosFireAbility extends TriggeredAbilityImpl {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
BurningCinderFuryOfCrimsonChaosFireEffect effect = (BurningCinderFuryOfCrimsonChaosFireEffect) this.getEffects().get(0);
|
BurningCinderFuryOfCrimsonChaosFireEffect effect = (BurningCinderFuryOfCrimsonChaosFireEffect) this.getEffects().get(0);
|
||||||
effect.setTargetPointer(new FixedTarget(permanent.getId()));
|
effect.setTargetPointer(new FixedTarget(permanent, game));
|
||||||
effect.setFirstController(permanent.getControllerId()); // it's necessary to remember the original controller, as the controller might change by the time the trigger resolves
|
effect.setFirstControllerId(permanent.getControllerId()); // it's necessary to remember the original controller, as the controller might change by the time the trigger resolves
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -92,7 +96,7 @@ class BurningCinderFuryOfCrimsonChaosFireAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
class BurningCinderFuryOfCrimsonChaosFireEffect extends OneShotEffect {
|
class BurningCinderFuryOfCrimsonChaosFireEffect extends OneShotEffect {
|
||||||
|
|
||||||
private UUID firstController = null;
|
private UUID firstControllerId = null;
|
||||||
|
|
||||||
public BurningCinderFuryOfCrimsonChaosFireEffect() {
|
public BurningCinderFuryOfCrimsonChaosFireEffect() {
|
||||||
super(Outcome.Detriment);
|
super(Outcome.Detriment);
|
||||||
|
@ -101,37 +105,42 @@ class BurningCinderFuryOfCrimsonChaosFireEffect extends OneShotEffect {
|
||||||
|
|
||||||
public BurningCinderFuryOfCrimsonChaosFireEffect(final BurningCinderFuryOfCrimsonChaosFireEffect effect) {
|
public BurningCinderFuryOfCrimsonChaosFireEffect(final BurningCinderFuryOfCrimsonChaosFireEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.firstController = effect.firstController;
|
this.firstControllerId = effect.firstControllerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BurningCinderFuryOfCrimsonChaosFireEffect copy() {
|
public BurningCinderFuryOfCrimsonChaosFireEffect copy() {
|
||||||
return new BurningCinderFuryOfCrimsonChaosFireEffect(this);
|
return new BurningCinderFuryOfCrimsonChaosFireEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFirstController(UUID newId) {
|
public void setFirstControllerId(UUID newId) {
|
||||||
this.firstController = newId;
|
this.firstControllerId = newId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(firstController);
|
Player tappingPlayer = game.getPlayer(firstControllerId);
|
||||||
if (player != null) {
|
Permanent permanentToControl = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||||
Target target = new TargetOpponent(true);
|
if (tappingPlayer != null && permanentToControl != null) {
|
||||||
if (target.canChoose(player.getId(), game)) {
|
// Create opponent filter list manually because otherwise opponent check prevents controller of this to be valid
|
||||||
while (!target.isChosen() && target.canChoose(player.getId(), game) && player.canRespond()) {
|
FilterPlayer filter = new FilterPlayer("opponent to control " + permanentToControl.getIdName());
|
||||||
player.chooseTarget(outcome, target, source, game);
|
List<PlayerIdPredicate> opponentPredicates = new ArrayList<>();
|
||||||
}
|
for (UUID opponentId : game.getOpponents(firstControllerId)) {
|
||||||
|
opponentPredicates.add(new PlayerIdPredicate(opponentId));
|
||||||
}
|
}
|
||||||
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
filter.add(Predicates.or(opponentPredicates));
|
||||||
Player chosenOpponent = game.getPlayer(target.getFirstTarget());
|
Target target = new TargetPlayer(1, 1, true, filter);
|
||||||
|
target.setTargetController(firstControllerId);
|
||||||
if (permanent != null && chosenOpponent != null) {
|
target.setAbilityController(source.getControllerId());
|
||||||
game.informPlayers(player.getLogName() + " chose " + chosenOpponent.getLogName() + " to gain control of " + permanent.getLogName() + " at the beginning of the next end step");
|
if (tappingPlayer.chooseTarget(outcome, target, source, game)) {
|
||||||
ContinuousEffect effect = new BurningCinderFuryOfCrimsonChaosFireCreatureGainControlEffect(Duration.Custom, chosenOpponent.getId());
|
Player chosenOpponent = game.getPlayer(target.getFirstTarget());
|
||||||
effect.setTargetPointer(new FixedTarget(permanent.getId()));
|
if (chosenOpponent != null) {
|
||||||
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
|
game.informPlayers(tappingPlayer.getLogName() + " chose " + chosenOpponent.getLogName() + " to gain control of " + permanentToControl.getLogName() + " at the beginning of the next end step");
|
||||||
return true;
|
ContinuousEffect effect = new BurningCinderFuryOfCrimsonChaosFireCreatureGainControlEffect(Duration.Custom, chosenOpponent.getId());
|
||||||
|
effect.setTargetPointer(new FixedTarget(permanentToControl.getId()));
|
||||||
|
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
|
|
||||||
package mage.target;
|
package mage.target;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.filter.FilterPlayer;
|
import mage.filter.FilterPlayer;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
Loading…
Reference in a new issue