use of mage.ConditionalMana in project mage by magefree.
the class OpenTheOmenpathsCondition method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Mana mana = ManaChoice.chooseTwoDifferentColors(player, game);
mana.add(mana);
ConditionalMana conditionalMana = new ConditionalMana(mana);
conditionalMana.addCondition(new OpenTheOmenpathsCondition());
player.getManaPool().addMana(conditionalMana, game, source);
return true;
}
use of mage.ConditionalMana in project mage by magefree.
the class NarsetOfTheAncientWayDrawEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
player.gainLife(2, game, source);
ChoiceColor choice = new ChoiceColor();
choice.getChoices().remove("Green");
choice.getChoices().remove("Black");
player.choose(Outcome.PutManaInPool, choice, game);
ConditionalMana mana = new ConditionalMana(choice.getMana(1));
mana.addCondition(new NarsetOfTheAncientWayManaCondition());
player.getManaPool().addMana(mana, game, source);
return true;
}
use of mage.ConditionalMana in project mage by magefree.
the class ManaTypeInManaPoolCount method calculate.
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int amount = 0;
Player player = game.getPlayer(sourceAbility.getControllerId());
if (player != null) {
amount = player.getManaPool().get(manaType);
for (ConditionalMana mana : player.getManaPool().getConditionalMana()) {
amount += mana.get(manaType);
}
}
return amount;
}
use of mage.ConditionalMana in project mage by magefree.
the class ManaOptions method toString.
@Override
public String toString() {
Iterator<Mana> it = this.iterator();
if (!it.hasNext()) {
return "[]";
}
StringBuilder sb = new StringBuilder();
sb.append('[');
for (; ; ) {
Mana mana = it.next();
sb.append(mana.toString());
if (mana instanceof ConditionalMana) {
sb.append(((ConditionalMana) mana).getConditionString());
}
if (!it.hasNext()) {
return sb.append(']').toString();
}
sb.append(',').append(' ');
}
}
use of mage.ConditionalMana in project mage by magefree.
the class ManaPool method addMana.
public void addMana(Mana manaToAdd, Game game, Ability source, boolean dontLoseUntilEOT) {
if (manaToAdd != null) {
Mana mana = manaToAdd.copy();
if (!game.replaceEvent(new ManaEvent(EventType.ADD_MANA, source.getId(), source, playerId, mana))) {
if (mana instanceof ConditionalMana) {
ConditionalMana conditionalMana = (ConditionalMana) mana;
ManaPoolItem item = new ManaPoolItem(conditionalMana, source.getSourceObject(game), conditionalMana.getManaProducerOriginalId() != null ? conditionalMana.getManaProducerOriginalId() : source.getOriginalId());
if (dontLoseUntilEOT) {
item.setDuration(Duration.EndOfTurn);
}
this.manaItems.add(item);
} else {
ManaPoolItem item = new ManaPoolItem(mana.getRed(), mana.getGreen(), mana.getBlue(), mana.getWhite(), mana.getBlack(), mana.getGeneric() + mana.getColorless(), source.getSourceObject(game), source.getOriginalId(), mana.getFlag());
if (dontLoseUntilEOT) {
item.setDuration(Duration.EndOfTurn);
}
this.manaItems.add(item);
}
ManaEvent manaEvent = new ManaEvent(EventType.MANA_ADDED, source.getId(), source, playerId, mana);
manaEvent.setData(mana.toString());
game.fireEvent(manaEvent);
}
}
}
Aggregations