exercise 4 fight club
play

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


  1. Exercise 4: Fight Club Karl Gmeiner 2015

  2. 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 and let them fight against each other. 1.1 Description of a fight The fight system works as follows: Each fighter has • lifepoints (in the beginning 100 points), • offense points (a random number between 25 and 50), • defense points (a random number between 25 and 50). 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 counterattack. Otherwise, he can return his hitpoints that is a random number y between 0 and the 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 offensePoints = random(25 to 50) 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 or defense (or both) abilities. You should implement at least 4 fighter types. These fighter types are • Warrior. The warrior is a brave fighter that sometimes can attack very strongly (one by six chance of double hitpoints). • Ninja: Ninjas move very fast, hence they can escape attacks sometimes but still launch a 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: • Mage (when attacking he drinks some special potion that lets him add spell points to an attack) • Cursed (turns into zombie after dead) • ChuckNorris (possibility of an instantly deadly roundhouse kick) 1

  3. 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 of fighter and set a (unique) nickname for it. 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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend