mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 20:32:06 -08:00
[WOE] Implement Ash, Party Crasher (add Celebration Condition) (#10818)
* implement Ash, Party Crasher (add Celebration Condition) * test Celebration with Ash
This commit is contained in:
parent
853400ef46
commit
cbec9ead63
6 changed files with 281 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
import mage.watchers.common.CelebrationWatcher;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public enum CelebrationCondition implements Condition {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
CelebrationWatcher watcher = game.getState().getWatcher(CelebrationWatcher.class);
|
||||
return watcher != null && watcher.celebrationActive(source.getControllerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "two or more nonland permanents entered the battlefield under your control this turn";
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ public enum AbilityWord {
|
|||
ALLIANCE("Alliance"),
|
||||
BATTALION("Battalion"),
|
||||
BLOODRUSH("Bloodrush"),
|
||||
CELEBRATION("Celebration"),
|
||||
CHANNEL("Channel"),
|
||||
CHROMA("Chroma"),
|
||||
COHORT("Cohort"),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package mage.watchers.common;
|
||||
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public class CelebrationWatcher extends Watcher {
|
||||
|
||||
// playerId -> number of nonland permanents entered the battlefield this turn under that player's control.
|
||||
private final Map<UUID, Integer> celebrationCounts = new HashMap<>();
|
||||
|
||||
public CelebrationWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
|
||||
return;
|
||||
}
|
||||
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null && !permanent.isLand(game)) {
|
||||
celebrationCounts.compute(permanent.getControllerId(), CardUtil::setOrIncrementValue);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean celebrationActive(UUID playerId) {
|
||||
return celebrationCounts.getOrDefault(playerId, 0) >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
celebrationCounts.clear();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue