@Override public List<Mana> getMana() { List<Mana> mana = new ArrayList<>(); for (ActivatedManaAbilityImpl ability : this.abilities.getActivatedManaAbilities(Zone.BATTLEFIELD)) { mana.addAll(ability.getNetMana(null)); } return mana; }
protected LinkedHashMap<UUID, ActivatedManaAbilityImpl> getUseableManaAbilities(MageObject object, Zone zone, Game game) { LinkedHashMap<UUID, ActivatedManaAbilityImpl> useable = new LinkedHashMap<>(); boolean canUse = !(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game); for (ActivatedManaAbilityImpl ability : object.getAbilities().getActivatedManaAbilities(zone)) { if (canUse || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) { if (ability.canActivate(playerId, game).canActivate()) { useable.put(ability.getId(), ability); } } } return useable; }
for (ActivatedManaAbilityImpl ability : card.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD)) { for (Mana netMana : ability.getNetMana(game)) { if (netMana.enough(mana)) { for (ActivatedManaAbilityImpl ability : card.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD)) { for (Mana netMana : ability.getNetMana(game)) { if (mana.contains(netMana)) {
public int evaluate(Permanent permanent, Game game) { if (!values.containsKey(permanent.getId())) { int value = 0; if (permanent.getCardType().contains(CardType.CREATURE)) { value += combat.evaluate(permanent, game); } value += permanent.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD).size(); value += permanent.getAbilities().getActivatedAbilities(Zone.BATTLEFIELD).size(); values.put(permanent.getId(), value); } return values.get(permanent.getId()); }
private Mana getManaTypes(Game game, Ability source) { Mana types = new Mana(); for (Cost cost : source.getCosts()) { if (cost instanceof SacrificeTargetCost && !((SacrificeTargetCost) cost).getPermanents().isEmpty()) { Permanent land = ((SacrificeTargetCost) cost).getPermanents().get(0); if (land != null) { Abilities<ActivatedManaAbilityImpl> manaAbilities = land.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD); for (ActivatedManaAbilityImpl ability : manaAbilities) { if (!ability.equals(source) && ability.definesMana(game)) { for (Mana netMana : ability.getNetMana(game)) { types.add(netMana); } } } } } } return types; }
public List<Permanent> getAvailableManaProducersWithCost(Game game) { List<Permanent> result = new ArrayList<>(); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) { Boolean canUse = null; for (ActivatedManaAbilityImpl ability : permanent.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD)) { if (canUse == null) { canUse = permanent.canUseActivatedAbilities(game); } if (canUse && ability.canActivate(playerId, game).canActivate() && !ability.getManaCosts().isEmpty()) { result.add(permanent); break; } } } return result; }
private Mana getManaTypes(Game game, Ability source) { List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game); Mana types = new Mana(); for (Permanent land : lands) { Abilities<ActivatedManaAbilityImpl> manaAbilities = land.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD); for (ActivatedManaAbilityImpl ability : manaAbilities) { if (!ability.equals(source) && ability.definesMana(game)) { for (Mana netMana : ability.getNetMana(game)) { types.add(netMana); } } } } return types; }
Boolean canUse = null; boolean canAdd = false; for (ActivatedManaAbilityImpl ability : permanent.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD)) { if (!ability.getManaCosts().isEmpty()) { canAdd = false; for (ActivatedManaAbilityImpl ability : card.getAbilities(game).getActivatedManaAbilities(Zone.HAND)) { if (!ability.getManaCosts().isEmpty()) { canAdd = false;
private Mana getManaTypes(Game game, Ability source) { Mana types = new Mana(); if (game == null || game.getPhase() == null) { return types; } if (inManaTypeCalculation) { return types; } inManaTypeCalculation = true; List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); for (Permanent land : lands) { Abilities<ActivatedManaAbilityImpl> mana = land.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD); for (ActivatedManaAbilityImpl ability : mana) { if (!ability.equals(source) && ability.definesMana(game)) { for (Mana netMana : ability.getNetMana(game)) { types.add(netMana); } } } } inManaTypeCalculation = false; return types; }
private Mana getManaTypes(Game game, Ability source) { Mana types = new Mana(); if (game == null || game.getPhase() == null) { return types; } if (inManaTypeCalculation) { return types; } inManaTypeCalculation = true; List<Permanent> lands = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, source.getControllerId(), source.getSourceId(), game); for (Permanent land : lands) { Abilities<ActivatedManaAbilityImpl> mana = land.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD); for (ActivatedManaAbilityImpl ability : mana) { if (!ability.equals(source) && ability.definesMana(game)) { for (Mana netMana : ability.getNetMana(game)) { types.add(netMana); } } } } inManaTypeCalculation = false; return types; } }
Mana mana = new Mana(); for (ActivatedManaAbilityImpl ability : permanent.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD)) { for (Mana netMana : ability.getNetMana(game)) { mana.add(netMana);
public static int evaluatePermanent(Permanent permanent, Game game, boolean ignoreTapped) { int value = 0; if (ignoreTapped) { value = 5; } else { value = permanent.isTapped() ? 4 : 5; } if (permanent.getCardType().contains(CardType.CREATURE)) { value += evaluateCreature(permanent, game) * CREATURE_FACTOR; } value += permanent.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD).size(); for (ActivatedAbility ability : permanent.getAbilities().getActivatedAbilities(Zone.BATTLEFIELD)) { if (!(ability instanceof ActivatedManaAbilityImpl) && ability.canActivate(ability.getControllerId(), game).canActivate()) { value += ability.getEffects().size(); } } for (Counter counter : permanent.getCounters(game).values()) { if (!(counter instanceof BoostCounter)) { value += counter.getCount(); } } value += permanent.getAbilities().getStaticAbilities(Zone.BATTLEFIELD).size(); value += permanent.getAbilities().getTriggeredAbilities(Zone.BATTLEFIELD).size(); value += permanent.getManaCost().convertedManaCost(); //TODO: add a difficulty to calculation to ManaCost - sort permanents by difficulty for casting when evaluating game states return value; }