Question: please help in c , i have following header files: #ifndef DUNGEON _ INFO _ H #define DUNGEON _ INFO _ H #include #include #include
please help in c i have following header files:
#ifndef DUNGEONINFOH
#define DUNGEONINFOH
#include
#include
#include "dungeonsettings.h
This is the name we will use for our shared memory.
const char dungeonshmname DungeonMem;
These are the names for the levers when getting the treasure at the end.
const char dungeonleverone LeverOne;
const char dungeonlevertwo LeverTwo;
struct Barbarian
int attack;
;
struct Rogue
float pick;
;
struct Wizard
char spellSPELLBUFFERSIZE;
;
struct Barrier
char spellSPELLBUFFERSIZE ;
;
struct Enemy
int health;
;
struct Trap
char direction;
bool locked;
;
struct Dungeon
bool running;
pidt dungeonPID;
struct Barbarian barbarian;
struct Rogue rogue;
struct Wizard wizard;
struct Barrier barrier;
struct Enemy enemy;
struct Trap trap;
char treasure;
char spoils;
;
#ifndef DUNGEONSETTINGSH
#define DUNGEONSETTINGSH
#include
This specifies how many possible characters you can have in your spell buffer. It is a char array. Default:
#define SPELLBUFFERSIZE
This is how many rounds the dungeon will play at a minimum. Default:
#define NUMROUNDS
This is how long the game will allow the rogue to try to guess the correct number for picking the lock. Default:
#define SECONDSTOPICK
This is how many seconds the wizard will have to guess decode the message for the barrier. Default:
#define SECONDSTOGUESSBARRIER
This is how long the barbarian has to attack the monster. Default:
#define SECONDSTOATTACK
This is the tolerance for guessing the rogue's pick. Lower values will be more difficult. Default:
#define LOCKTHRESHOLD
If true, the barbarian rounds can run. If false, barbarian rounds will not be run. Default: true
#define ALLOWBARBARIAN true
If true, the rogue rounds can run. If false, rogue rounds will not be run. Default: true
#define ALLOWROGUE true
If true, the wizard rounds can run. If false, rogue rounds will not be run. Default: true
#define ALLOWWIZARD true
How often the dungeon will check the value of the rogue's pick to see if the lock angle was guessed correctly.
Lower values will increase the rate of checks, but will also put more messages in the terminal. Default:
#define TIMEBETWEENROGUETICKS
The maximum angle used for the rogue's picking challenge. Default:
#define MAXPICKANGLE
This is the signal that the dungeon will use
Call this method to begin running the dungeon. Valid pid's must be passed for it to work.
void RunDungeonpidt wizard, pidt rogue, pidt barbarian;
#endif
Semaphore Overview
After your characters have successfully arrived at the end of the dungeon, they will have one final challenge. The
treasure room door must be held open by two party members in order to let the Rogue in to get the treasure! It
doesn't matter which party member holds which lever, only that both levers are held down by two separate party
members long enough for the Rogue to get all of the treasure. The last four points will be for releasing the
semaphores after the Rogue leaves the treasure room. Appropriate methods will be declared, and the names of the
semaphores will be given in the dungeoninfo. file. We will be using the Named Semaphores defined in
semoverview. Be sure to read the definitions for sempost and semwait, remembering that in this case, "holding"
the door for the Rogue here would be preventing the dungeon from accessing the room while the Rogue gets the
treasure. This is the final part of this assignment that is graded, so make sure everything else works first before
tackling this!
The dungeon will send a new signal, defined in dungeonsettings. as SEMAPHORESIGNAL. Make sure that your
classes can handle it without crashing! After your Rogue gets all four letters from the "treasure" field, copy them into
the "spoils" field of the Dungeon, and release the semaphores. Note: The treasure field will only give one character at
a time, and it will pause between adding additional characters. It will also not be null terminated, so make sure you
plan around tackling that problem!
Once the Rogue has gotten all of the treasure, it is up to you how you want to handle reopening the semaphores. Do
you want the Wizard and Barbarian to wait until the Rogue has four characters in the spoils field, and then
immediately release the door? Do you want the Rogue to send a signal to the Wizard and Barbarian to release the
door? This part is up to you to figure out. By now, if you've gotten this far, you should have at least one or two ideas
of how to tackle this.
Note: Your semaphores should be created before you call RunDungeon. Also, the treasure and spoils fields will be
initialized to null terminators before their values are used. This can be useful to note.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
