mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 04:42:07 -08:00
Added Norn's Decree (#10281)
* Added Norn's Decree Also added a couple of helper classes: - A triggered ability for when players attack - A triggered ability for the controller taking combat damage from one or more creatures (will be used in Starscream, Power Hungry) - A condition for when an attacked player is poisoned * Fixed rules comment issue * Fixed issue with incorrect logic in CombatDamageDealtToYouTriggeredAbility
This commit is contained in:
parent
75e5ee8462
commit
9a5fa9c8b0
5 changed files with 262 additions and 0 deletions
|
|
@ -0,0 +1,101 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedEvent;
|
||||
import mage.game.events.DamagedPlayerBatchEvent;
|
||||
import mage.game.events.DamagedPlayerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
* A triggered ability for whenever one or more creatures deal combat damage to
|
||||
* you. Has an optional component for setting the target pointer to the opponent
|
||||
* whose creatures dealt combat damage to you.
|
||||
*
|
||||
* @author alexander-novo
|
||||
*/
|
||||
public class CombatDamageDealtToYouTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
// Whether or not the ability should set a target targetting the opponent who
|
||||
// controls the creatures who dealt damage to you
|
||||
private final boolean setTarget;
|
||||
|
||||
/**
|
||||
* @param effect The effect that should happen when the ability resolves
|
||||
*/
|
||||
public CombatDamageDealtToYouTriggeredAbility(Effect effect) {
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param effect The effect that should happen when the ability resolves
|
||||
* @param setTarget Whether or not the ability should set a target targetting
|
||||
* the opponent who controls the creatures who dealt damage to
|
||||
* you
|
||||
*/
|
||||
public CombatDamageDealtToYouTriggeredAbility(Effect effect, boolean setTarget) {
|
||||
this(Zone.BATTLEFIELD, effect, setTarget, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param zone Which zone the ability shoudl take effect in
|
||||
* @param effect The effect that should happen when the ability resolves
|
||||
* @param setTarget Whether or not the ability should set a target targetting
|
||||
* the opponent who controls the creatures who dealt damage to
|
||||
* you
|
||||
* @param optional Whether or not the ability is optional
|
||||
*/
|
||||
public CombatDamageDealtToYouTriggeredAbility(Zone zone, Effect effect, boolean setTarget,
|
||||
boolean optional) {
|
||||
super(zone, effect, optional);
|
||||
|
||||
this.setTarget = setTarget;
|
||||
|
||||
setTriggerPhrase(generateTriggerPhrase());
|
||||
}
|
||||
|
||||
private CombatDamageDealtToYouTriggeredAbility(final CombatDamageDealtToYouTriggeredAbility ability) {
|
||||
super(ability);
|
||||
|
||||
this.setTarget = ability.setTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER_BATCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
DamagedPlayerBatchEvent damageEvent = (DamagedPlayerBatchEvent) event;
|
||||
boolean check = damageEvent.getEvents()
|
||||
.stream()
|
||||
.anyMatch(c -> c.isCombatDamage() && c.getPlayerId() == this.controllerId);
|
||||
|
||||
if (check) {
|
||||
if (this.setTarget) {
|
||||
this.getEffects().setTargetPointer(
|
||||
new FixedTarget(game.getPermanent(damageEvent.getSourceId()).getControllerId()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String generateTriggerPhrase() {
|
||||
if (setTarget) {
|
||||
return "Whenever one or more creatures an opponent controls deal combat damage to you, ";
|
||||
} else {
|
||||
return "Whenever one or more creatures deal combat damage to you, ";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CombatDamageDealtToYouTriggeredAbility copy() {
|
||||
return new CombatDamageDealtToYouTriggeredAbility(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedPlayerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
* A triggered ability for whenever a player attacks. Has an optional component
|
||||
* for setting the target pointer on effects to that attacking player.
|
||||
*
|
||||
* @author alexander-novo
|
||||
*/
|
||||
public class PlayerAttacksTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
// Whether or not the ability should set a target targetting the player who
|
||||
// attacked
|
||||
private final boolean setTarget;
|
||||
|
||||
/**
|
||||
* @param effect The effect that should happen when the ability resolves
|
||||
*/
|
||||
public PlayerAttacksTriggeredAbility(Effect effect) {
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param effect The effect that should happen when the ability resolves
|
||||
* @param setTarget Whether or not the ability should set a target targetting
|
||||
* the player who attacked
|
||||
*/
|
||||
public PlayerAttacksTriggeredAbility(Effect effect, boolean setTarget) {
|
||||
this(Zone.BATTLEFIELD, effect, setTarget, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param zone Which zone the ability shoudl take effect in
|
||||
* @param effect The effect that should happen when the ability resolves
|
||||
* @param setTarget Whether or not the ability should set a target targetting
|
||||
* the player who attacked
|
||||
* @param optional Whether or not the ability is optional
|
||||
*/
|
||||
public PlayerAttacksTriggeredAbility(Zone zone, Effect effect, boolean setTarget,
|
||||
boolean optional) {
|
||||
super(zone, effect, optional);
|
||||
|
||||
this.setTarget = setTarget;
|
||||
|
||||
setTriggerPhrase(generateTriggerPhrase());
|
||||
}
|
||||
|
||||
private PlayerAttacksTriggeredAbility(final PlayerAttacksTriggeredAbility ability) {
|
||||
super(ability);
|
||||
|
||||
this.setTarget = ability.setTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (!game.getCombat().getAttackers().isEmpty()) {
|
||||
if (this.setTarget) {
|
||||
this.getEffects().setTargetPointer(
|
||||
new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private String generateTriggerPhrase() {
|
||||
return "Whenever a player attacks, ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerAttacksTriggeredAbility copy() {
|
||||
return new PlayerAttacksTriggeredAbility(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.watchers.common.PlayerAttackedStepWatcher;
|
||||
|
||||
/**
|
||||
* A condition which checks whether any players being attacked are poisoned
|
||||
* (have one or more poison counters on them)
|
||||
*
|
||||
* @author alexander-novo
|
||||
*/
|
||||
public enum AttackedPlayersPoisonedCondition implements Condition {
|
||||
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getCombat().getDefenders().stream().map(defender -> game.getPlayer(defender))
|
||||
.anyMatch(player -> player != null && player.getCounters().containsKey(CounterType.POISON));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "one or more players being attacked are poisoned";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue