[UNF] Implemented Clown Car

This commit is contained in:
Evan Kranzler 2022-09-23 21:38:10 -04:00
parent 8bad38a027
commit 6b66d10089
4 changed files with 128 additions and 0 deletions

View file

@ -0,0 +1,95 @@
package mage.cards.c;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.CrewAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.token.ClownRobotToken;
import mage.players.Player;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author TheElk801
*/
public final class ClownCar extends CardImpl {
public ClownCar(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{X}");
this.subtype.add(SubType.VEHICLE);
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// When Clown Car enters the battlefield, roll X sx-sided dice. For each odd result, create a 1/1 white Clown Robot artifact creature token. For each even result, put a +1/+1 on Clown Car.
this.addAbility(new EntersBattlefieldTriggeredAbility(new ClownCarEffect()));
// Crew 2
this.addAbility(new CrewAbility(2));
}
private ClownCar(final ClownCar card) {
super(card);
}
@Override
public ClownCar copy() {
return new ClownCar(this);
}
}
class ClownCarEffect extends OneShotEffect {
ClownCarEffect() {
super(Outcome.Benefit);
staticText = "roll X sx-sided dice. For each odd result, " +
"create a 1/1 white Clown Robot artifact creature token. " +
"For each even result, put a +1/+1 on {this}";
}
private ClownCarEffect(final ClownCarEffect effect) {
super(effect);
}
@Override
public ClownCarEffect copy() {
return new ClownCarEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
int xValue = ManacostVariableValue.ETB.calculate(game, source, this);
if (player == null || xValue < 1) {
return false;
}
Map<Integer, Integer> rollMap = player
.rollDice(outcome, source, game, 6, xValue, 0)
.stream()
.map(x -> x % 2)
.collect(Collectors.toMap(Function.identity(), x -> 1, Integer::sum));
int odds = rollMap.getOrDefault(1, 0);
if (odds > 0) {
new ClownRobotToken().putOntoBattlefield(odds, game, source);
}
int evens = rollMap.getOrDefault(0, 0);
if (evens > 0) {
Optional.ofNullable(source.getSourcePermanentIfItStillExists(game))
.ifPresent(permanent -> permanent.addCounters(CounterType.P1P1.createInstance(evens), source, game));
}
return true;
}
}

View file

@ -22,6 +22,7 @@ public final class Unfinity extends ExpansionSet {
cards.add(new SetCardInfo("Blood Crypt", 279, Rarity.RARE, mage.cards.b.BloodCrypt.class));
cards.add(new SetCardInfo("Breeding Pool", 286, Rarity.RARE, mage.cards.b.BreedingPool.class));
cards.add(new SetCardInfo("Clown Car", 186, Rarity.RARE, mage.cards.c.ClownCar.class));
cards.add(new SetCardInfo("Forest", 239, Rarity.LAND, mage.cards.basiclands.Forest.class, FULL_ART_BFZ_VARIOUS));
cards.add(new SetCardInfo("Godless Shrine", 282, Rarity.RARE, mage.cards.g.GodlessShrine.class));
cards.add(new SetCardInfo("Hallowed Fountain", 277, Rarity.RARE, mage.cards.h.HallowedFountain.class));

View file

@ -107,6 +107,7 @@ public enum SubType {
CITIZEN("Citizen", SubTypeSet.CreatureType),
CLAMFOLK("Clamfolk", SubTypeSet.CreatureType, true), // Unglued
CLERIC("Cleric", SubTypeSet.CreatureType),
CLOWN("Clown", SubTypeSet.CreatureType),
COCKATRICE("Cockatrice", SubTypeSet.CreatureType),
CONSTRUCT("Construct", SubTypeSet.CreatureType),
COW("Cow", SubTypeSet.CreatureType, true), // Unglued
@ -307,6 +308,7 @@ public enum SubType {
REFLECTION("Reflection", SubTypeSet.CreatureType),
RHINO("Rhino", SubTypeSet.CreatureType),
RIGGER("Rigger", SubTypeSet.CreatureType),
ROBOT("Robot", SubTypeSet.CreatureType),
RODIAN("Rodian", SubTypeSet.CreatureType, true), // Star Wars
ROGUE("Rogue", SubTypeSet.CreatureType),
// S

View file

@ -0,0 +1,30 @@
package mage.game.permanent.token;
import mage.MageInt;
import mage.constants.CardType;
import mage.constants.SubType;
/**
* @author TheElk801
*/
public final class ClownRobotToken extends TokenImpl {
public ClownRobotToken() {
super("Clown Robot Token", "1/1 white Clown Robot artifact creature token");
cardType.add(CardType.ARTIFACT);
cardType.add(CardType.CREATURE);
color.setWhite(true);
subtype.add(SubType.CLOWN);
subtype.add(SubType.ROBOT);
power = new MageInt(1);
toughness = new MageInt(1);
}
public ClownRobotToken(final ClownRobotToken token) {
super(token);
}
public ClownRobotToken copy() {
return new ClownRobotToken(this);
}
}