Homework 8, OPIGS Adventure Game.
Short Description:
Write a program that will simulate a simple role playing game.
This assignment is worth 40 points.
Goals
When you finish this homework, you should have:
- Implemented a program using classes.
Formal Description
For this assignment you are to implement a simple role playing game based on the OPIGS rules. To make the project easier to implement we will change these rules somewhat.
An adventure consists of a series of encounters. In this game, you could consider the encounters to be just steps along a path that does not branch or fork. The player starts and the beginning and proceeds to the first encounter. If they successfully complete this encounter they move to the next, continuing until the adventure is over.
Each encounter consists of both an opponent to fight and a challenge to overcome.
An opponent is described in the rules and is very much like a player described below.
Challenges are things like traps, puzzles, or physical barriers that the player must overcome.
When a player enters an encounter, they must first defeat the opponent then overcome the challenge. If they die in the attempt, then the game is over. If they succeed, they collect experience and treasure.
Once a player has earned sufficient experience they will level up. This process is described in the rules as well.
Players and Opponents
A player has:
- Four attributes.
- Beef, Brains, Hammer, Coruba range between 2 and 28
- A number of hit points.
- A designated number and value of Hit Dice.
- A level, starting at 1.
- A number of experience points, starting at 0
- An amount of cash, starting at 100
- And a weapon designation. (None ... Mega), starting at None
We will ignore luck for this game.
The player should be able to change weapons if they find a better weapon.
A player or opponent is stored in a file in the following format
name:beef:brains:hammer:coruba:hp:maxhp:number of hd: value of hd: level:xp:cash:weapon:weapon description
so
Ralph the Rogue:17:23:13:26:10:14:3:10:1:0:100:None:Nothing
- Name: Ralph the Rogue
- Beef: 17
- Brains: 23
- Hammer: 13
- Coruba: 26
- Hit Points: 10
- Maximum Hit Points: 14
- Hit Dice: 3
- Die Value: 10 (ie 3D10)
- Level: 1
- Experience Points: 0
- Cash: 100
- Weapon: None
- Wepon Description: Nothing
Note that weapon can be None, Wimpy, Normal, Beefy, Mega.
Challenges
Challenges are much simpler. They consist of
- A name
- A description
- An attribute used to defeat the challenge
- The Level of the challenge
- The damage caused if the challenge is not overcome
- Experience points gained if the challenge is overcome.
- An amount of gold gained if the challenge is overcome.
Stored as a string, a challenge might will be
Name
Description
Attribute:Level:damage:xp:gold
so
Trap
A simple pitfall trap. Try to avoid it.
Coruba:1:1:1:0
Is a trap. It requires a Coruba roll (1D12 + Coruba bonus) to overcome. It will cause one hit point damage if the player falls in the trap and will yield 1 xp if the player succeeds in avoiding the trap. This particular trap has no gold value if it is avoided.
Combat
The rules say that combat begins anyone can attack first. We will modify that so that the player always attacks first. After the player attacks the opponent will attack. This continues until one of the two has 0 or fewer hit point remaining.
An attack consists of rolling 1D12 plus any Hammer bonus to see if the opponent is "hit". Find this score on the Combat table to determine the outcome. Compute the result and add any appropriate damage bonus based on the weapon the attacker is using and the attacker's beef bonus. This score is then subtracted from the appropriate player.
If the attacker has a self hit they take damage including bonuses.
A Critical Jam results in the attacker's weapon being set to None.
You can not "heal" from a hit. For example, an attacker with a Beef 2 (-4 damage bonus) scores a Scratch (d4) and rolls a 1. The actual damage should be 1-4 or -3, but this is not possible. Damage will always be at least a 1.
If the player defeats an opponent they gain the following
- 1 experience point.
- All of the cash the opponent is carrying.
- The option to pick up the opponent's weapon if it was not destroyed.
Leveling Up
After all phases of an encounter have been completed. The program should check to see if the player has gained enough experience points to advance. If they do, compute the new hit points. In addition, the player will also gain one point in any attribute of the user's choice.
Note, the rules state that a player will gain an experience point when they gain $\$$1000.
This can be the result of multiple encounters. Every time the gold gained goes over a $\$$1000 barrier, the player gains an additional experience point.
It might be possible to level up multiple times after a single encounter. Please make sure that you handle this correctly.
Gameplay
The game will have minimal interaction with the player. Battles and puzzles are automatically resolved. Players are automatically advanced when they have sufficient hit points. The only real choices are:
- Asking if the user wishes to pick up a weapon after a battle if the opponent had one.
- Asking which attribute the player wishes to improve on gaining a level.
- Asking what the player wishes to do after an encounter is complete.
- The player will have three options.
- Advance: move on to the next encounter.
- Resign: quit the game.
- Rest: stay in the room for a brief period, recovering up to 10 lost hit points.
- Sleep: stay in the room for a night recovering up to 30 hit points.
- Inventory: Print out a current description of the player.
- Look: Print out the names and descriptions of all opponents and challenges that are ahead in the adventure.
- This continues until the player resigns or advances.
Loading the Game
The game should be loaded from a file. The user should be prompted for the file name.
The file will contain
- A line describing the player character.
- A single integer describing the number of encounters. This will be less than 50.
- For each encounter, in order
- A line describing the opponent at the encounter.
- Three lines describing the challenge at the encounter.
This file will be error free.
Required Interaction
To be specified later.
Other Requirements
Required Files
A single tar file containing the source code and makefile for this program. Your tar file should not contain executable code (hw8) or any object files (*.o).
To create tar file, follow the Working with the Tape Archive Utility (tar)
Submission
Submit your tar file to the D2L assignment folder Homework 8 by the due date.