<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mafia.server.bus.notify;

import com.mafia.server.io.MessageRouter;
import com.mafia.server.model.comm.server.ChatMessage;
import com.mafia.server.model.comm.server.Messagebox;
import com.mafia.server.model.comm.server.PlayerList;
import com.mafia.server.model.state.Game;
import static com.mafia.server.model.state.MafiaTypes.ACTIVITY_PHASE.NIGHT;
import static com.mafia.server.model.state.MafiaTypes.GAME_PHASE.ACTIVITY;
import static com.mafia.server.model.state.MafiaTypes.GAME_PHASE.PREGAME;
import com.mafia.server.model.state.Player;
import com.mafia.server.model.state.Repository;
import java.util.List;

/**
 *
 * @author Just1689
 */
public class NotifyGame {

    public static void notifyCreatorOfGameCode(String createdBy, String key) {
        Player player = Repository.getPlayerBySessionId(createdBy);
        Messagebox messagebox = Messagebox.createMessageBoxSuccess("Game Code", key);
        MessageRouter.sendMessage(player, messagebox);
    }

    public static void sendPlayerList(Game game) {
        if (game.getGamePhase().equals(PREGAME)) {
            PlayerList playerList = PlayerList.makeReadyVsNot(game.getPlayersAsList());
            MessageRouter.sendMessage(game, playerList);
            return;
        }

        if (game.getGamePhase().equals(ACTIVITY)) {
            if (game.getActivityPhase().equals(NIGHT)) {
                PlayerList playerList = new PlayerList(game.getPlayersAsList());
                MessageRouter.sendMessage(game, playerList);
                return;
            }
        }

        PlayerList playerList = PlayerList.makeReadyVsNot(game.getPlayersAsList());
        MessageRouter.sendMessage(game, playerList);
    }

    public static void nofityOfRole(Game game) {
        List<Player> players = game.getPlayersAsList();
        for (Player player : players) {
            String role = player.getRole().name();
            Messagebox messagebox = Messagebox.createMessageBoxTimed("Role", role);
            MessageRouter.sendMessage(player, messagebox);
            MessageRouter.sendMessage(player, chatMessage);
        }
    }

}
<commit_msg>As start of game assign roles<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mafia.server.bus.notify;

import com.mafia.server.io.MessageRouter;
import com.mafia.server.model.comm.server.ChatMessage;
import com.mafia.server.model.comm.server.Messagebox;
import com.mafia.server.model.comm.server.PlayerList;
import com.mafia.server.model.state.Game;
import static com.mafia.server.model.state.MafiaTypes.ACTIVITY_PHASE.NIGHT;
import static com.mafia.server.model.state.MafiaTypes.GAME_PHASE.ACTIVITY;
import static com.mafia.server.model.state.MafiaTypes.GAME_PHASE.PREGAME;
import com.mafia.server.model.state.Player;
import com.mafia.server.model.state.Repository;
import java.util.List;

/**
 *
 * @author Just1689
 */
public class NotifyGame {

    public static void notifyCreatorOfGameCode(String createdBy, String key) {
        Player player = Repository.getPlayerBySessionId(createdBy);
        Messagebox messagebox = Messagebox.createMessageBoxSuccess("Game Code", key);
        MessageRouter.sendMessage(player, messagebox);
    }

    public static void sendPlayerList(Game game) {
        if (game.getGamePhase().equals(PREGAME)) {
            PlayerList playerList = PlayerList.makeReadyVsNot(game.getPlayersAsList());
            MessageRouter.sendMessage(game, playerList);
            return;
        }

        if (game.getGamePhase().equals(ACTIVITY)) {
            if (game.getActivityPhase().equals(NIGHT)) {
                PlayerList playerList = new PlayerList(game.getPlayersAsList());
                MessageRouter.sendMessage(game, playerList);
                return;
            }
        }

        PlayerList playerList = PlayerList.makeReadyVsNot(game.getPlayersAsList());
        MessageRouter.sendMessage(game, playerList);
    }

    public static void nofityOfRole(Game game) {
        List<Player> players = game.getPlayersAsList();
        for (Player player : players) {
            String role = player.getRole().name();
            Messagebox messagebox = Messagebox.createMessageBoxTimed("Role", role);
            MessageRouter.sendMessage(player, messagebox);
            ChatMessage chatMessage = new ChatMessage("<strong>You are a " + role + "</strong><br />");
            MessageRouter.sendMessage(player, chatMessage);
        }
    }

}

{'fraction_non_alphanumeric': 0.10414052697616061, 'fraction_numerical': 0.001672940192388122, 'mean_word_length': 3.2515555555555555, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3319470', 'n_tokens_mistral': 1402, 'n_tokens_neox': 1363, 'n_words': 269}