package org.royaldev.thehumanity.commands.impl.game.subcommands; import com.google.common.base.Joiner; 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.packs.CAHCardPack; import org.royaldev.thehumanity.commands.InGameCommand; import org.royaldev.thehumanity.game.TheHumanityGame; import org.royaldev.thehumanity.player.TheHumanityPlayer; import org.royaldev.thehumanity.util.ConversionHelper; import xyz.cardstock.cardstock.commands.CallInfo; import xyz.cardstock.cardstock.commands.Command; import java.util.List; @Command( name = "removepack", description = "Removes a card pack from the current game, optionally removing any dealt cards from the pack.", usage = "<command> [pack] (sweep)", aliases = {"rp"} ) public class RemovePackSubcommand extends InGameCommand { public RemovePackSubcommand(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.getHost().equals(player) && !this.humanity.hasChannelMode(game.getChannel(), u, 'o')) { u.sendNotice("You are not an op or the host!"); return; } if (arguments.size() < 1) { u.sendNotice("Not enough arguments."); return; } final CAHCardPack cp = game.getDeck().getCardPacks().stream() .filter(c -> c.getName().equalsIgnoreCase(Joiner.on(' ').join(arguments))) .findFirst() .orElse(null); if (cp == null) { u.sendNotice("No such card pack."); return; } ConversionHelper.respond(event, (game.removeCardPack(cp, arguments.size() > 1 && "sweep".equalsIgnoreCase(arguments.get(1))) ? "Removed" : "Could not remove") + " " + Format.BOLD + cp.getName() + Format.RESET + " from the game."); } }