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...
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...
Please, I need help with program c++. This is a chutes and ladders program. The code must be a novel code to the specifications of the problem statement. Thank you very much. Assignment Overview This program will implement a variation of the game “chutes and ladders” or “snakes and ladders:” https://en.wikipedia.org/wiki/Snakes_and_Ladders#Gameplay. Just like in the original game, landing on certain squares will jump the player ahead or behind. In this case, you are trying to reach to bottom of the...
the card game Acey Deucey, which is also known by several other names. In general, the game is played with three or more people that continue to gamble for a pot of money. The pot grows and shrinks depending on how much General description of the game ● Two cards are dealt face up to a player from a shuffled deck of cards. ○ If the face of each card is the same then the player adds $1 into the...
Requirements: 1. You are not allowed to use global variables. 2. Must declare the following two constants public static final int POINTS = 30; public static final int FORFEIT_POINTS = 20; 3. You can implement your own solution but you are required to break down the problem into smaller pieces. 4. You must provide the output for two rounds of game minimum. 5. Since we are using the Random number generator your output will not be exactly like mine. However,...