Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Mage.Sets/src/mage/cards/e/Excavator.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

package mage.cards.e;

import java.util.UUID;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
import mage.abilities.Ability;
Expand All @@ -17,9 +16,10 @@
import mage.filter.common.FilterControlledLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetCreaturePermanent;

import java.util.UUID;

/**
*
* @author Plopman
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public boolean pay(Ability ability, Game game, Ability source, UUID controllerId
* For storing additional info upon selecting permanents to sacrifice
*/
protected void addSacrificeTarget(Game game, Permanent permanent) {
permanents.add(permanent.copy());
permanents.add(permanent.saveImmutableCopy(game));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public boolean apply(Game game, Ability source) {
discard();
return false;
}
// As long as the permanent is still in the short living LKI continue to copy to get triggered abilities to TriggeredAbilities for dies events.
// Don't need to continue applying if permanent is in LKI
permanent = (Permanent) game.getLastKnownInformation(getSourceId(), Zone.BATTLEFIELD, source.getStackMomentSourceZCC());
if (permanent == null) {
if (permanent != null) {
discard();
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public boolean apply(Game game, Ability source) {
} else {
Permanent equipment = game.getPermanent(source.getSourceId());
if (equipment != null && equipment.getAttachedTo() != null) {
permanent = game.getPermanentOrLKIBattlefield(equipment.getAttachedTo());
permanent = game.getPermanent(equipment.getAttachedTo());
} else {
permanent = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public GainAbilityControlledEffect copy() {
public boolean apply(Game game, Ability source) {
if (getAffectedObjectsSet()) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { // filter may not be used again, because object can have changed filter relevant attributes but still geets boost
Permanent perm = it.next().getPermanentOrLKIBattlefield(game); //LKI is neccessary for "dies triggered abilities" to work given to permanets (e.g. Showstopper)
Permanent perm = it.next().getPermanent(game);
if (perm != null) {
for (Ability abilityToAdd : ability) {
perm.addAbility(abilityToAdd, source.getSourceId(), game);
Expand Down
15 changes: 12 additions & 3 deletions Mage/src/main/java/mage/game/GameImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import mage.target.TargetPlayer;
import mage.util.*;
import mage.util.functions.CopyApplier;
import mage.util.immutableWrappers.ImmutablePermanent;
import mage.watchers.Watcher;
import mage.watchers.common.*;
import org.apache.log4j.Logger;
Expand Down Expand Up @@ -2106,7 +2107,11 @@ public Permanent copyPermanent(Duration duration, Permanent copyFromPermanent, U

// if it was no copy of copy take the target itself
if (newBluePrint == null) {
newBluePrint = copyFromPermanent.copy();
if (copyFromPermanent instanceof ImmutablePermanent) {
newBluePrint = ((ImmutablePermanent) copyFromPermanent).getResetPermanent(this);
} else {
newBluePrint = copyFromPermanent.copy();
}

// reset to original characteristics
newBluePrint.reset(this);
Expand Down Expand Up @@ -3678,8 +3683,12 @@ public boolean checkShortLivingLKI(UUID objectId, Zone zone) {
public void rememberLKI(Zone zone, MageObject object) {
UUID objectId = object.getId();
if (object instanceof Permanent || object instanceof StackObject) {
MageObject copy = object.copy();

MageObject copy;
if (object instanceof Permanent) {
copy = ((Permanent) object).saveImmutableCopy(this);
} else {
copy = object.copy();
}
Map<UUID, MageObject> lkiMap = lki.computeIfAbsent(zone, k -> new HashMap<>());
lkiMap.put(objectId, copy);

Expand Down
Loading