Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

creating a game with“player used pattack and opponent used oattack. player defeated opponent”

The game should be able to determine a winner when executed. If you have not already done so, add a print statement to the conditional that will send something akin to the following to the screen after evaluating the attacks selected:

Let's assume the player wins this round:

"player used pattack and opponent used oattack. player defeated opponent"

Keeping Score

Now that the game mechanics are settled, you will need to create a score keeping system. We will keep it simple and award one point to the player that wins the round.

To do this, we will need to create variables to store each player's score values (pscore & oscore, respectively). When the game begins, they will need to start at zero (0).

The Game Start Conditions

We will also need a game toggle. Something to use to tell the script whenthe game is over. Let's keep is simple and use gameover. To begin with, we should probably set this to False.

Updating the Game Conditional

Now that we have set up the Game Start Conditions, we can update the game conditional (where we compare attacks and declare a winner). After each possible conditional you should add a line of code to increase the pscore or oscore depending on who the winner of that scenario is (remember variable += 1 ? That will come in handy here).

Additionally, you should include a line to update the user of the current score - something I would include at the START of each game, even before anyone scores.

Finally, you should place your game comparison conditional and scoring elements inside a loop to allow the game to continue until either the player or the opponent has score at least 3 points.

Hint: You should not attempt the loop until your conditional is recording the score correctly.

Hint 2: You will need an additional conditional statement when the game begins to check the score and determine if the code needs to continue. For example, if pscore is less than 3, play the game. Otherwise, set gameover equal to True.

Comments