Merge branch 'fights-once' into 'master'

Add Neyith of the Dire Hunt (with the triggers support)

See merge request core-developers/forge!3030
This commit is contained in:
Michael Kamensky
2020-07-23 19:50:46 +00:00
6 changed files with 110 additions and 0 deletions

View File

@@ -62,6 +62,7 @@ public enum AbilityKey {
Explorer("Explorer"),
Event("Event"),
Fighter("Fighter"),
Fighters("Fighters"),
FirstTime("FirstTime"),
Fizzle("Fizzle"),
IsCombat("IsCombat"), // TODO confirm that this and IsCombatDamage can be merged

View File

@@ -63,6 +63,10 @@ public class FightEffect extends DamageBaseEffect {
runParams.put(AbilityKey.Fighter, c);
game.getTriggerHandler().runTrigger(TriggerType.Fight, runParams, false);
}
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.Fighters, fighters);
game.getTriggerHandler().runTrigger(TriggerType.FightOnce, runParams, false);
}
private static List<Card> getFighters(SpellAbility sa) {

View File

@@ -22,6 +22,7 @@ import forge.game.card.Card;
import forge.game.spellability.SpellAbility;
import forge.util.Localizer;
import java.util.List;
import java.util.Map;
/**
@@ -48,6 +49,18 @@ public class TriggerBlockersDeclared extends Trigger {
* @param runParams*/
@Override
public final boolean performTest(final Map<AbilityKey, Object> runParams) {
if (hasParam("ValidBlockedAttacker")) {
List<Card> attackers = (List<Card>)runParams.get(AbilityKey.Attackers);
for (Card attacker : attackers) {
if (attacker.isValid(getParam("ValidBlockedAttacker").split(","),
getHostCard().getController(), getHostCard(), null)
&& !attacker.getGame().getCombat().getBlockers(attacker).isEmpty()) {
return true;
}
}
return false;
}
return true;
}

View File

@@ -0,0 +1,80 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.game.trigger;
import forge.game.ability.AbilityKey;
import forge.game.card.Card;
import forge.game.spellability.SpellAbility;
import forge.util.Localizer;
import java.util.List;
import java.util.Map;
public class TriggerFightOnce extends Trigger {
/**
* <p>
* Constructor for Trigger_Fight.
* </p>
*
* @param params
* a {@link java.util.HashMap} object.
* @param host
* a {@link forge.game.card.Card} object.
* @param intrinsic
* the intrinsic
*/
public TriggerFightOnce(final Map<String, String> params, final Card host, final boolean intrinsic) {
super(params, host, intrinsic);
}
/** {@inheritDoc}
* @param runParams*/
@Override
public final boolean performTest(final Map<AbilityKey, Object> runParams) {
final List<Card> fighters = (List<Card>) runParams.get(AbilityKey.Fighters);
if (hasParam("ValidCard")) {
for (Card fighter : fighters) {
if (fighter.isValid(getParam("ValidCard").split(","),
getHostCard().getController(), getHostCard(), null)) {
return true;
}
}
return false;
}
return true;
}
/** {@inheritDoc} */
@Override
public final void setTriggeringObjects(final SpellAbility sa, Map<AbilityKey, Object> runParams) {
sa.setTriggeringObjectsFrom(runParams, AbilityKey.Fighters);
}
@Override
public String getImportantStackObjects(SpellAbility sa) {
StringBuilder sb = new StringBuilder();
List<Card> fighters = (List<Card>)sa.getTriggeringObject(AbilityKey.Fighters);
sb.append(Localizer.getInstance().getMessage("lblFighter")).append(" 1: ").append(fighters.get(0)).append(", ");
sb.append(Localizer.getInstance().getMessage("lblFighter")).append(" 2: ").append(fighters.get(1));
return sb.toString();
}
}

View File

@@ -60,6 +60,7 @@ public enum TriggerType {
Exploited(TriggerExploited.class),
Explores(TriggerExplores.class),
Fight(TriggerFight.class),
FightOnce(TriggerFightOnce.class),
FlippedCoin(TriggerFlippedCoin.class),
Immediate(TriggerImmediate.class),
Investigated(TriggerInvestigated.class),

View File

@@ -0,0 +1,11 @@
Name:Neyith of the Dire Hunt
ManaCost:2 G G
Types:Legendary Creature Human Warrior
PT:3/3
T:Mode$ FightOnce | ValidCard$ Creature.YouCtrl | TriggerZones$ Battlefield | Execute$ TrigDraw | TriggerDescription$ Whenever one or more creatures you control fight or become blocked, draw a card.
T:Mode$ BlockersDeclared | ValidBlockedAttacker$ Creature.YouCtrl | TriggerZones$ Battlefield | Execute$ TrigDraw | Secondary$ True | TriggerDescription$ Whenever one or more creatures you control fight or become blocked, draw a card.
SVar:TrigDraw:DB$ Draw | NumCards$ 1
T:Mode$ Phase | Phase$ BeginCombat | ValidPlayer$ You | Execute$ TrigPump | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of combat on your turn, you may pay {2}{R/G}. If you do, double target creature's power until end of turn. That creature must be blocked this combat if able.
SVar:TrigPump:AB$ Pump | Cost$ 2 RG | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumAtt$ +X | References$ X | KW$ HIDDEN CARDNAME must be blocked if able.
SVar:X:Targeted$CardPower
Oracle:Whenever one or more creatures you control fight or become blocked, draw a card.\nAt the beginning of combat on your turn, you may pay {2}{R/G}. If you do, double target creature's power until end of turn. That creature must be blocked this combat if able. ({R/G} can be paid with either {R} or {G}.)