Merge pull request #4101 from magefree/phasingFix

Fixed how phasing is implemented
This commit is contained in:
LevelX2 2017-11-02 11:00:33 +01:00 committed by GitHub
commit b4ee3ff1da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 159 additions and 27 deletions

View file

@ -27,11 +27,13 @@
*/
package mage.cards.e;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PhaseOutAllEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -55,8 +57,7 @@ import mage.target.TargetPlayer;
public class Equipoise extends CardImpl {
public Equipoise(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
// At the beginning of your upkeep, for each land target player controls in excess of the number you control, choose a land he or she controls, then the chosen permanents phase out. Repeat this process for artifacts and creatures.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new EquipoiseEffect(), TargetController.YOU, false);
@ -112,17 +113,12 @@ class EquipoiseEffect extends OneShotEffect {
int numberTargetPlayer = game.getBattlefield().count(filter, source.getSourceId(), targetPlayer.getId(), game);
int excess = numberTargetPlayer - numberController;
if (excess > 0) {
FilterPermanent filterChoose = new FilterPermanent(cardType.toString().toLowerCase() + (excess > 1 ? "s":"") +" of target player");
FilterPermanent filterChoose = new FilterPermanent(cardType.toString().toLowerCase() + (excess > 1 ? "s" : "") + " of target player");
filterChoose.add(new ControllerIdPredicate(targetPlayer.getId()));
filterChoose.add(new CardTypePredicate(cardType));
Target target = new TargetPermanent(excess, excess, filterChoose, true);
controller.chooseTarget(outcome, target, source, game);
for (UUID permanentId:target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
permanent.phaseOut(game);
}
}
new PhaseOutAllEffect(target.getTargets()).apply(game, source);
}
}
}

View file

@ -27,11 +27,14 @@
*/
package mage.cards.t;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PhaseOutAllEffect;
import mage.abilities.keyword.PhasingAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
@ -41,6 +44,7 @@ import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SuperType;
import mage.constants.TargetController;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -53,7 +57,7 @@ import mage.players.Player;
public class Taniwha extends CardImpl {
public Taniwha(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}{U}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.SERPENT);
this.power = new MageInt(7);
@ -61,10 +65,10 @@ public class Taniwha extends CardImpl {
// Trample
this.addAbility(TrampleAbility.getInstance());
// Phasing
this.addAbility(PhasingAbility.getInstance());
// At the beginning of your upkeep, all lands you control phase out.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new TaniwhaEffect(), TargetController.YOU, false));
}
@ -99,10 +103,11 @@ class TaniwhaEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
List<UUID> permIds = new ArrayList<>();
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledLandPermanent(), controller.getId(), game)) {
permanent.phaseOut(game);
permIds.add(permanent.getId());
}
return true;
return new PhaseOutAllEffect(permIds).apply(game, source);
}
return false;
}

View file

@ -27,11 +27,14 @@
*/
package mage.cards.t;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSpellEffect;
import mage.abilities.effects.common.PhaseOutAllEffect;
import mage.abilities.effects.common.continuous.GainAbilityControllerEffect;
import mage.abilities.effects.common.continuous.LifeTotalCantChangeControllerEffect;
import mage.abilities.keyword.ProtectionAbility;
@ -170,10 +173,11 @@ class TeferisProtectionPhaseOutEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
List<UUID> permIds = new ArrayList<>();
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_PERMANENT, controller.getId(), game)) {
permanent.phaseOut(game);
permIds.add(permanent.getId());
}
return true;
return new PhaseOutAllEffect(permIds).apply(game, source);
}
return false;
}

View file

@ -27,6 +27,7 @@
*/
package mage.cards.t;
import java.util.ArrayList;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
@ -45,8 +46,11 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.abilities.effects.common.PhaseOutAllEffect;
import mage.filter.common.FilterControlledLandPermanent;
/**
*
@ -55,7 +59,7 @@ import java.util.UUID;
public class TeferisRealm extends CardImpl {
public TeferisRealm(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}{U}");
addSuperType(SuperType.WORLD);
// At the beginning of each player's upkeep, that player chooses artifact, creature, land, or non-Aura enchantment. All nontoken permanents of that type phase out.
@ -135,10 +139,11 @@ class TeferisRealmEffect extends OneShotEffect {
return false;
}
game.informPlayers(player.getLogName() + " chooses " + choosenType + "s to phase out");
List<UUID> permIds = new ArrayList<>();
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), game)) {
permanent.phaseOut(game);
permIds.add(permanent.getId());
}
return true;
return new PhaseOutAllEffect(permIds).apply(game, source);
}
return false;
}