@Override public EnumSet<CardType> getCardType() { return sourceObject.getCardType(); }
private boolean sharesType(Card card, EnumSet<CardType> cardTypes) { for (CardType type : card.getCardType()) { if (cardTypes.contains(type)) { return true; } } return false; }
@Override public EnumSet<CardType> getCardType() { if (faceDown) { EnumSet<CardType> cardTypes = EnumSet.noneOf(CardType.class); cardTypes.add(CardType.CREATURE); return cardTypes; } if (this.getSpellAbility() instanceof BestowAbility) { EnumSet<CardType> cardTypes = EnumSet.noneOf(CardType.class); cardTypes.addAll(card.getCardType()); cardTypes.remove(CardType.CREATURE); return cardTypes; } return card.getCardType(); }
/** * Checks whether two cards share card types. * * @param otherCard * @return */ default boolean shareTypes(Card otherCard) { if (otherCard == null) { throw new IllegalArgumentException("Params can't be null"); } for (CardType type : getCardType()) { if (otherCard.getCardType().contains(type)) { return true; } } return false; }
public GraftAbility(Card card, int amount) { super(Zone.BATTLEFIELD, new GraftDistributeCounterEffect(), true); this.amount = amount; StringBuilder sb = new StringBuilder(); for (CardType theCardtype : card.getCardType()) { sb.append(theCardtype.toString().toLowerCase(Locale.ENGLISH)).append(' '); } this.cardtype = sb.toString().trim(); addSubAbility(new GraftStaticAbility(amount)); }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { EnumSet<CardType> foundCardTypes = EnumSet.noneOf(CardType.class); for (Card card : controller.getGraveyard().getCards(game)) { foundCardTypes.addAll(card.getCardType()); } return foundCardTypes.size() >= 4; } return false; }
private static String getCardTypeLine(Game game, Card card) { StringBuilder sbType = new StringBuilder(); for (SuperType superType : card.getSuperType()) { sbType.append(superType).append(' '); } for (CardType cardType : card.getCardType()) { sbType.append(cardType.toString()).append(' '); } if (!card.getSubtype(game).isEmpty()) { sbType.append("- "); for (SubType subType : card.getSubtype(game)) { sbType.append(subType).append(' '); } } return sbType.toString(); }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Set<CardType> foundCardTypes = new HashSet<>(8); for (Card card : controller.getGraveyard().getCards(game)) { foundCardTypes.addAll(card.getCardType()); } CardUtil.reduceCost(abilityToModify, foundCardTypes.size()); return true; } return false; }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { boolean hasDelirium = false; Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { EnumSet<CardType> foundCardTypes = EnumSet.noneOf(CardType.class); for (Card card : controller.getGraveyard().getCards(game)) { foundCardTypes.addAll(card.getCardType()); } int number = foundCardTypes.size(); hasDelirium = number > 3; } return abilityToModify.getSourceId().equals(source.getSourceId()) && (abilityToModify instanceof SpellAbility) && hasDelirium; }
@Override public boolean applies(GameEvent event, Ability source, Game game) { CardType cardType = ArchonOfValorsReachChoice.getType((String) game.getState().getValue(source.getSourceId().toString() + "_cardtype")); // spell is not on the stack yet, so we have to check the card Card card = game.getCard(event.getSourceId()); return cardType != null && card != null && card.getCardType().contains(cardType); }
@Override public boolean apply(Game game, Ability source) { Card card = game.getCard(source.getFirstTarget()); if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { for (Cost cost : source.getCosts()) { if (cost instanceof ExileFromHandCost) { List<CardType> cardtypes = new ArrayList<>(); ExileFromHandCost exileCost = (ExileFromHandCost) cost; for (CardType cardtype : exileCost.getCards().get(0).getCardType()) { cardtypes.add(cardtype); } for (CardType cardtype : card.getCardType()) { if (cardtypes.contains(cardtype)) { Effect effect = new ReturnToHandTargetEffect(); effect.setTargetPointer(new FixedTarget(card.getId())); return effect.apply(game, source); } } } } } return false; } }
public static int getCardDefinitionScore(final Game game, final Card card) { int value = 3; //TODO: add new rating system card value if (card.isLand()) { int score = (int) ((value / 2.0f) * 50); //TODO: check this for "any color" lands //TODO: check this for dual and filter lands /*for (Mana mana : card.getMana()) { score += 50; }*/ score += card.getMana().size() * 50; return score; } final int score = value * 100 - card.getManaCost().convertedManaCost() * 20; if (card.getCardType().contains(CardType.CREATURE)) { return score + (card.getPower().getValue() + card.getToughness().getValue()) * 10; } else { return score + (/*card.getRemoval()*50*/+card.getRarity().getRating() * 30); } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { MageObject target = game.getObject(source.getSourceId()); if (target != null) { Set<CardType> foundCardTypes = EnumSet.noneOf(CardType.class); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Card card : player.getGraveyard().getCards(game)) { foundCardTypes.addAll(card.getCardType()); } } } int number = foundCardTypes.size(); target.getPower().setValue(number); target.getToughness().setValue(number + 1); return true; } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event; if (zEvent != null && Zone.GRAVEYARD == zEvent.getToZone() && zEvent.getCards() != null) { for (Card card : zEvent.getCards()) { if (card != null) { UUID cardOwnerId = card.getOwnerId(); Set<CardType> cardType = card.getCardType(); if (cardOwnerId != null && card.isOwnedBy(getControllerId()) && cardType != null && card.isLand()) { return true; } } } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event; if (zEvent != null && Zone.GRAVEYARD == zEvent.getToZone() && zEvent.getCards() != null) { for (Card card : zEvent.getCards()) { if (card != null) { UUID cardOwnerId = card.getOwnerId(); Set<CardType> cardType = card.getCardType(); if (cardOwnerId != null && card.isOwnedBy(getControllerId()) && cardType != null && card.isLand()) { return true; } } } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { ZoneChangeEvent zEvent = (ZoneChangeEvent) event; if (zEvent != null && zEvent.getFromZone() == Zone.LIBRARY && zEvent.getToZone() == Zone.GRAVEYARD) { Card card = game.getCard(event.getTargetId()); if (card != null) { UUID cardOwnerId = card.getOwnerId(); Set<CardType> cardType = card.getCardType(); if (cardOwnerId != null && card.isOwnedBy(getControllerId()) && cardType != null && card.isLand()) { return true; } } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event; if (zEvent != null && Zone.LIBRARY == zEvent.getFromZone() && Zone.GRAVEYARD == zEvent.getToZone() && zEvent.getCards() != null) { for (Card card : zEvent.getCards()) { if (card != null) { UUID cardOwnerId = card.getOwnerId(); Set<CardType> cardType = card.getCardType(); if (cardOwnerId != null && card.isOwnedBy(getControllerId()) && cardType != null && card.isCreature()) { return true; } } } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event; if (zEvent != null && Zone.GRAVEYARD == zEvent.getFromZone() && Zone.GRAVEYARD != zEvent.getToZone() && zEvent.getCards() != null) { for (Card card : zEvent.getCards()) { if (card != null) { UUID cardOwnerId = card.getOwnerId(); Set<CardType> cardType = card.getCardType(); if (cardOwnerId != null && card.isOwnedBy(getControllerId()) && cardType != null && card.isCreature()) { return true; } } } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event; if (zEvent != null && Zone.GRAVEYARD == zEvent.getToZone() && zEvent.getCards() != null) { // TODO: Switch to handle this with a game watcher because this does not work correctly if control changes Integer usedOnTurn = (Integer) game.getState().getValue("usedOnTurn" + getControllerId() + getOriginalId()); if (usedOnTurn == null || usedOnTurn < game.getTurnNum()) { for (Card card : zEvent.getCards()) { if (card != null) { UUID cardOwnerId = card.getOwnerId(); Set<CardType> cardType = card.getCardType(); if (cardOwnerId != null && card.isOwnedBy(getControllerId()) && cardType != null && card.isLand()) { game.getState().setValue("usedOnTurn" + getControllerId() + getOriginalId(), game.getTurnNum()); return true; } } } } } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent sourceObject = game.getPermanent(source.getSourceId()); ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source.getSourceId())); if (sourceObject == null || sourceObject.getImprinted() == null) { return false; } for (UUID imprinted : sourceObject.getImprinted()) { if (imprinted != null && exileZone.contains(imprinted)) { Card card = game.getCard(imprinted); if (card != null) { for (CardType cardType : card.getCardType()) { FilterCard filterCard; if (cardType.equals(CardType.SORCERY)) { filterCard = new FilterCard("sorceries"); } else if (cardType.equals(CardType.TRIBAL)) { filterCard = new FilterCard("tribal"); } else { filterCard = new FilterCard(cardType.toString() + "s"); } filterCard.add(new CardTypePredicate(cardType)); sourceObject.addAbility(new ProtectionAbility(filterCard)); } } } } return true; }