Implemented Fraying Omnipotence

This commit is contained in:
Evan Kranzler 2018-06-22 08:54:18 -04:00
parent 266a7cdb85
commit 2f3ef20048
3 changed files with 118 additions and 8 deletions

View file

@ -0,0 +1,107 @@
package mage.cards.f;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetControlledCreaturePermanent;
/**
*
* @author TheElk801
*/
public final class FrayingOmnipotence extends CardImpl {
public FrayingOmnipotence(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}{B}");
// Each player loses half their life, then discards half the cards in their hand, then sacrifices half the creatures they control. Round up each time.
this.getSpellAbility().addEffect(new FrayingOmnipotenceEffect());
}
public FrayingOmnipotence(final FrayingOmnipotence card) {
super(card);
}
@Override
public FrayingOmnipotence copy() {
return new FrayingOmnipotence(this);
}
}
class FrayingOmnipotenceEffect extends OneShotEffect {
FrayingOmnipotenceEffect() {
super(Outcome.Detriment);
this.staticText = "Each player loses half their life, "
+ "then discards half the cards in their hand, "
+ "then sacrifices half the creatures they control. "
+ "Round up each time.";
}
FrayingOmnipotenceEffect(final FrayingOmnipotenceEffect effect) {
super(effect);
}
@Override
public FrayingOmnipotenceEffect copy() {
return new FrayingOmnipotenceEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
// Each player loses half of their life,
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
int lifeToLose = (int) Math.ceil(player.getLife() / 2.0);
player.loseLife(lifeToLose, game, false);
}
// then discards half of the cards in their hand,
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
int cardsToDiscard = (int) Math.ceil(player.getHand().size() / 2.0);
if (cardsToDiscard > 0) {
player.discard(cardsToDiscard, false, source, game);
}
}
// then sacrifices half of the creatures they controls,
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
int creaturesToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), player.getId(), game) / 2.0);
if (creaturesToSacrifice == 0) {
continue;
}
Target target = new TargetControlledCreaturePermanent(creaturesToSacrifice, creaturesToSacrifice, filter, true);
target.chooseTarget(Outcome.Sacrifice, playerId, source, game);
for (UUID permanentId : target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
permanent.sacrifice(source.getSourceId(), game);
}
}
}
return true;
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.p;
import java.util.UUID;
@ -24,8 +23,7 @@ import mage.target.common.TargetControlledPermanent;
public final class Pox extends CardImpl {
public Pox(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{B}{B}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{B}{B}{B}");
// Each player loses a third of their life, then discards a third of the cards in their hand, then sacrifices a third of the creatures he or she controls, then sacrifices a third of the lands he or she controls. Round up each time.
this.getSpellAbility().addEffect(new PoxEffect());
@ -42,21 +40,25 @@ public final class Pox extends CardImpl {
}
class PoxEffect extends OneShotEffect {
PoxEffect() {
super(Outcome.Detriment);
this.staticText = "Each player loses a third of their life, then discards a third of the cards in their hand, then sacrifices a third of the creatures he or she controls, then sacrifices a third of the lands he or she controls. Round up each time.";
this.staticText = "Each player loses a third of their life, "
+ "then discards a third of the cards in their hand, "
+ "then sacrifices a third of the creatures they control, "
+ "then sacrifices a third of the lands they control. "
+ "Round up each time.";
}
PoxEffect(final PoxEffect effect) {
super(effect);
}
@Override
public PoxEffect copy() {
return new PoxEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());

View file

@ -102,6 +102,7 @@ public final class CoreSet2019 extends ExpansionSet {
cards.add(new SetCardInfo("Fiery Finish", 140, Rarity.UNCOMMON, mage.cards.f.FieryFinish.class));
cards.add(new SetCardInfo("Fire Elemental", 141, Rarity.COMMON, mage.cards.f.FireElemental.class));
cards.add(new SetCardInfo("Fountain of Renewal", 235, Rarity.UNCOMMON, mage.cards.f.FountainOfRenewal.class));
cards.add(new SetCardInfo("Fraying Omnipotence", 97, Rarity.RARE, mage.cards.f.FrayingOmnipotence.class));
cards.add(new SetCardInfo("Frilled Sea Serpent", 56, Rarity.COMMON, mage.cards.f.FrilledSeaSerpent.class));
cards.add(new SetCardInfo("Gallant Cavalry", 12, Rarity.COMMON, mage.cards.g.GallantCavalry.class));
cards.add(new SetCardInfo("Gearsmith Guardian", 237, Rarity.COMMON, mage.cards.g.GearsmithGuardian.class));