Exercise 4: Fight Club
Karl Gmeiner
2015
Exercise 4: Fight Club Karl Gmeiner 2015 Exercise 4: Fight Club 1 - - PDF document
Exercise 4: Fight Club Karl Gmeiner 2015 Exercise 4: Fight Club 1 Exercise 4: Fight Club The first rule of this exercise is, do not talk about this exercise. Implement a round and text-based fighter game. In this game, you can create fighters
2015
Exercise 4: Fight Club
The first rule of this exercise is, do not talk about this exercise. Implement a round and text-based fighter game. In this game, you can create fighters and let them fight against each other.
1.1 Description of a fight
The fight system works as follows: Each fighter has
When a fighter attacks another one, a random number x between 0 and the fighter’s offense points is used as hitpoints. The other fighter is then attacked with x hitpoints, meaning that his lifepoints are reduced by x. If the lifepoints of the attacked fighter reach 0, the fighter dies instantly without a chance for a
attacked fighter’s defense points. These hitpoints should be reduced from the attacker’s life points. A dead fighter cannot attack anyone anymore. The following pseudo code shows the initialization of a fighter. class Fighter int offensePoints int defensePoints int lifepoints constructor
defensePoints = random(25 to 50) lifepoints = 100
1.2 Fighters
There should be different kinds of fighters (hint: use inheritance). They should have special offense
These fighter types are
chance of double hitpoints).
counterattack (one by six chance that an attack does not cause any damage). You should implement 2 further fighter types. Invent some yourself and be creative. Some suggestions for fighters:
attack)
1
Exercise 4: Fight Club
1.3 Menu
You should have a small menu to create fighters. In this menu you should be able to pick the type
You should then be able to pick two fighter by their nickname and let them fight against each other. Last, there should be a “last man standing”-mode in which random fighters are picked to fight against each other until only one fighter is left. Be aware that fighters usually do not fight against themselves. You should output status messages on the outcome of each fight. It should be possible to list all fighters with their abilities and to delete a single fighter. Furthermore, dead fighters should be deleted instantly. 2