Write a c++ program to stimulate gameplay.
Randomly select two players to attack or restore.
A player starts off with 300 points. A player dies when his points is reduced to 0.
A player can either attack or restore another player.
Points:
If a player’s points are between 200 and 300 inclusive an attack can decrease a player points by a random number between 20 and 80 and a restore and increase a player points by a random number between 20 and 80.
200 ≤ POINTS ≤ 300 (Attack 80%, Restore 20%)
100 ≤ POINTS < 200 (Attack 70%, Restore 30%)
0 ≤ POINTS < 100 (Attack 40%, Restore 60%)
Create a struct for Players and Moves.
struct Player{
string name;
int points;
};
struct Move{
int amount;
char move; // ‘A’- Attack, ‘R’-Restore
};
Read from a file (input.txt) the following information:
20 20
paul
peter
kim
The first integer is the random number generator. The second number is a number of moves per player. After the integers there can be up to 50 names in the text file with each name on a separate line.
Sample Output:
paul attacks kim -50
peter restores paul +30
After 20 moves
paul 100
peter 150
kim 200
Here is the
solution to your question. I tried my best to solve your doubt,
however, if you find it is not as good as expected by you. Please
do write your further doubts regarding this question in the comment
section, I will try to resolve your doubts regarding the submitted
solution as soon as possible.
Please give proper indentation as shown in the screenshot.
If you think, the solution provided by me is helpful to you please
do an upvote.
Either you have forgotten to upload some files or you have provided incomplete questions. I am not able to find input and output files also some functions of your question are very confusing. Please do clarify in the comments
However, based on your provided information below is the solution that might help you.
![]() |
|
![]() |
Write a c++ program to stimulate gameplay. Randomly select two players to attack or restore. A...
Number Guessing Game Games Write program in C++. For this game, the computer will select a random number between 1 and 100 (inclusive). The computer will then ask the (human) player to guess the number the computer has selected. After the player’s guess is input to the computer, the computer will output one of three responses, depending on the relationship of the number the player guessed to the number the computer selected: “Your guess was too low.” “Your guess was...
The project in C is to create a game in which a player goes through a series of rooms in which they can find a prize or a monster to fight. Game Rules: • A player will enter the number of rooms (greater than 1) they want to endure. The program will dynamically allocate an array of Rooms and populate it with prizes and monsters. Then, the player will enter each room in which an action will occur: o If...
In need of some help with a LCR C++ game. The code will run, but I need it to cycle through the turns automatically so that the only input from the user is the number of players. It's also showing the winner as the person with 0 chips which is incorrect and I can't figure out why. Any help is greatly appreciated as this is already late. Game rules: Develop a program that follows the rules of Left Center Right...
The Rules of Pig Pig is a folk jeopardy dice game with simple rules: Two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 (”pig”) is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). At any time during a player’s turn, the player is faced with two decisions: roll If the player rolls a 1: the player scores nothing and it becomes the...
Need C programming help. I've started to work on the program, however I struggle when using files and pointers. Any help is appreciated as I am having a hard time comleting this code. #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_LINE 100 #define MAX_NAME 30 int countLinesInFile(FILE* fPtr); int findPlayerByName(char** names, char* target, int size); int findMVP(int* goals, int* assists, int size); void printPlayers(int* goals, int* assists, char** names, int size); void allocateMemory(int** goals, int** assists, char*** names, int size);...
python question
Question 1 Write a Python program to play two games. The program should be menu driven and should use different functions to play each game. Call the file containing your program fun games.py. Your program should include the following functions: • function guess The Number which implements the number guessing game. This game is played against the computer and outputs the result of the game (win/lose) as well as number of guesses the user made to during the...
C++ Can someone please help with this code... even when the players number isnt a winning number the program always says the player wins: #include <stdio.h> #include <time.h> //main function int main() { //seeding a random number srand(time(0)); //define the arrays for the wagered, winning amount, percent amount double amounts[7] = { 1, 5, 10, 20, 50, 100, 1000 }; double payoff[7] = { 100, 500, 1000, 2000, 5000, 10000, 100000 }; double percent[7] = { 0.01, 0.05, 1, 2,...
C++ programming: Write a program to score a two player game of
scrabble. The program reads the player number, word played and the
squares on the board used for each word played then reports the
scores for each word and the total score for each player.
• All information is read from the file, moves.in.
• Each line of the file contains a player number (1 or 2), the
word and the board spaces
used.
• The words are entered...
Please i need helpe with this JAVA code. Write a Java program simulates the dice game called GAMECrap. For this project, assume that the game is being played between two players, and that the rules are as follows: Problem Statement One of the players goes first. That player announces the size of the bet, and rolls the dice. If the player rolls a 7 or 11, it is called a natural. The player who rolled the dice wins. 2, 3...