}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Choice cardChoice = new ChoiceImpl();
switch(typeOfName) {
case ALL:
cardChoice.setChoices(CardRepository.instance.getNames());
cardChoice.setMessage("Name a card");
break;
case NON_LAND_AND_NON_CREATURE_NAME:
cardChoice.setChoices(CardRepository.instance.getNonLandAndNonCreatureNames());
cardChoice.setMessage("Name a non land and non creature card");
break;
case NON_LAND_NAME:
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.setMessage("Name a non land card");
break;
}
cardChoice.clearChoice();
while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
if (!controller.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers(sourceObject.getLogName() + ", named card: [" + cardName + "]");
game.getState().setValue(source.getSourceId().toString() + INFO_KEY, cardName);
if (sourceObject instanceof Permanent) {
((Permanent)sourceObject).addInfo(INFO_KEY, CardUtil.addToolTipMarkTags("Named card: " + cardName));
}
return true;