<commit_before>/*
Copyright (c) 2015 AscEmu Team <http://www.ascemu.org/>
This file is released under the MIT license. See README-MIT for more information.
*/

#include "StdAfx.h"

bool ChatHandler::HandleArenaCreateTeam(const char* args, WorldSession* m_session)
{
    uint8 team_type;
    uint8 internal_type;
    char team_name[1000];

    auto player = getSelectedChar(m_session, true);
    if (sscanf(args, "%u %[^\n]", &team_type, team_name) != 2)
    {
        SystemMessage(m_session, "Invalid syntax. Usage: .arena createteam <type> <name>");
        return true;
    }

    switch (team_type)
    {
        case 2:
            internal_type = 0;
            break;
        case 3:
            internal_type = 1;
            break;
        case 5:
            internal_type = 2;
            break;
        default:
            SystemMessage(m_session, "Invalid arena team type specified! Valid types: 2, 3 and 5.");
            return true;
    }

    if (player == nullptr)
    {
        SystemMessage(m_session, "Selected player not found!");
        return true;<commit_msg>Refactor: Moved internal_type to seperated function.<commit_after>/*
Copyright (c) 2015 AscEmu Team <http://www.ascemu.org/>
This file is released under the MIT license. See README-MIT for more information.
*/

#include "StdAfx.h"

uint8 GetArenaTeamInternalType(uint8 type)
{
    uint8 internal_type;
    switch (type)
    {
        case 2:
            internal_type = 0;
            break;
        case 3:
            internal_type = 1;
            break;
        case 5:
            internal_type = 2;
            break;
        default:
            internal_type = 10;
            break;
    }

    return internal_type;
}

bool ChatHandler::HandleArenaCreateTeam(const char* args, WorldSession* m_session)
{
    uint8 team_type;
    char team_name[1000];

    auto player = getSelectedChar(m_session, true);
    if (sscanf(args, "%u %[^\n]", &team_type, team_name) != 2)
    {
        SystemMessage(m_session, "Invalid syntax. Usage: .arena createteam <type> <name>");
        return true;
    }

    uint8 internal_type = GetArenaTeamInternalType(team_type);
    if (internal_type > 2)
    {
        SystemMessage(m_session, "Invalid arena team type specified! Valid types: 2, 3 and 5.");
        return true;
    }

    if (player == nullptr)
    {
        SystemMessage(m_session, "Selected player not found!");
        return true;
{'fraction_non_alphanumeric': 0.1042868920032976, 'fraction_numerical': 0.018961253091508656, 'mean_word_length': 2.2797297297297296, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4024698', 'n_tokens_mistral': 782, 'n_tokens_neox': 734, 'n_words': 212}