mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
No SpellAbilityRestriction in Subs (performance + fix AI mayplay Charms)
This commit is contained in:
@@ -90,6 +90,8 @@ public class CharmAi extends SpellAbilityAi {
|
||||
for (AbilitySub sub : choices) {
|
||||
sub.setActivatingPlayer(ai);
|
||||
sub.getRestrictions().setZone(sub.getParent().getRestrictions().getZone());
|
||||
|
||||
// TODO checks from MayPlay fail for subs currently
|
||||
if (AiPlayDecision.WillPlay == aic.canPlaySa(sub)) {
|
||||
chosenList.add(sub);
|
||||
if (chosenList.size() == num) {
|
||||
@@ -101,8 +103,6 @@ public class CharmAi extends SpellAbilityAi {
|
||||
// Second pass using doTrigger(false) to fulfill minimum choice
|
||||
choices.removeAll(chosenList);
|
||||
for (AbilitySub sub : choices) {
|
||||
sub.setActivatingPlayer(ai);
|
||||
sub.getRestrictions().setZone(sub.getParent().getRestrictions().getZone());
|
||||
if (aic.doTrigger(sub, false)) {
|
||||
chosenList.add(sub);
|
||||
if (chosenList.size() == min) {
|
||||
@@ -114,8 +114,6 @@ public class CharmAi extends SpellAbilityAi {
|
||||
if (chosenList.size() < min) {
|
||||
choices.removeAll(chosenList);
|
||||
for (AbilitySub sub : choices) {
|
||||
sub.setActivatingPlayer(ai);
|
||||
sub.getRestrictions().setZone(sub.getParent().getRestrictions().getZone());
|
||||
if (aic.doTrigger(sub, true)) {
|
||||
chosenList.add(sub);
|
||||
if (chosenList.size() == min) {
|
||||
|
||||
@@ -426,7 +426,9 @@ public final class AbilityFactory {
|
||||
private static final void makeRestrictions(final SpellAbility sa) {
|
||||
// SpellAbilityRestrictions should be added in here
|
||||
final SpellAbilityRestriction restrict = sa.getRestrictions();
|
||||
restrict.setRestrictions(sa.getMapParams());
|
||||
if (restrict != null) {
|
||||
restrict.setRestrictions(sa.getMapParams());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -438,7 +440,7 @@ public final class AbilityFactory {
|
||||
* a {@link forge.game.spellability.SpellAbility} object.
|
||||
*/
|
||||
private static final void makeConditions(final SpellAbility sa) {
|
||||
// SpellAbilityRestrictions should be added in here
|
||||
// SpellAbilityConditions should be added in here
|
||||
final SpellAbilityCondition condition = sa.getConditions();
|
||||
condition.setConditions(sa.getMapParams());
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
|
||||
/** The pay costs. */
|
||||
private Cost payCosts;
|
||||
private SpellAbilityRestriction restrictions = new SpellAbilityRestriction();
|
||||
private SpellAbilityRestriction restrictions;
|
||||
private SpellAbilityCondition conditions = new SpellAbilityCondition();
|
||||
private AbilitySub subAbility;
|
||||
|
||||
@@ -214,6 +214,9 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
view0 = new SpellAbilityView(this);
|
||||
}
|
||||
view = view0;
|
||||
if (!(this instanceof AbilitySub)) {
|
||||
restrictions = new SpellAbilityRestriction();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user