*Corrected mana ability flagging.

*Fixed crash when using Metalworker-likes during mana payment.
This commit is contained in:
Hellfish
2013-01-05 17:11:54 +00:00
parent 49d602d4f0
commit bb70d9c026
3 changed files with 44 additions and 10 deletions

View File

@@ -512,8 +512,16 @@ public class ManaPool {
final List<SpellAbility> paidAbs = sa.getPayingManaAbilities();
final List<Mana> manaPaid = sa.getPayingMana();
SpellAbility tail = ma;
AbilityManaPart abManaPart = null;
while(abManaPart == null && tail != null)
{
abManaPart = tail.getManaPart();
tail = tail.getSubAbility();
}
paidAbs.add(ma); // assumes some part on the mana produced by the ability will get used
for (final Mana mana : ma.getManaPart().getLastProduced()) {
for (final Mana mana : abManaPart.getLastProduced()) {
if (manaCost.isNeeded(mana)) {
manaCost.payMana(mana);
manaPaid.add(mana);

View File

@@ -125,16 +125,28 @@ public abstract class SpellAbility implements ISpellAbility {
}
public final boolean isManaAbility() {
if(manaPart != null && isAbility())
SpellAbility tail = this;
boolean manaProducing = false;
if(getRestrictions() != null)
{
return true;
if(getRestrictions().getPlaneswalker())
{
return false; //Loyalty ability, not a mana ability.
}
if(this.getSubAbility() != null)
}
while(tail != null) {
if(tail.getTarget() != null) {
return false; //Targeted ability,not a mana ability.
}
if(tail.getManaPart() != null)
{
return this.getSubAbility().isManaAbility();
manaProducing = true; //Can add mana to a players mana pool, possible mana ability.
}
return false;
tail = tail.getSubAbility();
}
return manaProducing;
}
public final void setManaPart(AbilityManaPart manaPart) {

View File

@@ -82,8 +82,16 @@ public class InputPayManaCostUtil {
for (SpellAbility ma : card.getManaAbility()) {
ma.setActivatingPlayer(Singletons.getControl().getPlayer());
AbilityManaPart m = ma.getManaPart();
if (!ma.canPlay()) {
AbilityManaPart m = null;
SpellAbility tail = ma;
while(m == null && tail != null)
{
m = tail.getManaPart();
tail = tail.getSubAbility();
}
if(m == null) {
continue;
} else if (!ma.canPlay()) {
continue;
} else if (!InputPayManaCostUtil.canMake(ma, cneeded.toString())) {
continue;
@@ -192,8 +200,14 @@ public class InputPayManaCostUtil {
chosen = GuiChoose.one("Choose mana ability", abilities);
}
SpellAbility subchosen = chosen;
while(subchosen.getManaPart() == null)
{
subchosen = subchosen.getSubAbility();
}
// save off color needed for use by any mana and reflected mana
chosen.getManaPart().setExpressChoice(colorsNeeded);
subchosen.getManaPart().setExpressChoice(colorsNeeded);
Singletons.getModel().getGame().getAction().playSpellAbility(chosen);