mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- Improved the AI for spBounceAll
- Added a getTokens CardList filter to CardList.java - Added sumCMC function to CardListUtil.java
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -386,7 +386,7 @@ src/forge/CardFactory_Planeswalkers.java -text svneol=native#text/plain
|
||||
src/forge/CardFilter.java -text svneol=native#text/plain
|
||||
src/forge/CardList.java -text svneol=native#text/plain
|
||||
src/forge/CardListFilter.java svneol=native#text/plain
|
||||
src/forge/CardListUtil.java svneol=native#text/plain
|
||||
src/forge/CardListUtil.java -text svneol=native#text/plain
|
||||
src/forge/CardShopTableModel.java -text svneol=native#text/plain
|
||||
src/forge/CardUtil.java svneol=native#text/plain
|
||||
src/forge/Combat.java svneol=native#text/plain
|
||||
|
||||
@@ -3112,11 +3112,17 @@ public class CardFactory implements NewConstants {
|
||||
CardList computer = new CardList(AllZone.Computer_Play.getCards());
|
||||
|
||||
human = human.getValidCards(Tgts);
|
||||
int humanvalue = sumCMC(human);
|
||||
humanvalue += human.getType("Land").size();
|
||||
humanvalue += human.getTokens().size() * 3; // X = total converted mana cost + number of lands + 3 * number of tokens (Human)
|
||||
computer = computer.getValidCards(Tgts);
|
||||
int computervalue = sumCMC(computer);
|
||||
computervalue += computer.getType("Land").size();
|
||||
computervalue += computer.getTokens().size() * 3; // Y = total converted mana cost + number of lands + 3 * number of tokens (Computer)
|
||||
|
||||
// the computer will at least bounce 2 more human permanents
|
||||
// the computer will play the spell if Y < X - 2
|
||||
return AllZone.Phase.getPhase().equals(Constant.Phase.Main2) &&
|
||||
(computer.size() < human.size() - 1);
|
||||
(computervalue < humanvalue - 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3151,6 +3157,7 @@ public class CardFactory implements NewConstants {
|
||||
|
||||
}//spBounceAll
|
||||
|
||||
|
||||
while(hasKeyword(card, "abDrawCards") != -1) {
|
||||
int n = hasKeyword(card, "abDrawCards");
|
||||
String parse = card.getKeyword().get(n).toString();
|
||||
|
||||
@@ -177,6 +177,13 @@ public class CardList implements Iterable<Card> {
|
||||
});
|
||||
}
|
||||
|
||||
public CardList getTokens() {
|
||||
return this.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
return c.isToken();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public CardList filter(CardListFilter f) {
|
||||
CardList c = new CardList();
|
||||
|
||||
@@ -1,346 +1,360 @@
|
||||
package forge;
|
||||
import java.util.*;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
|
||||
public class CardListUtil
|
||||
{
|
||||
public static CardList filterToughness(CardList in, int atLeastToughness)
|
||||
{
|
||||
CardList out = new CardList();
|
||||
for(int i = 0; i < in.size(); i++)
|
||||
if(in.get(i).getNetDefense() <= atLeastToughness)
|
||||
out.add(in.get(i));
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
//the higher the defense the better
|
||||
|
||||
public static void sortDefense(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
return b.getNetDefense() - a.getNetDefense();
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}//sortDefense()
|
||||
|
||||
//the higher the attack the better
|
||||
public static void sortAttack(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
|
||||
if (CombatUtil.isDoranInPlay())
|
||||
return b.getNetDefense() - a.getNetDefense();
|
||||
else
|
||||
return b.getNetAttack() - a.getNetAttack();
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}//sortAttack()
|
||||
|
||||
|
||||
//the lower the attack the better
|
||||
public static void sortAttackLowFirst(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
if (CombatUtil.isDoranInPlay())
|
||||
return a.getNetDefense() - b.getNetDefense();
|
||||
else
|
||||
return a.getNetAttack() - b.getNetAttack();
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}//sortAttackLowFirst()
|
||||
|
||||
public static void sortNonFlyingFirst(CardList list)
|
||||
{
|
||||
sortFlying(list);
|
||||
list.reverse();
|
||||
}//sortNonFlyingFirst
|
||||
|
||||
//the creature with flying are better
|
||||
public static void sortFlying(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
if(a.getKeyword().contains("Flying") && b.getKeyword().contains("Flying"))
|
||||
return 0;
|
||||
else if(a.getKeyword().contains("Flying"))
|
||||
return -1;
|
||||
else if(b.getKeyword().contains("Flying"))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}//sortFlying()
|
||||
|
||||
//sort by keyword
|
||||
public static void sortByKeyword(CardList list, String kw)
|
||||
{
|
||||
final String keyword = kw;
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
if(a.getKeyword().contains(keyword) && b.getKeyword().contains(keyword))
|
||||
return 0;
|
||||
else if(a.getKeyword().contains(keyword))
|
||||
return -1;
|
||||
else if(b.getKeyword().contains(keyword))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}//sortByKeyword()
|
||||
|
||||
public static void sortByDestroyEffect(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
ArrayList<String> aKeywords = a.getKeyword();
|
||||
ArrayList<String> bKeywords = b.getKeyword();
|
||||
|
||||
boolean aContains = false;
|
||||
boolean bContains = false;
|
||||
|
||||
for (String kw : aKeywords)
|
||||
{
|
||||
if (kw.startsWith("Whenever") && kw.contains("into a graveyard from the battlefield,"))
|
||||
{
|
||||
aContains = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (String kw : bKeywords)
|
||||
{
|
||||
if (kw.startsWith("Whenever") && kw.contains("into a graveyard from the battlefield,"))
|
||||
{
|
||||
bContains = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( aContains && bContains)
|
||||
return 0;
|
||||
else if(aContains)
|
||||
return 1;
|
||||
else if(bContains)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}
|
||||
|
||||
public static void sortByIndestructible(CardList list)
|
||||
{
|
||||
final ArrayList<String> arrList = new ArrayList<String>();
|
||||
arrList.add("Timber Protector");
|
||||
arrList.add("Eldrazi Monument");
|
||||
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
if( arrList.contains(a.getName()) && arrList.contains(b.getName()))
|
||||
return 0;
|
||||
else if(arrList.contains(a.getName()))
|
||||
return 1;
|
||||
else if(arrList.contains(b.getName()))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}
|
||||
|
||||
public static void sortByTapped(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
|
||||
if( a.isTapped() && b.isTapped())
|
||||
return 0;
|
||||
else if(a.isTapped())
|
||||
return 1;
|
||||
else if(b.isTapped())
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}
|
||||
|
||||
public static void sortByName(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b) {
|
||||
String aName = a.getName();
|
||||
String bName = b.getName();
|
||||
|
||||
return aName.compareTo(bName);
|
||||
}
|
||||
|
||||
};
|
||||
list.sort(com);
|
||||
}
|
||||
|
||||
public static void sortBySelectable(CardList list, String type)
|
||||
{
|
||||
final String t = type;
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
if( a.getType().contains(t) && b.getType().contains(t))
|
||||
return 0;
|
||||
else if(a.getKeyword().contains(t))
|
||||
return 1;
|
||||
else if(b.getKeyword().contains(t))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}
|
||||
|
||||
public static void sortByTextLen(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
int aLen = a.getText().length();
|
||||
int bLen = b.getText().length();
|
||||
|
||||
if (aLen == bLen)
|
||||
return 0;
|
||||
else if (aLen > bLen)
|
||||
return 1;
|
||||
else if (bLen > aLen)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}
|
||||
|
||||
//Sorts from high to low
|
||||
public static void sortCMC(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
int cmcA = CardUtil.getConvertedManaCost(a.getManaCost());
|
||||
int cmcB = CardUtil.getConvertedManaCost(b.getManaCost());
|
||||
|
||||
if (cmcA == cmcB)
|
||||
return 0;
|
||||
if (cmcA > cmcB)
|
||||
return -1;
|
||||
if (cmcB > cmcA)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}//sortCMC
|
||||
|
||||
|
||||
public static CardList getColor(CardList list, final String color)
|
||||
{
|
||||
return list.filter(new CardListFilter()
|
||||
{
|
||||
public boolean addCard(Card c)
|
||||
{
|
||||
return CardUtil.getColors(c).contains(color);
|
||||
}
|
||||
});
|
||||
}//getColor()
|
||||
|
||||
public static CardList getGoldCards(CardList list)
|
||||
{
|
||||
return list.filter(new CardListFilter()
|
||||
{
|
||||
public boolean addCard(Card c)
|
||||
{
|
||||
return CardUtil.getColors(c).size() >= 2;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static int sumAttack(CardList c)
|
||||
{
|
||||
int attack = 0;
|
||||
|
||||
for(int i = 0; i < c.size(); i++){
|
||||
//if(c.get(i).isCreature() && c.get(i).hasSecondStrike()) {
|
||||
if(c.get(i).isCreature() && (!c.get(i).hasFirstStrike() || (c.get(i).hasDoubleStrike() && c.get(i).hasFirstStrike())) ) {
|
||||
if (!CombatUtil.isDoranInPlay())
|
||||
attack += c.get(i).getNetAttack();
|
||||
else if(CombatUtil.isDoranInPlay())
|
||||
attack += c.get(i).getNetDefense();
|
||||
}
|
||||
}
|
||||
//System.out.println("Total attack: " +attack);
|
||||
return attack;
|
||||
}//sumAttack()
|
||||
|
||||
public static int sumDefense(CardList c)
|
||||
{
|
||||
int defense = 0;
|
||||
|
||||
for(int i = 0; i < c.size(); i++){
|
||||
//if(c.get(i).isCreature() && c.get(i).hasSecondStrike()) {
|
||||
if(c.get(i).isCreature() )
|
||||
defense += c.get(i).getNetDefense();
|
||||
}
|
||||
//System.out.println("Total attack: " +attack);
|
||||
return defense;
|
||||
}//sumAttack()
|
||||
|
||||
public static int sumFirstStrikeAttack(CardList c)
|
||||
{
|
||||
int attack = 0;
|
||||
|
||||
for(int i = 0; i < c.size(); i++){
|
||||
if(c.get(i).isCreature() && (c.get(i).hasFirstStrike() || c.get(i).hasDoubleStrike())) {
|
||||
if (!CombatUtil.isDoranInPlay())
|
||||
attack += c.get(i).getNetAttack();
|
||||
else if(CombatUtil.isDoranInPlay())
|
||||
attack += c.get(i).getNetDefense();
|
||||
}
|
||||
}
|
||||
Log.debug("Total First Strike attack: " +attack);
|
||||
return attack;
|
||||
}//sumFirstStrikeAttack()
|
||||
package forge;
|
||||
import java.util.*;
|
||||
|
||||
import com.esotericsoftware.minlog.Log;
|
||||
|
||||
public class CardListUtil
|
||||
{
|
||||
public static CardList filterToughness(CardList in, int atLeastToughness)
|
||||
{
|
||||
CardList out = new CardList();
|
||||
for(int i = 0; i < in.size(); i++)
|
||||
if(in.get(i).getNetDefense() <= atLeastToughness)
|
||||
out.add(in.get(i));
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
//the higher the defense the better
|
||||
|
||||
public static void sortDefense(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
return b.getNetDefense() - a.getNetDefense();
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}//sortDefense()
|
||||
|
||||
//the higher the attack the better
|
||||
public static void sortAttack(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
|
||||
if (CombatUtil.isDoranInPlay())
|
||||
return b.getNetDefense() - a.getNetDefense();
|
||||
else
|
||||
return b.getNetAttack() - a.getNetAttack();
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}//sortAttack()
|
||||
|
||||
|
||||
//the lower the attack the better
|
||||
public static void sortAttackLowFirst(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
if (CombatUtil.isDoranInPlay())
|
||||
return a.getNetDefense() - b.getNetDefense();
|
||||
else
|
||||
return a.getNetAttack() - b.getNetAttack();
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}//sortAttackLowFirst()
|
||||
|
||||
public static void sortNonFlyingFirst(CardList list)
|
||||
{
|
||||
sortFlying(list);
|
||||
list.reverse();
|
||||
}//sortNonFlyingFirst
|
||||
|
||||
//the creature with flying are better
|
||||
public static void sortFlying(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
if(a.getKeyword().contains("Flying") && b.getKeyword().contains("Flying"))
|
||||
return 0;
|
||||
else if(a.getKeyword().contains("Flying"))
|
||||
return -1;
|
||||
else if(b.getKeyword().contains("Flying"))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}//sortFlying()
|
||||
|
||||
//sort by keyword
|
||||
public static void sortByKeyword(CardList list, String kw)
|
||||
{
|
||||
final String keyword = kw;
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
if(a.getKeyword().contains(keyword) && b.getKeyword().contains(keyword))
|
||||
return 0;
|
||||
else if(a.getKeyword().contains(keyword))
|
||||
return -1;
|
||||
else if(b.getKeyword().contains(keyword))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}//sortByKeyword()
|
||||
|
||||
public static void sortByDestroyEffect(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
ArrayList<String> aKeywords = a.getKeyword();
|
||||
ArrayList<String> bKeywords = b.getKeyword();
|
||||
|
||||
boolean aContains = false;
|
||||
boolean bContains = false;
|
||||
|
||||
for (String kw : aKeywords)
|
||||
{
|
||||
if (kw.startsWith("Whenever") && kw.contains("into a graveyard from the battlefield,"))
|
||||
{
|
||||
aContains = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (String kw : bKeywords)
|
||||
{
|
||||
if (kw.startsWith("Whenever") && kw.contains("into a graveyard from the battlefield,"))
|
||||
{
|
||||
bContains = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( aContains && bContains)
|
||||
return 0;
|
||||
else if(aContains)
|
||||
return 1;
|
||||
else if(bContains)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}
|
||||
|
||||
public static void sortByIndestructible(CardList list)
|
||||
{
|
||||
final ArrayList<String> arrList = new ArrayList<String>();
|
||||
arrList.add("Timber Protector");
|
||||
arrList.add("Eldrazi Monument");
|
||||
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
if( arrList.contains(a.getName()) && arrList.contains(b.getName()))
|
||||
return 0;
|
||||
else if(arrList.contains(a.getName()))
|
||||
return 1;
|
||||
else if(arrList.contains(b.getName()))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}
|
||||
|
||||
public static void sortByTapped(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
|
||||
if( a.isTapped() && b.isTapped())
|
||||
return 0;
|
||||
else if(a.isTapped())
|
||||
return 1;
|
||||
else if(b.isTapped())
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}
|
||||
|
||||
public static void sortByName(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b) {
|
||||
String aName = a.getName();
|
||||
String bName = b.getName();
|
||||
|
||||
return aName.compareTo(bName);
|
||||
}
|
||||
|
||||
};
|
||||
list.sort(com);
|
||||
}
|
||||
|
||||
public static void sortBySelectable(CardList list, String type)
|
||||
{
|
||||
final String t = type;
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
if( a.getType().contains(t) && b.getType().contains(t))
|
||||
return 0;
|
||||
else if(a.getKeyword().contains(t))
|
||||
return 1;
|
||||
else if(b.getKeyword().contains(t))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}
|
||||
|
||||
public static void sortByTextLen(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
int aLen = a.getText().length();
|
||||
int bLen = b.getText().length();
|
||||
|
||||
if (aLen == bLen)
|
||||
return 0;
|
||||
else if (aLen > bLen)
|
||||
return 1;
|
||||
else if (bLen > aLen)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}
|
||||
|
||||
//Sorts from high to low
|
||||
public static void sortCMC(CardList list)
|
||||
{
|
||||
Comparator<Card> com = new Comparator<Card>()
|
||||
{
|
||||
public int compare(Card a, Card b)
|
||||
{
|
||||
int cmcA = CardUtil.getConvertedManaCost(a.getManaCost());
|
||||
int cmcB = CardUtil.getConvertedManaCost(b.getManaCost());
|
||||
|
||||
if (cmcA == cmcB)
|
||||
return 0;
|
||||
if (cmcA > cmcB)
|
||||
return -1;
|
||||
if (cmcB > cmcA)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
list.sort(com);
|
||||
}//sortCMC
|
||||
|
||||
|
||||
public static CardList getColor(CardList list, final String color)
|
||||
{
|
||||
return list.filter(new CardListFilter()
|
||||
{
|
||||
public boolean addCard(Card c)
|
||||
{
|
||||
return CardUtil.getColors(c).contains(color);
|
||||
}
|
||||
});
|
||||
}//getColor()
|
||||
|
||||
public static CardList getGoldCards(CardList list)
|
||||
{
|
||||
return list.filter(new CardListFilter()
|
||||
{
|
||||
public boolean addCard(Card c)
|
||||
{
|
||||
return CardUtil.getColors(c).size() >= 2;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static int sumAttack(CardList c)
|
||||
{
|
||||
int attack = 0;
|
||||
|
||||
for(int i = 0; i < c.size(); i++){
|
||||
//if(c.get(i).isCreature() && c.get(i).hasSecondStrike()) {
|
||||
if(c.get(i).isCreature() && (!c.get(i).hasFirstStrike() || (c.get(i).hasDoubleStrike() && c.get(i).hasFirstStrike())) ) {
|
||||
if (!CombatUtil.isDoranInPlay())
|
||||
attack += c.get(i).getNetAttack();
|
||||
else if(CombatUtil.isDoranInPlay())
|
||||
attack += c.get(i).getNetDefense();
|
||||
}
|
||||
}
|
||||
//System.out.println("Total attack: " +attack);
|
||||
return attack;
|
||||
}//sumAttack()
|
||||
|
||||
public static int sumDefense(CardList c)
|
||||
{
|
||||
int defense = 0;
|
||||
|
||||
for(int i = 0; i < c.size(); i++){
|
||||
//if(c.get(i).isCreature() && c.get(i).hasSecondStrike()) {
|
||||
if(c.get(i).isCreature() )
|
||||
defense += c.get(i).getNetDefense();
|
||||
}
|
||||
//System.out.println("Total attack: " +attack);
|
||||
return defense;
|
||||
}//sumAttack()
|
||||
|
||||
public static int sumFirstStrikeAttack(CardList c)
|
||||
{
|
||||
int attack = 0;
|
||||
|
||||
for(int i = 0; i < c.size(); i++){
|
||||
if(c.get(i).isCreature() && (c.get(i).hasFirstStrike() || c.get(i).hasDoubleStrike())) {
|
||||
if (!CombatUtil.isDoranInPlay())
|
||||
attack += c.get(i).getNetAttack();
|
||||
else if(CombatUtil.isDoranInPlay())
|
||||
attack += c.get(i).getNetDefense();
|
||||
}
|
||||
}
|
||||
Log.debug("Total First Strike attack: " +attack);
|
||||
return attack;
|
||||
}//sumFirstStrikeAttack()
|
||||
|
||||
//Get the total converted mana cost of a card list
|
||||
public static int sumCMC(CardList c)
|
||||
{
|
||||
int cmc = 0;
|
||||
|
||||
for(int i = 0; i < c.size(); i++){
|
||||
cmc += CardUtil.getConvertedManaCost(c.get(i).getManaCost());
|
||||
}
|
||||
//System.out.println("Total CMC: " +cmc);
|
||||
|
||||
return cmc;
|
||||
|
||||
}//sumCMC
|
||||
}
|
||||
Reference in New Issue
Block a user