mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 04:09:54 -08:00
[VOC] Implemented Shadowgrange Archfiend AND Changed MadnessAbility (#8628)
* Implemented Shadowgrange Archfiend * Changed MadnessAbility to work with cards which also require life to be paid as part of the madness cost (so far only Shadowgrange Archfiend). * Updated Shadowgrange Archfiend to work with new Madness implementation (and actually cost life to cast using madness) * Removed unnecessary variable
This commit is contained in:
parent
9ec6b617b8
commit
5945aaeda4
3 changed files with 233 additions and 63 deletions
138
Mage.Sets/src/mage/cards/s/ShadowgrangeArchfiend.java
Normal file
138
Mage.Sets/src/mage/cards/s/ShadowgrangeArchfiend.java
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
package mage.cards.s;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.costs.common.PayLifeCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.GainLifeEffect;
|
||||
import mage.abilities.keyword.MadnessAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.PowerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Alex-Vasile
|
||||
*/
|
||||
public final class ShadowgrangeArchfiend extends CardImpl {
|
||||
public ShadowgrangeArchfiend(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{6}{B}");
|
||||
this.subtype.add(SubType.DEMON);
|
||||
|
||||
this.power = new MageInt(8);
|
||||
this.toughness = new MageInt(4);
|
||||
|
||||
// When Shadowgrange Archfiend enters the battlefield,
|
||||
// each opponent sacrifices a creature with the greatest power among creatures they control.
|
||||
// You gain life equal to the greatest power among creatures sacrificed this way.
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new ShadowgrangeArchfiendEffect()));
|
||||
|
||||
// Madness—{2}{B}, Pay 8 life.
|
||||
MadnessAbility madnessAbility = new MadnessAbility(this, new ManaCostsImpl<>("{2}{B}"), 8);
|
||||
this.addAbility(madnessAbility);
|
||||
}
|
||||
|
||||
private ShadowgrangeArchfiend(final ShadowgrangeArchfiend card) { super(card); }
|
||||
|
||||
@Override
|
||||
public ShadowgrangeArchfiend copy() { return new ShadowgrangeArchfiend(this); }
|
||||
}
|
||||
|
||||
class ShadowgrangeArchfiendEffect extends OneShotEffect {
|
||||
|
||||
public ShadowgrangeArchfiendEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "each opponent sacrifices a creature with the greatest power among creatures they control. " +
|
||||
"You gain life equal to the greatest power among creatures sacrificed this way";
|
||||
}
|
||||
|
||||
private ShadowgrangeArchfiendEffect(final ShadowgrangeArchfiendEffect effect) { super(effect); }
|
||||
|
||||
@Override
|
||||
public ShadowgrangeArchfiendEffect copy() { return new ShadowgrangeArchfiendEffect(this); }
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {return false; }
|
||||
|
||||
List<Permanent> toSacrifice = new ArrayList<>();
|
||||
|
||||
// Iterate through each opponent
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
if (!controller.hasOpponent(playerId, game)) { continue; }
|
||||
|
||||
Player opponent = game.getPlayer(playerId);
|
||||
if (opponent == null) { continue; }
|
||||
|
||||
int greatestPower = Integer.MIN_VALUE;
|
||||
int numberOfCreatures = 0;
|
||||
Permanent creatureToSacrifice = null;
|
||||
|
||||
// Iterature through each creature
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game)) {
|
||||
if (permanent.getPower().getValue() > greatestPower) {
|
||||
greatestPower = permanent.getPower().getValue();
|
||||
numberOfCreatures = 1;
|
||||
creatureToSacrifice = permanent;
|
||||
} else if (permanent.getPower().getValue() == greatestPower) {
|
||||
numberOfCreatures++;
|
||||
}
|
||||
}
|
||||
|
||||
// If multiple creatures are tied for having the greatest power
|
||||
if (numberOfCreatures > 1) {
|
||||
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(
|
||||
"creature to sacrifice with power equal to " + greatestPower);
|
||||
filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, greatestPower));
|
||||
Target target = new TargetControlledCreaturePermanent(filter);
|
||||
if (opponent.choose(outcome, target, playerId, game)) {
|
||||
creatureToSacrifice = game.getPermanent(target.getFirstTarget());
|
||||
}
|
||||
}
|
||||
|
||||
if (creatureToSacrifice != null) {
|
||||
toSacrifice.add(creatureToSacrifice);
|
||||
}
|
||||
}
|
||||
|
||||
int greatestPowerAmongAllCreaturesSacked = Integer.MIN_VALUE;
|
||||
int powerOfCurrentCreature;
|
||||
|
||||
// Sack the creatures and save the greaterest power amoung those which were sacked
|
||||
for (Permanent permanent : toSacrifice) {
|
||||
powerOfCurrentCreature = permanent.getPower().getValue();
|
||||
|
||||
// Try to sack it
|
||||
if (permanent.sacrifice(source, game)) {
|
||||
if (powerOfCurrentCreature > greatestPowerAmongAllCreaturesSacked) {
|
||||
greatestPowerAmongAllCreaturesSacked = powerOfCurrentCreature;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Gain life equal to the power of greatest creature sacked, if it is positive
|
||||
if (greatestPowerAmongAllCreaturesSacked > 0) {
|
||||
new GainLifeEffect(greatestPowerAmongAllCreaturesSacked).apply(game, source);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -131,6 +131,8 @@ public final class CrimsonVowCommander extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Scion of Opulence", 28, Rarity.RARE, mage.cards.s.ScionOfOpulence.class));
|
||||
cards.add(new SetCardInfo("Shacklegeist", 112, Rarity.RARE, mage.cards.s.Shacklegeist.class));
|
||||
cards.add(new SetCardInfo("Shadowblood Ridge", 181, Rarity.RARE, mage.cards.s.ShadowbloodRidge.class));
|
||||
cards.add(new SetCardInfo("Shadowgrange Archfiend", 22, Rarity.RARE, mage.cards.s.ShadowgrangeArchfiend.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Shadowgrange Archfiend", 60, Rarity.RARE, mage.cards.s.ShadowgrangeArchfiend.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Sinister Waltz", 30, Rarity.RARE, mage.cards.s.SinisterWaltz.class));
|
||||
cards.add(new SetCardInfo("Sire of the Storm", 113, Rarity.UNCOMMON, mage.cards.s.SireOfTheStorm.class));
|
||||
cards.add(new SetCardInfo("Sky Diamond", 167, Rarity.COMMON, mage.cards.s.SkyDiamond.class));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue