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