mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
* AI: fixed that computer can cancel "target player or planeswalker" spells on bad effects (can't choose himself);
This commit is contained in:
parent
ff54141e97
commit
55f2893fc4
2 changed files with 13 additions and 8 deletions
|
@ -729,12 +729,6 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
List<Permanent> targets;
|
||||
TargetPermanentOrPlayer origTarget = ((TargetPermanentOrPlayer) target.getOriginalTarget());
|
||||
|
||||
// TODO: if effect is bad and no opponent's targets available then AI can't target yourself but must by rules
|
||||
/*
|
||||
battlefield:Computer:Mountain:5
|
||||
hand:Computer:Viashino Pyromancer:3
|
||||
battlefield:Human:Shalai, Voice of Plenty:1
|
||||
*/
|
||||
// TODO: in multiplayer game there many opponents - if random opponents don't have targets then AI must use next opponent, but it skips
|
||||
// (e.g. you randomOpponentId must be replaced by List<UUID> randomOpponents)
|
||||
|
||||
|
@ -782,6 +776,16 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
return tryAddTarget(target, randomOpponentId, source, game);
|
||||
}
|
||||
|
||||
// try target player as bad (bad on itself, good on opponent)
|
||||
for (UUID opponentId : game.getOpponents(abilityControllerId)) {
|
||||
if (target.canTarget(abilityControllerId, opponentId, source, game)) {
|
||||
return tryAddTarget(target, opponentId, source, game);
|
||||
}
|
||||
}
|
||||
if (target.canTarget(abilityControllerId, abilityControllerId, source, game)) {
|
||||
return tryAddTarget(target, abilityControllerId, source, game);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -329,8 +329,9 @@ public abstract class AbilityImpl implements Ability {
|
|||
}
|
||||
if (!getTargets().isEmpty()) {
|
||||
Outcome outcome = getEffects().getOutcome(this);
|
||||
// only activated abilities can be canceled by user (not triggered)
|
||||
if (!getTargets().chooseTargets(outcome, this.controllerId, this, noMana, game, this instanceof ActivatedAbility)) {
|
||||
// only activated abilities can be canceled by human user (not triggered)
|
||||
boolean canCancel = this instanceof ActivatedAbility && controller.isHuman();
|
||||
if (!getTargets().chooseTargets(outcome, this.controllerId, this, noMana, game, canCancel)) {
|
||||
// was canceled during targer selection
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue