当前位置: 首页>>代码示例>>C++>>正文


C++ Dice::RollDice方法代码示例

本文整理汇总了C++中Dice::RollDice方法的典型用法代码示例。如果您正苦于以下问题:C++ Dice::RollDice方法的具体用法?C++ Dice::RollDice怎么用?C++ Dice::RollDice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dice的用法示例。


在下文中一共展示了Dice::RollDice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RollDiceBeforeThrowingDoublet

bool Game::RollDiceBeforeThrowingDoublet(Player* activePlayer, Dice& firstDice, Dice& secondDice, ButtonText& button, bool ShownCard)
{
	int firstRollDice = firstDice.RollDice();
	int secondRollDice = secondDice.RollDice();
	if (!activePlayer->IsBlocked())
	{
		if (activePlayer->GetPawn().move(firstRollDice + secondRollDice))
			activePlayer->AddMoney(200);
		activePlayer->SetActiveField(true);
		ShownCard = false;

		if (firstRollDice == secondRollDice)
		{
			activePlayer->SetDoublet(true);
			button.GetText().setString(L"Wyrzuciłeś dublet!\nRzuć kostkami jeszcze raz!");
		}
		else
			activePlayer->SetActiveMovement(false);
	}
	else
	{
		if (firstRollDice == secondRollDice)
		{
			activePlayer->SetDoublet(true);
			button.GetText().setString(L"Wyrzuciłeś dublet!\nRzuć kostkami jeszcze raz!");
		}
		else
		{
			button.GetText().setString(L"Nie udało się wyrzucić dubletu!\nOddaj ruch kolejnemu graczowi!");
			activePlayer->SetActiveMovement(false);
		}
		--(*activePlayer);
	}
	return ShownCard;
}
开发者ID:mobetkal,项目名称:Game,代码行数:35,代码来源:game.cpp

示例2: RollDiceAfterThrowingDoublet

bool Game::RollDiceAfterThrowingDoublet(Player* activePlayer, Dice& firstDice, Dice& secondDice, ButtonText& button, bool ShownCard)
{
	int firstRollDice = firstDice.RollDice();
	int secondRollDice = secondDice.RollDice();
	if (!activePlayer->IsBlocked())
	{
		if (firstRollDice != secondRollDice)
		{
			textButtons[1].GetText().setString(L"Brak...");
			if (activePlayer->GetPawn().move(firstRollDice + secondRollDice))
				activePlayer->AddMoney(200);
			activePlayer->SetActiveField(true);
			ShownCard = false;
		}
		else
		{
			activePlayer->SetBlock(2, true);
			textButtons[1].GetText().setString(L"Wyrzuciłeś drugi dublet!\nTrafiasz do więzienia!");
		}
	}
	else
	{
		if (firstRollDice == secondRollDice)
		{
			textButtons[1].GetText().setString(L"Wyrzuciłeś drugi dublet!\nWychodzisz z więzienia!");
			activePlayer->GetPawn().SetArea(10);
			if (activePlayer->GetPawn().move(firstRollDice + secondRollDice))
				activePlayer->AddMoney(200);
			activePlayer->SetBlock(0);
			activePlayer->SetActiveField(true);
			ShownCard = false;
		}
	}
	activePlayer->SetDoublet(false);
	activePlayer->SetActiveMovement(false);
	return ShownCard;
}
开发者ID:mobetkal,项目名称:Game,代码行数:37,代码来源:game.cpp


注:本文中的Dice::RollDice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。