Implemented Carnival // Carnage

This commit is contained in:
Evan Kranzler 2019-01-04 12:28:14 -05:00
parent 958503cff2
commit 1f24af8716
6 changed files with 105 additions and 6 deletions

View file

@ -0,0 +1,82 @@
package mage.cards.c;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.discard.DiscardTargetEffect;
import mage.cards.CardSetInfo;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SpellAbilityType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreatureOrPlaneswalker;
import mage.target.common.TargetOpponent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class CarnivalCarnage extends SplitCard {
public CarnivalCarnage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, new CardType[]{CardType.SORCERY}, "{B/R}", "{2}{B}{R}", SpellAbilityType.SPLIT);
// Carnival
// Carnival deals 1 damage to target creature or planeswalker and 1 damage to that permanent's controller.
this.getLeftHalfCard().getSpellAbility().addEffect(new CarnivalEffect());
this.getLeftHalfCard().getSpellAbility().addTarget(new TargetCreatureOrPlaneswalker());
// Carnage
// Carnage deals 3 damage to target opponent. That player discards two cards.
this.getRightHalfCard().getSpellAbility().addEffect(new DamageTargetEffect(3));
this.getRightHalfCard().getSpellAbility().addEffect(
new DiscardTargetEffect(2).setText("That player discards two cards.")
);
this.getRightHalfCard().getSpellAbility().addTarget(new TargetOpponent());
}
private CarnivalCarnage(final CarnivalCarnage card) {
super(card);
}
@Override
public CarnivalCarnage copy() {
return new CarnivalCarnage(this);
}
}
class CarnivalEffect extends OneShotEffect {
CarnivalEffect() {
super(Outcome.Benefit);
staticText = "{this} deals 1 damage to target creature or planeswalker " +
"and 1 damage to that permanent's controller";
}
private CarnivalEffect(final CarnivalEffect effect) {
super(effect);
}
@Override
public CarnivalEffect copy() {
return new CarnivalEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
permanent.damage(1, source.getSourceId(), game);
Player player = game.getPlayer(permanent.getControllerId());
if (player != null) {
player.damage(1, source.getSourceId(), game);
}
return true;
}
}

View file

@ -44,6 +44,7 @@ public final class RavnicaAllegiance extends ExpansionSet {
cards.add(new SetCardInfo("Blood Crypt", 245, Rarity.RARE, mage.cards.b.BloodCrypt.class));
cards.add(new SetCardInfo("Bolrac-Clan Crusher", 159, Rarity.UNCOMMON, mage.cards.b.BolracClanCrusher.class));
cards.add(new SetCardInfo("Breeding Pool", 246, Rarity.RARE, mage.cards.b.BreedingPool.class));
cards.add(new SetCardInfo("Carnival // Carnage", 222, Rarity.UNCOMMON, mage.cards.c.CarnivalCarnage.class));
cards.add(new SetCardInfo("Depose // Deploy", 225, Rarity.UNCOMMON, mage.cards.d.DeposeDeploy.class));
cards.add(new SetCardInfo("Deputy of Detention", 165, Rarity.RARE, mage.cards.d.DeputyOfDetention.class));
cards.add(new SetCardInfo("Dovin, Grand Arbiter", 167, Rarity.MYTHIC, mage.cards.d.DovinGrandArbiter.class));

View file

@ -1,9 +1,6 @@
package mage.game.permanent;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.MageObjectReference;
import mage.abilities.Ability;
@ -14,6 +11,10 @@ import mage.game.Controllable;
import mage.game.Game;
import mage.game.GameState;
import java.util.List;
import java.util.Set;
import java.util.UUID;
public interface Permanent extends Card, Controllable {
void setControllerId(UUID controllerId);
@ -106,6 +107,8 @@ public interface Permanent extends Card, Controllable {
int getDamage();
int damage(int damage, UUID sourceId, Game game);
int damage(int damage, UUID sourceId, Game game, boolean combat, boolean preventable);
int damage(int damage, UUID sourceId, Game game, boolean combat, boolean preventable, List<UUID> appliedEffects);

View file

@ -711,6 +711,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
return this.damage;
}
@Override
public int damage(int damage, UUID sourceId, Game game) {
return damage(damage, sourceId, game, true, false, false, null);
}
@Override
public int damage(int damage, UUID sourceId, Game game, boolean combat, boolean preventable) {
return damage(damage, sourceId, game, preventable, combat, false, null);

View file

@ -1,7 +1,5 @@
package mage.players;
import java.io.Serializable;
import java.util.*;
import mage.MageItem;
import mage.MageObject;
import mage.MageObjectReference;
@ -39,6 +37,9 @@ import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
import mage.util.Copyable;
import java.io.Serializable;
import java.util.*;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -84,6 +85,8 @@ public interface Player extends MageItem, Copyable<Player> {
int gainLife(int amount, Game game, UUID sourceId);
int damage(int damage, UUID sourceId, Game game);
int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable);
int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, List<UUID> appliedEffects);

View file

@ -1919,6 +1919,11 @@ public abstract class PlayerImpl implements Player, Serializable {
return 0;
}
@Override
public int damage(int damage, UUID sourceId, Game game) {
return doDamage(damage, sourceId, game, true, false, null);
}
@Override
public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable) {
return doDamage(damage, sourceId, game, combatDamage, preventable, null);
@ -2491,7 +2496,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override
public void lookAtAllLibraries(Ability source, Game game) {
for(UUID playerId : game.getState().getPlayersInRange(this.getId(), game)){
for (UUID playerId : game.getState().getPlayersInRange(this.getId(), game)) {
Player player = game.getPlayer(playerId);
String playerName = this.getName().equals(player.getName()) ? "Your " : player.getName() + "'s ";
playerName += "library";