<commit_before>//
// Created by marcellus on 16.6.2015.
//

#include "TeamDeathMatch.h"
#include "../Game.h"
#include "TeamDeathMatchPlayerEventListener.h"

// Predefined teams as a temporary solution
std::vector<std::string> TEAMS = {"Alpha", "Bravo", "Charlie", "Delta", "Echo"};
std::vector<Duel6::Color> COLORS = { Duel6::Color(255, 0, 0), Duel6::Color(0, 255, 0), Duel6::Color(0, 0, 255), Duel6::Color(219, 216, 241), Duel6::Color(115,137,186)};


void Duel6::TeamDeathMatch::preparePlayer(Player *player, Int32 playerIndex, std::vector<Player> &allPlayers)
{
    int teamSize = std::max(0, (int)allPlayers.size() / teamsCount);
    int playerTeam = std::min(playerIndex / teamSize, teamsCount - 1);

    // todo: add support for custom teams in future versions
    std::string& teamName = TEAMS.at(playerTeam);
    Color teamColor = COLORS.at(playerTeam);

    player->setTeam(teamName);
    player->setOverlay(teamColor);
    player->setEventListener(eventListener);
}


bool Duel6::TeamDeathMatch::checkRoundOver(Duel6::World *world, std::vector<Duel6::Player*> &alivePlayers)
{
    bool oneTeamRemaining = true;
    std::string lastAliveTeam = "";

    for (Player *player : alivePlayers)
    {
        if (lastAliveTeam == "")
        {
            lastAliveTeam = player->getTeam();
        }
        else if (lastAliveTeam != player->getTeam())
        {
            oneTeamRemaining = false;
            break;
        }
    }

    if (oneTeamRemaining)
    {
        for(Player& player : world->getPlayers())
        {<commit_msg>Added round-draw state to TDM mode<commit_after>//
// Created by marcellus on 16.6.2015.
//

#include "TeamDeathMatch.h"
#include "../Game.h"
#include "TeamDeathMatchPlayerEventListener.h"

// Predefined teams as a temporary solution
std::vector<std::string> TEAMS = {"Alpha", "Bravo", "Charlie", "Delta", "Echo"};
std::vector<Duel6::Color> COLORS = { Duel6::Color(255, 0, 0), Duel6::Color(0, 255, 0), Duel6::Color(0, 0, 255), Duel6::Color(219, 216, 241), Duel6::Color(115,137,186)};


void Duel6::TeamDeathMatch::preparePlayer(Player *player, Int32 playerIndex, std::vector<Player> &allPlayers)
{
    int teamSize = std::max(0, (int)allPlayers.size() / teamsCount);
    int playerTeam = std::min(playerIndex / teamSize, teamsCount - 1);

    // todo: add support for custom teams in future versions
    std::string& teamName = TEAMS.at(playerTeam);
    Color teamColor = COLORS.at(playerTeam);

    player->setTeam(teamName);
    player->setOverlay(teamColor);
    player->setEventListener(eventListener);
}


bool Duel6::TeamDeathMatch::checkRoundOver(Duel6::World *world, std::vector<Duel6::Player*> &alivePlayers)
{
    if (alivePlayers.size() == 0)
    {
        for (const Player& player : world->getPlayers())
        {
            world->getMessageQueue().add(player, D6_L("End of round - no winner"));
        }
        return true;
    }


    bool oneTeamRemaining = true;
    std::string lastAliveTeam = "";

    for (Player *player : alivePlayers)
    {
        if (lastAliveTeam == "")
        {
            lastAliveTeam = player->getTeam();
        }
        else if (lastAliveTeam != player->getTeam())
        {
            oneTeamRemaining = false;
            break;
        }
    }

    if (oneTeamRemaining)
    {
        for(Player& player : world->getPlayers())
        {
{'fraction_non_alphanumeric': 0.1530398322851153, 'fraction_numerical': 0.03294399520814615, 'mean_word_length': 3.3096774193548386, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '4805501', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1068, 'n_words': 233}