use of mage.Mana in project mage by magefree.
the class SarkhanUnbrokenAbility1 method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.drawCards(1, source, game);
game.fireUpdatePlayersEvent();
Choice manaChoice = new ChoiceImpl();
Set<String> choices = new LinkedHashSet<>();
choices.add("White");
choices.add("Blue");
choices.add("Black");
choices.add("Red");
choices.add("Green");
manaChoice.setChoices(choices);
manaChoice.setMessage("Select color of mana to add");
Mana mana = new Mana();
if (!controller.choose(Outcome.Benefit, manaChoice, game)) {
return false;
}
switch(manaChoice.getChoice()) {
case "White":
mana.increaseWhite();
break;
case "Blue":
mana.increaseBlue();
break;
case "Black":
mana.increaseBlack();
break;
case "Red":
mana.increaseRed();
break;
case "Green":
mana.increaseGreen();
break;
}
controller.getManaPool().addMana(mana, game, source);
return true;
}
return false;
}
use of mage.Mana in project mage by magefree.
the class SasayasEssenceManaEffect method getNetMana.
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netMana = new ArrayList<>();
Player controller = game.getPlayer(source.getControllerId());
Mana producedMana = (Mana) this.getValue("mana");
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (controller != null && producedMana != null && permanent != null) {
FilterPermanent filter = new FilterLandPermanent();
filter.add(Predicates.not(new PermanentIdPredicate(permanent.getId())));
filter.add(new NamePredicate(permanent.getName()));
int count = game.getBattlefield().countAll(filter, controller.getId(), game);
if (count > 0) {
if (producedMana.getBlack() > 0) {
netMana.add(Mana.BlackMana(count));
}
if (producedMana.getRed() > 0) {
netMana.add(Mana.RedMana(count));
}
if (producedMana.getBlue() > 0) {
netMana.add(Mana.BlueMana(count));
}
if (producedMana.getGreen() > 0) {
netMana.add(Mana.GreenMana(count));
}
if (producedMana.getWhite() > 0) {
netMana.add(Mana.WhiteMana(count));
}
if (producedMana.getColorless() > 0) {
netMana.add(Mana.ColorlessMana(count));
}
}
}
return netMana;
}
use of mage.Mana in project mage by magefree.
the class UrzaAcademyHeadmasterBrainstormEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
int x = game.getBattlefield().count(new FilterControlledCreaturePermanent(), source.getSourceId(), source.getControllerId(), game);
Choice manaChoice = new ChoiceImpl();
Set<String> choices = new LinkedHashSet<>();
choices.add("White");
choices.add("Blue");
choices.add("Black");
choices.add("Red");
choices.add("Green");
manaChoice.setChoices(choices);
manaChoice.setMessage("Select color of mana to add");
for (int i = 0; i < x; i++) {
Mana mana = new Mana();
if (!player.choose(Outcome.Benefit, manaChoice, game)) {
return false;
}
if (manaChoice.getChoice() == null) {
// can happen if player leaves game
return false;
}
switch(manaChoice.getChoice()) {
case "White":
mana.increaseWhite();
break;
case "Blue":
mana.increaseBlue();
break;
case "Black":
mana.increaseBlack();
break;
case "Red":
mana.increaseRed();
break;
case "Green":
mana.increaseGreen();
break;
}
player.getManaPool().addMana(mana, game, source);
}
return true;
}
return false;
}
use of mage.Mana in project mage by magefree.
the class AddConditionalManaEffect method getNetMana.
@Override
public List<Mana> getNetMana(Game game, Ability source) {
if (game != null && game.inCheckPlayableState() && netAmount != null) {
List<Mana> maxAvailableMana = new ArrayList<>();
int amountAvailableMana = netAmount.calculate(game, source, this);
if (amountAvailableMana > 0) {
Mana calculatedMana = mana.copy();
for (ManaType manaType : ManaType.getTrueManaTypes()) {
calculatedMana.set(manaType, CardUtil.overflowMultiply(calculatedMana.get(manaType), amountAvailableMana));
}
maxAvailableMana.add(manaBuilder.setMana(calculatedMana, source, game).build());
}
return maxAvailableMana;
}
// To change body of generated methods, choose Tools | Templates.
return super.getNetMana(game, source);
}
use of mage.Mana in project mage by magefree.
the class AddManaAnyColorAttachedControllerEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
if (game != null) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null) {
Permanent land = game.getPermanent(enchantment.getAttachedTo());
if (land != null) {
Player player = game.getPlayer(land.getControllerId());
ChoiceColor choice = new ChoiceColor();
if (player != null && player.choose(outcome, choice, game)) {
return choice.getMana(1);
}
}
}
}
return new Mana();
}
Aggregations