Question: please help me in c language, i have following header files to help construct c files. Following code: #ifndef DUNGEON _ INFO _ H #define
please help me in c language, i have following header files to help construct c files. Following code:
#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;
;
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
#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 to communicate with user processes. Default: SIGUSR
#define DUNGEONSIGNAL SIGUSR
This is the signal that the dungeon will use to tell the processes to use their semaphores. Default: SIGUSR
#define SEMAPH
The Barbarian
The Barbarian is the first character class that you should probably make. The Barbarian works as follows:
When the Barbarian receives a signal defined in dungeonsettings. the Barbarian copies the integer in the
enemy's health field into the attack field. Use dungeoninfo. to see how the Dungeon struct is set up The Dungeon
will then wait an amount of time defined in dungeonsettings.h as SECONDSTOATTACK. If the integer in attack
matches the integer in health, then this will count as success.
The Wizard
The Wizard is probably the second class that you should make. The Wizard works as follows:
When the Wizard receives a signal defined in dungeonsettings. the Wizard reads the Caesar Cypher placed in
the Barrier's spell field. The Wizard then decodes the Caesar Cypher, using the first character as the key, and copies
the decoded message into the Wizard's spell field. The Dungeon will wait an amount of time defined in
dungeonsettings.h as SECONDSTOGUESSBARRIER for the decoding process to complete. If the Wizard's spell
field matches the decoded message after the Dungeon has finished waiting, then this will count as success.
The Rogue
The Rogue is probably the last class that you should make. The Rogue works as follows:
When the Rogue receives a signal defined in dungeonsettings. the Rogue will attempt to guess a float value to
"pick" a lock. The Trap struct has a char for direction, and a boolean for locked. This puzzle is a little unique. The
Dungeon will wait for a total amount of time defined in dungeonsettings. as SECONDSTOPICK, but will check
the value of the Rogue's current pick position using TIMEBETWEENROGUETICKS. Notice that these two values are
quite different, and that is because one of them uses sleep, and the other usleep. I recommend that you follow a
similar example.
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
