use of mage.ObjectColor in project mage by magefree.
the class HallOfGemstoneEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
ObjectColor colorChosen = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
if (colorChosen == null) {
return false;
}
ManaEvent manaEvent = (ManaEvent) event;
Mana mana = manaEvent.getMana();
// 8/23/2016 Colorless mana added to a player's mana pool isn't affected.
int genericAmount = mana.getGeneric();
int colorlessAmount = mana.getColorless();
int coloredAmount = mana.countColored();
switch(colorChosen.getOneColoredManaSymbol()) {
case W:
mana.setToMana(Mana.WhiteMana(coloredAmount));
break;
case U:
mana.setToMana(Mana.BlueMana(coloredAmount));
break;
case B:
mana.setToMana(Mana.BlackMana(coloredAmount));
break;
case R:
mana.setToMana(Mana.RedMana(coloredAmount));
break;
case G:
mana.setToMana(Mana.GreenMana(coloredAmount));
break;
}
mana.setGeneric(genericAmount);
mana.setColorless(colorlessAmount);
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class IlluminatedFolioTarget method possibleTargets.
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
if (this.getTargets().size() == 1) {
Card card = game.getCard(this.getTargets().get(0));
possibleTargets.removeIf(uuid -> !game.getCard(uuid).getColor(game).shares(card.getColor(game)));
return possibleTargets;
}
if (possibleTargets.size() < 2) {
possibleTargets.clear();
return possibleTargets;
}
Set<Card> allTargets = possibleTargets.stream().map(game::getCard).collect(Collectors.toSet());
possibleTargets.clear();
for (ObjectColor color : ObjectColor.getAllColors()) {
Set<Card> inColor = allTargets.stream().filter(card -> card.getColor(game).shares(color)).collect(Collectors.toSet());
if (inColor.size() > 1) {
inColor.stream().map(MageItem::getId).forEach(possibleTargets::add);
}
if (possibleTargets.size() == allTargets.size()) {
break;
}
}
return possibleTargets;
}
use of mage.ObjectColor in project mage by magefree.
the class IonaShieldOfEmeriaReplacementEffect method getInfoMessage.
@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
ObjectColor chosenColor = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null && chosenColor != null) {
return "You can't cast " + chosenColor.toString() + " spells (" + mageObject.getIdName() + ").";
}
return null;
}
use of mage.ObjectColor in project mage by magefree.
the class KatildaDawnhartPrimeManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game != null) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (controller != null && permanent != null) {
Choice choice = new ChoiceImpl();
choice.setMessage("Pick a mana color");
ObjectColor color = permanent.getColor(game);
if (color.isWhite()) {
choice.getChoices().add("White");
}
if (color.isBlue()) {
choice.getChoices().add("Blue");
}
if (color.isBlack()) {
choice.getChoices().add("Black");
}
if (color.isRed()) {
choice.getChoices().add("Red");
}
if (color.isGreen()) {
choice.getChoices().add("Green");
}
if (!choice.getChoices().isEmpty()) {
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
controller.choose(outcome, choice, game);
}
if (choice.getChoice() != null) {
switch(choice.getChoice()) {
case "White":
mana.setWhite(1);
break;
case "Blue":
mana.setBlue(1);
break;
case "Black":
mana.setBlack(1);
break;
case "Red":
mana.setRed(1);
break;
case "Green":
mana.setGreen(1);
break;
}
}
}
}
}
return mana;
}
use of mage.ObjectColor in project mage by magefree.
the class MournersShieldEffect method init.
@Override
public void init(Ability source, Game game) {
ObjectColor colorsAmongImprinted = new ObjectColor();
Permanent sourceObject = game.getPermanent(source.getSourceId());
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source.getSourceId()));
if (sourceObject == null || sourceObject.getImprinted() == null) {
noneExiled = true;
return;
}
for (UUID imprinted : sourceObject.getImprinted()) {
if (imprinted != null && exileZone.contains(imprinted)) {
Card card = game.getCard(imprinted);
if (card != null) {
colorsAmongImprinted = colorsAmongImprinted.union(card.getColor(game));
}
}
}
FilterObject filterObject = new FilterObject("a source of your choice that shares a color with the exiled card");
filterObject.add(new SharesColorPredicate(colorsAmongImprinted));
this.target = new TargetSource(filterObject);
this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game);
if (target.getFirstTarget() != null) {
mageObjectReference = new MageObjectReference(target.getFirstTarget(), game);
} else {
mageObjectReference = null;
}
}
Aggregations