@Override public int getConvertedManaCost() { if (manaCost != null) { return manaCost.convertedManaCost(); } return 0; }
public int getConvertedCost() { return this.card.getManaCost().convertedManaCost(); }
@Override public int announceXMana(int min, int max, String message, Game game, Ability ability) { log.debug("announceXMana"); //TODO: improve this int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().convertedManaCost(); if (numAvailable < 0) { numAvailable = 0; } else { if (numAvailable < min) { numAvailable = min; } if (numAvailable > max) { numAvailable = max; } } return numAvailable; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { int manaCost = abilityToModify.getManaCostsToPay().convertedManaCost(); if (manaCost < 3) { CardUtil.increaseCost(abilityToModify, 3 - manaCost); } return true; }
@Override public Cost getCost(Ability ability, Game game) { return new GenericManaCost(ability.getManaCosts().convertedManaCost()); }
@Override public boolean isCostless(GameEvent event, Ability source, Game game) { ManaCosts currentManaCosts = getManaCostToPay(event, source, game); if (currentManaCosts != null && currentManaCosts.convertedManaCost() > 0) { return false; } return getOtherCostToPay(event, source, game) == null; }
private boolean isCardFormatValid(Card card, Card commander, FilterMana color) { if (!cardHasValideColor(color, card)) { invalid.put(card.getName(), "Invalid color (" + commander.getName() + ')'); return false; } //905.5b - Converted mana cost must be 3 or less if (card instanceof SplitCard) { if (((SplitCard) card).getLeftHalfCard().getManaCost().convertedManaCost() > 3) { invalid.put(card.getName(), "Invalid cost (" + ((SplitCard) card).getLeftHalfCard().getManaCost().convertedManaCost() + ')'); return false; } if (((SplitCard) card).getRightHalfCard().getManaCost().convertedManaCost() > 3) { invalid.put(card.getName(), "Invalid cost (" + ((SplitCard) card).getRightHalfCard().getManaCost().convertedManaCost() + ')'); return false; } } else if (card.getManaCost().convertedManaCost() > 3) { invalid.put(card.getName(), "Invalid cost (" + card.getManaCost().convertedManaCost() + ')'); return false; } return true; }
@Override public boolean apply(Game game, Ability source) { Set<UUID> controllers = new HashSet<>(); Integer maxCMC = null; List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); for (Permanent permanent : permanents) { int cmc = permanent.getManaCost().convertedManaCost(); if (maxCMC == null || cmc > maxCMC) { maxCMC = cmc; controllers.clear(); } if (cmc == maxCMC) { controllers.add(permanent.getControllerId()); } } return controllers.contains(source.getControllerId()); }
private boolean suppressAbilityPicker(ActivatedAbility ability, Game game) { if (getControllingPlayersUserData(game).isShowAbilityPickerForced()) { if (ability instanceof PlayLandAbility) { return true; } if (!ability.getSourceId().equals(getCastSourceIdWithAlternateMana()) && ability.getManaCostsToPay().convertedManaCost() > 0) { return true; } return ability instanceof ActivatedManaAbilityImpl; } return true; }
protected void simulateVariableCosts(Ability ability, List<Ability> options, Game game) { int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().convertedManaCost(); int start = 0; if (!(ability instanceof SpellAbility)) { //only use x=0 on spell abilities if (numAvailable == 0) return; else start = 1; } for (int i = start; i < numAvailable; i++) { Ability newAbility = ability.copy(); newAbility.getManaCostsToPay().add(new GenericManaCost(i)); options.add(newAbility); } }
protected void simulateVariableCosts(Ability ability, Game game) { int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().convertedManaCost(); int start = 0; if (!(ability instanceof SpellAbility)) { //only use x=0 on spell abilities if (numAvailable == 0) return; else start = 1; } for (int i = start; i < numAvailable; i++) { Ability newAbility = ability.copy(); newAbility.getManaCostsToPay().add(new GenericManaCost(i)); allActions.add(newAbility); } }
/** * 202.3b When calculating the converted mana cost of an object with an {X} * in its mana cost, X is treated as 0 while the object is not on the stack, * and X is treated as the number chosen for it while the object is on the * stack. * * @return */ @Override public int getConvertedManaCost() { int cmc = 0; if (faceDown) { return 0; } for (SpellAbility spellAbility : spellAbilities) { cmc += spellAbility.getConvertedXManaCost(getCard()); } cmc += getCard().getManaCost().convertedManaCost(); return cmc; }
@Override public int getConvertedManaCost() { if (isTransformed()) { // 711.4b While a double-faced permanent's back face is up, it has only the characteristics of its back face. // However, its converted mana cost is calculated using the mana cost of its front face. This is a change from previous rules. // If a permanent is copying the back face of a double-faced card (even if the card representing that copy // is itself a double-faced card), the converted mana cost of that permanent is 0. return getCard().getConvertedManaCost(); } if (faceDown) { // game not neccessary return getManaCost().convertedManaCost(); } return super.getConvertedManaCost(); }
@Override public void watch(GameEvent event, Game game) { // Watcher saves all casts becaus of possible Clone cards that copy Jeleva if (event.getType() == GameEvent.EventType.SPELL_CAST) { if (!game.getStack().isEmpty()) { for (StackObject stackObject : game.getStack()) { if (stackObject instanceof Spell) { Spell spell = (Spell) stackObject; manaSpendToCast.putIfAbsent(spell.getSourceId().toString() + spell.getCard().getZoneChangeCounter(game), spell.getSpellAbility().getManaCostsToPay().convertedManaCost()); } } } } }
@Override public List<Mana> getNetMana(Game game, Ability source) { List<Mana> netMana = new ArrayList<>(); int cmc = -1; for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) { if (permanent.isCreature()) { cmc = Math.max(cmc, permanent.getManaCost().convertedManaCost()); } } if (cmc != -1) { netMana.add(manaBuilder.setMana(Mana.BlackMana(cmc + 1), source, game).build()); netMana.add(manaBuilder.setMana(Mana.BlueMana(cmc + 1), source, game).build()); netMana.add(manaBuilder.setMana(Mana.RedMana(cmc + 1), source, game).build()); netMana.add(manaBuilder.setMana(Mana.GreenMana(cmc + 1), source, game).build()); netMana.add(manaBuilder.setMana(Mana.WhiteMana(cmc + 1), source, game).build()); } return netMana; }
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 void adjustCosts(Ability ability, Game game) { if (ability instanceof EquipAbility) { Permanent targetCreature = game.getPermanent(ability.getTargets().getFirstTarget()); if (targetCreature != null && (targetCreature.hasSubtype(SubType.SITH, game) || targetCreature.hasSubtype(SubType.JEDI, game))) { CardUtil.increaseCost(ability, 1 - ability.getManaCostsToPay().convertedManaCost()); } } }
@Override public int calculate(Game game, Ability source, Effect effect) { Spell spell = game.getStack().getSpell(source.getSourceId()); if (spell == null) { MageObject mageObject = game.getLastKnownInformation(source.getSourceId(), Zone.STACK); if (mageObject instanceof Spell) { spell = (Spell) mageObject; } } if (spell != null) { // NOT the cmc of the spell on the stack return spell.getSpellAbility().getManaCostsToPay().convertedManaCost(); } return 0; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD && ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) { Permanent permanent = ((ZoneChangeEvent) event).getTarget(); if (permanent.isControlledBy(this.getControllerId()) && permanent.isArtifact()) { FilterCard filter = new FilterArtifactCard("artifact card in your graveyard with converted mana cost less than " + permanent.getManaCost().convertedManaCost()); filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, permanent.getManaCost().convertedManaCost())); TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter); getTargets().clear(); addTarget(target); return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { Card card = controller.getLibrary().getFromTop(game); if (card != null) { controller.moveCards(card, Zone.EXILED, source, game); // You may have Spark of Creativity deal damage to that creature equal to the converted mana cost of the exiled card. Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); if (targetCreature != null) { int cmc = card.getManaCost().convertedManaCost(); if (controller.chooseUse(outcome, "Let " + sourceObject.getLogName() + " deal " + cmc + " damage to " + targetCreature.getLogName() + '?', source, game)) { targetCreature.damage(cmc, source.getSourceId(), game, false, true); return true; } } // If you don't, you may play that card until end of turn game.addEffect(new SparkOfCreativityPlayEffect(new MageObjectReference(card, game)), source); } return true; } return false; } }