use of net.kodehawa.mantarobot.commands.game.core.GameLobby in project MantaroBot by Mantaro.
the class GameCmds method startGame.
private static void startGame(Game game, GuildMessageReceivedEvent event) {
if (GameLobby.LOBBYS.containsKey(event.getChannel())) {
event.getChannel().sendMessage(EmoteReference.ERROR + "Cannot start a new game when there is a game currently running.").queue();
return;
}
LinkedList<Game> list = new LinkedList<>();
list.add(game);
HashMap<Member, Player> map = new HashMap<>();
map.put(event.getMember(), MantaroData.db().getPlayer(event.getMember()));
if (!event.getMessage().getMentionedRoles().isEmpty()) {
StringBuilder b = new StringBuilder();
event.getMessage().getMentionedRoles().forEach(role -> event.getGuild().getMembersWithRoles(role).forEach(user -> {
if (!user.getUser().getId().equals(event.getJDA().getSelfUser().getId()))
map.put(user, MantaroData.db().getPlayer(user));
b.append(user.getEffectiveName()).append(" ");
}));
event.getChannel().sendMessage(EmoteReference.MEGA + "Started a MP game with all users with the specfied role: " + b.toString()).queue();
}
if (!event.getMessage().getMentionedUsers().isEmpty()) {
StringBuilder builder = new StringBuilder();
event.getMessage().getMentionedUsers().forEach(user -> {
if (!user.getId().equals(event.getJDA().getSelfUser().getId()))
map.put(event.getGuild().getMember(user), MantaroData.db().getPlayer(event.getGuild().getMember(user)));
builder.append(user.getName()).append(" ");
});
event.getChannel().sendMessage(EmoteReference.MEGA + "Started a MP game with users: " + builder.toString()).queue();
}
GameLobby lobby = new GameLobby(event, map, list);
lobby.startFirstGame();
}
Aggregations