mirror of
https://github.com/magefree/mage.git
synced 2025-12-29 23:12:10 -08:00
* Fixed that continuous effects of copied cards with limited duration stop to work as the copied card stops to exist.
This commit is contained in:
parent
7292a1625c
commit
d3dba58358
11 changed files with 113 additions and 38 deletions
|
|
@ -127,10 +127,8 @@ class PutIntoGraveFromAnywhereEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD
|
||||
&& event.getTargetId().equals(source.getSourceId()))
|
||||
{
|
||||
if (condition == null || condition.apply(game, source))
|
||||
{
|
||||
&& event.getTargetId().equals(source.getSourceId())) {
|
||||
if (condition == null || condition.apply(game, source)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,10 +351,8 @@ public class ContinuousEffects implements Serializable {
|
|||
if (ability.getAbilityType() != AbilityType.STATIC || ability.isInUseableZone(game, null, event)) {
|
||||
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||
if (!game.getScopeRelevant() || effect.hasSelfScope() || !event.getTargetId().equals(ability.getSourceId())) {
|
||||
if (checkAbilityStillExists(ability, effect, event, game)) { // TODO: This is really needed???
|
||||
if (effect.applies(event, ability, game)) {
|
||||
applicableAbilities.add(ability);
|
||||
}
|
||||
if (effect.applies(event, ability, game)) {
|
||||
applicableAbilities.add(ability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,10 +117,15 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
|
|||
return false;
|
||||
} else if (effect.isDiscarded()) {
|
||||
it.remove();
|
||||
} else if (ability.getSourceId() != null && game.getObject(ability.getSourceId()) == null) { // Commander effects have no sourceId
|
||||
it.remove(); // if the related source object does no longer exist the effect has to be removed
|
||||
} else {
|
||||
switch(effect.getDuration()) {
|
||||
case WhileOnBattlefield:
|
||||
case WhileInGraveyard:
|
||||
case WhileOnStack:
|
||||
if (ability.getSourceId() != null && game.getObject(ability.getSourceId()) == null) { // Commander effects have no sourceId
|
||||
it.remove(); // if the related source object does no longer exist in game - the effect has to be removed
|
||||
}
|
||||
break;
|
||||
case OneUse:
|
||||
if (effect.isUsed()) {
|
||||
it.remove();
|
||||
|
|
|
|||
|
|
@ -1424,6 +1424,35 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
Card card = copiedCards.next();
|
||||
Zone zone = state.getZone(card.getId());
|
||||
if (zone != Zone.BATTLEFIELD && zone != Zone.STACK) {
|
||||
switch (zone) {
|
||||
case GRAVEYARD:
|
||||
for(Player player: getPlayers().values()) {
|
||||
if (player.getGraveyard().contains(card.getId())) {
|
||||
player.getGraveyard().remove(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case HAND:
|
||||
for(Player player: getPlayers().values()) {
|
||||
if (player.getHand().contains(card.getId())) {
|
||||
player.getHand().remove(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LIBRARY:
|
||||
for(Player player: getPlayers().values()) {
|
||||
if (player.getLibrary().getCard(card.getId(), this) != null) {
|
||||
player.getLibrary().remove(card.getId(), this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EXILED:
|
||||
getExile().removeCard(card, this);
|
||||
break;
|
||||
}
|
||||
copiedCards.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,9 +136,10 @@ public class PermanentCard extends PermanentImpl {
|
|||
public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList<UUID> appliedEffects) {
|
||||
Zone fromZone = game.getState().getZone(objectId);
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null && controller.removeFromBattlefield(this, game)) {
|
||||
if (controller != null) {
|
||||
ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, controllerId, fromZone, toZone, appliedEffects);
|
||||
if (!game.replaceEvent(event)) {
|
||||
controller.removeFromBattlefield(this, game);
|
||||
Player owner = game.getPlayer(ownerId);
|
||||
game.rememberLKI(objectId, Zone.BATTLEFIELD, this);
|
||||
if (owner != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue