package org.royaldev.thehumanity.commands.impl;
import org.jetbrains.annotations.NotNull;
import org.kitteh.irc.client.library.util.Format;
import org.kitteh.irc.client.library.element.User;
import org.kitteh.irc.client.library.event.channel.ChannelMessageEvent;
import org.royaldev.thehumanity.TheHumanity;
import org.royaldev.thehumanity.cards.types.WhiteCard;
import org.royaldev.thehumanity.commands.InGameCommand;
import org.royaldev.thehumanity.game.HouseRule;
import org.royaldev.thehumanity.game.TheHumanityGame;
import org.royaldev.thehumanity.player.TheHumanityPlayer;
import xyz.cardstock.cardstock.commands.CallInfo;
import xyz.cardstock.cardstock.commands.Command;
import java.util.List;
@Command(
name = "neverhaveiever",
description = "Used to discard a card that the player doesn't know the meaning of.",
aliases = {"nhie", "never"},
usage = "<command> [card]"
)
public class NeverHaveIEverCommand extends InGameCommand {
public NeverHaveIEverCommand(final TheHumanity instance) {
super(instance);
}
@Override
public void run(@NotNull ChannelMessageEvent event, @NotNull CallInfo callInfo, @NotNull TheHumanityGame game, @NotNull TheHumanityPlayer player, @NotNull List<String> arguments) {
final User u = player.getUser();
if (!game.hasHouseRule(HouseRule.NEVER_HAVE_I_EVER)) {
u.sendNotice("This command may only be used when the " + HouseRule.NEVER_HAVE_I_EVER + " house rule is enabled.");
return;
}
if (arguments.size() < 1) {
u.sendNotice("Please specify a card.");
return;
}
int index;
try {
index = Integer.parseInt(arguments.get(0)) - 1;
} catch (final NumberFormatException ex) {
u.sendNotice("Invalid number.");
return;
}
if (index < 0 || index >= player.getHand().size()) {
u.sendNotice("Invalid card.");
return;
}
final WhiteCard unknown = player.getHand().get(index);
player.getHand().remove(unknown);
game.sendMessage(Format.BOLD + u.getNick() + Format.RESET + " doesn't know what " + Format.BOLD + unknown + Format.RESET + " means and has discarded that card.");
game.deal(player);
game.showCards(player);
}
}