コード例 #1
0
ファイル: player.cpp プロジェクト: popkc/FreeSanGuoSha
unique_ptr<Card> PlayerServer::judge()
{
	auto card = move(GAME->drawCards(1).front());
	WriteBuffer wb;
	wb << card->id;
	GAME->notify(100, Notify_JudgeStart, wb);
	TRIEV(t_Judge, &card);
	wb.clear();
	wb << card->id;
	GAME->notify(100, Notify_JudgeEnd, wb);
	return card;
}
コード例 #2
0
ファイル: player.cpp プロジェクト: popkc/FreeSanGuoSha
void PlayerServer::died(PlayerServer *killer)
{
	WriteBuffer wb;
	wb << position;
	GAME->notify(100, Notify_PlayerDied, wb);
	TRIEV(t_PlayerDied,&killer);
	alive = false;
	eventsRegister.clear();
	wb.clear();
	wb << position << role;
	GAME->notify(100, Notify_PlayerRole, wb);
	switch (role)
	{
	case Role_Zhu:
	{
		int aliveNei = 0;
		for (auto player : game->players) {
			if (player->alive) {
				if (player->role==Role_Nei) {
					aliveNei++;
				}
				else {
					throw Role_Fan;
				}
			}
		}
		if (aliveNei == 1) {
			throw Role_Nei;
		}
		else
			throw Role_Fan;
		break;
	}
	case Role_Zhong:
		if (killer && killer->role==Role_Zhu) {
			killer->discardAll();
		}
		break;
	case Role_Fan:
		if (killer) {
			killer->getHands(GAME->drawCards(3));
		}
	case Role_Nei:
	{
		for (auto player : game->players) {
			if (player->alive && player->role != Role_Zhu && player->role != Role_Zhong) {
				goto endSwitch;
			}
		}
		throw Role_Zhu;
	}
	}
endSwitch:;
	discardAll();
	for (int i = 0; i < 3; i++) {
		if (this->judgingArea[i]) {
			list<unique_ptr<Card>> cards;
			cards.push_back(move(loseJudgingArea((JudgingArea)i)));
			discardCards(cards);
		}
	}
	for (auto &p : skillCards) {
		for (auto &card : p.second) {
			GAME->addToDeadwood(card);
		}
	}
}