mirror of
https://github.com/correl/mage.git
synced 2025-04-01 19:07:57 -09:00
* Fixed that commander replacement effect was wrongly only applied once (903.9). Simplified some replacement effects that move objects to other zones. (fixes #4585).
This commit is contained in:
parent
2ebc0f2b83
commit
c2a4890603
7 changed files with 25 additions and 40 deletions
Mage.Sets/src/mage/cards
Mage/src/main/java/mage
abilities
effects
keyword
players
|
@ -49,9 +49,9 @@ import mage.cards.CardSetInfo;
|
|||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
|
@ -69,7 +69,7 @@ import mage.target.targetpointer.FixedTarget;
|
|||
public class KheruLichLord extends CardImpl {
|
||||
|
||||
public KheruLichLord(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{B}{G}{U}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}{G}{U}");
|
||||
this.subtype.add(SubType.ZOMBIE);
|
||||
this.subtype.add(SubType.WIZARD);
|
||||
|
||||
|
@ -166,14 +166,8 @@ class KheruLichLordReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Card card = game.getCard(getTargetPointer().getFirst(game, source));
|
||||
if (card != null) {
|
||||
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, game.getState().getZone(card.getId()), true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
((ZoneChangeEvent) event).setToZone(Zone.EXILED);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -148,12 +148,8 @@ class WhipOfErebosReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (permanent != null && controller != null) {
|
||||
controller.moveCardToExileWithInfo(permanent, null, null, source.getSourceId(), game, Zone.BATTLEFIELD, true);
|
||||
}
|
||||
return true;
|
||||
((ZoneChangeEvent) event).setToZone(Zone.EXILED);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -111,7 +111,7 @@ public class ContinuousEffects implements Serializable {
|
|||
|
||||
costModificationEffects = effect.costModificationEffects.copy();
|
||||
spliceCardEffects = effect.spliceCardEffects.copy();
|
||||
for (Map.Entry<ContinuousEffect, Set<Ability>> entry: effect.temporaryEffects.entrySet()) {
|
||||
for (Map.Entry<ContinuousEffect, Set<Ability>> entry : effect.temporaryEffects.entrySet()) {
|
||||
temporaryEffects.put(entry.getKey().copy(), entry.getValue());
|
||||
}
|
||||
collectAllEffects();
|
||||
|
@ -352,9 +352,11 @@ public class ContinuousEffects implements Serializable {
|
|||
continue;
|
||||
}
|
||||
if (event.getAppliedEffects() != null && event.getAppliedEffects().contains(effect.getId())) {
|
||||
// Effect already applied to this event, ignore it
|
||||
// TODO: Handle also gained effect that are connected to different abilities.
|
||||
continue;
|
||||
if (!(effect instanceof CommanderReplacementEffect)) { // 903.9.
|
||||
// Effect already applied to this event, ignore it
|
||||
// TODO: Handle also gained effect that are connected to different abilities.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Set<Ability> abilities = replacementEffects.getAbility(effect.getId());
|
||||
Set<Ability> applicableAbilities = new HashSet<>();
|
||||
|
@ -752,7 +754,7 @@ public class ContinuousEffects implements Serializable {
|
|||
// Remove all consumed effects (ability dependant)
|
||||
for (Iterator<ReplacementEffect> it1 = rEffects.keySet().iterator(); it1.hasNext();) {
|
||||
ReplacementEffect entry = it1.next();
|
||||
if (consumed.containsKey(entry.getId())) {
|
||||
if (consumed.containsKey(entry.getId()) /*&& !(entry instanceof CommanderReplacementEffect) */) { // 903.9.
|
||||
Set<UUID> consumedAbilitiesIds = consumed.get(entry.getId());
|
||||
if (rEffects.get(entry) == null || consumedAbilitiesIds.size() == rEffects.get(entry).size()) {
|
||||
it1.remove();
|
||||
|
|
|
@ -49,6 +49,9 @@ import mage.players.Player;
|
|||
/*
|
||||
* 903.11. If a commander would be put into its owner’s graveyard from anywhere, that player may put it into the command zone instead.
|
||||
* 903.12. If a commander would be put into the exile zone from anywhere, its owner may put it into the command zone instead.
|
||||
* 903.9. If a commander would be exiled from anywhere or put into its owner’s hand, graveyard, or
|
||||
library from anywhere, its owner may put it into the command zone instead. This replacement effect
|
||||
may apply more than once to the same event. This is an exception to rule 614.5.
|
||||
*/
|
||||
public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
||||
|
||||
|
@ -138,11 +141,10 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
|||
if (permanent != null) {
|
||||
Player player = game.getPlayer(permanent.getOwnerId());
|
||||
if (player != null && player.chooseUse(Outcome.Benefit, "Move commander to command zone?", source, game)) {
|
||||
boolean result = permanent.moveToZone(Zone.COMMAND, source.getSourceId(), game, false);
|
||||
((ZoneChangeEvent) event).setToZone(Zone.COMMAND);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(player.getLogName() + " has moved his or her commander to the command zone");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -159,11 +161,10 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
|
|||
if (card != null) {
|
||||
Player player = game.getPlayer(card.getOwnerId());
|
||||
if (player != null && player.chooseUse(Outcome.Benefit, "Move commander to command zone?", source, game)) {
|
||||
boolean result = card.moveToZone(Zone.COMMAND, source.getSourceId(), game, false);
|
||||
((ZoneChangeEvent) event).setToZone(Zone.COMMAND);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(player.getLogName() + " has moved his or her commander to the command zone");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,8 +44,6 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -158,11 +156,7 @@ class UnearthLeavesBattlefieldEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && permanent != null) {
|
||||
controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true);
|
||||
}
|
||||
return true;
|
||||
((ZoneChangeEvent) event).setToZone(Zone.EXILED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -731,7 +731,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
/**
|
||||
* Uses card.moveToExile and posts a inform message about moving the card to
|
||||
* exile into the game log
|
||||
* exile into the game log. Don't use this in replacement effects, because
|
||||
* list of applied effects is not saved
|
||||
*
|
||||
* @param card
|
||||
* @param exileId exile zone id (optional)
|
||||
|
|
|
@ -1097,7 +1097,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
if (!ignoreTiming && !playLandAbility.canActivate(this.playerId, game)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, card.getId(), card.getId(), playerId));
|
||||
//20091005 - 305.1
|
||||
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, card.getId(), card.getId(), playerId))) {
|
||||
|
@ -3602,11 +3602,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCardToExileWithInfo(Card card, UUID exileId,
|
||||
String exileName, UUID sourceId,
|
||||
Game game, Zone fromZone,
|
||||
boolean withName
|
||||
) {
|
||||
public boolean moveCardToExileWithInfo(Card card, UUID exileId, String exileName, UUID sourceId,
|
||||
Game game, Zone fromZone, boolean withName) {
|
||||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue