* Urborg Justice - Fixed that tokens going to graveyard were not counted.

This commit is contained in:
LevelX2 2017-05-18 23:42:32 +02:00
parent 11ba007fd3
commit e090b26240
6 changed files with 168 additions and 177 deletions

View file

@ -42,7 +42,7 @@ public class CreaturesDiedThisTurnCount implements DynamicValue {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatchers().get(CreaturesDiedWatcher.class.getSimpleName());
if (watcher != null) {
return watcher.getAmountOfCreaturesDiesThisTurn();
return watcher.getAmountOfCreaturesDiedThisTurn();
}
return 0;
}

View file

@ -29,8 +29,6 @@ package mage.watchers.common;
import java.util.HashMap;
import java.util.UUID;
import java.util.stream.Collectors;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -43,6 +41,7 @@ import mage.watchers.Watcher;
public class CreaturesDiedWatcher extends Watcher {
private final HashMap<UUID, Integer> amountOfCreaturesThatDiedByController = new HashMap<>();
private final HashMap<UUID, Integer> amountOfCreaturesThatDiedByOwner = new HashMap<>();
public CreaturesDiedWatcher() {
super(CreaturesDiedWatcher.class.getSimpleName(), WatcherScope.GAME);
@ -51,6 +50,7 @@ public class CreaturesDiedWatcher extends Watcher {
public CreaturesDiedWatcher(final CreaturesDiedWatcher watcher) {
super(watcher);
this.amountOfCreaturesThatDiedByController.putAll(watcher.amountOfCreaturesThatDiedByController);
this.amountOfCreaturesThatDiedByOwner.putAll(watcher.amountOfCreaturesThatDiedByOwner);
}
@Override
@ -60,8 +60,10 @@ public class CreaturesDiedWatcher extends Watcher {
if (zEvent.isDiesEvent()
&& zEvent.getTarget() != null
&& zEvent.getTarget().isCreature()) {
int amount = getAmountOfCreaturesDiesThisTurn(zEvent.getTarget().getControllerId());
int amount = getAmountOfCreaturesDiedThisTurnByController(zEvent.getTarget().getControllerId());
amountOfCreaturesThatDiedByController.put(zEvent.getTarget().getControllerId(), amount + 1);
amount = getAmountOfCreaturesDiedThisTurnByOwner(zEvent.getTarget().getOwnerId());
amountOfCreaturesThatDiedByOwner.put(zEvent.getTarget().getOwnerId(), amount + 1);
}
}
}
@ -69,19 +71,23 @@ public class CreaturesDiedWatcher extends Watcher {
@Override
public void reset() {
amountOfCreaturesThatDiedByController.clear();
amountOfCreaturesThatDiedByOwner.clear();
}
public int getAmountOfCreaturesDiesThisTurn(UUID playerId) {
public int getAmountOfCreaturesDiedThisTurnByController(UUID playerId) {
return amountOfCreaturesThatDiedByController.getOrDefault(playerId, 0);
}
public int getAmountOfCreaturesDiedThisTurnByOwner(UUID playerId) {
return amountOfCreaturesThatDiedByOwner.getOrDefault(playerId, 0);
}
@Override
public CreaturesDiedWatcher copy() {
return new CreaturesDiedWatcher(this);
}
public int getAmountOfCreaturesDiesThisTurn() {
public int getAmountOfCreaturesDiedThisTurn() {
return amountOfCreaturesThatDiedByController.values().stream().mapToInt(x -> x).sum();
}
}