I am doing a program which switches betwen two players, first players throws two dices and their added, then second player throws.
So far so good, however:
I need it to run again, so it goes back to player 1 so he can chooce to either throw again or stop and let the other one throw or stop.
The game will continue until you reach 18, or close to it, however not above it.
If you stop, the other player can chooce to continue.
I am betting I should use a while and if for all this, however I am confused on the actual part of it.
Any suggestions on what kind of combination of while and if's and maybe for's I should use?
ex:
While
Player 1 choces
If
Player chooced Y
Player rolls
Dice sum and throw is written out
else
Player 2 chooces
if
Player choosed Y
Player rolls
Dice sum and throw is written out
if(dice < 18)
Cancel the while
This is a sum of what I got so far.
Problem is however for the info to be stored, so if sum on player 2 is 5 first, then 11 it should then be 16 and then its player 1 to throw again, and lets say he had total sum of 9 before, then it should add the previus sum and the new sum ex 17, in which case its player 2 to do it again until either one gets above 18 or one stops and other one fails.
(Also: If player 1 throws and player 2 stops, then it should be player 1 again)
I know its a bit of walltext, but I suddenly got a huge motivation for this as it feels its a bit out of my league, yet in my league.