mirror of
https://github.com/correl/mage.git
synced 2025-04-05 01:09:06 -09:00
[MH2] Implemented Caprichrome
This commit is contained in:
parent
c63c00be3b
commit
2c7a04b346
3 changed files with 113 additions and 43 deletions
Mage.Sets/src/mage
Mage/src/main/java/mage/abilities/effects/common
45
Mage.Sets/src/mage/cards/c/Caprichrome.java
Normal file
45
Mage.Sets/src/mage/cards/c/Caprichrome.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.effects.common.DevourEffect;
|
||||
import mage.abilities.keyword.DevourAbility;
|
||||
import mage.abilities.keyword.FlashAbility;
|
||||
import mage.abilities.keyword.VigilanceAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class Caprichrome extends CardImpl {
|
||||
|
||||
public Caprichrome(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}{W}");
|
||||
|
||||
this.subtype.add(SubType.GOAT);
|
||||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(2);
|
||||
|
||||
// Flash
|
||||
this.addAbility(FlashAbility.getInstance());
|
||||
|
||||
// Vigilance
|
||||
this.addAbility(VigilanceAbility.getInstance());
|
||||
|
||||
// Devour artifact 1
|
||||
this.addAbility(new DevourAbility(DevourEffect.DevourFactor.DevourArtifact1));
|
||||
}
|
||||
|
||||
private Caprichrome(final Caprichrome card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Caprichrome copy() {
|
||||
return new Caprichrome(this);
|
||||
}
|
||||
}
|
|
@ -68,6 +68,7 @@ public final class ModernHorizons2 extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Cabal Coffers", 301, Rarity.MYTHIC, mage.cards.c.CabalCoffers.class));
|
||||
cards.add(new SetCardInfo("Cabal Initiate", 78, Rarity.COMMON, mage.cards.c.CabalInitiate.class));
|
||||
cards.add(new SetCardInfo("Calibrated Blast", 118, Rarity.RARE, mage.cards.c.CalibratedBlast.class));
|
||||
cards.add(new SetCardInfo("Caprichrome", 9, Rarity.UNCOMMON, mage.cards.c.Caprichrome.class));
|
||||
cards.add(new SetCardInfo("Captain Ripley Vance", 119, Rarity.UNCOMMON, mage.cards.c.CaptainRipleyVance.class));
|
||||
cards.add(new SetCardInfo("Captured by Lagacs", 188, Rarity.COMMON, mage.cards.c.CapturedByLagacs.class));
|
||||
cards.add(new SetCardInfo("Chainer, Nightmare Adept", 289, Rarity.RARE, mage.cards.c.ChainerNightmareAdept.class));
|
||||
|
|
|
@ -3,10 +3,11 @@ package mage.abilities.effects.common;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.mageobject.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.EntersTheBattlefieldEvent;
|
||||
|
@ -14,7 +15,7 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -35,12 +36,6 @@ import java.util.UUID;
|
|||
*/
|
||||
public class DevourEffect extends ReplacementEffectImpl {
|
||||
|
||||
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creatures to devour");
|
||||
|
||||
static {
|
||||
filter.add(AnotherPredicate.instance);
|
||||
}
|
||||
|
||||
private final DevourFactor devourFactor;
|
||||
|
||||
public DevourEffect(DevourFactor devourFactor) {
|
||||
|
@ -77,49 +72,54 @@ public class DevourEffect extends ReplacementEffectImpl {
|
|||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (creature != null && controller != null) {
|
||||
Target target = new TargetControlledCreaturePermanent(1, Integer.MAX_VALUE, filter, true);
|
||||
target.setRequired(false);
|
||||
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
|
||||
return false;
|
||||
}
|
||||
if (controller.chooseUse(Outcome.Detriment, "Devour creatures?", source, game)) {
|
||||
controller.chooseTarget(Outcome.Detriment, target, source, game);
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
List<Permanent> creaturesDevoured = new ArrayList<>();
|
||||
int devouredCreatures = 0;
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Permanent targetCreature = game.getPermanent(targetId);
|
||||
if (targetCreature != null && targetCreature.sacrifice(source, game)) {
|
||||
creaturesDevoured.add(targetCreature);
|
||||
devouredCreatures++;
|
||||
}
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(creature.getLogName() + " devours " + devouredCreatures + " creatures");
|
||||
}
|
||||
game.getState().processAction(game); // need for multistep effects
|
||||
|
||||
int amountCounters;
|
||||
if (devourFactor == DevourFactor.DevourX) {
|
||||
amountCounters = devouredCreatures * devouredCreatures;
|
||||
} else {
|
||||
amountCounters = devouredCreatures * devourFactor.getFactor();
|
||||
}
|
||||
creature.addCounters(CounterType.P1P1.createInstance(amountCounters), source.getControllerId(), source, game);
|
||||
game.getState().setValue(creature.getId().toString() + "devoured", creaturesDevoured);
|
||||
}
|
||||
|
||||
if (creature == null || controller == null) {
|
||||
return false;
|
||||
}
|
||||
Target target = new TargetControlledPermanent(1, Integer.MAX_VALUE, devourFactor.getFilter(), true);
|
||||
target.setRequired(false);
|
||||
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
|
||||
return false;
|
||||
}
|
||||
if (!controller.chooseUse(Outcome.Detriment, "Devour " + devourFactor.getCardType().toString().toLowerCase() + "s?", source, game)) {
|
||||
return false;
|
||||
}
|
||||
controller.chooseTarget(Outcome.Detriment, target, source, game);
|
||||
if (target.getTargets().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
List<Permanent> creaturesDevoured = new ArrayList<>();
|
||||
int devouredCreatures = 0;
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Permanent targetCreature = game.getPermanent(targetId);
|
||||
if (targetCreature != null && targetCreature.sacrifice(source, game)) {
|
||||
creaturesDevoured.add(targetCreature);
|
||||
devouredCreatures++;
|
||||
}
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(creature.getLogName() + " devours " + devouredCreatures + " " + devourFactor.getCardType().toString().toLowerCase() + "s");
|
||||
}
|
||||
game.getState().processAction(game); // need for multistep effects
|
||||
|
||||
int amountCounters;
|
||||
if (devourFactor == DevourFactor.DevourX) {
|
||||
amountCounters = devouredCreatures * devouredCreatures;
|
||||
} else {
|
||||
amountCounters = devouredCreatures * devourFactor.getFactor();
|
||||
}
|
||||
creature.addCounters(CounterType.P1P1.createInstance(amountCounters), source.getControllerId(), source, game);
|
||||
game.getState().setValue(creature.getId().toString() + "devoured", creaturesDevoured);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
StringBuilder sb = new StringBuilder(devourFactor.toString());
|
||||
sb.append(" <i>(As this enters the battlefield, you may sacrifice any number of creatures. This creature enters the battlefield with ");
|
||||
sb.append(devourFactor.getRuleText()).append(")</i>");
|
||||
sb.append(" <i>(As this enters the battlefield, you may sacrifice any number of ");
|
||||
sb.append(devourFactor.getCardType());
|
||||
sb.append("s. This creature enters the battlefield with ");
|
||||
sb.append(devourFactor.getRuleText());
|
||||
sb.append(")</i>");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
@ -149,16 +149,25 @@ public class DevourEffect extends ReplacementEffectImpl {
|
|||
Devour1("Devour 1", "that many +1/+1 counters on it", 1),
|
||||
Devour2("Devour 2", "twice that many +1/+1 counters on it", 2),
|
||||
Devour3("Devour 3", "three times that many +1/+1 counters on it", 3),
|
||||
DevourArtifact1("Devour artifact 1", "that many +1/+1 counters on it", 1, CardType.ARTIFACT),
|
||||
DevourX("Devour X, where X is the number of creatures devoured this way", "X +1/+1 counters on it for each of those creatures", Integer.MAX_VALUE);
|
||||
|
||||
private final String text;
|
||||
private final String ruleText;
|
||||
private final int factor;
|
||||
private final CardType cardType;
|
||||
private final FilterControlledPermanent filter;
|
||||
|
||||
DevourFactor(String text, String ruleText, int factor) {
|
||||
this(text, ruleText, factor, CardType.CREATURE);
|
||||
}
|
||||
|
||||
DevourFactor(String text, String ruleText, int factor, CardType cardType) {
|
||||
this.text = text;
|
||||
this.ruleText = ruleText;
|
||||
this.factor = factor;
|
||||
this.cardType = cardType;
|
||||
this.filter = makeFilter(cardType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -173,5 +182,20 @@ public class DevourEffect extends ReplacementEffectImpl {
|
|||
public int getFactor() {
|
||||
return factor;
|
||||
}
|
||||
|
||||
public CardType getCardType() {
|
||||
return cardType;
|
||||
}
|
||||
|
||||
public FilterControlledPermanent getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
private static final FilterControlledPermanent makeFilter(CardType cardType) {
|
||||
FilterControlledPermanent filter = new FilterControlledPermanent(cardType.toString().toLowerCase() + "s to devour");
|
||||
filter.add(cardType.getPredicate());
|
||||
filter.add(AnotherPredicate.instance);
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue