mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
test mana-can-pay removes manasource abilities from lists instead of mantaining a list of used cards.
This commit is contained in:
@@ -3,6 +3,7 @@ package forge.game.ai;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@@ -105,11 +106,7 @@ public class ComputerUtilMana {
|
|||||||
MapOfLists<ManaCostShard, SpellAbility> sourcesForShards = ComputerUtilMana.groupAndOrderToPayShards(ai, manaAbilityMap, cost);
|
MapOfLists<ManaCostShard, SpellAbility> sourcesForShards = ComputerUtilMana.groupAndOrderToPayShards(ai, manaAbilityMap, cost);
|
||||||
|
|
||||||
// Loop over mana needed
|
// Loop over mana needed
|
||||||
List<Card> cardsUsed = new ArrayList<Card>();
|
|
||||||
|
|
||||||
//don't use a card to pay for itself - miscalculations!
|
|
||||||
cardsUsed.add(sa.getSourceCard());
|
|
||||||
|
|
||||||
ManaCostShard toPay = null;
|
ManaCostShard toPay = null;
|
||||||
while (!cost.isPaid()) {
|
while (!cost.isPaid()) {
|
||||||
toPay = getNextShardToPay(cost, sourcesForShards);
|
toPay = getNextShardToPay(cost, sourcesForShards);
|
||||||
@@ -118,7 +115,7 @@ public class ComputerUtilMana {
|
|||||||
SpellAbility saPayment = null;
|
SpellAbility saPayment = null;
|
||||||
if( saList != null ) {
|
if( saList != null ) {
|
||||||
for (final SpellAbility ma : saList) {
|
for (final SpellAbility ma : saList) {
|
||||||
if(cardsUsed.contains(ma.getSourceCard()) )
|
if(ma.getSourceCard() == sa.getSourceCard())
|
||||||
continue;
|
continue;
|
||||||
if( canPayShardWithSpellAbility(toPay, ai, ma, sa, checkPlayable || !test ) ) {
|
if( canPayShardWithSpellAbility(toPay, ai, ma, sa, checkPlayable || !test ) ) {
|
||||||
saPayment = ma;
|
saPayment = ma;
|
||||||
@@ -147,9 +144,13 @@ public class ComputerUtilMana {
|
|||||||
|
|
||||||
// remove from available lists
|
// remove from available lists
|
||||||
for(Collection<SpellAbility> kv : sourcesForShards.values()) {
|
for(Collection<SpellAbility> kv : sourcesForShards.values()) {
|
||||||
kv.remove(saPayment);
|
Iterator<SpellAbility> itSa = kv.iterator();
|
||||||
|
while(itSa.hasNext()) {
|
||||||
|
SpellAbility srcSa = itSa.next();
|
||||||
|
if( srcSa.getSourceCard().equals(saPayment.getSourceCard()) )
|
||||||
|
itSa.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cardsUsed.add(saPayment.getSourceCard());
|
|
||||||
} else {
|
} else {
|
||||||
if (saPayment.getPayCosts() != null) {
|
if (saPayment.getPayCosts() != null) {
|
||||||
final CostPayment pay = new CostPayment(saPayment.getPayCosts(), saPayment);
|
final CostPayment pay = new CostPayment(saPayment.getPayCosts(), saPayment);
|
||||||
|
|||||||
Reference in New Issue
Block a user