mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
AI - Added code to handle TargetSpellOrPermanent (not smart).
This commit is contained in:
parent
35b1e776d2
commit
0523905cc6
2 changed files with 35 additions and 3 deletions
|
@ -559,6 +559,41 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (target instanceof TargetSpellOrPermanent) {
|
||||
List<Permanent> targets;
|
||||
boolean outcomeTargets = true;
|
||||
if (outcome.isGood()) {
|
||||
targets = threats(playerId, source == null?null:source.getSourceId(), ((TargetPermanent)target).getFilter(), game, target.getTargets());
|
||||
}
|
||||
else {
|
||||
targets = threats(opponentId, source == null?null:source.getSourceId(), ((TargetPermanent)target).getFilter(), game, target.getTargets());
|
||||
}
|
||||
if (targets.isEmpty() && target.isRequired()) {
|
||||
targets = threats(null, source == null?null:source.getSourceId(), ((TargetPermanent)target).getFilter(), game, target.getTargets());
|
||||
Collections.reverse(targets);
|
||||
outcomeTargets = false;
|
||||
//targets = game.getBattlefield().getActivePermanents(((TargetPermanent)target).getFilter(), playerId, game);
|
||||
}
|
||||
for (Permanent permanent: targets) {
|
||||
if (((TargetPermanent)target).canTarget(playerId, permanent.getId(), source, game)) {
|
||||
target.addTarget(permanent.getId(), source, game);
|
||||
if (!outcomeTargets || target.getMaxNumberOfTargets() <= target.getTargets().size()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (game.getStack().size() > 0) {
|
||||
Iterator<StackObject> it = game.getStack().iterator();
|
||||
while (it.hasNext()) {
|
||||
StackObject o = it.next();
|
||||
if (o instanceof Spell && !source.getId().equals(o.getStackAbility().getId())) {
|
||||
target.addTarget(o.getId(), source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (target instanceof TargetCardInOpponentsGraveyard) {
|
||||
List<Card> cards = new ArrayList<>();
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.util.UUID;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.ExileTargetEffect;
|
||||
|
@ -43,7 +42,6 @@ import mage.constants.CardType;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledLandPermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
|
@ -56,7 +54,6 @@ import mage.game.events.ZoneChangeEvent;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.watchers.WatcherImpl;
|
||||
|
||||
/**
|
||||
* If the land Chained to the Rocks is enchanting stops being a Mountain or another player
|
||||
|
|
Loading…
Reference in a new issue