Implement The Ring Tempts You mechanic (#10320)

* remove skip

* initial implementation of the ring mechanic

* some changes

* rework ring-bearer choosing

* [LTR] Implement Call of the Ring

* update ring-bearer condition
This commit is contained in:
Evan Kranzler 2023-05-07 14:32:28 -04:00 committed by GitHub
parent d56c148118
commit 3503513c4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 508 additions and 48 deletions

View file

@ -41,6 +41,7 @@ import mage.game.combat.Combat;
import mage.game.combat.CombatGroup;
import mage.game.command.*;
import mage.game.command.dungeons.UndercityDungeon;
import mage.game.command.emblems.TheRingEmblem;
import mage.game.events.*;
import mage.game.events.TableEvent.EventType;
import mage.game.mulligan.Mulligan;
@ -563,6 +564,34 @@ public abstract class GameImpl implements Game {
fireEvent(GameEvent.getEvent(GameEvent.EventType.VENTURED, playerId, null, playerId));
}
private TheRingEmblem getOrCreateTheRing(UUID playerId) {
TheRingEmblem emblem = state
.getCommand()
.stream()
.filter(TheRingEmblem.class::isInstance)
.map(TheRingEmblem.class::cast)
.filter(commandObject -> commandObject.isControlledBy(playerId))
.findFirst()
.orElse(null);
if (emblem != null) {
return emblem;
}
TheRingEmblem newEmblem = new TheRingEmblem(playerId);
state.addCommandObject(newEmblem);
return newEmblem;
}
@Override
public void temptWithTheRing(UUID playerId) {
Player player = getPlayer(playerId);
if (player == null) {
return;
}
player.chooseRingBearer(this);
getOrCreateTheRing(playerId).addNextAbility(this);
fireEvent(GameEvent.getEvent(GameEvent.EventType.TEMPTED_BY_RING, playerId, null, playerId));
}
@Override
public boolean hasDayNight() {
return state.isHasDayNight();
@ -1302,6 +1331,7 @@ public abstract class GameImpl implements Game {
newWatchers.add(new EndStepCountWatcher());
newWatchers.add(new CommanderPlaysCountWatcher()); // commander plays count uses in non commander games by some cards
newWatchers.add(new CreaturesDiedWatcher());
newWatchers.add(new TemptedByTheRingWatcher());
// runtime check - allows only GAME scope (one watcher per game)
newWatchers.forEach(watcher -> {