<commit_before>#include "GMCommand.h"
#include "map"

typedef void (*PTRFUN)(GameGrail*, PlayerEntity*, vector<string>&); 
map<string, PTRFUN> cmd_mapping;

/*
energy: ýɫ2ʯˮ
*/
void setEnergy(GameGrail* engine, PlayerEntity* player, vector<string>& ss)
{
	player->setGem(atoi(ss[1].c_str()));
	player->setCrystal(stoi(ss[2].c_str()));

	GameInfo game_info;
	Coder::energyNotice(player->getID(), player->getGem(), player->getCrystal(), game_info);
	engine->sendMessage(-1, MSG_GAME, game_info);
}

/*
¼gmָgmָcmd_mappingУkeyΪgmָʽַvalueǴָ
*/
void initialize_gm_command()
{
	cmd_mapping["!`energy"] = setEnergy;  // 
}

/*
ַָи
*/
void split(const string& src, const string& separator, vector<string>& dest)
{
    string str = src;
    string substring;
    string::size_type start = 0, index;

    do
    {
        index = str.find_first_of(separator,start);
        if (index != string::npos)
        {    
            substring = str.substr(start,index-start);
            dest.push_back(substring);
            start = str.find_first_not_of(separator,index);
            if (start == string::npos) return;
        }
    }while(index != string::npos);
    
    //the last token
    substring = str.substr(start);
    dest.push_back(substring);
}

void gm_cmd(GameGrail* engine, PlayerEntity* player, string cmd)
{
	vector<string> ss;
	split(cmd, " ", ss);
	// ָöӦgmûжӦֱָ
	if (cmd_mapping.find(ss[0]) == cmd_mapping.end())
	{
		return;
	}
	PTRFUN func = cmd_mapping[ss[0]];
	func(engine, player, ss);
}
<commit_msg>添加手牌的gm指令<commit_after>#include "GMCommand.h"
#include "map"

typedef void (*PTRFUN)(GameGrail*, PlayerEntity*, vector<string>&); 
map<string, PTRFUN> cmd_mapping;

/*
energy: ýɫ2ʯˮ
*/
void setEnergy(GameGrail* engine, PlayerEntity* player, vector<string>& ss)
{
	player->setGem(atoi(ss[1].c_str()));
	player->setCrystal(stoi(ss[2].c_str()));

	GameInfo game_info;
	Coder::energyNotice(player->getID(), player->getGem(), player->getCrystal(), game_info);
	engine->sendMessage(-1, MSG_GAME, game_info);
}

/*
card: ƣΪӵid
*/
void addCard(GameGrail* engine, PlayerEntity* player, vector<string>& ss)
{
	int howmany;
	vector<int> cards;
	for (int i = 1; i < ss.size(); ++i)
		cards.push_back(atoi(ss[i].c_str()));
	howmany = ss.size() - 1;
	player->addHandCards(howmany, cards);

	GameInfo game_info;
	Coder::handNotice(player->getID(), player->getHandCards(), game_info);
	engine->sendMessage(-1, MSG_GAME, game_info);
}

/*
¼gmָgmָcmd_mappingУkeyΪgmָʽַvalueǴָ
*/
void initialize_gm_command()
{
	cmd_mapping["!`energy"] = setEnergy;  // 
	cmd_mapping["!`card"] = addCard;     // 
}

/*
ַָи
*/
void split(const string& src, const string& separator, vector<string>& dest)
{
    string str = src;
    string substring;
    string::size_type start = 0, index;

    do
    {
        index = str.find_first_of(separator,start);
        if (index != string::npos)
        {    
            substring = str.substr(start,index-start);
            dest.push_back(substring);
            start = str.find_first_not_of(separator,index);
            if (start == string::npos) return;
        }
    }while(index != string::npos);
    
    //the last token
    substring = str.substr(start);
    dest.push_back(substring);
}

void gm_cmd(GameGrail* engine, PlayerEntity* player, string cmd)
{
	vector<string> ss;
	split(cmd, " ", ss);
	// ָöӦgmûжӦֱָ
	if (cmd_mapping.find(ss[0]) == cmd_mapping.end())
	{
		return;
	}
	PTRFUN func = cmd_mapping[ss[0]];
	func(engine, player, ss);
}

{'fraction_non_alphanumeric': 0.16326530612244897, 'fraction_numerical': 0.004688361831218974, 'mean_word_length': 3.2027809965237544, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 31, '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': '4304392', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1379, 'n_words': 238}