public static void logMissingWatcher(Game game, Ability source, Class watcherClass, Class usingClass) { MageObject sourceObject = source.getSourceObject(game); Logger.getLogger(usingClass).error("Needed watcher is not started " + watcherClass.getSimpleName() + " - " + (sourceObject == null ? " no source object" : sourceObject.getName())); } }
@Override public UUID getSourceId() { if (sourceObject != null) { return sourceObject.getId(); } return null; }
public static void setPermanentToFaceDownCreature(MageObject mageObject) { mageObject.getPower().modifyBaseValue(2); mageObject.getToughness().modifyBaseValue(2); mageObject.getAbilities().clear(); mageObject.getColor(null).setColor(new ObjectColor()); mageObject.setName(""); mageObject.getCardType().clear(); mageObject.addCardType(CardType.CREATURE); mageObject.getSubtype(null).clear(); mageObject.getSuperType().clear(); mageObject.getManaCost().clear(); if (mageObject instanceof Permanent) { ((Permanent) mageObject).setExpansionSetCode(""); ((Permanent) mageObject).setRarity(Rarity.SPECIAL); } } }
default boolean isHistoric() { return getCardType().contains(CardType.ARTIFACT) || getSuperType().contains(SuperType.LEGENDARY) || hasSubtype(SubType.SAGA, null); }
public static String getObjectZoneString(String text, MageObject mageObject, Game game) { int zoneChangeCounter = 0; if (mageObject instanceof Permanent) { zoneChangeCounter = mageObject.getZoneChangeCounter(game); } else if (mageObject instanceof Card) { zoneChangeCounter = mageObject.getZoneChangeCounter(game); } return getObjectZoneString(text, mageObject.getId(), game, zoneChangeCounter, false); }
@Override public boolean apply(Game game, MageObject mageObject, Ability source, UUID copyToObjectId) { if (!mageObject.hasSubtype(subtype, game)) { mageObject.getSubtype(game).add(subtype); } return true; }
@Override public boolean apply(MageObject input, Game game) { return input.getPower().getValue() != input.getToughness().getValue(); }
@Override public boolean apply(MageObject input, Game game) { return input.getCardType().contains(cardType); }
default boolean shareSubtypes(Card otherCard, Game game) { if (otherCard == null) { throw new IllegalArgumentException("Params can't be null"); } if (this.isCreature() && otherCard.isCreature()) { if (this.getAbilities().contains(ChangelingAbility.getInstance()) || this.isAllCreatureTypes() || otherCard.getAbilities().contains(ChangelingAbility.getInstance()) || otherCard.isAllCreatureTypes()) { return true; } } for (SubType subtype : this.getSubtype(game)) { if (otherCard.hasSubtype(subtype, game)) { return true; } } return false; }
private String getRelatedObjectName(UUID sourceId, Game game) { MageObject mageObject = game.getObject(sourceId); if (mageObject != null) { return mageObject.getLogName(); } return null; }
@Override public boolean apply(Game game, MageObject mageObject, Ability source, UUID copyToObjectId) { if (!mageObject.hasSubtype(SubType.ILLUSION, game)) { mageObject.getSubtype(game).add(SubType.ILLUSION); } // Add directly because the created permanent is only used to copy from, so there is no need to add the ability to e.g. TriggeredAbilities mageObject.getAbilities().add(new BecomesTargetTriggeredAbility(new SacrificeSourceEffect())); //permanent.addAbility(new BecomesTargetTriggeredAbility(new SacrificeSourceEffect()), game); return true; } };
@Override public boolean applies(GameEvent event, Ability source, Game game) { MageObject object = game.getObject(event.getSourceId()); // fixes issue #1072 return object != null && !object.isCopy() && object.getName().equals(game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY)); }
@Override public boolean apply(Game game, MageObject mageObject, Ability source, UUID copyToObjectId) { mageObject.getAbilities().add(ability); return true; }
@Override public boolean apply(Game game, MageObject mageObject, Ability source, UUID copyToObjectId) { mageObject.removePTCDA(); mageObject.getPower().modifyBaseValue(7); mageObject.getToughness().modifyBaseValue(7); return true; }
@Override public boolean apply(MageObject input, Game game) { // 708.3. Each split card that consists of two halves with different colored mana symbols in their mana costs // is a multicolored card while it's not a spell on the stack. While it's a spell on the stack, it's only the // color or colors of the half or halves being cast. # if (input instanceof SplitCardHalf && game.getState().getZone(input.getId()) != Zone.STACK) { return 1 < ((SplitCardHalf) input).getMainCard().getColor(game).getColorCount(); } else { return 1 < input.getColor(game).getColorCount(); } }
@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent bestowPermanent = game.getPermanentEntering(source.getSourceId()); if (bestowPermanent != null) { if (bestowPermanent.hasSubtype(SubType.AURA, game)) { MageObject basicObject = bestowPermanent.getBasicMageObject(game); if (basicObject != null && !basicObject.getSubtype(null).contains(SubType.AURA)) { basicObject.getSubtype(null).add(SubType.AURA); basicObject.getCardType().remove(CardType.CREATURE); } } } return false; }
@Override public boolean cantBeAttachedBy(MageObject source, Game game) { for (ProtectionAbility ability : this.getAbilities(game).getProtectionAbilities()) { if (!(source.hasSubtype(SubType.AURA, game) && !ability.removesAuras()) && !source.getId().equals(ability.getAuraIdNotToBeRemoved()) && !ability.canTarget(source, game)) { return true; } } return game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.STAY_ATTACHED, objectId, source.getId(), null), null, game, false); }
static public void becomeCreature(Permanent permanent, Game game) { if (permanent != null) { MageObject basicObject = permanent.getBasicMageObject(game); if (basicObject != null) { basicObject.getSubtype(null).remove(SubType.AURA); if (!basicObject.isCreature()) { basicObject.addCardType(CardType.CREATURE); } } permanent.getSubtype(null).remove(SubType.AURA); if (!permanent.isCreature()) { permanent.addCardType(CardType.CREATURE); } } } }
@Override public boolean checkTrigger(GameEvent event, Game game) { return event.getPlayerId().equals(this.getControllerId()) && game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD).isCreature() && game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD).getColor(game).isBlack(); }