Merge branch 'ambush' into 'master'

J21: Skyshroud Ambush

See merge request core-developers/forge!5191
This commit is contained in:
Michael Kamensky
2021-08-08 02:10:22 +00:00
3 changed files with 36 additions and 3 deletions

View File

@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import forge.game.spellability.SpellAbilityStackInstance;
import org.apache.commons.lang3.tuple.ImmutablePair;
import com.google.common.base.Predicate;
@@ -1157,7 +1158,11 @@ public class GameAction {
// sol(10/29) added for Phase updates, state effects shouldn't be
// checked during Spell Resolution (except when persist-returning
if (game.getStack().isResolving()) {
return;
Iterator<SpellAbilityStackInstance> it = game.getStack().iterator();
SpellAbility top = it.next().getSpellAbility(true);
if (!top.hasParam("CheckStates") && !top.getSubAbility().hasParam("CheckStates")) {
return;
}
}
if (game.isGameOver()) {

View File

@@ -15,6 +15,7 @@ import forge.game.player.Player;
import forge.game.replacement.ReplacementType;
import forge.game.spellability.SpellAbility;
import forge.game.trigger.TriggerType;
import forge.game.zone.ZoneType;
import forge.util.CardTranslation;
import forge.util.Localizer;
@@ -77,6 +78,24 @@ public class FightEffect extends DamageBaseEffect {
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.Fighters, fighters);
game.getTriggerHandler().runTrigger(TriggerType.FightOnce, runParams, false);
if (sa.hasParam("ConditionWinnerDefined")) {
Card mustWin = AbilityUtils.getDefinedCards(host, sa.getParam("ConditionWinnerDefined"), sa).get(0);
Card mustLose = null;
for (Card l : fighters) {
if (l != mustWin) {
mustLose = l;
}
}
game.getAction().checkStateEffects(true);
SpellAbility sub = sa.getAdditionalAbility("WinSubAbility");
if (mustWin.getZone().getZoneType().equals(ZoneType.Battlefield) && mustLose != null &&
!mustLose.getZone().getZoneType().equals(ZoneType.Battlefield)) {
if (sub != null) {
AbilityUtils.resolve(sub);
}
}
}
}
private static List<Card> getFighters(SpellAbility sa) {

View File

@@ -0,0 +1,9 @@
Name:Skyshroud Ambush
ManaCost:1 G
Types:Instant
A:SP$ Pump | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Choose target creature you control | ImprintCards$ ThisTargetedCard | SubAbility$ DBFight | StackDescription$ Target creature you control [{c:ThisTargetedCard}] | SpellDescription$ Target creature you control fights target creature you don't control. When the creature you control wins the fight, draw a card.
SVar:DBFight:DB$ Fight | Defined$ ParentTarget | ValidTgts$ Creature.YouDontCtrl | TgtPrompt$ Choose target creature you don't control | RememberObjects$ ThisTargetedCard | ConditionWinnerDefined$ Imprinted | WinSubAbility$ DBImmediateTrigger | CheckStates$ True | SubAbility$ DBCleanup | StackDescription$ fights target creature you don't control [{c:ThisTargetedCard}]. When the creature you control wins the fight, draw a card.
SVar:DBImmediateTrigger:DB$ ImmediateTrigger | Execute$ TrigDraw | Secondary$ True | StackDescription$ None | TriggerDescription$ When the creature you control wins the fight, draw a card.
SVar:TrigDraw:DB$ Draw | NumCards$ 1
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True | ClearImprinted$ True
Oracle:Target creature you control fights target creature you don't control. When the creature you control wins the fight, draw a card.