mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 21:02:08 -08:00
[CLB] Implemented Ellyn Harbreeze, Busybody
This commit is contained in:
parent
662857c5f8
commit
8442d3280f
5 changed files with 117 additions and 77 deletions
|
|
@ -0,0 +1,41 @@
|
|||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.abilities.hint.ValueHint;
|
||||
import mage.game.Game;
|
||||
import mage.watchers.common.CreatedTokenWatcher;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public enum TokensCreatedThisTurnCount implements DynamicValue {
|
||||
instance;
|
||||
private static final Hint hint = new ValueHint("The number of tokens you created this turn", instance);
|
||||
|
||||
public static Hint getHint() {
|
||||
return hint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
return CreatedTokenWatcher.getPlayerCount(sourceAbility.getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokensCreatedThisTurnCount copy() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "the number of tokens you created this turn";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
}
|
||||
|
|
@ -3,10 +3,11 @@ package mage.watchers.common;
|
|||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.util.CardUtil;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -14,7 +15,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class CreatedTokenWatcher extends Watcher {
|
||||
|
||||
private final Set<UUID> playerIds = new HashSet<>();
|
||||
private final Map<UUID, Integer> playerMap = new HashMap<>();
|
||||
|
||||
public CreatedTokenWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
|
|
@ -23,16 +24,24 @@ public class CreatedTokenWatcher extends Watcher {
|
|||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.CREATED_TOKEN) {
|
||||
playerIds.add(event.getPlayerId());
|
||||
playerMap.compute(event.getPlayerId(), CardUtil::setOrIncrementValue);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
playerIds.clear();
|
||||
playerMap.clear();
|
||||
}
|
||||
|
||||
public static boolean checkPlayer(UUID playerId, Game game) {
|
||||
return game.getState().getWatcher(CreatedTokenWatcher.class).playerIds.contains(playerId);
|
||||
return getPlayerCount(playerId, game) > 0;
|
||||
}
|
||||
|
||||
public static int getPlayerCount(UUID playerId, Game game) {
|
||||
return game
|
||||
.getState()
|
||||
.getWatcher(CreatedTokenWatcher.class)
|
||||
.playerMap
|
||||
.getOrDefault(playerId, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue