对于我正在制作的老虎机,我的CheckBet()方法似乎有问题。
基本上,我在旋转机器轮之前检查用户的赌注。
由于某种原因,CheckBet()返回true。我不确定我做错了什么。
问题是,"设置代码"总是跑。
设置代码
validbet = CheckBet(Player_Bet, Player_Chips);
if(validbet);
{
Player_Chips = DeductChips(Player_Bet, Player_Chips);
RedrawStatistics(Player_Chips, Winning_Chips, Player_Bet);
//Winning_Chips = CheckResult(SpinChamber(40, 11, 2), SpinChamber(39, 11, 1), SpinChamber(38, 11, 0), Player_Bet);
}
CHECKBET
inline bool CheckBet(int Player_Bet, int Player_Chips)
{
bool validbet = true;
if (Player_Bet <= 0)
{
Draw_String(26, 17, "You Must Bet at least 20 Chips");
validbet = false;
}
else if (Player_Bet > Player_Chips)
{
Draw_String(26, 17, "You don't own that many chips!");
validbet = false;
}
return validbet;
}
答案 0 :(得分:3)
这是问题所在:
if(validbet);
你的if语句没有做任何事情!
然后这个代码块总是被执行 - 它与if:
无关{
Player_Chips = DeductChips(Player_Bet, Player_Chips);
RedrawStatistics(Player_Chips, Winning_Chips, Player_Bet);
//Winning_Chips = CheckResult(SpinChamber(40, 11, 2), SpinChamber(39, 11, 1), SpinChamber(38, 11, 0), Player_Bet);
}
删除if语句后的;
,以便该块是if适用于的语句:
if(validbet)
{
Player_Chips = DeductChips(Player_Bet, Player_Chips);
RedrawStatistics(Player_Chips, Winning_Chips, Player_Bet);
//Winning_Chips = CheckResult(SpinChamber(40, 11, 2), SpinChamber(39, 11, 1), SpinChamber(38, 11, 0), Player_Bet);
}