*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

@@ -511,9 +511,17 @@ public class ManaPool {
final List<SpellAbility> paidAbs = sa.getPayingManaAbilities(); final List<SpellAbility> paidAbs = sa.getPayingManaAbilities();
final List<Mana> manaPaid = sa.getPayingMana(); 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 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)) { if (manaCost.isNeeded(mana)) {
manaCost.payMana(mana); manaCost.payMana(mana);
manaPaid.add(mana); manaPaid.add(mana);

View File

@@ -125,16 +125,28 @@ public abstract class SpellAbility implements ISpellAbility {
} }
public final boolean isManaAbility() { 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 this.getSubAbility().isManaAbility(); return false; //Targeted ability,not a mana ability.
}
if(tail.getManaPart() != null)
{
manaProducing = true; //Can add mana to a players mana pool, possible mana ability.
}
tail = tail.getSubAbility();
} }
return false; return manaProducing;
} }
public final void setManaPart(AbilityManaPart manaPart) { public final void setManaPart(AbilityManaPart manaPart) {

View File

@@ -82,8 +82,16 @@ public class InputPayManaCostUtil {
for (SpellAbility ma : card.getManaAbility()) { for (SpellAbility ma : card.getManaAbility()) {
ma.setActivatingPlayer(Singletons.getControl().getPlayer()); ma.setActivatingPlayer(Singletons.getControl().getPlayer());
AbilityManaPart m = ma.getManaPart(); AbilityManaPart m = null;
if (!ma.canPlay()) { SpellAbility tail = ma;
while(m == null && tail != null)
{
m = tail.getManaPart();
tail = tail.getSubAbility();
}
if(m == null) {
continue;
} else if (!ma.canPlay()) {
continue; continue;
} else if (!InputPayManaCostUtil.canMake(ma, cneeded.toString())) { } else if (!InputPayManaCostUtil.canMake(ma, cneeded.toString())) {
continue; continue;
@@ -191,9 +199,15 @@ public class InputPayManaCostUtil {
} }
chosen = GuiChoose.one("Choose mana ability", abilities); 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 // 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); Singletons.getModel().getGame().getAction().playSpellAbility(chosen);