mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- Fix potential NPE in SetStateAI
- Unroll UntapAI into new style
This commit is contained in:
@@ -64,7 +64,7 @@ public abstract class SpellAbilityAi {
|
|||||||
* Checks if the AI will play a SpellAbility with the specified AiLogic
|
* Checks if the AI will play a SpellAbility with the specified AiLogic
|
||||||
*/
|
*/
|
||||||
protected boolean checkAiLogic(final Player ai, final SpellAbility sa, final String aiLogic) {
|
protected boolean checkAiLogic(final Player ai, final SpellAbility sa, final String aiLogic) {
|
||||||
return true;
|
return !("Never".equals(aiLogic));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -204,8 +204,8 @@ public abstract class SpellAbilityAi {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this method.
|
* TODO: Write javadoc for this method.
|
||||||
* @param ai
|
* @param aiPlayer
|
||||||
* @param subAb
|
* @param ab
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean chkDrawbackWithSubs(Player aiPlayer, AbilitySub ab) {
|
public boolean chkDrawbackWithSubs(Player aiPlayer, AbilitySub ab) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class SetStateAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
// check if the other side is legendary and if such Card already is in Play
|
// check if the other side is legendary and if such Card already is in Play
|
||||||
final CardState other = source.getAlternateState();
|
final CardState other = source.getAlternateState();
|
||||||
if (other.getType().isLegendary() && aiPlayer.isCardInPlay(other.getName())) {
|
if (other != null && other.getType().isLegendary() && aiPlayer.isCardInPlay(other.getName())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,17 @@ import forge.game.zone.ZoneType;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class UntapAi extends SpellAbilityAi {
|
public class UntapAi extends SpellAbilityAi {
|
||||||
@Override
|
protected boolean checkAiLogic(final Player ai, final SpellAbility sa, final String aiLogic) {
|
||||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
|
||||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
|
||||||
final Card source = sa.getHostCard();
|
final Card source = sa.getHostCard();
|
||||||
final Cost cost = sa.getPayCosts();
|
if ("EOT".equals(sa.getParam("AILogic")) && (source.getGame().getPhaseHandler().getNextTurn() != ai
|
||||||
|
|| !source.getGame().getPhaseHandler().getPhase().equals(PhaseType.END_OF_TURN))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !("Never".equals(aiLogic));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean willPayCosts(final Player ai, final SpellAbility sa, final Cost cost, final Card source) {
|
||||||
if (!ComputerUtilCost.checkAddM1M1CounterCost(cost, source)) {
|
if (!ComputerUtilCost.checkAddM1M1CounterCost(cost, source)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -34,17 +39,20 @@ public class UntapAi extends SpellAbilityAi {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean checkApiLogic(Player ai, SpellAbility sa) {
|
||||||
|
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||||
|
final Card source = sa.getHostCard();
|
||||||
|
|
||||||
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if ("EOT".equals(sa.getParam("AILogic")) && (source.getGame().getPhaseHandler().getNextTurn() != ai
|
|
||||||
|| !source.getGame().getPhaseHandler().getPhase().equals(PhaseType.END_OF_TURN))) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
final List<Card> pDefined = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
|
final List<Card> pDefined = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa);
|
||||||
if (pDefined != null && pDefined.get(0).isUntapped() && pDefined.get(0).getController() == ai) {
|
if (pDefined != null && pDefined.get(0).isUntapped() && pDefined.get(0).getController() == ai) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user