public TrevasCharm(UUID ownerId) { super( ownerId, 129, "Treva's Charm", Rarity.UNCOMMON, new CardType[] {CardType.INSTANT}, "{G}{W}{U}"); this.expansionSetCode = "PLS"; // Choose one - Destroy target enchantment; this.getSpellAbility().addEffect(new DestroyTargetEffect()); this.getSpellAbility().addTarget(new TargetEnchantmentPermanent()); // or exile target attacking creature; Mode mode = new Mode(); mode.getEffects().add(new ExileTargetEffect()); mode.getTargets().add(new TargetAttackingCreature()); this.getSpellAbility().addMode(mode); // or draw a card, then discard a card. mode = new Mode(); mode.getEffects().add(new DrawDiscardControllerEffect()); this.getSpellAbility().addMode(mode); }
public CrosissCharm(UUID ownerId) { super( ownerId, 181, "Crosis's Charm", Rarity.UNCOMMON, new CardType[] {CardType.INSTANT}, "{U}{B}{R}"); this.expansionSetCode = "C13"; // Choose one - Return target permanent to its owner's hand; this.getSpellAbility().addEffect(new ReturnToHandTargetEffect()); this.getSpellAbility().addTarget(new TargetPermanent()); // or destroy target nonblack creature, and it can't be regenerated; Mode mode = new Mode(); mode.getEffects().add(new DestroyTargetEffect(true)); mode.getTargets().add(new TargetCreaturePermanent(filter)); this.getSpellAbility().addMode(mode); // or destroy target artifact. mode = new Mode(); mode.getEffects().add(new DestroyTargetEffect(true)); Target target = new TargetArtifactPermanent(); mode.getTargets().add(target); this.getSpellAbility().addMode(mode); }
public AustereCommand(UUID ownerId) { super( ownerId, 8, "Austere Command", Rarity.RARE, new CardType[] {CardType.SORCERY}, "{4}{W}{W}"); this.expansionSetCode = "CMD"; this.color.setWhite(true); // Choose two - this.getSpellAbility().getModes().setMinModes(2); this.getSpellAbility().getModes().setMaxModes(2); // Destroy all artifacts; this.getSpellAbility() .addEffect(new DestroyAllEffect(new FilterArtifactPermanent("artifacts"))); // or destroy all enchantments; Mode mode = new Mode(); mode.getEffects().add(new DestroyAllEffect(new FilterEnchantmentPermanent("enchantments"))); this.getSpellAbility().getModes().addMode(mode); // or destroy all creatures with converted mana cost 3 or less; mode = new Mode(); mode.getEffects().add(new DestroyAllEffect(filter3orLess)); this.getSpellAbility().getModes().addMode(mode); // or destroy all creatures with converted mana cost 4 or greater. mode = new Mode(); mode.getEffects().add(new DestroyAllEffect(filter4orMore)); this.getSpellAbility().getModes().addMode(mode); }
@Override public String getText(Mode mode) { if (staticText != null && !staticText.isEmpty()) { return staticText; } StringBuilder sb = new StringBuilder(); if (mode.getTargets().size() > 0) { sb.append("Target ").append(mode.getTargets().get(0).getTargetName()); } else { sb.append("that player"); } if (optional) { sb.append(" may draw "); } else { sb.append(" draws "); } if (upTo) { sb.append("up to "); } sb.append(CardUtil.numberToText(amount.toString())).append(" card"); try { if (Integer.parseInt(amount.toString()) > 1) { sb.append("s"); } } catch (Exception e) { sb.append("s"); } String message = amount.getMessage(); if (message.length() > 0) { sb.append(" for each "); } sb.append(message); return sb.toString(); }
@Override public String getText(Mode mode) { if (mode.getTargets().isEmpty()) { return "Exile it"; } else { return "Exile target " + mode.getTargets().get(0).getTargetName(); } }
public SteelSabotage(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[] {CardType.INSTANT}, "{U}"); // Choose one - Counter target artifact spell; or return target artifact to its owner's hand. this.getSpellAbility().addEffect(new CounterTargetEffect()); this.getSpellAbility().addTarget(new TargetSpell(new FilterArtifactSpell())); Mode mode = new Mode(); mode.getEffects().add(new ReturnToHandTargetEffect()); mode.getTargets().add(new TargetArtifactPermanent()); this.getSpellAbility().addMode(mode); }
public FeastOrFamine(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[] {CardType.INSTANT}, "{3}{B}"); // Choose one - Create a 2/2 black Zombie creature token; this.getSpellAbility().addEffect(new CreateTokenEffect(new ZombieToken())); // or destroy target nonartifact, nonblack creature and it can't be regenerated. Mode mode = new Mode(); mode.getEffects().add(new DestroyTargetEffect(true)); mode.getTargets().add(new TargetCreaturePermanent(filter)); this.getSpellAbility().addMode(mode); }
public void addAbility(Ability ability, UUID sourceId, MageObject attachedTo) { if (ability instanceof StaticAbility) { for (Mode mode : ability.getModes().values()) { for (Effect effect : mode.getEffects()) { if (effect instanceof ContinuousEffect) { addEffect((ContinuousEffect) effect, sourceId, ability); } } } } else if (ability instanceof TriggeredAbility) { // TODO: add sources for triggers - the same way as in addEffect: sources this.triggers.add((TriggeredAbility) ability, sourceId, attachedTo); } }
@Deprecated public void addAbility(Ability ability, MageObject attachedTo) { if (ability instanceof StaticAbility) { for (Mode mode : ability.getModes().values()) { for (Effect effect : mode.getEffects()) { if (effect instanceof ContinuousEffect) { addEffect((ContinuousEffect) effect, ability); } } } } else if (ability instanceof TriggeredAbility) { this.triggers.add((TriggeredAbility) ability, attachedTo); } }
public Vandalize(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[] {CardType.SORCERY}, "{4}{R}"); // Choose one or both - Destroy target artifact; or Destroy target land. this.getSpellAbility().getModes().setMinModes(1); this.getSpellAbility().getModes().setMaxModes(2); this.getSpellAbility().addTarget(new TargetArtifactPermanent()); this.getSpellAbility().addEffect(new DestroyTargetEffect()); Mode mode1 = new Mode(); mode1.getTargets().add(new TargetLandPermanent()); mode1.getEffects().add(new DestroyTargetEffect()); this.getSpellAbility().addMode(mode1); }
@Override public String getText(Mode mode) { return "Gain control of target " + mode.getTargets().get(0).getTargetName() + " " + duration.toString(); }
@Override public String getText(Mode mode) { if (staticText != null && !staticText.isEmpty()) { return staticText; } StringBuilder sb = new StringBuilder(); if (mode.getTargets().size() > 0) { sb.append("target "); sb.append(mode.getTargets().get(0).getMessage()); sb.append(" becomes the color or colors of your choice"); if (duration.toString().length() > 0) { sb.append(" ").append(duration.toString()); } } return sb.toString(); }
@Override public String getText(Mode mode) { StringBuilder sb = new StringBuilder(); sb.append("{source} deals ").append(amount.toString()); sb.append(" damage divided as you choose among any number of target ") .append(mode.getTargets().get(0).getTargetName()); return sb.toString(); }
public DawnCharm(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[] {CardType.INSTANT}, "{1}{W}"); // Choose one - Prevent all combat damage that would be dealt this turn this.getSpellAbility() .addEffect(new PreventAllDamageByAllPermanentsEffect(Duration.EndOfTurn, true)); // or regenerate target creature; Mode mode = new Mode(); mode.getEffects().add(new RegenerateTargetEffect()); mode.getTargets().add(new TargetCreaturePermanent()); this.getSpellAbility().addMode(mode); // or counter target spell that targets you. mode = new Mode(); mode.getEffects().add(new CounterTargetEffect()); mode.getTargets().add(new TargetSpell(filter)); this.getSpellAbility().addMode(mode); }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify instanceof SpellAbility) { if (source.getControllerId().equals(abilityToModify.getControllerId())) { for (UUID modeId : abilityToModify.getModes().getSelectedModes()) { Mode mode = abilityToModify.getModes().get(modeId); for (Target target : mode.getTargets()) { for (UUID targetUUID : target.getTargets()) { Permanent enchantment = game.getPermanent(source.getSourceId()); UUID attachedTo = enchantment.getAttachedTo(); if (targetUUID.equals(attachedTo)) { return true; } } } } } } return false; }
@Override public String getText(Mode mode) { if (staticText != null && !staticText.isEmpty()) { return staticText; } StringBuilder sb = new StringBuilder(); sb.append("copy target ") .append(mode.getTargets().get(0).getTargetName()) .append(". You may choose new targets for the copy"); return sb.toString(); }
public RainOfRust(UUID ownerId) { super( ownerId, 76, "Rain of Rust", Rarity.COMMON, new CardType[] {CardType.INSTANT}, "{3}{R}{R}"); this.expansionSetCode = "5DN"; this.color.setRed(true); // Choose one - this.getSpellAbility().getModes().setMinModes(1); this.getSpellAbility().getModes().setMaxModes(1); // Destroy target artifact; this.getSpellAbility().addEffect(new DestroyTargetEffect()); this.getSpellAbility().addTarget(new TargetArtifactPermanent()); // or destroy target land. Mode mode = new Mode(); mode.getEffects().add(new DestroyTargetEffect()); mode.getTargets().add(new TargetLandPermanent()); this.getSpellAbility().getModes().addMode(mode); // Entwine {3}{R} this.addAbility(new EntwineAbility("{3}{R}")); }
public UlashtTheHateSeed(UUID ownerId) { super( ownerId, 136, "Ulasht, the Hate Seed", Rarity.RARE, new CardType[] {CardType.CREATURE}, "{2}{R}{G}"); this.expansionSetCode = "GPT"; this.supertype.add("Legendary"); this.subtype.add("Hellion"); this.subtype.add("Hydra"); this.color.setGreen(true); this.color.setRed(true); this.power = new MageInt(0); this.toughness = new MageInt(0); // Ulasht, the Hate Seed enters the battlefield with a +1/+1 counter on it for each other red // creature you control and a +1/+1 counter on it for each other green creature you control. this.addAbility( new EntersBattlefieldAbility( new UlashtTheHateSeedEffect(), "with a +1/+1 counter on it for each other red creature you control and a +1/+1 counter on it for each other green creature you control.")); // {1}, Remove a +1/+1 counter from Ulasht: Choose one - Ulasht deals 1 damage to target // creature; Ability ability = new SimpleActivatedAbility( Zone.BATTLEFIELD, new DamageTargetEffect(1), new GenericManaCost(1)); ability.addCost(new RemoveCountersSourceCost(CounterType.P1P1.createInstance())); ability.addTarget(new TargetCreaturePermanent()); // or put a 1/1 green Saproling creature token onto the battlefield. Mode mode = new Mode(); Effect effect = new CreateTokenEffect(new SaprolingToken()); effect.setText("Put a 1/1 green Saproling creature token onto the battlefield."); mode.getEffects().add(effect); ability.addMode(mode); this.addAbility(ability); }
@Override public String getText(Mode mode) { if (this.staticText != null && !this.staticText.isEmpty()) { return staticText; } StringBuilder sb = new StringBuilder(); Target target = mode.getTargets().get(0); sb.append("Put "); if (target.getMaxNumberOfTargets() == 0) { sb.append("any number of "); } else { if (target.getMaxNumberOfTargets() != 1 || target.getNumberOfTargets() != 1) { if (target.getMaxNumberOfTargets() > target.getNumberOfTargets()) { sb.append("up to "); } sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" "); } } sb.append("target ").append(mode.getTargets().get(0).getTargetName()).append(" on "); sb.append(onTop ? "top" : "the bottom").append(" of its owner's library"); return sb.toString(); }
private void updateTargets(Game game, StackAbility ability) { List<String> names = new ArrayList<>(); for (Mode mode : ability.getModes().getSelectedModes()) { if (mode.getTargets().size() > 0) { setTargets(mode.getTargets()); } else { List<UUID> targetList = new ArrayList<>(); for (Effect effect : mode.getEffects()) { TargetPointer targetPointer = effect.getTargetPointer(); if (targetPointer instanceof FixedTarget) { targetList.add(((FixedTarget) targetPointer).getTarget()); } } if (targetList.size() > 0) { overrideTargets(targetList); for (UUID uuid : targetList) { MageObject mageObject = game.getObject(uuid); if (mageObject != null) { if ((mageObject instanceof Card) && ((Card) mageObject).isFaceDown(game)) { continue; } names.add(GameLog.getColoredObjectIdNameForTooltip(mageObject)); } } } } } if (!names.isEmpty()) { getRules().add("<i>Related objects: " + names.toString() + "</i>"); } // show for modal ability, which mode was choosen if (ability.isModal()) { Modes modes = ability.getModes(); for (Mode mode : modes.getSelectedModes()) { this.rules.add( "<span color='green'><i>Chosen mode: " + mode.getEffects().getText(mode) + "</i></span>"); } } }
public String getValue(boolean useHidden, Game game) { StringBuilder sb = new StringBuilder(1024); sb.append(turnNum) .append(turn.getPhaseType()) .append(turn.getStepType()) .append(activePlayerId) .append(priorityPlayerId); for (Player player : players.values()) { sb.append("player").append(player.isPassed()).append(player.getLife()).append("hand"); if (useHidden) { sb.append(player.getHand()); } else { sb.append(player.getHand().size()); } sb.append("library").append(player.getLibrary().size()); sb.append("graveyard"); for (Card card : player.getGraveyard().getCards(game)) { sb.append(card.getName()); } } sb.append("permanents"); List<String> perms = new ArrayList<String>(); for (Permanent permanent : battlefield.getAllPermanents()) { perms.add(permanent.getValue()); } Collections.sort(perms); sb.append(perms); sb.append("spells"); for (StackObject spell : stack) { sb.append(spell.getControllerId()).append(spell.getName()); sb.append(spell.getStackAbility().toString()); for (Mode mode : spell.getStackAbility().getModes().values()) { if (!mode.getTargets().isEmpty()) { sb.append("targets"); for (Target target : mode.getTargets()) { sb.append(target.getTargets()); } } if (!mode.getChoices().isEmpty()) { sb.append("choices"); for (Choice choice : mode.getChoices()) { sb.append(choice.getChoice()); } } } } for (ExileZone zone : exile.getExileZones()) { sb.append("exile").append(zone.getName()).append(zone); } sb.append("combat"); for (CombatGroup group : combat.getGroups()) { sb.append(group.getDefenderId()).append(group.getAttackers()).append(group.getBlockers()); } return sb.toString(); }