mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 13:19:18 -08:00
Added TargetController parameter to DiscardEachPlayerEffect.
This commit is contained in:
parent
6022c01af8
commit
d5feac4bfe
8 changed files with 128 additions and 158 deletions
|
|
@ -28,16 +28,12 @@
|
|||
package mage.sets.magic2010;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DiscardEachPlayerEffect;
|
||||
import mage.abilities.effects.common.DrawCardAllEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -53,7 +49,9 @@ public class BurningInquiry extends CardImpl<BurningInquiry> {
|
|||
|
||||
// Each player draws three cards, then discards three cards at random.
|
||||
this.getSpellAbility().addEffect(new DrawCardAllEffect(3));
|
||||
this.getSpellAbility().addEffect(new BurningInquiryEffect());
|
||||
Effect effect = new DiscardEachPlayerEffect(3, true);
|
||||
effect.setText("then discards three cards at random");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
}
|
||||
|
||||
public BurningInquiry(final BurningInquiry card) {
|
||||
|
|
@ -65,41 +63,3 @@ public class BurningInquiry extends CardImpl<BurningInquiry> {
|
|||
return new BurningInquiry(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BurningInquiryEffect extends OneShotEffect<BurningInquiryEffect> {
|
||||
|
||||
public BurningInquiryEffect() {
|
||||
super(Outcome.Discard);
|
||||
this.staticText = "Each player discards three cards at random";
|
||||
}
|
||||
|
||||
public BurningInquiryEffect(final BurningInquiryEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BurningInquiryEffect copy() {
|
||||
return new BurningInquiryEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (UUID playerId : controller.getInRange()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Card card = player.getHand().getRandom(game);
|
||||
if (card != null) {
|
||||
player.discard(card, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,15 +29,17 @@
|
|||
package mage.sets.magic2011;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DiscardEachPlayerEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TargetController;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
|
|
@ -56,7 +58,7 @@ public class LilianasSpecter extends CardImpl<LilianasSpecter> {
|
|||
this.toughness = new MageInt(1);
|
||||
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new LilianasSpecterEffect(), false));
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new DiscardEachPlayerEffect(TargetController.OPPONENT), false));
|
||||
}
|
||||
|
||||
public LilianasSpecter(final LilianasSpecter card) {
|
||||
|
|
@ -69,30 +71,3 @@ public class LilianasSpecter extends CardImpl<LilianasSpecter> {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class LilianasSpecterEffect extends OneShotEffect<LilianasSpecterEffect> {
|
||||
|
||||
public LilianasSpecterEffect() {
|
||||
super(Outcome.Discard);
|
||||
staticText = "each opponent discards a card";
|
||||
}
|
||||
|
||||
public LilianasSpecterEffect(final LilianasSpecterEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID playerId: game.getOpponents(source.getControllerId())) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
player.discard(1, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LilianasSpecterEffect copy() {
|
||||
return new LilianasSpecterEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.sets.magic2012;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
|
|
@ -85,36 +86,36 @@ class SmallpoxEffect extends OneShotEffect<SmallpoxEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID playerId : game.getPlayerList()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.loseLife(1, game);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Set <UUID> players = controller.getInRange();
|
||||
for (UUID playerId : players) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.loseLife(1, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID playerId : game.getPlayerList()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.discard(1, source, game);
|
||||
for (UUID playerId : players) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.discard(1, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (UUID playerId : game.getPlayerList()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
sacrifice(game, source, player, filterCreature);
|
||||
for (UUID playerId : players) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
sacrifice(game, source, player, filterCreature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID playerId : game.getPlayerList()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
sacrifice(game, source, player, filterLand);
|
||||
for (UUID playerId : players) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
sacrifice(game, source, player, filterLand);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -125,7 +126,7 @@ class SmallpoxEffect extends OneShotEffect<SmallpoxEffect> {
|
|||
private void sacrifice(Game game, Ability source, Player player, FilterPermanent filter) {
|
||||
Target target = new TargetControlledPermanent(1, 1, filter, false);
|
||||
if (target.canChoose(player.getId(), game)) {
|
||||
while (!target.isChosen() && target.canChoose(player.getId(), game)) {
|
||||
while (!target.isChosen() && target.canChoose(player.getId(), game) && player.isInGame()) {
|
||||
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.Rarity;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DiscardEachPlayerEffect;
|
||||
import mage.abilities.effects.common.LoseLifePlayersEffect;
|
||||
import mage.abilities.effects.common.SacrificeAllEffect;
|
||||
|
|
@ -54,9 +55,15 @@ public class DeathCloud extends CardImpl<DeathCloud> {
|
|||
// Each player loses X life, discards X cards, sacrifices X creatures, then sacrifices X lands.
|
||||
DynamicValue xValue = new ManacostVariableValue();
|
||||
this.getSpellAbility().addEffect(new LoseLifePlayersEffect(xValue));
|
||||
this.getSpellAbility().addEffect(new DiscardEachPlayerEffect(xValue, false));
|
||||
this.getSpellAbility().addEffect(new SacrificeAllEffect(xValue, new FilterControlledCreaturePermanent("creatures")));
|
||||
this.getSpellAbility().addEffect(new SacrificeAllEffect(xValue, new FilterControlledLandPermanent("lands")));
|
||||
Effect effect = new DiscardEachPlayerEffect(xValue, false);
|
||||
effect.setText(", discards X cards");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
effect = new SacrificeAllEffect(xValue, new FilterControlledCreaturePermanent("creatures"));
|
||||
effect.setText(", sacrifices X creatures");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
effect = new SacrificeAllEffect(xValue, new FilterControlledLandPermanent("lands"));
|
||||
effect.setText("then sacrifices X lands");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
}
|
||||
|
||||
public DeathCloud(final DeathCloud card) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
package mage.sets.planeshift;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.effects.common.DiscardEachPlayerEffect;
|
||||
|
|
@ -50,9 +51,12 @@ public class UrzasGuilt extends CardImpl<UrzasGuilt> {
|
|||
|
||||
// Each player draws two cards, then discards three cards, then loses 4 life.
|
||||
this.getSpellAbility().addEffect(new DrawCardAllEffect(2));
|
||||
this.getSpellAbility().addEffect(new DiscardEachPlayerEffect(3, false));
|
||||
this.getSpellAbility().addEffect(new LoseLifeAllEffect(4));
|
||||
|
||||
Effect effect = new DiscardEachPlayerEffect(3, false);
|
||||
effect.setText("then discards three cards");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
effect = new LoseLifeAllEffect(4);
|
||||
effect.setText("then loses 4 life");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
}
|
||||
|
||||
public UrzasGuilt(final UrzasGuilt card) {
|
||||
|
|
|
|||
|
|
@ -36,8 +36,10 @@ import mage.MageInt;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DiscardEachPlayerEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.TargetController;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
|
|
@ -56,7 +58,7 @@ public class CacklingFiend extends CardImpl<CacklingFiend> {
|
|||
this.toughness = new MageInt(1);
|
||||
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new CacklingFiendEffect(), false));
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new DiscardEachPlayerEffect(TargetController.OPPONENT), false));
|
||||
}
|
||||
|
||||
public CacklingFiend(final CacklingFiend card) {
|
||||
|
|
@ -69,30 +71,3 @@ public class CacklingFiend extends CardImpl<CacklingFiend> {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class CacklingFiendEffect extends OneShotEffect<CacklingFiendEffect> {
|
||||
|
||||
public CacklingFiendEffect() {
|
||||
super(Outcome.Discard);
|
||||
staticText = "each opponent discards a card";
|
||||
}
|
||||
|
||||
public CacklingFiendEffect(final CacklingFiendEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID playerId: game.getOpponents(source.getControllerId())) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
player.discard(1, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CacklingFiendEffect copy() {
|
||||
return new CacklingFiendEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue