mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
- The AI will now check activation restrictions when checking possible animated blockers.
This commit is contained in:
@@ -98,7 +98,8 @@ public class AiAttackController {
|
|||||||
}
|
}
|
||||||
for (SpellAbility sa : c.getSpellAbilities()) {
|
for (SpellAbility sa : c.getSpellAbilities()) {
|
||||||
if (sa.getApi() == ApiType.Animate) {
|
if (sa.getApi() == ApiType.Animate) {
|
||||||
if (ComputerUtilCost.canPayCost(sa, this.defendingOpponent)) {
|
if (ComputerUtilCost.canPayCost(sa, this.defendingOpponent)
|
||||||
|
&& sa.getRestrictions().checkOtherRestrictions(c, sa, this.defendingOpponent)) {
|
||||||
Card animatedCopy = CardFactory.getCard(c.getPaperCard(), this.defendingOpponent);
|
Card animatedCopy = CardFactory.getCard(c.getPaperCard(), this.defendingOpponent);
|
||||||
AnimateAi.becomeAnimated(animatedCopy, sa);
|
AnimateAi.becomeAnimated(animatedCopy, sa);
|
||||||
this.oppList.add(animatedCopy);
|
this.oppList.add(animatedCopy);
|
||||||
|
|||||||
@@ -291,68 +291,11 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public final boolean checkOtherRestrictions(final Card c, final SpellAbility sa, final Player activator) {
|
||||||
* <p>
|
|
||||||
* canPlay.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param c
|
|
||||||
* a {@link forge.game.card.Card} object.
|
|
||||||
* @param sa
|
|
||||||
* a {@link forge.game.spellability.SpellAbility} object.
|
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
public final boolean canPlay(final Card c, final SpellAbility sa) {
|
|
||||||
if (c.isPhasedOut() || c.isUsedToPay()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player activator = sa.getActivatingPlayer();
|
|
||||||
if (activator == null) {
|
|
||||||
activator = c.getController();
|
|
||||||
sa.setActivatingPlayer(activator);
|
|
||||||
System.out.println(c.getName() + " Did not have activator set in SpellAbilityRestriction.canPlay()");
|
|
||||||
}
|
|
||||||
|
|
||||||
final Game game = activator.getGame();
|
final Game game = activator.getGame();
|
||||||
|
|
||||||
if (this.isSorcerySpeed() && !activator.canCastSorcery()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!checkTimingRestrictions(c, sa)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!checkActivatorRestrictions(c, sa)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!checkZoneRestrictions(c, sa)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getLimitToCheck() != null) {
|
|
||||||
String limit = this.getLimitToCheck();
|
|
||||||
int activationLimit = AbilityUtils.calculateAmount(c, limit, sa);
|
|
||||||
this.setActivationLimit(activationLimit);
|
|
||||||
|
|
||||||
if ((this.getActivationLimit() != -1) && (this.getNumberTurnActivations() >= this.getActivationLimit())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getGameLimitToCheck() != null) {
|
|
||||||
String limit = this.getGameLimitToCheck();
|
|
||||||
int gameActivationLimit = AbilityUtils.calculateAmount(c, limit, sa);
|
|
||||||
this.setGameActivationLimit(gameActivationLimit);
|
|
||||||
|
|
||||||
if ((this.getGameActivationLimit() != -1) && (this.getNumberGameActivations() >= this.getGameActivationLimit())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getCardsInHand() != -1) {
|
if (this.getCardsInHand() != -1) {
|
||||||
if (activator.getCardsIn(ZoneType.Hand).size() != this.getCardsInHand()) {
|
if (activator.getCardsIn(ZoneType.Hand).size() != this.getCardsInHand()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -430,7 +373,6 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.isPwAbility()) {
|
if (this.isPwAbility()) {
|
||||||
|
|
||||||
for (final SpellAbility pwAbs : c.getAllSpellAbilities()) {
|
for (final SpellAbility pwAbs : c.getAllSpellAbilities()) {
|
||||||
// check all abilities on card that have their planeswalker
|
// check all abilities on card that have their planeswalker
|
||||||
// restriction set to confirm they haven't been activated
|
// restriction set to confirm they haven't been activated
|
||||||
@@ -460,6 +402,71 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* canPlay.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* a {@link forge.game.card.Card} object.
|
||||||
|
* @param sa
|
||||||
|
* a {@link forge.game.spellability.SpellAbility} object.
|
||||||
|
* @return a boolean.
|
||||||
|
*/
|
||||||
|
public final boolean canPlay(final Card c, final SpellAbility sa) {
|
||||||
|
if (c.isPhasedOut() || c.isUsedToPay()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player activator = sa.getActivatingPlayer();
|
||||||
|
if (activator == null) {
|
||||||
|
activator = c.getController();
|
||||||
|
sa.setActivatingPlayer(activator);
|
||||||
|
System.out.println(c.getName() + " Did not have activator set in SpellAbilityRestriction.canPlay()");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isSorcerySpeed() && !activator.canCastSorcery()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkTimingRestrictions(c, sa)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkActivatorRestrictions(c, sa)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkZoneRestrictions(c, sa)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkOtherRestrictions(c, sa, activator)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getLimitToCheck() != null) {
|
||||||
|
String limit = this.getLimitToCheck();
|
||||||
|
int activationLimit = AbilityUtils.calculateAmount(c, limit, sa);
|
||||||
|
this.setActivationLimit(activationLimit);
|
||||||
|
|
||||||
|
if ((this.getActivationLimit() != -1) && (this.getNumberTurnActivations() >= this.getActivationLimit())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getGameLimitToCheck() != null) {
|
||||||
|
String limit = this.getGameLimitToCheck();
|
||||||
|
int gameActivationLimit = AbilityUtils.calculateAmount(c, limit, sa);
|
||||||
|
this.setGameActivationLimit(gameActivationLimit);
|
||||||
|
|
||||||
|
if ((this.getGameActivationLimit() != -1) && (this.getNumberGameActivations() >= this.getGameActivationLimit())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // canPlay()
|
} // canPlay()
|
||||||
|
|||||||
Reference in New Issue
Block a user