diff --git a/Mage.Sets/src/mage/cards/y/YurlokOfScorchThrash.java b/Mage.Sets/src/mage/cards/y/YurlokOfScorchThrash.java new file mode 100644 index 00000000000..7fb3153c38e --- /dev/null +++ b/Mage.Sets/src/mage/cards/y/YurlokOfScorchThrash.java @@ -0,0 +1,138 @@ +package mage.cards.y; + +import mage.MageInt; +import mage.Mana; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.mana.ManaEffect; +import mage.abilities.keyword.VigilanceAbility; +import mage.abilities.mana.SimpleManaAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.players.Player; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class YurlokOfScorchThrash extends CardImpl { + + public YurlokOfScorchThrash(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{R}{G}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.VIASHINO); + this.subtype.add(SubType.SHAMAN); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Vigilance + this.addAbility(VigilanceAbility.getInstance()); + + // A player losing unspent mana causes that player to lose that much life. + this.addAbility(new SimpleStaticAbility(new YurlokOfScorchThrashRuleEffect())); + + // {1}, {T}: Each player adds {B}{R}{G}. + Ability ability = new SimpleManaAbility( + Zone.BATTLEFIELD, new YurlokOfScorchThrashManaEffect(), new GenericManaCost(1) + ); + ability.addCost(new TapSourceCost()); + this.addAbility(ability); + } + + private YurlokOfScorchThrash(final YurlokOfScorchThrash card) { + super(card); + } + + @Override + public YurlokOfScorchThrash copy() { + return new YurlokOfScorchThrash(this); + } +} + +class YurlokOfScorchThrashRuleEffect extends ContinuousEffectImpl { + + YurlokOfScorchThrashRuleEffect() { + super(Duration.WhileOnBattlefield, Outcome.Detriment); + staticText = "A player losing unspent mana causes that player to lose that much life."; + } + + private YurlokOfScorchThrashRuleEffect(final YurlokOfScorchThrashRuleEffect effect) { + super(effect); + } + + @Override + public YurlokOfScorchThrashRuleEffect copy() { + return new YurlokOfScorchThrashRuleEffect(this); + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + game.getState().setManaBurn(true); + return true; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean hasLayer(Layer layer) { + return layer == Layer.RulesEffects; + } +} + +class YurlokOfScorchThrashManaEffect extends ManaEffect { + + YurlokOfScorchThrashManaEffect() { + super(); + staticText = "each player adds {B}{R}{G}"; + } + + private YurlokOfScorchThrashManaEffect(final YurlokOfScorchThrashManaEffect effect) { + super(effect); + } + + @Override + public YurlokOfScorchThrashManaEffect copy() { + return new YurlokOfScorchThrashManaEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player == null) { + continue; + } + Mana manaToAdd = produceMana(game, source); + if (manaToAdd == null || manaToAdd.count() <= 0) { + continue; + } + checkToFirePossibleEvents(manaToAdd, game, source); + addManaToPool(player, manaToAdd, game, source); + } + return true; + } + + @Override + public List getNetMana(Game game, Ability source) { + List netMana = new ArrayList<>(); + netMana.add(new Mana(1, 1, 0, 0, 1, 0, 0, 0)); + return netMana; + } + + @Override + public Mana produceMana(Game game, Ability source) { + return new Mana(1, 1, 0, 0, 1, 0, 0, 0); + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegends.java b/Mage.Sets/src/mage/sets/CommanderLegends.java index 3b957f980a1..3adae0f4169 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegends.java +++ b/Mage.Sets/src/mage/sets/CommanderLegends.java @@ -544,6 +544,7 @@ public final class CommanderLegends extends ExpansionSet { cards.add(new SetCardInfo("Xenagos, God of Revels", 541, Rarity.MYTHIC, mage.cards.x.XenagosGodOfRevels.class)); cards.add(new SetCardInfo("Yavimaya Elder", 441, Rarity.COMMON, mage.cards.y.YavimayaElder.class)); cards.add(new SetCardInfo("Yuriko, the Tiger's Shadow", 542, Rarity.MYTHIC, mage.cards.y.YurikoTheTigersShadow.class)); + cards.add(new SetCardInfo("Yurlok of Scorch Thrash", 293, Rarity.RARE, mage.cards.y.YurlokOfScorchThrash.class)); cards.add(new SetCardInfo("Zara, Renegade Recruiter", 294, Rarity.RARE, mage.cards.z.ZaraRenegadeRecruiter.class)); cards.add(new SetCardInfo("Zedruu the Greathearted", 543, Rarity.MYTHIC, mage.cards.z.ZedruuTheGreathearted.class)); cards.add(new SetCardInfo("Zur the Enchanter", 544, Rarity.MYTHIC, mage.cards.z.ZurTheEnchanter.class)); diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index ddb3842cf89..ce581eb5837 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -1540,7 +1540,10 @@ public abstract class GameImpl implements Game, Serializable { @Override public void emptyManaPools() { for (Player player : getPlayers().values()) { - player.getManaPool().emptyPool(this); + int amount = player.getManaPool().emptyPool(this); + if (state.isManaBurn() && amount > 0) { + player.loseLife(amount, this, false); + } } } diff --git a/Mage/src/main/java/mage/game/GameState.java b/Mage/src/main/java/mage/game/GameState.java index 6f406d28f70..bb0379e2e2a 100644 --- a/Mage/src/main/java/mage/game/GameState.java +++ b/Mage/src/main/java/mage/game/GameState.java @@ -103,6 +103,7 @@ public class GameState implements Serializable, Copyable { private int permanentOrderNumber; private final Map usePowerInsteadOfToughnessForDamageLethalityFilters = new HashMap<>(); private Set commandersToStay = new HashSet<>(); // commanders that do not go back to command zone + private boolean manaBurn = false; private int applyEffectsCounter; // Upcounting number of each applyEffects execution @@ -1089,6 +1090,7 @@ public class GameState implements Serializable, Copyable { state.clearAbilities(); } cardAttribute.clear(); + this.setManaBurn(false); } public void clear() { @@ -1269,4 +1271,12 @@ public class GameState implements Serializable, Copyable { void setCommanderShouldStay(Card card, Game game) { commandersToStay.add(new MageObjectReference(card, game)); } + + public void setManaBurn(boolean manaBurn) { + this.manaBurn = manaBurn; + } + + public boolean isManaBurn() { + return manaBurn; + } }