The Ring Emblem - fixed not working 3rd effect with blocker sacrifice (closes #11425), added docs and usage example for BLOCKER_DECLARED and CREATURE_BLOCKED game events

This commit is contained in:
Oleg Agafonov 2023-11-19 19:16:55 +04:00
parent 571711e67d
commit 27c9543f62
5 changed files with 33 additions and 10 deletions

View file

@ -81,7 +81,6 @@ enum BaneLordOfDarknessCondition implements Condition {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return Optional return Optional
.ofNullable(game.getPlayer(source.getControllerId())) .ofNullable(game.getPlayer(source.getControllerId()))
.filter(Objects::nonNull)
.map(Player::getLife) .map(Player::getLife)
.map(x -> 2 * x <= game.getStartingLife()) .map(x -> 2 * x <= game.getStartingLife())
.orElse(false); .orElse(false);

View file

@ -32,7 +32,6 @@ public abstract class VillainousChoice {
} }
String controllerName = Optional String controllerName = Optional
.ofNullable(game.getPlayer(source.getControllerId())) .ofNullable(game.getPlayer(source.getControllerId()))
.filter(Objects::nonNull)
.map(Player::getName) .map(Player::getName)
.orElse("Opponent"); .orElse("Opponent");
return message.replace("{controller}", controllerName); return message.replace("{controller}", controllerName);

View file

@ -3963,6 +3963,7 @@ public abstract class GameImpl implements Game {
public String toString() { public String toString() {
Player activePayer = this.getPlayer(this.getActivePlayerId()); Player activePayer = this.getPlayer(this.getActivePlayerId());
StringBuilder sb = new StringBuilder() StringBuilder sb = new StringBuilder()
.append(this.isSimulation() ? "!!!SIMULATION!!! " : "")
.append(this.getGameType().toString()) .append(this.getGameType().toString())
.append("; ").append(CardUtil.getTurnInfo(this)) .append("; ").append(CardUtil.getTurnInfo(this))
.append("; active: ").append((activePayer == null ? "none" : activePayer.getName())) .append("; active: ").append((activePayer == null ? "none" : activePayer.getName()))

View file

@ -24,8 +24,6 @@ import mage.players.Player;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.TemptedByTheRingWatcher; import mage.watchers.common.TemptedByTheRingWatcher;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
/** /**
@ -130,7 +128,6 @@ class TheRingEmblemLegendaryEffect extends ContinuousEffectImpl {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = Optional Permanent permanent = Optional
.ofNullable(game.getPlayer(source.getControllerId())) .ofNullable(game.getPlayer(source.getControllerId()))
.filter(Objects::nonNull)
.map(player -> player.getRingBearer(game)) .map(player -> player.getRingBearer(game))
.orElse(null); .orElse(null);
if (permanent == null) { if (permanent == null) {
@ -186,7 +183,7 @@ class TheRingEmblemTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkEventType(GameEvent event, Game game) { public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CREATURE_BLOCKED; return event.getType() == GameEvent.EventType.BLOCKER_DECLARED;
} }
@Override @Override
@ -195,7 +192,7 @@ class TheRingEmblemTriggeredAbility extends TriggeredAbilityImpl {
Permanent blocker = game.getPermanent(event.getSourceId()); Permanent blocker = game.getPermanent(event.getSourceId());
if (attacker == null if (attacker == null
|| blocker == null || blocker == null
|| attacker.isControlledBy(getControllerId()) || !attacker.isControlledBy(getControllerId())
|| !attacker.isRingBearer()) { || !attacker.isRingBearer()) {
return false; return false;
} }

View file

@ -307,13 +307,40 @@ public class GameEvent implements Serializable {
DECLARING_BLOCKERS, DECLARING_BLOCKERS,
DECLARED_BLOCKERS, DECLARED_BLOCKERS,
DECLARE_BLOCKER, DECLARE_BLOCKER,
/* BLOCKER_DECLARED /* BLOCKER_DECLARED
raise one time for each declared blocker (e.g. multiple events per attacker allows)
warning, must use for rules: becomes blocked by a creature
rules ref:
Acolyte of the Infernos last ability will trigger once for each creature that blocks it.
Each of those creatures will be dealt 2 damage.
(2015-06-22)
targetId attacker id targetId attacker id
sourceId blocker id sourceId blocker id
playerId blocker controller id playerId blocker controller id
*/ */
BLOCKER_DECLARED, BLOCKER_DECLARED,
/* CREATURE_BLOCKED
raise one time per attacker (e.g. only one event per attacker allows)
warning, must use for rules: xxx becomes blocked,
rules ref:
Rakdos Roustabout
An ability that triggers when a creature becomes blocked triggers only once
if two or more creatures block it.
(2019-01-25)
targetId attacker id
sourceId not used for this event
playerId not used for this event
*/
CREATURE_BLOCKED, CREATURE_BLOCKED,
CREATURE_BLOCKS, CREATURE_BLOCKS,
BATCH_BLOCK_NONCOMBAT, BATCH_BLOCK_NONCOMBAT,
UNBLOCKED_ATTACKER, UNBLOCKED_ATTACKER,