use of mage.Mana in project mage by magefree.
the class IceCauldronManaCondition method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
Permanent iceCauldron = game.getPermanent(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (iceCauldron != null && controller != null) {
storedMana = (Mana) game.getState().getValue("IceCauldronMana" + source.getSourceId().toString());
exiledCardMor = (MageObjectReference) game.getState().getValue("IceCauldronCard" + source.getSourceId().toString());
if (storedMana != null) {
// should be adding the mana even if exiled card is null
Card card = exiledCardMor.getCard(game);
if (card == null) {
card = game.getCard(exiledCardMor.getSourceId());
if (card != null && !(card.getZoneChangeCounter(game) == exiledCardMor.getZoneChangeCounter() + 1 && game.getState().getZone(card.getId()) == Zone.STACK)) {
card = null;
}
}
if (card != null) {
return new IceCauldronConditionalMana(storedMana, card);
}
}
}
return mana;
}
use of mage.Mana in project mage by magefree.
the class NakedSingularityEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
TappedForManaEvent manaEvent = (TappedForManaEvent) event;
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = manaEvent.getPermanent();
if (controller == null || permanent == null) {
return false;
}
Choice choice = new ChoiceColor(true);
choice.getChoices().clear();
choice.setMessage("Pick a color to produce");
if (permanent.hasSubtype(SubType.PLAINS, game)) {
choice.getChoices().add("Red");
}
if (permanent.hasSubtype(SubType.ISLAND, game)) {
choice.getChoices().add("Green");
}
if (permanent.hasSubtype(SubType.SWAMP, game)) {
choice.getChoices().add("White");
}
if (permanent.hasSubtype(SubType.MOUNTAIN, game)) {
choice.getChoices().add("Blue");
}
if (permanent.hasSubtype(SubType.FOREST, game)) {
choice.getChoices().add("Black");
}
String chosenColor;
if (choice.getChoices().size() == 1) {
chosenColor = choice.getChoices().iterator().next();
} else {
controller.choose(Outcome.PutManaInPool, choice, game);
chosenColor = choice.getChoice();
}
if (chosenColor == null) {
return false;
}
Mana mana = manaEvent.getMana();
int amount = mana.count();
switch(chosenColor) {
case "White":
mana.setToMana(Mana.WhiteMana(amount));
break;
case "Blue":
mana.setToMana(Mana.BlueMana(amount));
break;
case "Black":
mana.setToMana(Mana.BlackMana(amount));
break;
case "Red":
mana.setToMana(Mana.RedMana(amount));
break;
case "Green":
mana.setToMana(Mana.GreenMana(amount));
break;
}
return false;
}
use of mage.Mana in project mage by magefree.
the class RitualOfSubdualReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
ManaEvent manaEvent = (ManaEvent) event;
Mana mana = manaEvent.getMana();
mana.setToMana(Mana.ColorlessMana(mana.count()));
return false;
}
use of mage.Mana in project mage by magefree.
the class YurlokOfScorchThrashManaEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
Mana manaToAdd = produceMana(game, source);
if (manaToAdd == null || manaToAdd.count() <= 0) {
continue;
}
checkToFirePossibleEvents(manaToAdd, game, source);
addManaToPool(player, manaToAdd, game, source);
}
return true;
}
use of mage.Mana in project mage by magefree.
the class SpellsCostReductionControllerEffect method apply.
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
if (manaCostsToReduce != null) {
CardUtil.adjustCost((SpellAbility) abilityToModify, manaCostsToReduce, false);
} else {
if (upTo) {
Mana mana = abilityToModify.getManaCostsToPay().getMana();
int reduceMax = mana.getGeneric();
if (reduceMax > this.amount) {
reduceMax = this.amount;
}
if (reduceMax > 0) {
Player controller = game.getPlayer(abilityToModify.getControllerId());
if (controller == null) {
return false;
}
int reduce = reduceMax;
if (!game.inCheckPlayableState()) {
ChoiceImpl choice = new ChoiceImpl(false);
Set<String> set = new LinkedHashSet<>();
for (int i = 0; i <= reduceMax; i++) {
set.add(String.valueOf(i));
}
choice.setChoices(set);
MageObject mageObject = game.getObject(abilityToModify.getSourceId());
choice.setMessage("Reduce cost of " + (mageObject != null ? mageObject.getIdName() : filter.getMessage()));
if (controller.choose(Outcome.Benefit, choice, game)) {
reduce = Integer.parseInt(choice.getChoice());
} else {
// cancel will be set to max possible reduce
reduce = reduceMax;
}
}
if (reduce > 0) {
CardUtil.reduceCost(abilityToModify, reduce);
}
}
} else {
CardUtil.reduceCost(abilityToModify, this.amount);
}
}
return true;
}
Aggregations