mirror of
https://github.com/magefree/mage.git
synced 2026-01-25 12:49:39 -08:00
[ROE] 4 cards with tests. ROE is 100% implemented.
This commit is contained in:
parent
309ebc7ee3
commit
0471771451
8 changed files with 936 additions and 0 deletions
167
Mage.Sets/src/mage/sets/riseoftheeldrazi/CastThroughTime.java
Normal file
167
Mage.Sets/src/mage/sets/riseoftheeldrazi/CastThroughTime.java
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
* 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.riseoftheeldrazi;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.keyword.ReboundAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.WatcherImpl;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author magenoxx_at_gmail.com
|
||||
*/
|
||||
public class CastThroughTime extends CardImpl<CastThroughTime> {
|
||||
|
||||
protected static final FilterCard filter = new FilterCard("Instant and sorcery spells you control");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.or(new CardTypePredicate(CardType.INSTANT), new CardTypePredicate(CardType.SORCERY)));
|
||||
}
|
||||
|
||||
public CastThroughTime(UUID ownerId) {
|
||||
super(ownerId, 55, "Cast Through Time", Rarity.MYTHIC, new CardType[]{CardType.ENCHANTMENT}, "{4}{U}{U}{U}");
|
||||
this.expansionSetCode = "ROE";
|
||||
|
||||
this.color.setBlue(true);
|
||||
|
||||
// Instant and sorcery spells you control have rebound.
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainReboundEffect()));
|
||||
|
||||
this.addWatcher(new LeavesBattlefieldWatcher());
|
||||
}
|
||||
|
||||
public CastThroughTime(final CastThroughTime card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CastThroughTime copy() {
|
||||
return new CastThroughTime(this);
|
||||
}
|
||||
}
|
||||
|
||||
class GainReboundEffect extends ContinuousEffectImpl<GainReboundEffect> {
|
||||
|
||||
public GainReboundEffect() {
|
||||
super(Constants.Duration.Custom, Constants.Layer.AbilityAddingRemovingEffects_6, Constants.SubLayer.NA, Constants.Outcome.AddAbility);
|
||||
staticText = "Instant and sorcery spells you control have rebound";
|
||||
}
|
||||
|
||||
public GainReboundEffect(final GainReboundEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainReboundEffect copy() {
|
||||
return new GainReboundEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && permanent != null) {
|
||||
for (Card card : player.getHand().getCards(CastThroughTime.filter, game)) {
|
||||
boolean found = false;
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability instanceof ReboundAbility) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
card.addAbility(new AttachedReboundAbility());
|
||||
Ability ability = new AttachedReboundAbility();
|
||||
ability.setControllerId(source.getControllerId());
|
||||
ability.setSourceId(card.getId());
|
||||
game.getState().addAbility(ability, source.getSourceId(), card);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private class AttachedReboundAbility extends ReboundAbility {}
|
||||
}
|
||||
|
||||
class LeavesBattlefieldWatcher extends WatcherImpl<LeavesBattlefieldWatcher> {
|
||||
|
||||
public LeavesBattlefieldWatcher() {
|
||||
super("LeavesBattlefieldWatcher", Constants.WatcherScope.CARD);
|
||||
}
|
||||
|
||||
public LeavesBattlefieldWatcher(final LeavesBattlefieldWatcher watcher) {
|
||||
super(watcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId())) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
|
||||
if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD) {
|
||||
Player player = game.getPlayer(this.getControllerId());
|
||||
if (player != null) {
|
||||
for (Card card : player.getHand().getCards(CastThroughTime.filter, game)) {
|
||||
Iterator<Ability> it = card.getAbilities().iterator();
|
||||
while (it.hasNext()) {
|
||||
if (it.next() instanceof ReboundAbility) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LeavesBattlefieldWatcher copy() {
|
||||
return new LeavesBattlefieldWatcher(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* 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.riseoftheeldrazi;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.common.CastCardFromOursideTheGameEffect;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.keyword.AnnihilatorAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.permanent.token.EldraziSpawnToken;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author magenoxx_at_gmail.com
|
||||
*/
|
||||
public class SpawnsireOfUlamog extends CardImpl<SpawnsireOfUlamog> {
|
||||
|
||||
private static final String ruleText = "Cast any number of Eldrazi cards you own from outside the game without paying their mana costs";
|
||||
|
||||
private static final FilterCard filter = new FilterCard("Eldrazi cards");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Eldrazi"));
|
||||
}
|
||||
|
||||
public SpawnsireOfUlamog(UUID ownerId) {
|
||||
super(ownerId, 11, "Spawnsire of Ulamog", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{10}");
|
||||
this.expansionSetCode = "ROE";
|
||||
this.subtype.add("Eldrazi");
|
||||
|
||||
this.power = new MageInt(7);
|
||||
this.toughness = new MageInt(11);
|
||||
|
||||
// Annihilator 1
|
||||
this.addAbility(new AnnihilatorAbility(1));
|
||||
|
||||
// {4}: Put two 0/1 colorless Eldrazi Spawn creature tokens onto the battlefield. They have "Sacrifice this creature: Add {1} to your mana pool."
|
||||
this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new CreateTokenEffect(new EldraziSpawnToken(), 2), new GenericManaCost(4)));
|
||||
|
||||
// {20}: Cast any number of Eldrazi cards you own from outside the game without paying their mana costs.
|
||||
this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new CastCardFromOursideTheGameEffect(filter, ruleText), new GenericManaCost(20)));
|
||||
}
|
||||
|
||||
public SpawnsireOfUlamog(final SpawnsireOfUlamog card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpawnsireOfUlamog copy() {
|
||||
return new SpawnsireOfUlamog(this);
|
||||
}
|
||||
}
|
||||
112
Mage.Sets/src/mage/sets/riseoftheeldrazi/WarmongersChariot.java
Normal file
112
Mage.Sets/src/mage/sets/riseoftheeldrazi/WarmongersChariot.java
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* 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.riseoftheeldrazi;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.common.continious.BoostEquippedEffect;
|
||||
import mage.abilities.keyword.DefenderAbility;
|
||||
import mage.abilities.keyword.EquipAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author magenoxx_at_gmail.com
|
||||
*/
|
||||
public class WarmongersChariot extends CardImpl<WarmongersChariot> {
|
||||
|
||||
private static final String staticText = "As long as equipped creature has defender, it can attack as though it didn't have defender";
|
||||
|
||||
public WarmongersChariot(UUID ownerId) {
|
||||
super(ownerId, 226, "Warmonger's Chariot", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}");
|
||||
this.expansionSetCode = "ROE";
|
||||
this.subtype.add("Equipment");
|
||||
|
||||
// Equipped creature gets +2/+2.
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new BoostEquippedEffect(2, 2)));
|
||||
|
||||
// As long as equipped creature has defender, it can attack as though it didn't have defender.
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new WarmongersChariotEffect()));
|
||||
|
||||
// Equip {3}
|
||||
this.addAbility(new EquipAbility(Constants.Outcome.AddAbility, new GenericManaCost(3)));
|
||||
}
|
||||
|
||||
public WarmongersChariot(final WarmongersChariot card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WarmongersChariot copy() {
|
||||
return new WarmongersChariot(this);
|
||||
}
|
||||
}
|
||||
|
||||
class WarmongersChariotEffect extends AsThoughEffectImpl<WarmongersChariotEffect> {
|
||||
|
||||
public WarmongersChariotEffect() {
|
||||
super(Constants.AsThoughEffectType.ATTACK, Constants.Duration.WhileOnBattlefield, Constants.Outcome.Benefit);
|
||||
staticText = "As long as equipped creature has defender, it can attack as though it didn't have defender";
|
||||
}
|
||||
|
||||
public WarmongersChariotEffect(final WarmongersChariotEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WarmongersChariotEffect copy() {
|
||||
return new WarmongersChariotEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
Permanent creature = game.getPermanent(equipment.getAttachedTo());
|
||||
if (creature != null && creature.getId().equals(sourceId)
|
||||
&& creature.getAbilities().containsKey(DefenderAbility.getInstance().getId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
186
Mage.Sets/src/mage/sets/riseoftheeldrazi/WorldAtWar.java
Normal file
186
Mage.Sets/src/mage/sets/riseoftheeldrazi/WorldAtWar.java
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
* 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.riseoftheeldrazi;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.ReboundAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.turn.TurnMod;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.common.AttackedThisTurnWatcher;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author magenoxx_at_gmail.com
|
||||
*/
|
||||
public class WorldAtWar extends CardImpl<WorldAtWar> {
|
||||
|
||||
public WorldAtWar(UUID ownerId) {
|
||||
super(ownerId, 172, "World at War", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{R}{R}");
|
||||
this.expansionSetCode = "ROE";
|
||||
|
||||
this.color.setRed(true);
|
||||
|
||||
// After the first postcombat main phase this turn, there's an additional combat phase followed by an additional main phase. At the beginning of that combat, untap all creatures that attacked this turn.
|
||||
this.getSpellAbility().addEffect(new WorldAtWarEffect());
|
||||
|
||||
// Rebound
|
||||
this.addAbility(new ReboundAbility());
|
||||
|
||||
this.addWatcher(new AttackedThisTurnWatcher());
|
||||
}
|
||||
|
||||
public WorldAtWar(final WorldAtWar card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldAtWar copy() {
|
||||
return new WorldAtWar(this);
|
||||
}
|
||||
}
|
||||
|
||||
class WorldAtWarEffect extends OneShotEffect<WorldAtWarEffect> {
|
||||
|
||||
public WorldAtWarEffect() {
|
||||
super(Constants.Outcome.Benefit);
|
||||
staticText = "After the first postcombat main phase this turn, there's an additional combat phase followed by an additional main phase. At the beginning of that combat, untap all creatures that attacked this turn";
|
||||
}
|
||||
|
||||
public WorldAtWarEffect(final WorldAtWarEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldAtWarEffect copy() {
|
||||
return new WorldAtWarEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
// we can't add two turn modes at once, will add additional post combat on delayed trigger resolution
|
||||
TurnMod combat = new TurnMod(source.getControllerId(), Constants.TurnPhase.COMBAT, Constants.TurnPhase.POSTCOMBAT_MAIN, false);
|
||||
game.getState().getTurnMods().add(combat);
|
||||
UntapDelayedTriggeredAbility delayedTriggeredAbility = new UntapDelayedTriggeredAbility();
|
||||
delayedTriggeredAbility.setSourceId(source.getSourceId());
|
||||
delayedTriggeredAbility.setControllerId(source.getControllerId());
|
||||
delayedTriggeredAbility.setConnectedTurnMod(combat.getId());
|
||||
game.addDelayedTriggeredAbility(delayedTriggeredAbility);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UntapDelayedTriggeredAbility extends DelayedTriggeredAbility<UntapDelayedTriggeredAbility> {
|
||||
|
||||
private UUID connectedTurnMod;
|
||||
private boolean enabled;
|
||||
|
||||
public UntapDelayedTriggeredAbility() {
|
||||
super(new UntapAttackingThisTurnEffect());
|
||||
}
|
||||
|
||||
public UntapDelayedTriggeredAbility(UntapDelayedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.connectedTurnMod = ability.connectedTurnMod;
|
||||
this.enabled = ability.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UntapDelayedTriggeredAbility copy() {
|
||||
return new UntapDelayedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.PHASE_CHANGED && this.connectedTurnMod.equals(event.getSourceId())) {
|
||||
enabled = true;
|
||||
return false;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.COMBAT_PHASE_PRE && enabled) {
|
||||
// add additional post combat phase after that
|
||||
game.getState().getTurnMods().add(new TurnMod(getControllerId(), Constants.TurnPhase.POSTCOMBAT_MAIN, Constants.TurnPhase.COMBAT, false));
|
||||
enabled = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setConnectedTurnMod(UUID connectedTurnMod) {
|
||||
this.connectedTurnMod = connectedTurnMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "At the beginning of that combat, untap all creatures that attacked this turn";
|
||||
}
|
||||
}
|
||||
|
||||
class UntapAttackingThisTurnEffect extends OneShotEffect<UntapAttackingThisTurnEffect> {
|
||||
|
||||
public UntapAttackingThisTurnEffect() {
|
||||
super(Constants.Outcome.Benefit);
|
||||
}
|
||||
|
||||
public UntapAttackingThisTurnEffect(final UntapAttackingThisTurnEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UntapAttackingThisTurnEffect copy() {
|
||||
return new UntapAttackingThisTurnEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Watcher watcher = game.getState().getWatchers().get("AttackedThisTurn");
|
||||
if (watcher != null && watcher instanceof AttackedThisTurnWatcher) {
|
||||
Set<UUID> attackedThisTurn = ((AttackedThisTurnWatcher)watcher).getAttackedThisTurnCreatures();
|
||||
for (UUID uuid : attackedThisTurn) {
|
||||
Permanent permanent = game.getPermanent(uuid);
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
|
||||
permanent.untap(game);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue