Hello! I've designed a simple card game where two cards are displayed and the user has to bet on whether they will get a card that is inbetween the two cards displayed. If the user doesn't want to bet, they just deal again. The user begins with £100.
The game works fine in most aspects, but has a huge flaw. The user can bet more than they have in thier balance. So, if the user has £100, they bet £105, and they win, they will have £205 in thier balance. This is clearly bad! And if they have £100, they bet £105 and they lose, thier balance stays the same. This is also pretty bad.
So I thought a simple if-statement would sort this out:
if (wager > balance)
{
winLoseLabel.Text = "You can't bet more than you have!";
}
switch (betResult)
{
case TIE:
winloseLabel.Text = "Tie. You still lose. HA!";
myRules.Balance -= wager;
break;
case PLAYERWINS:
winloseLabel.Text = "You win. Woop-de-do..";
myRules.Balance += wager;
break;
case DEALERWINS:
winloseLabel.Text = "You lose. Get over it.";
myRules.Balance -= wager;
break;
}
Why doesn't this work? I'm pretty sure it's something so simple, but I'm pretty new to C#, so go easy on me!