Project 4 – Monster Masher
Pitt is being threatened! Monsters are swarming and only YOU can stop them! You will implement a monster battling game and using your own custom functions to break the program into manageable chunks.
Gameplay
The player will start with a certain amount of health points, attack points, and a modifier value which will be used to improve either the attack or defend ability. A configurable number of monsters will be generated with a random number of health points and a random attack value. The player will face the monsters one at a time and decide whether to attack or defend in a particular round. The game ends when all the monsters are slain or the player has no remaining health points.
Setup
masher.config file
Line
Indicates
Type
1st
Seed value
Integer or blank (blank indicates that no seed should be set)
2nd
Number of monsters
Integer
Player starting stats:
Key
Value
Health
20
Attack
20
Modifier
10
Monster stats
Key
Value
Health
Random integer between 25 & 35 inclusive
Attack
Random integer between 5 & 15 inclusive
Structure
Monster Masher should begin by reading the ‘masher.config’ file which can be assumed to be in the same directory as the program. masher.config is a text file containing two lines. The first will either hold an integer or be blank. If this value is not blank it should be passed to random.seed(). The second line will be an integer indicating the number of monsters to generate.
Player data and monsters are then initialized. Use the values in the above tables.
The game loop then beings. It should continue as long as there are monsters to fight and the player’s health is above 0. If either of these conditions is not met exit the game loop. If there are no monsters left notify the user that they won, otherwise inform them of their defeat.
The game loop should perform the following steps:
1. Select a monster
2. While the monster’s health and the player’s health are both above 0:
a. Determine the monster’s attack. This will be a random integer between 0 and the monster’s attack value, inclusive
b. Display a hint to the user as to the size of the attack value. The attack value will range from 0-15 so break it into 5 hints:
i. 0-2 – “It’s looking tired!”
ii. 3-5 – “It’s focused.”
iii. 6-9 – “Looking tough!”
iv. 10-13 – “May be a challenge…”
v. 14-15 – “It’s going berserk!”
c. Prompt if the player would like to attack or defend. The player’s attack and defense for the turn should be based on the following table:
Player Choice
Player Turn Attack
Player Turn Defense
Attack
Player’s attack value + random integer between 0 and player modifier
2
Defense
Player’s attack value
Random integer between 0 and player modifier
d. Resolve the attack phase by subtracting the player’s turn attack value from monster’s health. Find the difference between the monster’s attack value and the player’s turn defense value. If the difference is positive (the monster’s attack was greater than the player’s defense) subtract that from the player’s health, otherwise do nothing.
e. Display the results of the round including player’s attack and defense value, monster’s attack value, and remaining health of both.
3. If the player killed the monster add 10 points to the player’s health.
Grading
A sample framework has been provided along with some pseudocode. You do not have to use this, but it is provided as a guide.
A function is used for program initialization. The program is initialized properly – 5pts
Gameplay loop is broken into logical portions using functions – 5pts
Feedback is provided as described – 5pts
Damage is computer properly – 5pts
Total – 20pts
CS案例之python game battling game:Project 4 – Mons
2017-12-16