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(Game game, Permanent permanent) { if (!permanent.getCardType().contains(cardType)) { permanent.getCardType().add(cardType); } return true; }
@Override public boolean apply(Game game, Ability source) { Permanent creature1 = game.getPermanent(source.getSourceId()); Permanent creature2 = game.getPermanent(source.getFirstTarget()); // 20110930 - 701.10 if (creature1 != null && creature2 != null) { if (creature1.getCardType().contains(CardType.CREATURE) && creature2.getCardType().contains(CardType.CREATURE)) { return creature1.fight(creature2, source, game); } } return false; }
@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(Game game, Ability source) { Permanent creature1 = game.getPermanent(source.getSourceId()); Permanent creature2 = game.getPermanent(source.getFirstTarget()); // 20110930 - 701.10 if (creature1 != null && creature2 != null) { if (creature1.getCardType().contains(CardType.CREATURE) && creature2.getCardType().contains(CardType.CREATURE)) { creature1.damage(creature2.getPower().getValue(), creature2.getId(), game, true, false); creature2.damage(creature1.getPower().getValue(), creature1.getId(), game, true, false); return true; } } return false; }
@Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { switch (layer) { case TypeChangingEffects_4: if (sublayer == SubLayer.NA) { affectedObjectList.clear(); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) { if (permanent != null) { affectedObjectList.add(new MageObjectReference(permanent, game)); permanent.getCardType().add(CardType.CREATURE); } } } break; case PTChangingEffects_7: if (sublayer == SubLayer.SetPT_7b) { for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) { Permanent permanent = it.next().getPermanent(game); if (permanent != null) { int manaCost = permanent.getConvertedManaCost(); permanent.getPower().setValue(manaCost); permanent.getToughness().setValue(manaCost); } } } } return true; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.TAPPED) { Permanent p = game.getPermanent(event.getTargetId()); if (p != null && p.getCardType().contains(CardType.CREATURE)) { if (game.getOpponents(this.controllerId).contains(p.getControllerId())) return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { for (Permanent permanent : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) { if (permanent != null && permanent.getCardType().contains(CardType.ARTIFACT) && permanent.getManaCost().convertedManaCost() <= source.getManaCostsToPay().getX()) { permanent.destroy(source.getSourceId(), game, false); } } return true; }
@Override public void watch(GameEvent event, Game game) { if (condition == true) { // no need to check - condition has already occured return; } if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent.getCardType().contains(CardType.LAND) && permanent.getControllerId().equals(this.controllerId)) { condition = true; } } }
@Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) { Permanent card = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); if (card != null && card.getOwnerId().equals(this.controllerId) && card.getCardType().contains(CardType.CREATURE) && !(card instanceof PermanentToken)) { creaturesCount++; } } }
@Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { Permanent perm = game.getPermanent(event.getTargetId()); if (perm.getCardType().contains(CardType.LAND)) { Integer amount = amountOfLandsPlayedThisTurn.get(perm.getControllerId()); if (amount == null) { amount = Integer.valueOf(1); } else { ++amount; } amountOfLandsPlayedThisTurn.put(perm.getControllerId(), amount); } } }
@Override public boolean apply(Game game, Ability source) { for (UUID permanentId : game.getBattlefield().getAllPermanentIds()) { Permanent p = game.getPermanent(permanentId); if (p != null && p.getCardType().contains(CardType.CREATURE)) { p.damage(1, source.getSourceId(), game, false, true); } } for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player p = game.getPlayer(playerId); if (p != null) { p.damage(1, source.getSourceId(), game, false, true); } } return true; }
@Override public void watch(GameEvent event, Game game) { if (condition == true) { // no need to check - condition has already occured return; } Player player = game.getPlayer(controllerId); if (player != null && event.getType() == EventType.DESTROYED_PERMANENT) { Permanent perm = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); if (perm != null && !perm.getCardType().contains(CardType.CREATURE)) { if (game.getStack().size() > 0) { StackObject spell = game.getStack().getStackObject(event.getSourceId()); if (spell != null && game.getOpponents(controllerId).contains(spell.getControllerId())) { condition = true; } } } } }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { if (!event.getTargetId().equals(this.getSourceId())) { Permanent triggeringCreature = game.getPermanent(event.getTargetId()); if (triggeringCreature != null && triggeringCreature.getCardType().contains(CardType.CREATURE) && triggeringCreature.getControllerId().equals(this.controllerId)) { Permanent sourceCreature = game.getPermanent(sourceId); if (sourceCreature != null && isPowerOrThoughnessGreater(sourceCreature, triggeringCreature)) { this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getTargetId())); return true; } } } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD && ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) { Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); if (permanent != null && permanent.getControllerId().equals(this.getControllerId()) && permanent.getCardType().contains(CardType.CREATURE)) { this.getTargets().clear(); this.addTarget(new TargetControlledCreaturePermanent()); this.getEffects().clear(); this.addEffect( new AddCountersTargetEffect( CounterType.P1P1.createInstance(permanent.getPower().getValue()))); return true; } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.ZONE_CHANGE) { ZoneChangeEvent zEvent = (ZoneChangeEvent) event; if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) { Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); if (permanent != null) { if (permanent.getId().equals(this.getSourceId())) { return true; } else { if (permanent.getCardType().contains(CardType.CREATURE)) { return true; } } } } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent.getCardType().contains(CardType.CREATURE) && (permanent.getControllerId().equals(this.controllerId))) { if (!this.getTargets().isEmpty()) { // remove previous target if (this.getTargets().get(0).getTargets().size() > 0) { this.getTargets().clear(); this.addTarget(new TargetCreaturePermanent()); } Target target = this.getTargets().get(0); if (target instanceof TargetCreaturePermanent) { target.add(event.getTargetId(), game); } } return 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; }