use of mage.choices.ChoiceCreatureType in project mage by magefree.
the class CallousOppressorChooseCreatureTypeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
if (mageObject == null) {
mageObject = game.getObject(source.getSourceId());
}
if (controller != null) {
TargetOpponent target = new TargetOpponent(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
while (!target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) {
controller.chooseTarget(outcome, target, source, game);
}
} else {
return false;
}
Player opponent = game.getPlayer(target.getFirstTarget());
if (opponent != null && mageObject != null) {
Choice typeChoice = new ChoiceCreatureType(mageObject);
typeChoice.setMessage("Choose creature type");
if (!opponent.choose(outcome, typeChoice, game)) {
return false;
}
if (typeChoice.getChoice() == null) {
return false;
}
if (!game.isSimulation()) {
game.informPlayers(mageObject.getName() + ": " + opponent.getLogName() + " has chosen " + typeChoice.getChoice());
}
game.getState().setValue(mageObject.getId() + "_type", SubType.byDescription(typeChoice.getChoice()));
if (mageObject instanceof Permanent) {
((Permanent) mageObject).addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game);
}
return true;
}
}
return false;
}
use of mage.choices.ChoiceCreatureType in project mage by magefree.
the class ChooseCreatureTypeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId());
Choice typeChoice = new ChoiceCreatureType(mageObject);
if (controller != null && mageObject != null && controller.choose(outcome, typeChoice, game)) {
if (!game.isSimulation()) {
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
}
game.getState().setValue(mageObject.getId() + "_type", SubType.byDescription(typeChoice.getChoice()));
return true;
}
return false;
}
use of mage.choices.ChoiceCreatureType in project mage by magefree.
the class CoordinatedBarrageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice choice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
if (controller.choose(Outcome.Damage, choice, game)) {
String chosenType = choice.getChoice();
FilterControlledPermanent filter = new FilterControlledPermanent();
filter.add(SubType.byDescription(chosenType).getPredicate());
int damageDealt = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (permanent != null) {
permanent.damage(damageDealt, source.getSourceId(), source, game, false, true);
}
return true;
}
}
return false;
}
use of mage.choices.ChoiceCreatureType in project mage by magefree.
the class DefensiveManeuversEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (player == null || sourceObject == null) {
return false;
}
Choice choice = new ChoiceCreatureType(sourceObject);
SubType subType = null;
if (player.choose(outcome, choice, game)) {
subType = SubType.byDescription(choice.getChoice());
}
if (subType == null) {
return false;
}
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(subType.getPredicate());
game.addEffect(new BoostAllEffect(0, 4, Duration.EndOfTurn, filter, false), source);
return true;
}
Aggregations