for automatic mana selection, if number of sources equal to min cost, further check that each source only has one mana activation

master
melvin 2013-01-11 09:35:23 +08:00
parent de0aa1d565
commit 5baeb0bf68
1 changed files with 9 additions and 8 deletions

View File

@ -136,15 +136,16 @@ public class MagicPayManaCostChoice extends MagicChoice {
if (validSources.size() == 1) {
// only one valid choice
sourcePermanent = validSources.iterator().next();
}
if (builder.getActivationsSize() == costMinAmount) {
// more than one valid choice but number of activations = cost
// find permanent with only one mana activation
} else if (builder.getActivationsSize() == costMinAmount) {
// number of sources = costMinAmount
// check that total mana activations = costMinAmount
// which means each permanent has one activation
int totalManaActivations = 0;
for (final MagicPermanent perm : validSources) {
if (perm.countManaActivations() == 1) {
sourcePermanent = perm;
break;
}
totalManaActivations += perm.countManaActivations();
}
if (totalManaActivations == costMinAmount) {
sourcePermanent = validSources.iterator().next();
}
}