use of mage.Mana in project mage by magefree.
the class EmergeAbility method getMinimumCostToActivate.
@Override
public ManaOptions getMinimumCostToActivate(UUID playerId, Game game) {
int maxCMC = 0;
for (Permanent creature : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), playerId, this.getSourceId(), game)) {
int cmc = creature.getManaValue();
if (cmc > maxCMC) {
maxCMC = cmc;
}
}
ManaOptions manaOptions = super.getMinimumCostToActivate(playerId, game);
for (Mana mana : manaOptions) {
if (mana.getGeneric() > maxCMC) {
mana.setGeneric(mana.getGeneric() - maxCMC);
} else {
mana.setGeneric(0);
}
}
return manaOptions;
}
use of mage.Mana in project mage by magefree.
the class ConvokeEffect method getManaOptions.
@Override
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
ManaOptions options = new ManaOptions();
FilterControlledCreaturePermanent filterBasic = new FilterControlledCreaturePermanent();
// each creature can give {1} or color mana
game.getBattlefield().getActivePermanents(filterBasic, source.getControllerId(), source.getSourceId(), game).stream().filter(permanent -> !permanent.isTapped()).forEach(permanent -> {
ManaOptions permMana = new ManaOptions();
permMana.add(Mana.GenericMana(1));
for (ObjectColor color : permanent.getColor(game).getColors()) {
if (color.isBlack())
permMana.add(Mana.BlackMana(1));
if (color.isBlue())
permMana.add(Mana.BlueMana(1));
if (color.isGreen())
permMana.add(Mana.GreenMana(1));
if (color.isRed())
permMana.add(Mana.RedMana(1));
if (color.isWhite())
permMana.add(Mana.WhiteMana(1));
}
options.addMana(permMana);
});
options.removeDuplicated();
return options;
}
use of mage.Mana in project mage by magefree.
the class ManaChoice method chooseTwoDifferentColors.
public static Mana chooseTwoDifferentColors(Player player, Game game) {
Mana mana = new Mana();
if (game == null || player == null) {
return mana;
}
ChoiceColor color1 = new ChoiceColor(true, "Choose color 1");
if (!player.choose(Outcome.PutManaInPool, color1, game) || color1.getColor() == null) {
return mana;
}
ChoiceColor color2 = new ChoiceColor(true, "Choose color 2");
color2.removeColorFromChoices(color1.getChoice());
if (!player.choose(Outcome.PutManaInPool, color2, game) || color2.getColor() == null) {
return mana;
}
if (color1.getColor().equals(color2.getColor())) {
game.informPlayers("Player " + player.getName() + " is cheating with mana choices.");
return mana;
}
mana.add(color1.getMana(1));
mana.add(color2.getMana(1));
return mana;
}
use of mage.Mana in project mage by magefree.
the class FluctuatorEffect method apply.
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
Player controller = game.getPlayer(abilityToModify.getControllerId());
if (controller != null) {
Mana mana = abilityToModify.getManaCostsToPay().getMana();
int reduceMax = mana.getGeneric();
if (reduceMax > 2) {
reduceMax = 2;
}
if (reduceMax > 0) {
int reduce;
if (game.inCheckPlayableState() || controller.isComputer()) {
reduce = reduceMax;
} else {
ChoiceImpl choice = new ChoiceImpl(true);
Set<String> set = new LinkedHashSet<>();
for (int i = 0; i <= reduceMax; i++) {
set.add(String.valueOf(i));
}
choice.setChoices(set);
choice.setMessage("Reduce cycling cost");
if (controller.choose(Outcome.Benefit, choice, game)) {
reduce = Integer.parseInt(choice.getChoice());
} else {
return false;
}
}
CardUtil.reduceCost(abilityToModify, reduce);
}
return true;
}
return false;
}
use of mage.Mana in project mage by magefree.
the class GauntletOfPowerManaEffect2 method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
TappedForManaEvent mEvent = (TappedForManaEvent) event;
Permanent permanent = mEvent.getPermanent();
if (permanent == null || !permanent.isLand() || !permanent.isBasic()) {
return false;
}
ObjectColor color = (ObjectColor) game.getState().getValue(getSourceId() + "_color");
if (color == null) {
return false;
}
Mana mana = mEvent.getMana();
if ((!color.isBlack() || mana.getBlack() < 1) && (!color.isBlue() || mana.getBlue() < 1) && (!color.isGreen() || mana.getGreen() < 1) && (!color.isWhite() || mana.getWhite() < 1) && (!color.isRed() || mana.getRed() < 1)) {
return false;
}
getEffects().setValue("mana", mEvent.getMana());
getEffects().setTargetPointer(new FixedTarget(permanent, game));
return true;
}
Aggregations