if (player != null) {
if (player.getHand().isEmpty()) {
// he or she puts the top card of his or her library into his or her graveyard
Effect effect = new PutTopCardOfLibraryIntoGraveTargetEffect(1);
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
effect.apply(game, source);
return true;
} else {
// discards a card instead. If the player discards a card this way, he or she draws a card.
player.discard(1, source, game);
return false; // because player draws a card, the draw event is kept