Skip to content

Commit

Permalink
v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Northmoc committed Mar 23, 2024
1 parent 0884fb4 commit 2993199
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 22 deletions.
4 changes: 2 additions & 2 deletions forge-ai/src/main/java/forge/ai/PlayerControllerAi.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public <T extends GameEntity> List<T> chooseEntitiesForEffect(

@Override
public List<SpellAbility> chooseSpellAbilitiesForEffect(List<SpellAbility> spells, SpellAbility sa, String title,
int min, int max, Map<String, Object> params) {
int num, Map<String, Object> params) {
List<SpellAbility> remaining = Lists.newArrayList(spells);
List<SpellAbility> selecteds = Lists.newArrayList();
SpellAbility selected;
Expand All @@ -227,7 +227,7 @@ public List<SpellAbility> chooseSpellAbilitiesForEffect(List<SpellAbility> spell
remaining.remove(selected);
selecteds.add(selected);
}
} while (selected != null && selecteds.size() < max);
} while (selected != null && selecteds.size() < num);
return selecteds;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.apache.commons.lang3.tuple.Pair;

import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;

import forge.game.GameEntity;
Expand Down Expand Up @@ -39,18 +38,7 @@ public void resolve(SpellAbility sa) {
final Player chooser = sa.hasParam("Chooser") ? getDefinedPlayersOrTargeted(sa, "Chooser").get(0) : activator;

final MagicStack stack = activator.getGame().getStack();
if (sa.hasParam("Any")) {
List<SpellAbility> stackAbs = new ArrayList<>();
for (SpellAbilityStackInstance stackinst : stack) {
final SpellAbility stSA = stackinst.getSpellAbility();
if (stSA.usesTargeting()) { // no need to change targets if it doesn't target
stackAbs.add(stSA);
}
}
sas.addAll(chooser.getController().chooseSpellAbilitiesForEffect(stackAbs, sa, "Choose some now",
0, stackAbs.size(), ImmutableMap.of()));
}


for (final SpellAbility tgtSA : sas) {
SpellAbilityStackInstance si = stack.getInstanceMatchingSpellAbilityID(tgtSA);
if (si == null) {
Expand Down Expand Up @@ -114,7 +102,7 @@ public void resolve(SpellAbility sa) {
candidates.removeIf(new java.util.function.Predicate<GameEntity>() {
@Override
public boolean test(GameEntity c) {
return !c.isValid(sa.getParam("RandomTargetRestriction").split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa);
return !c.isValid(sa.getParam("RandomTargetRestriction").split(","), activator, sa.getHostCard(), sa);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ public void endTempShowCards() { }
public final <T extends GameEntity> T chooseSingleEntityForEffect(FCollectionView<T> optionList, SpellAbility sa, String title, boolean isOptional, Map<String, Object> params) { return chooseSingleEntityForEffect(optionList, null, sa, title, isOptional, null, params); }
public abstract <T extends GameEntity> T chooseSingleEntityForEffect(FCollectionView<T> optionList, DelayedReveal delayedReveal, SpellAbility sa, String title, boolean isOptional, Player relatedPlayer, Map<String, Object> params);

public final List<SpellAbility> chooseSpellAbilitiesForEffect(List<SpellAbility> spells, SpellAbility sa, String title, int num, Map<String, Object> params) { return chooseSpellAbilitiesForEffect(spells, sa, title, num, num, params); }
public abstract List<SpellAbility> chooseSpellAbilitiesForEffect(List<SpellAbility> spells, SpellAbility sa, String title, int min, int max, Map<String, Object> params);
public abstract List<SpellAbility> chooseSpellAbilitiesForEffect(List<SpellAbility> spells, SpellAbility sa, String title, int num, Map<String, Object> params);

public abstract SpellAbility chooseSingleSpellForEffect(List<SpellAbility> spells, SpellAbility sa, String title, Map<String, Object> params);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ public CardCollection chooseCardsForEffectMultiple(Map<String, CardCollection> v

@Override
public List<SpellAbility> chooseSpellAbilitiesForEffect(List<SpellAbility> spells, SpellAbility sa, String title,
int min, int max, Map<String, Object> params) {
int num, Map<String, Object> params) {
// TODO Auto-generated method stub
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion forge-gui/res/cardsfolder/b/boltbender.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Types:Creature Goblin Wizard
PT:4/2
K:Disguise:1 R
T:Mode$ TurnFaceUp | ValidCard$ Card.Self | Execute$ TrigChangeTgts | TriggerZones$ Battlefield | OptionalDecider$ You | TriggerDescription$ When CARDNAME is turned face up, you may choose new targets for any number of other spells and/or abilities.
SVar:TrigChangeTgts:DB$ ChangeTargets | Any$ True
SVar:TrigChangeTgts:DB$ ChangeTargets | Defined$ ValidStack SpellAbility | Optional$ True
AI:RemoveDeck:All
Oracle:Disguise {1}{R} (You may cast this card face down for {3} as a 2/2 creature with ward {2}. Turn it face up any time for its disguise cost.)\nWhen Boltbender is turned face up, you may choose new targets for any number of other spells and/or abilities.
Original file line number Diff line number Diff line change
Expand Up @@ -747,13 +747,13 @@ public SpellAbility chooseSingleSpellForEffect(final List<SpellAbility> spells,
}

@Override
public List<SpellAbility> chooseSpellAbilitiesForEffect(List<SpellAbility> spells, SpellAbility sa, String title, int min, int max, Map<String, Object> params) {
public List<SpellAbility> chooseSpellAbilitiesForEffect(List<SpellAbility> spells, SpellAbility sa, String title, int num, Map<String, Object> params) {
List<SpellAbility> result = Lists.newArrayList();
// create a mapping between a spell's view and the spell itself
Map<SpellAbilityView, SpellAbility> spellViewCache = SpellAbilityView.getMap(spells);

//override generic
List<SpellAbilityView> chosen = getGui().getChoices(title, min, max, Lists.newArrayList(spellViewCache.keySet()));
List<SpellAbilityView> chosen = getGui().getChoices(title, num, num, Lists.newArrayList(spellViewCache.keySet()));

for (SpellAbilityView view : chosen) {
if (spellViewCache.containsKey(view)) {
Expand Down

0 comments on commit 2993199

Please sign in to comment.