mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Implement [M3C] Blaster Hulk/Create EnergySpentOrLostThisTurnCount and update Izzet Generatorium (#12426)
* Implement-M3C-Blaster-Hulk * Update BlasterHulk.java * Update BlasterHulk to fix number of targets --------- Co-authored-by: Grath <1895280+Grath@users.noreply.github.com>
This commit is contained in:
parent
f6d7ede7e5
commit
9f1031f286
5 changed files with 152 additions and 63 deletions
|
|
@ -0,0 +1,31 @@
|
|||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.watchers.common.EnergySpentOrLostWatcher;
|
||||
|
||||
public enum EnergySpentOrLostThisTurnCount implements DynamicValue {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
return EnergySpentOrLostWatcher.getAmountEnergyLostOrSpentThisTurn(game, sourceAbility.getControllerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnergySpentOrLostThisTurnCount copy() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "{E} spent or lost this turn";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package mage.watchers.common;
|
||||
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EnergySpentOrLostWatcher extends Watcher {
|
||||
|
||||
// player -> amount of energy spent or lost this turn
|
||||
private final Map<UUID, Integer> energyLostOrSpent = new HashMap<>();
|
||||
|
||||
public EnergySpentOrLostWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() != GameEvent.EventType.COUNTERS_REMOVED) {
|
||||
return;
|
||||
}
|
||||
if (!event.getData().equals(CounterType.ENERGY.getName())) {
|
||||
return;
|
||||
}
|
||||
int amount = event.getAmount();
|
||||
if (amount <= 0) {
|
||||
return;
|
||||
}
|
||||
energyLostOrSpent.compute(event.getTargetId(), (k, i) -> i == null ? amount : Integer.sum(i, amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
energyLostOrSpent.clear();
|
||||
}
|
||||
|
||||
public static int getAmountEnergyLostOrSpentThisTurn(Game game, UUID playerId) {
|
||||
EnergySpentOrLostWatcher watcher = game.getState().getWatcher(EnergySpentOrLostWatcher.class);
|
||||
return watcher == null ? 0 : watcher.energyLostOrSpent.getOrDefault(playerId, 0);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue