mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Fix bug with convoke where colored mana could end up being used as colorless.
Before this patch, the code would try to pay the mana symbols as they appear - for example if you convoke with a white creature and click "white" in the dialog, but the cost for the spell is "1WW", it would actually use that white mana to pay for the "1" portion of the cost, leaving "WW" to be paid (which is problematic if you have a swamp and a plains untapped which you were planning to use in addition to the white creature). This change moves the logic for paying the cost from the UI code to the engine code (and re-uses existing code there) and also adds some unit tests for it.
This commit is contained in:
@@ -52,18 +52,12 @@ public final class InputSelectCardsForConvoke extends InputSelectManyBase<Card>
|
||||
}
|
||||
else {
|
||||
byte chosenColor = player.getController().chooseColorAllowColorless("Convoke " + card.toString() + " for which color?", card, CardUtil.getColors(card));
|
||||
|
||||
if (remainingCost.getColorlessManaAmount() > 0 && (chosenColor == 0 || !remainingCost.needsColor(chosenColor, player.getManaPool()))) {
|
||||
registerConvoked(card, ManaCostShard.COLORLESS, chosenColor);
|
||||
ManaCostShard shard = remainingCost.payManaViaConvoke(chosenColor);
|
||||
if (shard != null) {
|
||||
chosenCards.put(card, ImmutablePair.of(chosenColor, shard));
|
||||
onSelectStateChanged(card, true);
|
||||
}
|
||||
else {
|
||||
for (ManaCostShard shard : remainingCost.getDistinctShards()) {
|
||||
if (shard.canBePaidWithManaOfColor(chosenColor)) {
|
||||
registerConvoked(card, shard, chosenColor);
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
showMessage("The colors provided by " + card.toString() + " you've chosen cannot be used to decrease the manacost of " + remainingCost.toString());
|
||||
return false;
|
||||
}
|
||||
@@ -73,13 +67,6 @@ public final class InputSelectCardsForConvoke extends InputSelectManyBase<Card>
|
||||
return true;
|
||||
}
|
||||
|
||||
private void registerConvoked(Card card, ManaCostShard shard, byte chosenColor) {
|
||||
remainingCost.decreaseShard(shard, 1);
|
||||
chosenCards.put(card, ImmutablePair.of(chosenColor, shard));
|
||||
onSelectStateChanged(card, true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected final void onPlayerSelected(Player player, final ITriggerEvent triggerEvent) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user