I would start by looking at your classes then.
It'd probably be a good idea to create a player class, each with it's own score. You can give the class a function, something like ThrowDart(), where you can write the logic that deducts the score from the remaining total. You can then create two instances of that player class within your code, one called Cid and one called Joe.
It'd then be a case of looping through and calling the ThrowDart() function of each player three times, until someone wins. You'll have to put some kind of check in the function to see if they've won or gone bust.
The random logic is potentially difficult, depending on how smart/skilled you want your players to be. At the lowest level, you can randomly pick a number between 0 and 60 for each thrown dart, logic which would be calculated in your ThrowDart() function. If you wanted to implement some intelligence, I would work out some sort of system where you work out the desired target and then, depending on the AI player's skill, assign probabilities for the likelihood of hitting that target. That'll work out better when you get near the end of the game and the player is trying to hit specific values, rather than flowing blindly.
As I've mentioned, I'd implement a check to see if the player has one in the ThrowDart() function. It could call a HasWon() function that checks to see if the score is equal to zero. If the score is less than zero, you can assume the player has thrown a dart that's too high for the remaining value and gone bust, ceasing their turn.
1 2 3 4 5 6
|
// Declare players
// Start while loop (while nobody has won)
// -- Iterate a for loop 3 times, throwing Cid's darts
// -- Iterate a for loop 3 times, throwing Joe's darts
// End while loop (someone has one)
// Output name of winner
|