forked from External/mage
* Some target pointer changes and code clean up.
This commit is contained in:
parent
142681c354
commit
7a78be8c6a
207 changed files with 531 additions and 358 deletions
|
|
@ -5,17 +5,18 @@
|
|||
*/
|
||||
package mage.target.targetpointer;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
|
|
@ -116,4 +117,34 @@ public class FixedTargets implements TargetPointer {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permanent getFirstTargetPermanentOrLKI(Game game, Ability source) {
|
||||
UUID targetId = null;
|
||||
int zoneChangeCounter = Integer.MIN_VALUE;
|
||||
if (!targets.isEmpty()) {
|
||||
MageObjectReference mor = targets.get(0);
|
||||
targetId = mor.getSourceId();
|
||||
zoneChangeCounter = mor.getZoneChangeCounter();
|
||||
} else if (!targetsNotInitialized.isEmpty()) {
|
||||
targetId = targetsNotInitialized.get(0);
|
||||
}
|
||||
if (targetId != null) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null
|
||||
&& (zoneChangeCounter == Integer.MIN_VALUE || permanent.getZoneChangeCounter(game) == zoneChangeCounter)) {
|
||||
return permanent;
|
||||
}
|
||||
MageObject mageObject;
|
||||
if (zoneChangeCounter == Integer.MIN_VALUE) {
|
||||
mageObject = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD);
|
||||
} else {
|
||||
mageObject = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD, zoneChangeCounter);
|
||||
}
|
||||
if (mageObject instanceof Permanent) {
|
||||
return (Permanent) mageObject;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue