magefree / magefree/mage

Deep Gnome Terramancer bug with Circuitous Route

Open
#10,088 0 comments 0 reactions 0 assignees View on GitHub
bug refactoring
Dominant language
Java
Stars
2.4k
Forks
940
Avg merge
2d 12h
Merged PRs (30d)
160

Description

From the discussion in #9858

**Bug reproduction steps**:
Player A controls a [[Deep Gnome Terramancer]]
Player B casts [[Circuitous Route]], finding two lands and putting them onto the battlefield
Player A's DGT triggers twice (but can still only be *used* once)

**Expected outcome**:
Player A's DGT triggers once, in accordance to the "one or more" part of DGT's "_one or more lands enter the battlefield under an opponent’s control without being played_"

This has minor impact on gameplay due to the fact that regardless of the number of instances of the ability on the stack, the card's optional land finding effect can only be *used* once per turn, meaning that any other instances will not resolve if the controller chooses to search.

An attempted approach was to use a `ZONE_CHANGE_GROUP` event in order to resolve the issue with Circuitous Route and using the `checkTrigger` code below:
```java
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
PlayLandWatcher watcher = game.getState().getWatcher(PlayLandWatcher.class);
return zEvent != null
&& zEvent.getToZone() == Zone.BATTLEFIELD
&& zEvent.getCards() != null
&& zEvent.getCards()
.stream()
.map(MageItem::getId)
.map(game::getPermanent)
.filter(Objects::nonNull)
.filter(permanent -> permanent.isLand(game))
.filter(permanent -> !watcher.wasLandPlayed(permanent.getId()))
.anyMatch(permanent -> permanent.getControllerId() != getControllerId());
}
```
But this resulted in [[Field of Ruin]] no longer putting 3 triggers on the stack in a game where 3 opponents put lands into play simultaneously, which would have been the expected outcome, but the above code resulted in the ability going on the stack only once.

@alexander-novo has suggested the use of a new `ZONE_CHANGE_PLAYER_GROUP` event in order to achieve separate triggers for multiple players by using the players' separate `playerId`s, whilst still allowing for singular triggers when a player puts multiple of a type of permanent into play (thus solving the Circuitous Route issue and the Field of Ruin issue).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Deep Gnome Terramancer checkTrigger example and the described ZONE_CHANGE_GROUP behavior. Compare Circuitous Route, which should produce one trigger for multiple lands controlled by one opponent, with Field of Ruin, which should produce separate triggers for multiple opponents. The proposed ZONE_CHANGE_PLAYER_GROUP event and playerId-based grouping define the expected completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
game-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.