public static void transform(Permanent permanent, Card sourceCard, Game game) { if (sourceCard == null) { return; } permanent.setName(sourceCard.getName()); permanent.getColor().setColor(sourceCard.getColor()); permanent.getManaCost().clear(); permanent.getManaCost().add(sourceCard.getManaCost()); permanent.getCardType().clear(); for (CardType type : sourceCard.getCardType()) { permanent.getCardType().add(type); } permanent.getSubtype().clear(); for (String type : sourceCard.getSubtype()) { permanent.getSubtype().add(type); } permanent.getSupertype().clear(); for (String type : sourceCard.getSupertype()) { permanent.getSupertype().add(type); } permanent.setExpansionSetCode(sourceCard.getExpansionSetCode()); permanent.getAbilities().clear(); for (Ability ability : sourceCard.getAbilities()) { permanent.addAbility(ability, game); } permanent.getPower().setValue(sourceCard.getPower().getValue()); permanent.getToughness().setValue(sourceCard.getToughness().getValue()); }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), game)) { if (permanent != null) { switch (layer) { case TypeChangingEffects_4: if (loseOther) { permanent.getSubtype().clear(); permanent.getSubtype().addAll(subtypes); } else { for (String subtype : subtypes) { if (!permanent.getSubtype().contains(subtype)) { permanent.getSubtype().add(subtype); } } } break; } } else { if (duration.equals(Duration.Custom)) { discard(); } } } return true; }
@Override public boolean apply(Game game, Ability source) { Card card = game.getCard(source.getFirstTarget()); Permanent permanent = game.getPermanent(source.getSourceId()); if (card == null || permanent == null) { return false; } card.moveToExile(null, "Dimir Doppelganger", source.getSourceId(), game); Card cardToCopy = card.copy(); cardToCopy.assignNewId(); permanent.setName(cardToCopy.getName()); permanent.getPower().setValue(cardToCopy.getPower().getValue()); permanent.getToughness().setValue(cardToCopy.getToughness().getValue()); permanent.getColor(game).setColor(cardToCopy.getColor(game)); permanent.getManaCost().clear(); permanent.getManaCost().add(cardToCopy.getManaCost()); permanent.getCardType().clear(); for (CardType type : cardToCopy.getCardType()) { if (!permanent.getCardType().contains(type)) { permanent.getCardType().add(type); } } permanent.getSubtype(game).clear(); for (String type : cardToCopy.getSubtype(game)) { if (!permanent.getSubtype(game).contains(type)) { permanent.getSubtype(game).add(type); } } permanent.getSupertype().clear(); for (String type : cardToCopy.getSupertype()) { if (!permanent.getSupertype().contains(type)) { permanent.getSupertype().add(type); } } permanent.removeAllAbilities(source.getSourceId(), game); // gains ability of Dimir Doppelganger Ability dimirDoppelgangerAbility = new SimpleActivatedAbility( Zone.BATTLEFIELD, new DimirDoppelgangerEffect(), new ManaCostsImpl("{1}{U}{B}")); dimirDoppelgangerAbility.addTarget( new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard"))); permanent.addAbility(dimirDoppelgangerAbility, source.getSourceId(), game); for (Ability ability : cardToCopy.getAbilities()) { if (!permanent.getAbilities().contains(ability)) { permanent.addAbility(ability, source.getSourceId(), game); } } return true; }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { if (permanent.getImprinted().size() > 0) { Card card = game.getCard(permanent.getImprinted().get(0)); if (card != null && card.getCardType().contains(CardType.CREATURE)) { switch (layer) { case TypeChangingEffects_4: if (sublayer == SubLayer.NA) { permanent.getSubtype().addAll(card.getSubtype()); } break; case PTChangingEffects_7: if (sublayer == SubLayer.SetPT_7b) { permanent.getPower().setValue(card.getPower().getValue()); permanent.getToughness().setValue(card.getToughness().getValue()); } } return true; } } } return false; }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { for (Permanent land : game.getState() .getBattlefield() .getAllActivePermanents(new FilterLandPermanent(), source.getControllerId(), game)) { if (land != null) { switch (layer) { case AbilityAddingRemovingEffects_6: Mana mana = new Mana(); for (Ability ability : land.getAbilities()) { if (ability instanceof BasicManaAbility) { for (Mana netMana : ((BasicManaAbility) ability).getNetMana(game)) { mana.add(netMana); } } } if (mana.getGreen() == 0 && landTypes.contains("Forest")) { land.addAbility(new GreenManaAbility(), source.getSourceId(), game); } if (mana.getRed() == 0 && landTypes.contains("Mountain")) { land.addAbility(new RedManaAbility(), source.getSourceId(), game); } if (mana.getBlue() == 0 && landTypes.contains("Island")) { land.addAbility(new BlueManaAbility(), source.getSourceId(), game); } if (mana.getWhite() == 0 && landTypes.contains("Plains")) { land.addAbility(new WhiteManaAbility(), source.getSourceId(), game); } if (mana.getBlack() == 0 && landTypes.contains("Swamp")) { land.addAbility(new BlackManaAbility(), source.getSourceId(), game); } break; case TypeChangingEffects_4: for (String subtype : landTypes) { if (!land.getSubtype().contains(subtype)) { land.getSubtype().add(subtype); } } break; } } } return true; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Permanent blocker = game.getPermanent(event.getSourceId()); Permanent blocked = game.getPermanent(event.getTargetId()); Permanent rockBasilisk = game.getPermanent(sourceId); if (blocker != null && blocker != rockBasilisk && !blocker.getSubtype().contains("Wall") && blocked == rockBasilisk) { this.getEffects().get(0).setTargetPointer(new FixedTarget(blocker.getId())); return true; } if (blocker != null && blocker == rockBasilisk && !blocked.getSubtype().contains("Wall")) { this.getEffects().get(0).setTargetPointer(new FixedTarget(blocked.getId())); return true; } return false; }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); if (permanent != null) { switch (layer) { case ControlChangingEffects_2: if (sublayer == SubLayer.NA) { permanent.changeControllerId(source.getControllerId(), game); } break; case TypeChangingEffects_4: if (sublayer == SubLayer.NA) { if (!permanent.getSubtype().contains("Vampire")) { permanent.getSubtype().add("Vampire"); } } break; } return true; } discard(); return false; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null) { LinkedList<UUID> attachments = new LinkedList(); attachments.addAll(permanent.getAttachments()); for (UUID uuid : attachments) { Permanent aura = game.getPermanent(uuid); if (aura != null && aura.getSubtype().contains("Aura")) { aura.destroy(source.getId(), game, false); } } } return false; }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (creature != null) { switch (layer) { case TypeChangingEffects_4: if (sublayer == SubLayer.NA) { creature.getSubtype().add("Nightmare"); } break; } return true; } else { this.used = true; } return false; }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { switch (layer) { case TypeChangingEffects_4: if (sublayer == SubLayer.NA) { permanent.getCardType().add(CardType.CREATURE); permanent.getSubtype().add("Construct"); } break; case PTChangingEffects_7: if (sublayer == SubLayer.SetPT_7b) { int xValue = source.getManaCostsToPay().getX(); if (xValue != 0) { permanent.getPower().setValue(xValue); permanent.getToughness().setValue(xValue); } } } return true; } return false; }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Player you = game.getPlayer(source.getControllerId()); List<Permanent> lands = game.getBattlefield() .getAllActivePermanents( new FilterControlledLandPermanent(), source.getControllerId(), game); String choice = (String) game.getState() .getValue(source.getSourceId().toString() + ChooseBasicLandTypeEffect.VALUE_KEY); if (you != null && choice != null) { for (Permanent land : lands) { if (land != null) { switch (layer) { case TypeChangingEffects_4: if (sublayer == SubLayer.NA && !land.getSubtype().contains(choice)) { land.getSubtype().add(choice); } break; case AbilityAddingRemovingEffects_6: if (sublayer == SubLayer.NA) { boolean addAbility = true; if (choice.equals("Forest")) { for (Ability existingAbility : land.getAbilities()) { if (existingAbility instanceof GreenManaAbility) { addAbility = false; break; } } if (addAbility) { land.addAbility(new GreenManaAbility(), source.getSourceId(), game); } } if (choice.equals("Plains")) { for (Ability existingAbility : land.getAbilities()) { if (existingAbility instanceof WhiteManaAbility) { addAbility = false; break; } } if (addAbility) { land.addAbility(new WhiteManaAbility(), source.getSourceId(), game); } } if (choice.equals("Mountain")) { for (Ability existingAbility : land.getAbilities()) { if (existingAbility instanceof RedManaAbility) { addAbility = false; break; } } if (addAbility) { land.addAbility(new RedManaAbility(), source.getSourceId(), game); } } if (choice.equals("Island")) { for (Ability existingAbility : land.getAbilities()) { if (existingAbility instanceof BlueManaAbility) { addAbility = false; break; } } if (addAbility) { land.addAbility(new BlueManaAbility(), source.getSourceId(), game); } } if (choice.equals("Swamp")) { for (Ability existingAbility : land.getAbilities()) { if (existingAbility instanceof BlackManaAbility) { addAbility = false; break; } } if (addAbility) { land.addAbility(new BlackManaAbility(), source.getSourceId(), game); } } } break; } } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); Permanent enchantment = game.getPermanent(source.getSourceId()); if (player == null || enchantment.getAttachedTo() == null) { return false; } Permanent creature = game.getPermanent(enchantment.getAttachedTo()); if (creature == null) { return false; } Cards cards = new CardsImpl(Zone.PICK); int count = Math.min(player.getLibrary().size(), 5); for (int i = 0; i < count; i++) { Card card = player.getLibrary().removeFromTop(game); if (card != null) { cards.add(card); game.setZone(card.getId(), Zone.PICK); } } player.lookAtCards("Call to the Kindred", cards, game); FilterCreatureCard filter = new FilterCreatureCard(); StringBuilder sb = new StringBuilder("creature card with at least one subtype from: "); ArrayList<Predicate<MageObject>> subtypes = new ArrayList<Predicate<MageObject>>(); for (String subtype : creature.getSubtype()) { subtypes.add(new SubtypePredicate(subtype)); sb.append(subtype).append(", "); } filter.add(Predicates.or(subtypes)); sb.delete(sb.length() - 2, sb.length()); filter.setMessage(sb.toString()); if (cards.count(filter, game) > 0 && player.chooseUse( Outcome.DrawCard, "Do you wish to put a creature card onto the battlefield?", source, game)) { TargetCard target = new TargetCard(Zone.PICK, filter); if (player.choose(Outcome.PutCreatureInPlay, cards, target, game)) { Card card = cards.get(target.getFirstTarget(), game); if (card != null) { cards.remove(card); card.putOntoBattlefield(game, Zone.PICK, source.getSourceId(), source.getControllerId()); } } } TargetCard target = new TargetCard(Zone.PICK, new FilterCard("card to put on the bottom of your library")); while (player.isInGame() && cards.size() > 1) { player.choose(Outcome.Neutral, cards, target, game); Card card = cards.get(target.getFirstTarget(), game); if (card != null) { cards.remove(card); card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); } target.clearChosen(); } if (cards.size() == 1) { Card card = cards.get(cards.iterator().next(), game); card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); } return true; }