mirror of
https://github.com/correl/mage.git
synced 2025-01-11 11:05:23 +00:00
Fixed a bug that AI did not choose a creature card in her graveyard if opponent casts Exhume.
This commit is contained in:
parent
9e9256cd82
commit
2fce670024
9 changed files with 42 additions and 1 deletions
|
@ -591,7 +591,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
card = pickWorstCard(cards, null, target, source, game);
|
||||
}
|
||||
if (source != null) {
|
||||
if (target.canTarget(card.getId(), source, game)) {
|
||||
if (target.canTarget(card.getId(), this.getId(), source, game)) {
|
||||
return card;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ public interface Target extends Serializable {
|
|||
void addTarget(UUID id, int amount, Ability source, Game game, boolean skipEvent);
|
||||
boolean canTarget(UUID id, Game game);
|
||||
boolean canTarget(UUID id, Ability source, Game game);
|
||||
boolean canTarget(UUID id, UUID playerId, Ability source, Game game);
|
||||
boolean isLegal(Ability source, Game game);
|
||||
List<? extends Target> getTargetOptions(Ability source, Game game);
|
||||
|
||||
|
|
|
@ -87,4 +87,9 @@ public abstract class TargetObject<T extends TargetObject<T>> extends TargetImpl
|
|||
return canTarget(id, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, UUID playerId, Ability source, Game game) {
|
||||
return canTarget(id, source, game);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,6 +72,16 @@ public class TargetCardInYourGraveyard extends TargetCard<TargetCardInYourGravey
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, UUID playerId, Ability ability, Game game) {
|
||||
Card card = game.getCard(id);
|
||||
if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD)
|
||||
if (game.getPlayer(playerId).getGraveyard().contains(id)) {
|
||||
return filter.match(card, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are enough {@link Card} that can be selected.
|
||||
*
|
||||
|
|
|
@ -110,6 +110,11 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount<TargetCreatureOrP
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, UUID playerId, Ability source, Game game) {
|
||||
return canTarget(id, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
|
|
|
@ -91,6 +91,11 @@ public class TargetCreaturePermanentAmount extends TargetAmount<TargetCreaturePe
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, UUID playerId, Ability source, Game game) {
|
||||
return canTarget(id, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
|
|
|
@ -206,6 +206,11 @@ public class TargetDefender extends TargetImpl<TargetDefender> {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, UUID playerId, Ability source, Game game) {
|
||||
return canTarget(id, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetDefender copy() {
|
||||
return new TargetDefender(this);
|
||||
|
|
|
@ -103,6 +103,11 @@ public class TargetPermanentOrPlayer extends TargetImpl<TargetPermanentOrPlayer>
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, UUID playerId, Ability source, Game game) {
|
||||
return canTarget(id, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
|
|
|
@ -128,6 +128,11 @@ public class TargetSpellOrPermanent extends TargetImpl<TargetSpellOrPermanent> {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, UUID playerId, Ability source, Game game) {
|
||||
return canTarget(id, source, game);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are enough {@link mage.game.permanent.Permanent} or {@link mage.game.stack.Spell} that can be chosen. Should only be used
|
||||
* for Ability targets since this checks for protection, shroud etc.
|
||||
|
|
Loading…
Reference in a new issue