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