in payCostDuringAbilityResolve used CostPartWithList overloads to execute the action needed to pay.

addListToHash - removed second parameter, since it can be obtained from the same instance.
This commit is contained in:
Maxmtg
2013-03-27 19:38:24 +00:00
parent c9ea57b938
commit ddb952ea30
5 changed files with 15 additions and 9 deletions

View File

@@ -80,7 +80,8 @@ public abstract class CostPartWithList extends CostPart {
* @param hash
* the hash
*/
public final void addListToHash(final SpellAbility sa, final String hash) {
public final void addListToHash(final SpellAbility sa) {
final String hash = getHashForList();
for (final Card card : this.getList()) {
Card copy = CardUtil.getLKICopy(card);
sa.addCostToHashList(copy, hash);

View File

@@ -215,7 +215,7 @@ public class CostPayment {
return;
}
if( part instanceof CostPartWithList )
((CostPartWithList) part).addListToHash(ability, ((CostPartWithList) part).getHashForList());
((CostPartWithList) part).addListToHash(ability);
setPaidPart(part);
}
this.resetUndoList();

View File

@@ -192,7 +192,7 @@ public class CostSacrifice extends CostPartWithList {
*/
@Override
public final void payAI(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment, final GameState game) {
this.addListToHash(ability, "Sacrificed");
this.addListToHash(ability);
for (final Card c : this.getList()) {
executePayment(ability, c);
}

View File

@@ -103,7 +103,7 @@ public class CostUnattach extends CostPartWithList {
Card equippingCard = cardToUnattach.getEquipping().get(0);
cardToUnattach.unEquipCard(equippingCard);
this.addToList(cardToUnattach);
this.addListToHash(ability, "Unattached");
this.addListToHash(ability);
}
/*

View File

@@ -45,6 +45,7 @@ import forge.card.cost.CostDiscard;
import forge.card.cost.CostExile;
import forge.card.cost.CostPart;
import forge.card.cost.CostPartMana;
import forge.card.cost.CostPartWithList;
import forge.card.cost.CostPayLife;
import forge.card.cost.CostPutCounter;
import forge.card.cost.CostRemoveCounter;
@@ -526,9 +527,11 @@ public final class GameActionUtil {
hasPaid = false;
break;
}
CostPartWithList cpl = (CostPartWithList)part;
for(Card c : toSac) {
p.getGame().getAction().sacrifice(c, ability);
cpl.executePayment(ability, c);
}
cpl.addListToHash(ability);
}
else if (part instanceof CostReturn) {
@@ -544,10 +547,11 @@ public final class GameActionUtil {
hasPaid = false;
break;
}
((CostReturn)part).addListToHash(ability, "Returned");
CostPartWithList cpl = (CostPartWithList)part;
for(Card c : inp.getSelected()) {
p.getGame().getAction().moveTo(ZoneType.Hand, c);
cpl.executePayment(ability, c);
}
cpl.addListToHash(ability);
}
else if (part instanceof CostDiscard) {
@@ -563,10 +567,11 @@ public final class GameActionUtil {
hasPaid = false;
break;
}
((CostDiscard)part).addListToHash(ability, "Discarded");
CostPartWithList cpl = (CostPartWithList)part;
for(Card c : inp.getSelected()) {
p.discard(c, ability);
cpl.executePayment(ability, c);
}
cpl.addListToHash(ability);
}
else if (part instanceof CostPartMana ) {