mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Added debug output to ComputerUtilMana
This commit is contained in:
@@ -9,11 +9,14 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
|
import forge.FThreads;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
@@ -43,6 +46,8 @@ import forge.util.maps.TreeMapOfLists;
|
|||||||
*/
|
*/
|
||||||
public class ComputerUtilMana {
|
public class ComputerUtilMana {
|
||||||
|
|
||||||
|
private final static boolean DEBUG_MANA_PAYMENT = false;
|
||||||
|
|
||||||
public static boolean canPayManaCost(final SpellAbility sa, final Player ai, final int extraMana) {
|
public static boolean canPayManaCost(final SpellAbility sa, final Player ai, final int extraMana) {
|
||||||
return payManaCost(sa, ai, true, extraMana, true);
|
return payManaCost(sa, ai, true, extraMana, true);
|
||||||
}
|
}
|
||||||
@@ -107,8 +112,19 @@ public class ComputerUtilMana {
|
|||||||
|
|
||||||
// Loop over mana needed
|
// Loop over mana needed
|
||||||
|
|
||||||
//List<String> paymentPlan = new ArrayList<String>();
|
if ( DEBUG_MANA_PAYMENT ) {
|
||||||
|
System.out.println((test ? "test -- " : "PROD -- ") + FThreads.debugGetStackTraceItem(5, true));
|
||||||
|
for(Entry<ManaCostShard, Collection<SpellAbility>> src : sourcesForShards.entrySet()) {
|
||||||
|
System.out.println("\t" +src.getKey() + " : " + src.getValue().size() + " source(s)");
|
||||||
|
for(SpellAbility sss : src.getValue()) {
|
||||||
|
System.out.printf("\t\t%s - %s%n", sss.getSourceCard(), sss);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> paymentPlan = new ArrayList<String>();
|
||||||
|
|
||||||
|
String originalCost = cost.toString(false);
|
||||||
ManaCostShard toPay = null;
|
ManaCostShard toPay = null;
|
||||||
while (!cost.isPaid()) {
|
while (!cost.isPaid()) {
|
||||||
toPay = getNextShardToPay(cost, sourcesForShards);
|
toPay = getNextShardToPay(cost, sourcesForShards);
|
||||||
@@ -126,7 +142,8 @@ public class ComputerUtilMana {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//paymentPlan.add(String.format("%s : (%s) %s", toPay, saPayment == null ? "LIFE" : saPayment.getSourceCard(), saPayment));
|
if( DEBUG_MANA_PAYMENT )
|
||||||
|
paymentPlan.add(String.format("%s : (%s) %s", toPay, saPayment == null ? "LIFE" : saPayment.getSourceCard(), saPayment));
|
||||||
|
|
||||||
if( saPayment == null ) {
|
if( saPayment == null ) {
|
||||||
if(!toPay.isPhyrexian() || !ai.canPayLife(2))
|
if(!toPay.isPhyrexian() || !ai.canPayLife(2))
|
||||||
@@ -177,7 +194,9 @@ public class ComputerUtilMana {
|
|||||||
|
|
||||||
manapool.clearManaPaid(sa, test);
|
manapool.clearManaPaid(sa, test);
|
||||||
|
|
||||||
//System.err.printf("[%s] payment %s for (%s)+%d %s:%n\t%s%n%n", test ? "test" : "PROD", cost.isPaid() ? "*PAID*" : "failed", sa.getSourceCard(), extraMana, sa.toUnsuppressedString(), StringUtils.join(paymentPlan, "\n\t") );
|
if( DEBUG_MANA_PAYMENT )
|
||||||
|
System.err.printf("%s > [%s] payment has %s (%s +%d) for (%s) %s:%n\t%s%n%n", FThreads.debugGetCurrThreadId(), test ? "test" : "PROD", cost.isPaid() ? "*PAID*" : "failed", originalCost, extraMana, sa.getSourceCard(), sa.toUnsuppressedString(), StringUtils.join(paymentPlan, "\n\t") );
|
||||||
|
|
||||||
if(!cost.isPaid()) {
|
if(!cost.isPaid()) {
|
||||||
if( test )
|
if( test )
|
||||||
return false;
|
return false;
|
||||||
@@ -398,7 +417,7 @@ public class ComputerUtilMana {
|
|||||||
* @return Were all mana sources found?
|
* @return Were all mana sources found?
|
||||||
*/
|
*/
|
||||||
private static MapOfLists<ManaCostShard, SpellAbility> groupAndOrderToPayShards(final Player ai, final MapOfLists<Integer, SpellAbility> manaAbilityMap, final ManaCostBeingPaid cost) {
|
private static MapOfLists<ManaCostShard, SpellAbility> groupAndOrderToPayShards(final Player ai, final MapOfLists<Integer, SpellAbility> manaAbilityMap, final ManaCostBeingPaid cost) {
|
||||||
MapOfLists<ManaCostShard, SpellAbility> res = new EnumMapOfLists<ManaCostShard, SpellAbility>(ManaCostShard.class, CollectionSuppliers.<SpellAbility>arrayLists());
|
MapOfLists<ManaCostShard, SpellAbility> res = new EnumMapOfLists<ManaCostShard, SpellAbility>(ManaCostShard.class, CollectionSuppliers.<SpellAbility>hashSets());
|
||||||
|
|
||||||
// loop over cost parts
|
// loop over cost parts
|
||||||
for (ManaCostShard shard : cost.getDistinctShards() ) {
|
for (ManaCostShard shard : cost.getDistinctShards() ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user