mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
a couple fixes for AF_Charm:
1. Charms weren't chosen from Triggers. Now they are. 2. Defined in a Charm caused a crash because ActivatingPlayer wasn't set for newly linked Ability_Subs. This is fixed.
This commit is contained in:
@@ -4,6 +4,7 @@ package forge;
|
|||||||
import forge.Constant.Zone;
|
import forge.Constant.Zone;
|
||||||
import forge.card.abilityFactory.AbilityFactory;
|
import forge.card.abilityFactory.AbilityFactory;
|
||||||
import forge.card.abilityFactory.AbilityFactory_Attach;
|
import forge.card.abilityFactory.AbilityFactory_Attach;
|
||||||
|
import forge.card.abilityFactory.AbilityFactory_Charm;
|
||||||
import forge.card.cardFactory.CardFactoryInterface;
|
import forge.card.cardFactory.CardFactoryInterface;
|
||||||
import forge.card.cardFactory.CardFactoryUtil;
|
import forge.card.cardFactory.CardFactoryUtil;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
@@ -12,7 +13,6 @@ import forge.card.mana.ManaCost;
|
|||||||
import forge.card.mana.ManaPool;
|
import forge.card.mana.ManaPool;
|
||||||
import forge.card.spellability.Ability;
|
import forge.card.spellability.Ability;
|
||||||
import forge.card.spellability.Ability_Static;
|
import forge.card.spellability.Ability_Static;
|
||||||
import forge.card.spellability.Ability_Sub;
|
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.card.spellability.SpellAbility_Requirements;
|
import forge.card.spellability.SpellAbility_Requirements;
|
||||||
import forge.card.spellability.Target;
|
import forge.card.spellability.Target;
|
||||||
@@ -2114,29 +2114,7 @@ public class GameAction {
|
|||||||
public final void playSpellAbility(final SpellAbility sa) {
|
public final void playSpellAbility(final SpellAbility sa) {
|
||||||
sa.setActivatingPlayer(AllZone.getHumanPlayer());
|
sa.setActivatingPlayer(AllZone.getHumanPlayer());
|
||||||
|
|
||||||
//make Charm choices
|
AbilityFactory_Charm.setupCharmSAs(sa);
|
||||||
if (sa.isCharm()) {
|
|
||||||
ArrayList<SpellAbility> choices = new ArrayList<SpellAbility>();
|
|
||||||
choices.addAll(sa.getCharmChoices());
|
|
||||||
for (int i = 0; i < choices.size(); i++) {
|
|
||||||
if (!sa.canPlay()) {
|
|
||||||
choices.remove(sa);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < sa.getCharmNumber(); i++) {
|
|
||||||
Object o = GuiUtils.getChoice("Choose a spell", choices.toArray());
|
|
||||||
Ability_Sub chosen = (Ability_Sub) o;
|
|
||||||
sa.addCharmChoice(chosen);
|
|
||||||
choices.remove(chosen);
|
|
||||||
|
|
||||||
//walk down the SpellAbility tree and add to the child Ability_Sub
|
|
||||||
SpellAbility child = sa;
|
|
||||||
while (child.getSubAbility() != null) {
|
|
||||||
child = child.getSubAbility();
|
|
||||||
}
|
|
||||||
child.setSubAbility(chosen);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Need to check PayCosts, and Ability + All SubAbilities for Target
|
// Need to check PayCosts, and Ability + All SubAbilities for Target
|
||||||
boolean newAbility = sa.getPayCosts() != null;
|
boolean newAbility = sa.getPayCosts() != null;
|
||||||
@@ -2206,6 +2184,8 @@ public class GameAction {
|
|||||||
public void playSpellAbility_NoStack(final SpellAbility sa, final boolean skipTargeting) {
|
public void playSpellAbility_NoStack(final SpellAbility sa, final boolean skipTargeting) {
|
||||||
sa.setActivatingPlayer(AllZone.getHumanPlayer());
|
sa.setActivatingPlayer(AllZone.getHumanPlayer());
|
||||||
|
|
||||||
|
AbilityFactory_Charm.setupCharmSAs(sa);
|
||||||
|
|
||||||
if (sa.getPayCosts() != null) {
|
if (sa.getPayCosts() != null) {
|
||||||
Target_Selection ts = new Target_Selection(sa.getTarget(), sa);
|
Target_Selection ts = new Target_Selection(sa.getTarget(), sa);
|
||||||
Cost_Payment payment = new Cost_Payment(sa.getPayCosts(), sa);
|
Cost_Payment payment = new Cost_Payment(sa.getPayCosts(), sa);
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package forge.card.abilityFactory;
|
package forge.card.abilityFactory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import forge.card.spellability.Ability_Activated;
|
import forge.card.spellability.Ability_Activated;
|
||||||
import forge.card.spellability.Ability_Sub;
|
import forge.card.spellability.Ability_Sub;
|
||||||
import forge.card.spellability.Spell;
|
import forge.card.spellability.Spell;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
|
import forge.gui.GuiUtils;
|
||||||
|
|
||||||
// Charm specific params:
|
// Charm specific params:
|
||||||
// Choices - a ","-delimited list of SVars containing ability choices
|
// Choices - a ","-delimited list of SVars containing ability choices
|
||||||
@@ -114,4 +117,34 @@ public final class AbilityFactory_Charm {
|
|||||||
//and that Ability_Sub.resolve() is called from AbilityFactory
|
//and that Ability_Sub.resolve() is called from AbilityFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setupCharmSAs(final SpellAbility sa) {
|
||||||
|
//make Charm choices
|
||||||
|
if (sa.isCharm()) {
|
||||||
|
ArrayList<SpellAbility> choices = new ArrayList<SpellAbility>();
|
||||||
|
choices.addAll(sa.getCharmChoices());
|
||||||
|
for (int i = 0; i < choices.size(); i++) {
|
||||||
|
if (!sa.canPlay()) {
|
||||||
|
choices.remove(sa);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < sa.getCharmNumber(); i++) {
|
||||||
|
Object o = GuiUtils.getChoice("Choose a spell", choices.toArray());
|
||||||
|
Ability_Sub chosen = (Ability_Sub) o;
|
||||||
|
sa.addCharmChoice(chosen);
|
||||||
|
choices.remove(chosen);
|
||||||
|
|
||||||
|
//walk down the SpellAbility tree and add to the child Ability_Sub
|
||||||
|
SpellAbility child = sa;
|
||||||
|
while (child.getSubAbility() != null) {
|
||||||
|
child = child.getSubAbility();
|
||||||
|
}
|
||||||
|
child.setSubAbility(chosen);
|
||||||
|
if (chosen.getActivatingPlayer() == null) {
|
||||||
|
chosen.setActivatingPlayer(child.getActivatingPlayer());
|
||||||
|
}
|
||||||
|
chosen.setParent(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} //end class AbilityFactory_Charm
|
} //end class AbilityFactory_Charm
|
||||||
|
|||||||
Reference in New Issue
Block a user