mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
cleanup regarding params in a couple AFs
This commit is contained in:
@@ -44,8 +44,9 @@ public class AbilityFactory_DelayedTrigger {
|
|||||||
|
|
||||||
private static boolean doChkAI_Drawback(final AbilityFactory AF, final SpellAbility SA)
|
private static boolean doChkAI_Drawback(final AbilityFactory AF, final SpellAbility SA)
|
||||||
{
|
{
|
||||||
String svarName = AF.getMapParams().get("Execute");
|
HashMap<String,String> params = AF.getMapParams();
|
||||||
SpellAbility trigsa = tempCreator.getAbility(AF.getHostCard().getSVar(svarName),AF.getHostCard());
|
String svarName = params.get("Execute");
|
||||||
|
SpellAbility trigsa = tempCreator.getAbility(AF.getHostCard().getSVar(svarName), AF.getHostCard());
|
||||||
|
|
||||||
if(trigsa instanceof Ability_Sub)
|
if(trigsa instanceof Ability_Sub)
|
||||||
{
|
{
|
||||||
@@ -59,16 +60,17 @@ public class AbilityFactory_DelayedTrigger {
|
|||||||
|
|
||||||
private static boolean doTriggerAI(final AbilityFactory AF,final SpellAbility SA)
|
private static boolean doTriggerAI(final AbilityFactory AF,final SpellAbility SA)
|
||||||
{
|
{
|
||||||
String svarName = AF.getMapParams().get("Execute");
|
HashMap<String,String> params = AF.getMapParams();
|
||||||
|
String svarName = params.get("Execute");
|
||||||
SpellAbility trigsa = tempCreator.getAbility(AF.getHostCard().getSVar(svarName),AF.getHostCard());
|
SpellAbility trigsa = tempCreator.getAbility(AF.getHostCard().getSVar(svarName),AF.getHostCard());
|
||||||
|
|
||||||
if(!AF.getMapParams().containsKey("OptionalDecider"))
|
if(!params.containsKey("OptionalDecider"))
|
||||||
{
|
{
|
||||||
return trigsa.doTrigger(true);
|
return trigsa.doTrigger(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return trigsa.doTrigger(!AF.getMapParams().get("OptionalDecider").equals("You"));
|
return trigsa.doTrigger(!params.get("OptionalDecider").equals("You"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,8 @@ public class AbilityFactory_Destroy {
|
|||||||
Cost abCost = sa.getPayCosts();
|
Cost abCost = sa.getPayCosts();
|
||||||
Target abTgt = sa.getTarget();
|
Target abTgt = sa.getTarget();
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
final boolean noRegen = af.getMapParams().containsKey("NoRegen");
|
HashMap<String,String> params = af.getMapParams();
|
||||||
|
final boolean noRegen = params.containsKey("NoRegen");
|
||||||
|
|
||||||
CardList list;
|
CardList list;
|
||||||
list = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
|
list = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
|
||||||
@@ -220,7 +221,8 @@ public class AbilityFactory_Destroy {
|
|||||||
|
|
||||||
Target tgt = sa.getTarget();
|
Target tgt = sa.getTarget();
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
final boolean noRegen = af.getMapParams().containsKey("NoRegen");
|
HashMap<String,String> params = af.getMapParams();
|
||||||
|
final boolean noRegen = params.containsKey("NoRegen");
|
||||||
|
|
||||||
|
|
||||||
if (tgt != null){
|
if (tgt != null){
|
||||||
@@ -313,11 +315,12 @@ public class AbilityFactory_Destroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String destroyStackDescription(final AbilityFactory af, SpellAbility sa) {
|
private static String destroyStackDescription(final AbilityFactory af, SpellAbility sa) {
|
||||||
final boolean noRegen = af.getMapParams().containsKey("NoRegen");
|
HashMap<String,String> params = af.getMapParams();
|
||||||
|
final boolean noRegen = params.containsKey("NoRegen");
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
Card host = af.getHostCard();
|
Card host = af.getHostCard();
|
||||||
|
|
||||||
String conditionDesc = af.getMapParams().get("ConditionDescription");
|
String conditionDesc = params.get("ConditionDescription");
|
||||||
if (conditionDesc != null)
|
if (conditionDesc != null)
|
||||||
sb.append(conditionDesc).append(" ");
|
sb.append(conditionDesc).append(" ");
|
||||||
|
|
||||||
@@ -327,7 +330,7 @@ public class AbilityFactory_Destroy {
|
|||||||
if (tgt != null)
|
if (tgt != null)
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
else{
|
else{
|
||||||
tgtCards = AbilityFactory.getDefinedCards(sa.getSourceCard(), af.getMapParams().get("Defined"), sa);
|
tgtCards = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub)
|
if (sa instanceof Ability_Sub)
|
||||||
@@ -376,7 +379,7 @@ public class AbilityFactory_Destroy {
|
|||||||
if (tgt != null)
|
if (tgt != null)
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
else{
|
else{
|
||||||
tgtCards = AbilityFactory.getDefinedCards(sa.getSourceCard(), af.getMapParams().get("Defined"), sa);
|
tgtCards = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Card tgtC : tgtCards){
|
for(Card tgtC : tgtCards){
|
||||||
@@ -496,33 +499,34 @@ public class AbilityFactory_Destroy {
|
|||||||
public static String destroyAllStackDescription(final AbilityFactory af, SpellAbility sa, boolean noRegen){
|
public static String destroyAllStackDescription(final AbilityFactory af, SpellAbility sa, boolean noRegen){
|
||||||
// when getStackDesc is called, just build exactly what is happening
|
// when getStackDesc is called, just build exactly what is happening
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
String name = af.getHostCard().getName();
|
String name = af.getHostCard().getName();
|
||||||
|
HashMap<String,String> params = af.getMapParams();
|
||||||
String conditionDesc = af.getMapParams().get("ConditionDescription");
|
|
||||||
|
String conditionDesc = params.get("ConditionDescription");
|
||||||
if (conditionDesc != null)
|
if (conditionDesc != null)
|
||||||
sb.append(conditionDesc).append(" ");
|
sb.append(conditionDesc).append(" ");
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
|
|
||||||
Target tgt = af.getAbTgt();
|
Target tgt = af.getAbTgt();
|
||||||
if (tgt != null)
|
if (tgt != null)
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
else{
|
else{
|
||||||
tgtCards = new ArrayList<Card>();
|
tgtCards = new ArrayList<Card>();
|
||||||
tgtCards.add(sa.getSourceCard());
|
tgtCards.add(sa.getSourceCard());
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(name).append(" - Destroy permanents");
|
sb.append(name).append(" - Destroy permanents");
|
||||||
|
|
||||||
if(noRegen) sb.append(". They can't be regenerated");
|
if(noRegen) sb.append(". They can't be regenerated");
|
||||||
|
|
||||||
Ability_Sub abSub = sa.getSubAbility();
|
Ability_Sub abSub = sa.getSubAbility();
|
||||||
if (abSub != null) {
|
if (abSub != null) {
|
||||||
sb.append(abSub.getStackDescription());
|
sb.append(abSub.getStackDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean destroyAllCanPlayAI(final AbilityFactory af, final SpellAbility sa, final boolean noRegen){
|
public static boolean destroyAllCanPlayAI(final AbilityFactory af, final SpellAbility sa, final boolean noRegen){
|
||||||
@@ -532,26 +536,26 @@ public class AbilityFactory_Destroy {
|
|||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
final HashMap<String,String> params = af.getMapParams();
|
final HashMap<String,String> params = af.getMapParams();
|
||||||
String Valid = "";
|
String Valid = "";
|
||||||
|
|
||||||
if(params.containsKey("ValidCards"))
|
if(params.containsKey("ValidCards"))
|
||||||
Valid = params.get("ValidCards");
|
Valid = params.get("ValidCards");
|
||||||
|
|
||||||
if (Valid.contains("X") && source.getSVar("X").equals("Count$xPaid")){
|
if (Valid.contains("X") && source.getSVar("X").equals("Count$xPaid")){
|
||||||
// Set PayX here to maximum value.
|
// Set PayX here to maximum value.
|
||||||
int xPay = ComputerUtil.determineLeftoverMana(sa);
|
int xPay = ComputerUtil.determineLeftoverMana(sa);
|
||||||
source.setSVar("PayX", Integer.toString(xPay));
|
source.setSVar("PayX", Integer.toString(xPay));
|
||||||
Valid = Valid.replace("X", Integer.toString(xPay));
|
Valid = Valid.replace("X", Integer.toString(xPay));
|
||||||
}
|
}
|
||||||
|
|
||||||
CardList humanlist = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
|
CardList humanlist = AllZoneUtil.getPlayerCardsInPlay(AllZone.HumanPlayer);
|
||||||
CardList computerlist = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
|
CardList computerlist = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
|
||||||
|
|
||||||
humanlist = humanlist.getValidCards(Valid.split(","), source.getController(), source);
|
humanlist = humanlist.getValidCards(Valid.split(","), source.getController(), source);
|
||||||
computerlist = computerlist.getValidCards(Valid.split(","), source.getController(), source);
|
computerlist = computerlist.getValidCards(Valid.split(","), source.getController(), source);
|
||||||
|
|
||||||
humanlist = humanlist.getNotKeyword("Indestructible");
|
humanlist = humanlist.getNotKeyword("Indestructible");
|
||||||
computerlist = computerlist.getNotKeyword("Indestructible");
|
computerlist = computerlist.getNotKeyword("Indestructible");
|
||||||
|
|
||||||
if (abCost != null){
|
if (abCost != null){
|
||||||
// AI currently disabled for some costs
|
// AI currently disabled for some costs
|
||||||
if (abCost.getSacCost()){
|
if (abCost.getSacCost()){
|
||||||
@@ -562,35 +566,35 @@ public class AbilityFactory_Destroy {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (abCost.getDiscardCost()) ;//OK
|
if (abCost.getDiscardCost()) ;//OK
|
||||||
|
|
||||||
if (abCost.getSubCounter()){
|
if (abCost.getSubCounter()){
|
||||||
// OK
|
// OK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ComputerUtil.canPayCost(sa))
|
if (!ComputerUtil.canPayCost(sa))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// prevent run-away activations - first time will always return true
|
// prevent run-away activations - first time will always return true
|
||||||
boolean chance = r.nextFloat() <= Math.pow(.6667, source.getAbilityUsed());
|
boolean chance = r.nextFloat() <= Math.pow(.6667, source.getAbilityUsed());
|
||||||
|
|
||||||
// if only creatures are affected evaluate both lists and pass only if human creatures are more valuable
|
// if only creatures are affected evaluate both lists and pass only if human creatures are more valuable
|
||||||
if (humanlist.getNotType("Creature").size() == 0 && computerlist.getNotType("Creature").size() == 0) {
|
if (humanlist.getNotType("Creature").size() == 0 && computerlist.getNotType("Creature").size() == 0) {
|
||||||
if(CardFactoryUtil.evaluateCreatureList(computerlist) + 200 >= CardFactoryUtil.evaluateCreatureList(humanlist))
|
if(CardFactoryUtil.evaluateCreatureList(computerlist) + 200 >= CardFactoryUtil.evaluateCreatureList(humanlist))
|
||||||
return false;
|
return false;
|
||||||
}//only lands involved
|
}//only lands involved
|
||||||
else if (humanlist.getNotType("Land").size() == 0 && computerlist.getNotType("Land").size() == 0) {
|
else if (humanlist.getNotType("Land").size() == 0 && computerlist.getNotType("Land").size() == 0) {
|
||||||
if(CardFactoryUtil.evaluatePermanentList(computerlist) + 1 >= CardFactoryUtil.evaluatePermanentList(humanlist))
|
if(CardFactoryUtil.evaluatePermanentList(computerlist) + 1 >= CardFactoryUtil.evaluatePermanentList(humanlist))
|
||||||
return false;
|
return false;
|
||||||
} // otherwise evaluate both lists by CMC and pass only if human permanents are more valuable
|
} // otherwise evaluate both lists by CMC and pass only if human permanents are more valuable
|
||||||
else if(CardFactoryUtil.evaluatePermanentList(computerlist) + 3 >= CardFactoryUtil.evaluatePermanentList(humanlist))
|
else if(CardFactoryUtil.evaluatePermanentList(computerlist) + 3 >= CardFactoryUtil.evaluatePermanentList(humanlist))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null)
|
if (subAb != null)
|
||||||
chance &= subAb.chkAI_Drawback();
|
chance &= subAb.chkAI_Drawback();
|
||||||
|
|
||||||
return ((r.nextFloat() < .9667) && chance);
|
return ((r.nextFloat() < .9667) && chance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void destroyAllResolve(final AbilityFactory af, final SpellAbility sa, final boolean noRegen){
|
public static void destroyAllResolve(final AbilityFactory af, final SpellAbility sa, final boolean noRegen){
|
||||||
@@ -627,4 +631,5 @@ public class AbilityFactory_Destroy {
|
|||||||
card.addRemembered(list.get(i));
|
card.addRemembered(list.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}//end class AbilityFactory_Destroy
|
||||||
|
|||||||
@@ -542,6 +542,7 @@ public class AbilityFactory_PermanentState {
|
|||||||
if (!ComputerUtil.canPayCost(sa))
|
if (!ComputerUtil.canPayCost(sa))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
HashMap<String,String> params = af.getMapParams();
|
||||||
Target tgt = af.getAbTgt();
|
Target tgt = af.getAbTgt();
|
||||||
Card source = sa.getSourceCard();
|
Card source = sa.getSourceCard();
|
||||||
|
|
||||||
@@ -549,7 +550,7 @@ public class AbilityFactory_PermanentState {
|
|||||||
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, source.getAbilityUsed());
|
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, source.getAbilityUsed());
|
||||||
|
|
||||||
if (tgt == null){
|
if (tgt == null){
|
||||||
ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, af.getMapParams().get("Defined"), sa);
|
ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, params.get("Defined"), sa);
|
||||||
|
|
||||||
boolean bFlag = false;
|
boolean bFlag = false;
|
||||||
for(Card c : defined)
|
for(Card c : defined)
|
||||||
@@ -1216,36 +1217,38 @@ public class AbilityFactory_PermanentState {
|
|||||||
|
|
||||||
private static String tapOrUntapStackDescription(AbilityFactory af, SpellAbility sa){
|
private static String tapOrUntapStackDescription(AbilityFactory af, SpellAbility sa){
|
||||||
// when getStackDesc is called, just build exactly what is happening
|
// when getStackDesc is called, just build exactly what is happening
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (sa instanceof Ability_Sub)
|
HashMap<String,String> params = af.getMapParams();
|
||||||
sb.append(" ");
|
|
||||||
else
|
if (sa instanceof Ability_Sub)
|
||||||
sb.append(sa.getSourceCard()).append(" - ");
|
sb.append(" ");
|
||||||
|
else
|
||||||
sb.append("Tap or untap ");
|
sb.append(sa.getSourceCard()).append(" - ");
|
||||||
|
|
||||||
|
sb.append("Tap or untap ");
|
||||||
|
|
||||||
ArrayList<Card> tgtCards;
|
ArrayList<Card> tgtCards;
|
||||||
Target tgt = af.getAbTgt();
|
Target tgt = af.getAbTgt();
|
||||||
if (tgt != null)
|
if (tgt != null)
|
||||||
tgtCards = tgt.getTargetCards();
|
tgtCards = tgt.getTargetCards();
|
||||||
else{
|
else{
|
||||||
tgtCards = AbilityFactory.getDefinedCards(sa.getSourceCard(), af.getMapParams().get("Defined"), sa);
|
tgtCards = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<Card> it = tgtCards.iterator();
|
Iterator<Card> it = tgtCards.iterator();
|
||||||
while(it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
sb.append(it.next());
|
sb.append(it.next());
|
||||||
if(it.hasNext()) sb.append(", ");
|
if(it.hasNext()) sb.append(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(".");
|
sb.append(".");
|
||||||
|
|
||||||
Ability_Sub subAb = sa.getSubAbility();
|
Ability_Sub subAb = sa.getSubAbility();
|
||||||
if (subAb != null)
|
if (subAb != null)
|
||||||
sb.append(subAb.getStackDescription());
|
sb.append(subAb.getStackDescription());
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean tapOrUntapCanPlayAI(final AbilityFactory af, SpellAbility sa){
|
private static boolean tapOrUntapCanPlayAI(final AbilityFactory af, SpellAbility sa){
|
||||||
@@ -1253,6 +1256,7 @@ public class AbilityFactory_PermanentState {
|
|||||||
if (!ComputerUtil.canPayCost(sa))
|
if (!ComputerUtil.canPayCost(sa))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
HashMap<String,String> params = af.getMapParams();
|
||||||
Target tgt = af.getAbTgt();
|
Target tgt = af.getAbTgt();
|
||||||
Card source = sa.getSourceCard();
|
Card source = sa.getSourceCard();
|
||||||
|
|
||||||
@@ -1262,7 +1266,7 @@ public class AbilityFactory_PermanentState {
|
|||||||
if (tgt == null){
|
if (tgt == null){
|
||||||
//assume we are looking to tap human's stuff
|
//assume we are looking to tap human's stuff
|
||||||
//TODO - check for things with untap abilities, and don't tap those.
|
//TODO - check for things with untap abilities, and don't tap those.
|
||||||
ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, af.getMapParams().get("Defined"), sa);
|
ArrayList<Card> defined = AbilityFactory.getDefinedCards(source, params.get("Defined"), sa);
|
||||||
|
|
||||||
boolean bFlag = false;
|
boolean bFlag = false;
|
||||||
for(Card c : defined)
|
for(Card c : defined)
|
||||||
|
|||||||
Reference in New Issue
Block a user