mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
* Fixed that some Obstinate Baloth, Loxodon Smiter and Wilt Leafe Liege that caused "Discard" event to trigger twice if they were discarded (fixes #607). Some minor reworks.
This commit is contained in:
parent
f85f477b90
commit
6e0a99c610
6 changed files with 40 additions and 34 deletions
|
@ -118,7 +118,6 @@ class ObstinateBalothEffect extends ReplacementEffectImpl {
|
|||
Player owner = game.getPlayer(card.getOwnerId());
|
||||
if (owner != null) {
|
||||
if (owner.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId())) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DISCARDED_CARD, card.getId(), source.getSourceId(), owner.getId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,6 @@ class LoxodonSmiterEffect extends ReplacementEffectImpl {
|
|||
Player player = game.getPlayer(card.getOwnerId());
|
||||
if (player != null) {
|
||||
if (card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), player.getId())) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DISCARDED_CARD, card.getId(), source.getSourceId(), player.getId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,11 +28,6 @@
|
|||
package mage.sets.returntoravnica;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
@ -40,7 +35,11 @@ import mage.abilities.effects.OneShotEffect;
|
|||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
|
@ -109,19 +108,22 @@ class RestInPeaceExileAllEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID playerId : game.getPlayerList()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
for (UUID cid : player.getGraveyard().copy()) {
|
||||
Card c = game.getCard(cid);
|
||||
if (c != null) {
|
||||
c.moveToExile(null, null, source.getSourceId(), game);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (UUID playerId : controller.getInRange()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
for (UUID cid : player.getGraveyard().copy()) {
|
||||
Card card = game.getCard(cid);
|
||||
if (card != null) {
|
||||
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.GRAVEYARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,16 +150,20 @@ class RestInPeaceReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
if (((ZoneChangeEvent)event).getFromZone() == Zone.BATTLEFIELD) {
|
||||
Permanent permanent = ((ZoneChangeEvent)event).getTarget();
|
||||
if (permanent != null) {
|
||||
return permanent.moveToExile(null, "", source.getSourceId(), game);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
if (((ZoneChangeEvent)event).getFromZone() == Zone.BATTLEFIELD) {
|
||||
Permanent permanent = ((ZoneChangeEvent)event).getTarget();
|
||||
if (permanent != null) {
|
||||
return controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null) {
|
||||
return card.moveToExile(null, "", source.getSourceId(), game);
|
||||
else {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
return controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, zEvent.getFromZone());
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -168,4 +174,4 @@ class RestInPeaceReplacementEffect extends ReplacementEffectImpl {
|
|||
return event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,10 +132,8 @@ class WiltLeafLiegeEffect extends ReplacementEffectImpl {
|
|||
if (card != null) {
|
||||
Player player = game.getPlayer(card.getOwnerId());
|
||||
if (player != null) {
|
||||
if (card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), player.getId())) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DISCARDED_CARD, card.getId(), source.getSourceId(), player.getId()));
|
||||
return true;
|
||||
}
|
||||
card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), player.getId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -145,6 +145,10 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
|||
return discarded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the discarded state of the effect. So it
|
||||
* will be removed on next check.
|
||||
*/
|
||||
@Override
|
||||
public void discard() {
|
||||
this.discarded = true;
|
||||
|
|
|
@ -714,10 +714,10 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
701.7c If a card is discarded, but an effect causes it to be put into a hidden zone
|
||||
instead of into its owners graveyard without being revealed, all values of that
|
||||
cards characteristics are considered to be undefined.
|
||||
TODOD:
|
||||
If a card is discarded this way to pay a cost that specifies a characteristic
|
||||
about the discarded card, that cost payment is illegal; the game returns to
|
||||
the moment before the cost was paid (see rule 717, "Handling Illegal Actions").
|
||||
TODO:
|
||||
If a card is discarded this way to pay a cost that specifies a characteristic
|
||||
about the discarded card, that cost payment is illegal; the game returns to
|
||||
the moment before the cost was paid (see rule 717, "Handling Illegal Actions").
|
||||
*/
|
||||
if (card != null) {
|
||||
// write info to game log first so game log infos from triggered or replacement effects follow in the game log
|
||||
|
|
Loading…
Reference in a new issue