Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement [M3C] Blaster Hulk/Create EnergySpentOrLostThisTurnCount and update Izzet Generatorium #12426

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions Mage.Sets/src/mage/cards/b/BlasterHulk.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package mage.cards.b;

import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AttacksAloneSourceTriggeredAbility;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.delayed.ReflexiveTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.costs.common.PayEnergyCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.AttackingCreatureCount;
import mage.abilities.dynamicvalue.common.EnergySpentOrLostThisTurnCount;
import mage.abilities.effects.common.DamageMultiEffect;
import mage.abilities.effects.common.DoWhenCostPaid;
import mage.abilities.effects.common.cost.SpellCostReductionForEachSourceEffect;
import mage.abilities.effects.common.cost.SpellCostReductionSourceEffect;
import mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect;
import mage.abilities.hint.ValueHint;
import mage.constants.SubType;
import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.target.common.TargetAnyTargetAmount;

/**
*
* @author grimreap124
*/
public final class BlasterHulk extends CardImpl {

public BlasterHulk(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{6}{R}{R}");

this.subtype.add(SubType.PIRATE);
this.power = new MageInt(8);
this.toughness = new MageInt(8);

// This spell costs {1} less to cast for each {E} you've paid or lost this turn.
DynamicValue xValue = EnergySpentOrLostThisTurnCount.instance;
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SpellCostReductionForEachSourceEffect(1, xValue))
.addHint(new ValueHint("{E} you've paid or lost this turn", xValue))
);
// Haste
this.addAbility(HasteAbility.getInstance());

// Whenever Blaster Hulk attacks, you get {E}{E}, then you may pay eight {E}. When you do, Blaster Hulk deals 8 damage divided as you choose among up to eight targets.
Ability ability = new AttacksTriggeredAbility(new GetEnergyCountersControllerEffect(2));
ReflexiveTriggeredAbility reflexiveAbility = new ReflexiveTriggeredAbility(new DamageMultiEffect(8).setText("{this} deals 8 damage divided as you choose among up to eight targets"), false);
reflexiveAbility.addTarget(new TargetAnyTargetAmount(4));
ability.addEffect(new DoWhenCostPaid(reflexiveAbility, new PayEnergyCost(8), "Pay eight {E} to deal 8 damage divided as you choose among up to eight targets?"));

this.addAbility(ability);
}

private BlasterHulk(final BlasterHulk card) {
super(card);
}

@Override
public BlasterHulk copy() {
return new BlasterHulk(this);
}
}
68 changes: 5 additions & 63 deletions Mage.Sets/src/mage/cards/i/IzzetGeneratorium.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import mage.abilities.condition.IntCompareCondition;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.EnergySpentOrLostThisTurnCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
Expand All @@ -20,6 +21,7 @@
import mage.game.events.GameEvent;
import mage.util.CardUtil;
import mage.watchers.Watcher;
import mage.watchers.common.EnergySpentOrLostWatcher;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -31,7 +33,7 @@
public final class IzzetGeneratorium extends CardImpl {

private static final Condition condition = new IzzetGeneratoriumCondition();
private static final Hint hint = new ValueHint("{E} paid or lost this turn", IzzetGeneratoriumValue.instance);
private static final Hint hint = new ValueHint("{E} paid or lost this turn", EnergySpentOrLostThisTurnCount.instance);

public IzzetGeneratorium(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{U}{R}");
Expand All @@ -44,7 +46,7 @@ public IzzetGeneratorium(UUID ownerId, CardSetInfo setInfo) {
new DrawCardSourceControllerEffect(1),
new TapSourceCost(),
condition
).addHint(hint), new IzzetGeneratoriumWatcher());
).addHint(hint), new EnergySpentOrLostWatcher());
}

private IzzetGeneratorium(final IzzetGeneratorium card) {
Expand Down Expand Up @@ -100,71 +102,11 @@ class IzzetGeneratoriumCondition extends IntCompareCondition {

@Override
protected int getInputValue(Game game, Ability source) {
return IzzetGeneratoriumValue.instance.calculate(game, source, null);
return EnergySpentOrLostThisTurnCount.instance.calculate(game, source, null);
}

@Override
public String toString() {
return "if you've paid or lost four or more {E} this turn";
}
}

enum IzzetGeneratoriumValue implements DynamicValue {
instance;

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return IzzetGeneratoriumWatcher.getAmountEnergyLostOrSpentThisTurn(game, sourceAbility.getControllerId());
}

@Override
public IzzetGeneratoriumValue copy() {
return this;
}

@Override
public String getMessage() {
return "{E} spent or lost this turn";
}

@Override
public String toString() {
return "X";
}
}

class IzzetGeneratoriumWatcher extends Watcher {

// player -> amount of energy spent or lost this turn
private final Map<UUID, Integer> energyLostOrSpent = new HashMap<>();

IzzetGeneratoriumWatcher() {
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) {
IzzetGeneratoriumWatcher watcher = game.getState().getWatcher(IzzetGeneratoriumWatcher.class);
return watcher == null ? 0 : watcher.energyLostOrSpent.getOrDefault(playerId, 0);
}
}
1 change: 1 addition & 0 deletions Mage.Sets/src/mage/sets/ModernHorizons3Commander.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private ModernHorizons3Commander() {
cards.add(new SetCardInfo("Bident of Thassa", 177, Rarity.RARE, mage.cards.b.BidentOfThassa.class));
cards.add(new SetCardInfo("Bituminous Blast", 255, Rarity.UNCOMMON, mage.cards.b.BituminousBlast.class));
cards.add(new SetCardInfo("Blast Zone", 322, Rarity.RARE, mage.cards.b.BlastZone.class));
cards.add(new SetCardInfo("Blaster Hulk", 55, Rarity.RARE, mage.cards.b.BlasterHulk.class));
cards.add(new SetCardInfo("Bloodbraid Challenger", 70, Rarity.RARE, mage.cards.b.BloodbraidChallenger.class));
cards.add(new SetCardInfo("Bloodbraid Elf", 256, Rarity.UNCOMMON, mage.cards.b.BloodbraidElf.class));
cards.add(new SetCardInfo("Bonders' Enclave", 323, Rarity.RARE, mage.cards.b.BondersEnclave.class));
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}