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:
Alexander Novotny 2023-06-05 19:14:54 -07:00 committed by GitHub
parent 75e5ee8462
commit 9a5fa9c8b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 262 additions and 0 deletions

View file

@ -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);
}
}