mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
I made some changes to the AI for the enPump keyword code. The AI will no longer enchant it's walls or enchant previously enchanted creatures.
This commit is contained in:
@@ -1615,15 +1615,19 @@ public class CardFactoryUtil {
|
|||||||
final SpellAbility enchant = new Spell(sourceCard) {
|
final SpellAbility enchant = new Spell(sourceCard) {
|
||||||
private static final long serialVersionUID = -8259560434384053776L;
|
private static final long serialVersionUID = -8259560434384053776L;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* for flash, which is not working through the keyword for some reason
|
||||||
|
* if not flash then limit to main 1 and 2 on controller's turn and card in hand
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlay() {
|
public boolean canPlay() {
|
||||||
return (sourceCard.getKeyword().contains("Flash") && (AllZone.GameAction.isCardInZone(sourceCard, AllZone.Human_Hand) ||
|
return (sourceCard.getKeyword().contains("Flash") && (AllZone.GameAction.isCardInZone(sourceCard, AllZone.Human_Hand) ||
|
||||||
AllZone.GameAction.isCardInZone(sourceCard, AllZone.Computer_Hand)) // for flash, which is not working through the keyword for some reason
|
AllZone.GameAction.isCardInZone(sourceCard, AllZone.Computer_Hand))
|
||||||
|| // if not flash then limit to main 1 and 2 on controller's turn and card in hand
|
||
|
||||||
(! sourceCard.getKeyword().contains("Flash") && (sourceCard.getController().equals(AllZone.Phase.getActivePlayer()) &&
|
(! sourceCard.getKeyword().contains("Flash") && (sourceCard.getController().equals(AllZone.Phase.getActivePlayer()) &&
|
||||||
(AllZone.GameAction.isCardInZone(sourceCard, AllZone.Human_Hand) || AllZone.GameAction.isCardInZone(sourceCard, AllZone.Computer_Hand)) &&
|
(AllZone.GameAction.isCardInZone(sourceCard, AllZone.Human_Hand) || AllZone.GameAction.isCardInZone(sourceCard, AllZone.Computer_Hand)) &&
|
||||||
(AllZone.Phase.getPhase().equals(Constant.Phase.Main1) || AllZone.Phase.getPhase().equals(Constant.Phase.Main2)))));
|
(AllZone.Phase.getPhase().equals(Constant.Phase.Main1) || AllZone.Phase.getPhase().equals(Constant.Phase.Main2)))));
|
||||||
}
|
}// CanPlay (for auras with Flash)
|
||||||
|
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
CardList list = new CardList(AllZone.Computer_Play.getCards());
|
CardList list = new CardList(AllZone.Computer_Play.getCards());
|
||||||
@@ -1650,15 +1654,18 @@ public class CardFactoryUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//else (if aura is keyword only)
|
|
||||||
|
|
||||||
if (Power == 0 && Tough == 0) { // This aura is keyword only
|
/*
|
||||||
|
* else (if aura is keyword only)
|
||||||
|
* Do not duplicate keyword or enchant card with Defender or enchant card already enchanted
|
||||||
|
*/
|
||||||
|
if (Power == 0 && Tough == 0) {
|
||||||
list = list.filter(new CardListFilter() {
|
list = list.filter(new CardListFilter() {
|
||||||
public boolean addCard(Card c){
|
public boolean addCard(Card c){
|
||||||
ArrayList<String> extKeywords = new ArrayList<String>(Arrays.asList(extrinsicKeywords));
|
ArrayList<String> extKeywords = new ArrayList<String>(Arrays.asList(extrinsicKeywords));
|
||||||
for (String s:extKeywords) {
|
for (String s:extKeywords) {
|
||||||
if (!c.getKeyword().contains(s))
|
if (!c.getKeyword().contains(s) && !c.getKeyword().contains("Defender") && !c.isEnchanted())
|
||||||
return true; // Do not duplicate keyword and do not kill by reducing toughness to <= zero
|
return true;
|
||||||
}
|
}
|
||||||
// no new keywords:
|
// no new keywords:
|
||||||
return false;
|
return false;
|
||||||
@@ -1666,16 +1673,20 @@ public class CardFactoryUtil {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//else aura is power/toughness boost and may have keyword(s)
|
/*
|
||||||
|
* else aura is power/toughness boost and may have keyword(s)
|
||||||
|
* Do not reduce power to <= zero or kill by reducing toughness to <= zero
|
||||||
|
* Do not enchant card with Defender or enchant card already enchanted
|
||||||
|
*/
|
||||||
CardListUtil.sortAttack(list);
|
CardListUtil.sortAttack(list);
|
||||||
CardListUtil.sortFlying(list);
|
CardListUtil.sortFlying(list);
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
if (CardFactoryUtil.canTarget(sourceCard, list.get(i)) &&
|
if (CardFactoryUtil.canTarget(sourceCard, list.get(i)) &&
|
||||||
list.get(i).getNetAttack() + Power > 0 && list.get(i).getNetDefense() + Tough > 0) {
|
list.get(i).getNetAttack() + Power > 0 && list.get(i).getNetDefense() + Tough > 0 &&
|
||||||
setTargetCard(list.get(i)); // Do not reduce power to <= zero
|
!list.get(i).getKeyword().contains("Defender") && !list.get(i).isEnchanted()) {
|
||||||
return true; // Do not kill by reducing toughness to <= zero
|
setTargetCard(list.get(i));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user