mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
- Added Coveted Jewel
This commit is contained in:
@@ -613,23 +613,36 @@ public class Combat {
|
||||
}
|
||||
|
||||
// Call this method right after turn-based action of declare blockers has been performed
|
||||
public final void fireTriggersForUnblockedAttackers() {
|
||||
public final void fireTriggersForUnblockedAttackers(final Game game) {
|
||||
boolean bFlag = false;
|
||||
List<GameEntity> defenders = Lists.newArrayList();
|
||||
for (AttackingBand ab : attackedByBands.values()) {
|
||||
Collection<Card> blockers = blockedBands.get(ab);
|
||||
boolean isBlocked = blockers != null && !blockers.isEmpty();
|
||||
ab.setBlocked(isBlocked);
|
||||
|
||||
if (!isBlocked) {
|
||||
bFlag = true;
|
||||
defenders.add(getDefenderByAttacker(ab));
|
||||
for (Card attacker : ab.getAttackers()) {
|
||||
// Run Unblocked Trigger
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Attacker", attacker);
|
||||
runParams.put("Defender",getDefenderByAttacker(attacker));
|
||||
runParams.put("DefendingPlayer", getDefenderPlayerByAttacker(attacker));
|
||||
attacker.getGame().getTriggerHandler().runTrigger(TriggerType.AttackerUnblocked, runParams, false);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.AttackerUnblocked, runParams, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bFlag) {
|
||||
// triggers for Coveted Jewel
|
||||
// currently there is only one attacking player
|
||||
// should be updated when two-headed-giant is done
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("AttackingPlayer", getAttackingPlayer());
|
||||
runParams.put("Defenders", defenders);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.AttackerUnblockedOnce, runParams, false);
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean assignBlockersDamage(boolean firstStrikeDamage) {
|
||||
|
||||
@@ -666,7 +666,7 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
|
||||
combat.removeAbsentCombatants();
|
||||
|
||||
combat.fireTriggersForUnblockedAttackers();
|
||||
combat.fireTriggersForUnblockedAttackers(game);
|
||||
|
||||
final List<Card> declaredBlockers = combat.getAllBlockers();
|
||||
if (!declaredBlockers.isEmpty()) {
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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.GameEntity;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Trigger_AttackerUnblockedOnce class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class TriggerAttackerUnblockedOnce extends Trigger {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for Trigger_AttackerUnblocked.
|
||||
* </p>
|
||||
*
|
||||
* @param params
|
||||
* a {@link java.util.HashMap} object.
|
||||
* @param host
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @param intrinsic
|
||||
* the intrinsic
|
||||
*/
|
||||
public TriggerAttackerUnblockedOnce(final java.util.Map<String, String> params, final Card host, final boolean intrinsic) {
|
||||
super(params, host, intrinsic);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public final boolean performTest(final Map<String, Object> runParams2) {
|
||||
if (hasParam("ValidDefenders")) {
|
||||
boolean valid = false;
|
||||
|
||||
final List<GameEntity> srcs = (List<GameEntity>) runParams2.get("Defenders");
|
||||
for (GameEntity c : srcs) {
|
||||
if (c.isValid(this.mapParams.get("ValidDefenders").split(","), this.getHostCard().getController(), this.getHostCard(), null)) {
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
if (hasParam("ValidAttackers")) {
|
||||
// should be updated if a creature of a specific type attackes a defender
|
||||
}
|
||||
*/
|
||||
}
|
||||
if (hasParam("ValidAttackingPlayer")) {
|
||||
if (!matchesValid(runParams2.get("AttackingPlayer"),
|
||||
this.mapParams.get("ValidAttackingPlayer").split(","), this.getHostCard())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void setTriggeringObjects(final SpellAbility sa) {
|
||||
sa.setTriggeringObject("AttackingPlayer", this.getRunParams().get("AttackingPlayer"));
|
||||
sa.setTriggeringObject("Defenders", this.getRunParams().get("Defenders"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImportantStackObjects(SpellAbility sa) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("AttackingPlayer: ").append(sa.getTriggeringObject("AttackingPlayer"));
|
||||
sb.append("Defenders: ").append(sa.getTriggeringObject("Defenders"));
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ public enum TriggerType {
|
||||
AttackerBlockedByCreature(TriggerAttackerBlockedByCreature.class),
|
||||
AttackersDeclared(TriggerAttackersDeclared.class),
|
||||
AttackerUnblocked(TriggerAttackerUnblocked.class),
|
||||
AttackerUnblockedOnce(TriggerAttackerUnblockedOnce.class),
|
||||
Attacks(TriggerAttacks.class),
|
||||
BecomeMonarch(TriggerBecomeMonarch.class),
|
||||
BecomeMonstrous(TriggerBecomeMonstrous.class),
|
||||
|
||||
10
forge-gui/res/cardsfolder/c/coveted_jewel.txt
Normal file
10
forge-gui/res/cardsfolder/c/coveted_jewel.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
Name:Coveted Jewel
|
||||
ManaCost:6
|
||||
Types:Artifact
|
||||
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigDraw | TriggerDescription$ When CARDNAME enters the battlefield, draw three cards.
|
||||
SVar:TrigDraw:DB$ Draw | Defined$ You | NumCards$ 3
|
||||
A:AB$ Mana | Cost$ T | Produced$ Any | Amount$ 3 | SpellDescription$ Add three mana of any one color.
|
||||
T:Mode$ AttackerUnblockedOnce | ValidAttackingPlayer$ Player.Opponent | ValidDefenders$ You | TriggerZones$ Battlefield | Execute$ TrigDraw | TriggerDescription$ Whenever one or more creatures an opponent controls attack you and aren't blocked, that player draws three cards and gains control of CARDNAME. Untap it.
|
||||
SVar:TrigDraw:DB$ Draw | Defined$ TriggeredAttackingPlayer | NumCards$ 3 | SubAbility$ DBGainGontrol
|
||||
SVar:DBGainGontrol:DB$ GainControl | NewController$ TriggeredAttackingPlayer | Untap$ True
|
||||
Oracle:When Coveted Jewel enters the battlefield, draw three cards.\n{T}: Add three mana of any one color.\nWhenever one or more creatures an opponent controls attack you and aren't blocked, that player draws three cards and gains control of Coveted Jewel. Untap it.
|
||||
Reference in New Issue
Block a user