[LTR] Implement The Balrog, Durin's Bane (#10515)

* [LTR] Implement The Balrog, Durin's Bane

I could use someone more experienced for this card:
Should the watcher `PermanentsSacrificedWatcher` be initialized locally in the card's class, or is a global initializing in GameImpl.java alright? I went for the latter for now, as my base for implementing the static cost reduction was Blood for the Blood God!

* apply review

* no longer instantiate watcher on every game.
This commit is contained in:
Susucre 2023-07-01 18:53:31 +02:00 committed by GitHub
parent 44928e65f7
commit 496faaf5cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 152 additions and 0 deletions

View file

@ -0,0 +1,40 @@
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.PermanentsSacrificedWatcher;
/**
* @author Susucr
*/
public enum PermanentsSacrificedThisTurnCount implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
PermanentsSacrificedWatcher watcher = game.getState().getWatcher(PermanentsSacrificedWatcher.class);
if (watcher != null) {
return watcher.getThisTurnSacrificedPermanents();
}
return 0;
}
@Override
public PermanentsSacrificedThisTurnCount copy() {
return PermanentsSacrificedThisTurnCount.instance;
}
@Override
public String toString() {
return "X";
}
@Override
public String getMessage() {
return "permanents sacrificed this turn";
}
}

View file

@ -0,0 +1,28 @@
package mage.abilities.hint.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.PermanentsSacrificedThisTurnCount;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.game.Game;
/**
* @author Susucr
*/
public enum PermanentsSacrificedThisTurnHint implements Hint {
instance;
private static final Hint hint = new ValueHint(
"Permanents sacrificed this turn", PermanentsSacrificedThisTurnCount.instance
);
@Override
public String getText(Game game, Ability ability) {
return hint.getText(game, ability);
}
@Override
public PermanentsSacrificedThisTurnHint copy() {
return this;
}
}

View file

@ -46,4 +46,8 @@ public class PermanentsSacrificedWatcher extends Watcher {
public List<Permanent> getThisTurnSacrificedPermanents(UUID playerId) {
return sacrificedPermanents.get(playerId);
}
public int getThisTurnSacrificedPermanents() {
return sacrificedPermanents.values().stream().mapToInt(permanents -> permanents.size()).sum();
}
}