mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Fixed some handling problems of all players asked to pay a cost to counter the spell with this ability.
This commit is contained in:
parent
e166018027
commit
12500464be
5 changed files with 44 additions and 35 deletions
|
@ -29,6 +29,7 @@ package mage.sets.planarchaos;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
@ -92,23 +93,26 @@ class BrainGorgersCounterSourceEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Spell spell = game.getStack().getSpell(source.getSourceId());
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
if (spell != null) {
|
if (sourceObject != null) {
|
||||||
SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent());
|
SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent());
|
||||||
for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) {
|
for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) {
|
||||||
cost.clearPaid();
|
cost.clearPaid();
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
if (cost.canPay(source, source.getSourceId(), player.getId(), game)
|
if (cost.canPay(source, source.getSourceId(), player.getId(), game)
|
||||||
&& player.chooseUse(outcome, "Sacrifice a creature to counter " + spell.getIdName() + "?", source, game)) {
|
&& player.chooseUse(outcome, "Sacrifice a creature to counter " + sourceObject.getIdName() + "?", source, game)) {
|
||||||
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
|
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
|
||||||
game.informPlayers(player.getLogName() + " sacrifices a creature to counter " + spell.getIdName() + ".");
|
game.informPlayers(player.getLogName() + " sacrifices a creature to counter " + sourceObject.getIdName() + ".");
|
||||||
|
Spell spell = game.getStack().getSpell(source.getSourceId());
|
||||||
|
if (spell != null) {
|
||||||
game.getStack().counter(spell.getId(), source.getSourceId(), game);
|
game.getStack().counter(spell.getId(), source.getSourceId(), game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
package mage.sets.planarchaos;
|
package mage.sets.planarchaos;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.common.PayLifeCost;
|
import mage.abilities.costs.common.PayLifeCost;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
@ -88,20 +89,23 @@ class DashHopesCounterSourceEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Spell spell = game.getStack().getSpell(source.getSourceId());
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
if (spell != null) {
|
if (sourceObject != null) {
|
||||||
PayLifeCost cost = new PayLifeCost(5);
|
PayLifeCost cost = new PayLifeCost(5);
|
||||||
for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) {
|
for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
cost.clearPaid();
|
cost.clearPaid();
|
||||||
if (cost.canPay(source, source.getSourceId(), player.getId(), game)
|
if (cost.canPay(source, source.getSourceId(), player.getId(), game)
|
||||||
&& player.chooseUse(outcome, "Pay 5 life to counter " + spell.getIdName() + "?", source, game)) {
|
&& player.chooseUse(outcome, "Pay 5 life to counter " + sourceObject.getIdName() + "?", source, game)) {
|
||||||
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
|
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
|
||||||
game.informPlayers(player.getLogName() + " pays 5 life to counter " + spell.getIdName() + ".");
|
game.informPlayers(player.getLogName() + " pays 5 life to counter " + sourceObject.getIdName() + ".");
|
||||||
|
Spell spell = game.getStack().getSpell(source.getSourceId());
|
||||||
|
if (spell != null) {
|
||||||
game.getStack().counter(spell.getId(), source.getSourceId(), game);
|
game.getStack().counter(spell.getId(), source.getSourceId(), game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -29,6 +29,7 @@ package mage.sets.planarchaos;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Mode;
|
import mage.abilities.Mode;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
@ -44,7 +45,6 @@ import mage.constants.Zone;
|
||||||
import mage.filter.FilterCard;
|
import mage.filter.FilterCard;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.stack.Spell;
|
import mage.game.stack.Spell;
|
||||||
import mage.game.stack.StackObject;
|
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetCardInHand;
|
import mage.target.common.TargetCardInHand;
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public class Phantasmagorian extends CardImpl {
|
||||||
class CounterSourceEffect extends OneShotEffect {
|
class CounterSourceEffect extends OneShotEffect {
|
||||||
|
|
||||||
public CounterSourceEffect() {
|
public CounterSourceEffect() {
|
||||||
super(Outcome.Detriment);
|
super(Outcome.AIDontUseIt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CounterSourceEffect(final CounterSourceEffect effect) {
|
public CounterSourceEffect(final CounterSourceEffect effect) {
|
||||||
|
@ -95,25 +95,20 @@ class CounterSourceEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
StackObject spell = null;
|
if (sourceObject != null) {
|
||||||
for (StackObject objet : game.getStack()) {
|
|
||||||
if (objet instanceof Spell && objet.getSourceId().equals(source.getSourceId())) {
|
|
||||||
spell = objet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (spell != null) {
|
|
||||||
DiscardTargetCost cost = new DiscardTargetCost(new TargetCardInHand(3, 3, new FilterCard()));
|
DiscardTargetCost cost = new DiscardTargetCost(new TargetCardInHand(3, 3, new FilterCard()));
|
||||||
for (UUID uuid : game.getPlayerList()) {
|
for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) {
|
||||||
Player player = game.getPlayer(uuid);
|
Player player = game.getPlayer(playerId);
|
||||||
cost.clearPaid();
|
cost.clearPaid();
|
||||||
if (cost.canPay(source, source.getSourceId(), player.getId(), game)
|
if (cost.canPay(source, source.getSourceId(), player.getId(), game)
|
||||||
&& player.chooseUse(Outcome.Detriment, "Discard three cards to counter " + spell.getName() + "?", source, game)) {
|
&& player.chooseUse(outcome, "Discard three cards to counter " + sourceObject.getIdName() + "?", source, game)) {
|
||||||
|
if (cost.pay(source, game, source.getSourceId(), playerId, false)) {
|
||||||
if (cost.pay(source, game, source.getSourceId(), uuid, false)) {
|
game.informPlayers(player.getLogName() + " discards 3 cards to counter " + sourceObject.getIdName() + ".");
|
||||||
game.informPlayers(player.getLogName() + " discards 3 cards to counter " + spell.getName() + ".");
|
Spell spell = game.getStack().getSpell(source.getSourceId());
|
||||||
|
if (spell != null) {
|
||||||
game.getStack().counter(spell.getId(), source.getSourceId(), game);
|
game.getStack().counter(spell.getId(), source.getSourceId(), game);
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
package mage.sets.planarchaos;
|
package mage.sets.planarchaos;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.CastSourceTriggeredAbility;
|
import mage.abilities.effects.common.CastSourceTriggeredAbility;
|
||||||
|
@ -85,17 +86,20 @@ class TemporalExtortionCounterSourceEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Spell spell = game.getStack().getSpell(source.getSourceId());
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
if (spell != null) {
|
if (sourceObject != null) {
|
||||||
for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) {
|
for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
if (player.chooseUse(outcome, "Pay half your life, rounded up to counter " + spell.getIdName() + "?", source, game)) {
|
if (player.chooseUse(outcome, "Pay half your life, rounded up to counter " + sourceObject.getIdName() + "?", source, game)) {
|
||||||
Integer amount = (int) Math.ceil(player.getLife() / 2f);
|
Integer amount = (int) Math.ceil(player.getLife() / 2f);
|
||||||
player.loseLife(amount, game);
|
player.loseLife(amount, game);
|
||||||
game.informPlayers(player.getLogName() + " pays half his or her life, rounded up to counter " + spell.getIdName() + ".");
|
game.informPlayers(player.getLogName() + " pays half his or her life, rounded up to counter " + sourceObject.getIdName() + ".");
|
||||||
|
Spell spell = game.getStack().getSpell(source.getSourceId());
|
||||||
|
if (spell != null) {
|
||||||
game.getStack().counter(spell.getId(), source.getSourceId(), game);
|
game.getStack().counter(spell.getId(), source.getSourceId(), game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -68,6 +68,7 @@ public class DiscardTargetCost extends CostImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||||
this.cards.clear();
|
this.cards.clear();
|
||||||
|
this.targets.clear();
|
||||||
Player player = game.getPlayer(controllerId);
|
Player player = game.getPlayer(controllerId);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -94,7 +95,8 @@ public class DiscardTargetCost extends CostImpl {
|
||||||
@Override
|
@Override
|
||||||
public void clearPaid() {
|
public void clearPaid() {
|
||||||
super.clearPaid();
|
super.clearPaid();
|
||||||
cards.clear();
|
this.cards.clear();
|
||||||
|
this.targets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue