mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Fixed some problems of CastFromHandCondition.
This commit is contained in:
parent
0e2e4ccedd
commit
5b15f96342
1 changed files with 14 additions and 2 deletions
|
@ -2,8 +2,10 @@ package mage.abilities.condition.common;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
/**
|
||||
|
@ -15,11 +17,21 @@ public class CastFromHandCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
||||
int zccDiff = 0;
|
||||
if (permanent == null) {
|
||||
permanent = game.getPermanentEntering(source.getSourceId());
|
||||
permanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); // can be alredy again removed from battlefield so also check LKI
|
||||
zccDiff = -1;
|
||||
}
|
||||
if (permanent != null) {
|
||||
// check that the spell is still in the LKI
|
||||
Spell spell = game.getStack().getSpell(source.getSourceId());
|
||||
if (spell == null || spell.getZoneChangeCounter(game) != permanent.getZoneChangeCounter(game) + zccDiff) {
|
||||
if (game.getLastKnownInformation(source.getSourceId(), Zone.STACK, permanent.getZoneChangeCounter(game) + zccDiff) == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Probably watcher is no longer needed
|
||||
Watcher watcher = game.getState().getWatchers().get("CastFromHand", source.getSourceId());
|
||||
if (watcher != null && watcher.conditionMet()) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue