mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Code cleanup
This commit is contained in:
@@ -34,10 +34,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this type.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ComputerUtilMana {
|
public class ComputerUtilMana {
|
||||||
private final static boolean DEBUG_MANA_PAYMENT = false;
|
private final static boolean DEBUG_MANA_PAYMENT = false;
|
||||||
|
|
||||||
@@ -84,7 +81,6 @@ public class ComputerUtilMana {
|
|||||||
private int manaCount;
|
private int manaCount;
|
||||||
|
|
||||||
public ManaProducingCard(final SpellAbility ability) {
|
public ManaProducingCard(final SpellAbility ability) {
|
||||||
|
|
||||||
Card hostCard = ability.getHostCard();
|
Card hostCard = ability.getHostCard();
|
||||||
|
|
||||||
for (SpellAbility spellAbility : hostCard.getSpellAbilities()) {
|
for (SpellAbility spellAbility : hostCard.getSpellAbilities()) {
|
||||||
@@ -95,18 +91,19 @@ public class ComputerUtilMana {
|
|||||||
|
|
||||||
if (hostCard.isCreature()) {
|
if (hostCard.isCreature()) {
|
||||||
cardType = CoreType.Creature;
|
cardType = CoreType.Creature;
|
||||||
} else if (hostCard.isArtifact()) {
|
}
|
||||||
|
else if (hostCard.isArtifact()) {
|
||||||
cardType = CoreType.Artifact;
|
cardType = CoreType.Artifact;
|
||||||
} else if (hostCard.isEnchantment()) {
|
}
|
||||||
|
else if (hostCard.isEnchantment()) {
|
||||||
cardType = CoreType.Enchantment;
|
cardType = CoreType.Enchantment;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
cardType = CoreType.Land;
|
cardType = CoreType.Land;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAbility(final SpellAbility ability) {
|
private void addAbility(final SpellAbility ability) {
|
||||||
|
|
||||||
if (ability.getManaPart() == null) {
|
if (ability.getManaPart() == null) {
|
||||||
manaCount += 1; //Assume a mana ability can generate at least 1 mana if the amount of mana can't be determined now.
|
manaCount += 1; //Assume a mana ability can generate at least 1 mana if the amount of mana can't be determined now.
|
||||||
return;
|
return;
|
||||||
@@ -116,16 +113,14 @@ public class ComputerUtilMana {
|
|||||||
|
|
||||||
if (!mana.equals("Any")) {
|
if (!mana.equals("Any")) {
|
||||||
manaCount += mana.length();
|
manaCount += mana.length();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
manaCount += 6;
|
manaCount += 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sortManaAbilities(final ArrayListMultimap<ManaCostShard, SpellAbility> manaAbilityMap) {
|
private static void sortManaAbilities(final ArrayListMultimap<ManaCostShard, SpellAbility> manaAbilityMap) {
|
||||||
|
|
||||||
final Map<Card, ManaProducingCard> manaCardMap = new HashMap<>();
|
final Map<Card, ManaProducingCard> manaCardMap = new HashMap<>();
|
||||||
final List<Card> orderedCards = new ArrayList<>();
|
final List<Card> orderedCards = new ArrayList<>();
|
||||||
|
|
||||||
@@ -138,21 +133,16 @@ public class ComputerUtilMana {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(orderedCards, new Comparator<Card>() {
|
Collections.sort(orderedCards, new Comparator<Card>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(final Card card1, final Card card2) {
|
public int compare(final Card card1, final Card card2) {
|
||||||
|
|
||||||
int card1Score = scoreCard(manaCardMap.get(card1));
|
int card1Score = scoreCard(manaCardMap.get(card1));
|
||||||
int card2Score = scoreCard(manaCardMap.get(card2));
|
int card2Score = scoreCard(manaCardMap.get(card2));
|
||||||
|
|
||||||
return card1Score - card2Score;
|
return card1Score - card2Score;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int scoreCard(final ManaProducingCard card) {
|
private int scoreCard(final ManaProducingCard card) {
|
||||||
|
|
||||||
int score = 0;
|
int score = 0;
|
||||||
|
|
||||||
score += card.manaCount * 2;
|
score += card.manaCount * 2;
|
||||||
@@ -1201,7 +1191,8 @@ public class ComputerUtilMana {
|
|||||||
if (!res.contains(a)) {
|
if (!res.contains(a)) {
|
||||||
if (cost.isReusuableResource()) {
|
if (cost.isReusuableResource()) {
|
||||||
res.add(0, a);
|
res.add(0, a);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
res.add(res.size(), a);
|
res.add(res.size(), a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user