use of mage.choices.ChoiceColor in project mage by magefree.
the class ProtectionChosenColorTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) {
ChoiceColor colorChoice = new ChoiceColor();
if (!controller.choose(Outcome.Benefit, colorChoice, game)) {
return false;
}
game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + colorChoice.getChoice());
game.getState().setValue(target.getId() + "_color", colorChoice.getColor());
ObjectColor protectColor = (ObjectColor) game.getState().getValue(target.getId() + "_color");
if (protectColor != null) {
ContinuousEffect effect = new ProtectionChosenColorTargetEffect();
game.addEffect(effect, source);
ObjectColor color = target.getColor(game);
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
if (!permanent.getId().equals(target.getId()) && permanent.getColor(game).shares(color)) {
game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor());
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
}
}
return true;
}
}
return false;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class CorruptedGrafstoneManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
Mana types = getManaTypesInGraveyard(game, source);
Choice choice = new ChoiceColor(true);
choice.getChoices().clear();
choice.setMessage("Pick a mana color");
if (types.getBlack() > 0) {
choice.getChoices().add("Black");
}
if (types.getRed() > 0) {
choice.getChoices().add("Red");
}
if (types.getBlue() > 0) {
choice.getChoices().add("Blue");
}
if (types.getGreen() > 0) {
choice.getChoices().add("Green");
}
if (types.getWhite() > 0) {
choice.getChoices().add("White");
}
if (!choice.getChoices().isEmpty()) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
if (!player.choose(outcome, choice, game)) {
return mana;
}
}
switch(choice.getChoice()) {
case "Black":
mana.setBlack(1);
break;
case "Blue":
mana.setBlue(1);
break;
case "Red":
mana.setRed(1);
break;
case "Green":
mana.setGreen(1);
break;
case "White":
mana.setWhite(1);
break;
}
}
}
return mana;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class SehtsTigerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId());
ChoiceColor choice = new ChoiceColor();
if (controller != null && mageObject != null && controller.choose(Outcome.Protect, choice, game)) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(choice.getColor()));
filter.setMessage(choice.getChoice());
Ability ability = new ProtectionAbility(filter);
game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
return true;
}
return false;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class ConditionalManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
if (condition.apply(game, source)) {
mana = effect.getManaTemplate().copy();
} else if (otherwiseEffect != null) {
mana = otherwiseEffect.getManaTemplate().copy();
}
if (mana.getAny() > 0) {
int amount = mana.getAny();
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return mana;
}
ChoiceColor choice = new ChoiceColor(true);
if (controller.choose(outcome, choice, game)) {
mana.setAny(0);
mana.add(choice.getMana(amount));
}
}
return mana;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class FaithsShieldEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null && mageObject != null) {
if (FatefulHourCondition.instance.apply(game, source)) {
ChoiceColor choice = new ChoiceColor();
if (!controller.choose(Outcome.Protect, choice, game)) {
return false;
}
if (choice.getColor() != null) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(choice.getColor()));
filter.setMessage(choice.getChoice());
Ability ability = new ProtectionAbility(filter);
game.addEffect(new GainAbilityControlledEffect(ability, Duration.EndOfTurn), source);
game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
return true;
}
} else {
game.addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), source);
return true;
}
}
return false;
}
Aggregations