mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
- Updated sacrifice cost AI in more AF's.
This commit is contained in:
@@ -17,6 +17,7 @@ import forge.card.cardFactory.CardFactoryUtil;
|
||||
import forge.card.spellability.Ability;
|
||||
import forge.card.spellability.Ability_Activated;
|
||||
import forge.card.spellability.Ability_Sub;
|
||||
import forge.card.spellability.Cost;
|
||||
import forge.card.spellability.Spell;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
@@ -143,10 +144,28 @@ public class AbilityFactory_CounterMagic {
|
||||
|
||||
private boolean counterCanPlayAI(final AbilityFactory af, final SpellAbility sa){
|
||||
boolean toReturn = true;
|
||||
Cost abCost = af.getAbCost();
|
||||
final Card source = sa.getSourceCard();
|
||||
if(AllZone.Stack.size() < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (abCost != null){
|
||||
// AI currently disabled for these costs
|
||||
if (abCost.getSacCost() && !abCost.getSacThis()){
|
||||
//only sacrifice something that's supposed to be sacrificed
|
||||
String type = abCost.getSacType();
|
||||
CardList typeList = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
|
||||
typeList = typeList.getValidCards(type.split(","), source.getController(), source);
|
||||
if(ComputerUtil.getCardPreference(source, "SacCost", typeList) == null)
|
||||
return false;
|
||||
}
|
||||
if (abCost.getLifeCost()){
|
||||
if (AllZone.ComputerPlayer.getLife() - abCost.getLifeAmount() < 4)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SpellAbility topSA = AllZone.Stack.peek();
|
||||
if (!CardFactoryUtil.isCounterable(topSA.getSourceCard()) || topSA.getActivatingPlayer().isComputer())
|
||||
return false;
|
||||
@@ -155,11 +174,9 @@ public class AbilityFactory_CounterMagic {
|
||||
tgt.resetTargets();
|
||||
if (Target_Selection.matchSpellAbility(sa, topSA, tgt))
|
||||
tgt.addTarget(topSA);
|
||||
|
||||
else
|
||||
return false;
|
||||
|
||||
Card source = sa.getSourceCard();
|
||||
if (unlessCost != null){
|
||||
// Is this Usable Mana Sources? Or Total Available Mana?
|
||||
int usableManaSources = CardFactoryUtil.getUsableManaSources(AllZone.HumanPlayer);
|
||||
|
||||
@@ -205,8 +205,13 @@ public class AbilityFactory_Counters {
|
||||
|
||||
if (abCost != null){
|
||||
// AI currently disabled for these costs
|
||||
if (abCost.getSacCost()){
|
||||
return false;
|
||||
if (abCost.getSacCost() && !abCost.getSacThis()){
|
||||
//only sacrifice something that's supposed to be sacrificed
|
||||
String sacType = abCost.getSacType();
|
||||
CardList typeList = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
|
||||
typeList = typeList.getValidCards(sacType.split(","), source.getController(), source);
|
||||
if(ComputerUtil.getCardPreference(source, "SacCost", typeList) == null)
|
||||
return false;
|
||||
}
|
||||
if (abCost.getLifeCost()) return false;
|
||||
if (abCost.getDiscardCost()) return false;
|
||||
@@ -661,8 +666,13 @@ public class AbilityFactory_Counters {
|
||||
|
||||
if (abCost != null){
|
||||
// AI currently disabled for these costs
|
||||
if (abCost.getSacCost()){
|
||||
return false;
|
||||
if (abCost.getSacCost() && !abCost.getSacThis()){
|
||||
//only sacrifice something that's supposed to be sacrificed
|
||||
String sacType = abCost.getSacType();
|
||||
CardList typeList = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
|
||||
typeList = typeList.getValidCards(sacType.split(","), source.getController(), source);
|
||||
if(ComputerUtil.getCardPreference(source, "SacCost", typeList) == null)
|
||||
return false;
|
||||
}
|
||||
if (abCost.getLifeCost()) return false;
|
||||
if (abCost.getDiscardCost()) return false;
|
||||
|
||||
@@ -196,6 +196,7 @@ public class AbilityFactory_DealDamage {
|
||||
if (!ComputerUtil.canPayCost(saMe))
|
||||
return false;
|
||||
|
||||
Cost abCost = AF.getAbCost();
|
||||
Card source = saMe.getSourceCard();
|
||||
|
||||
int dmg = 0;
|
||||
@@ -209,9 +210,13 @@ public class AbilityFactory_DealDamage {
|
||||
boolean rr = AF.isSpell();
|
||||
|
||||
// temporarily disabled until better AI
|
||||
if (AF.getAbCost().getSacCost()) {
|
||||
if(AF.getHostCard().isCreature() && AllZone.HumanPlayer.getLife() - dmg > 0) // only if damage from this ability would kill the human
|
||||
return false;
|
||||
if (abCost.getSacCost() && !abCost.getSacThis() && AllZone.HumanPlayer.getLife() - dmg > 0){
|
||||
//only sacrifice something that's supposed to be sacrificed
|
||||
String sacType = abCost.getSacType();
|
||||
CardList typeList = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
|
||||
typeList = typeList.getValidCards(sacType.split(","), source.getController(), source);
|
||||
if(ComputerUtil.getCardPreference(source, "SacCost", typeList) == null)
|
||||
return false;
|
||||
}
|
||||
if (AF.getAbCost().getSubCounter()) {
|
||||
// +1/+1 counters only if damage from this ability would kill the human, otherwise ok
|
||||
|
||||
@@ -141,8 +141,13 @@ public class AbilityFactory_Destroy {
|
||||
|
||||
if (abCost != null){
|
||||
// AI currently disabled for some costs
|
||||
if (abCost.getSacCost() && source.isCreature()){
|
||||
return false;
|
||||
if (abCost.getSacCost() && !abCost.getSacThis()){
|
||||
//only sacrifice something that's supposed to be sacrificed
|
||||
String sacType = abCost.getSacType();
|
||||
CardList typeList = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
|
||||
typeList = typeList.getValidCards(sacType.split(","), source.getController(), source);
|
||||
if(ComputerUtil.getCardPreference(source, "SacCost", typeList) == null)
|
||||
return false;
|
||||
}
|
||||
if (abCost.getLifeCost()){
|
||||
if (AllZone.ComputerPlayer.getLife() - abCost.getLifeAmount() < 4)
|
||||
|
||||
Reference in New Issue
Block a user