83 lines
2.6 KiB
C++
Executable File
83 lines
2.6 KiB
C++
Executable File
#ifndef ROOM_H_
|
|
#define ROOM_H_
|
|
|
|
#include <iostream>
|
|
using namespace std;
|
|
class Room {
|
|
bool isEnd;
|
|
int exits,newExits;
|
|
int secrets;
|
|
int monsters;
|
|
int items;
|
|
bool inRoom;
|
|
|
|
public:
|
|
Room(bool ie,int e,int s,int m,int i)
|
|
{
|
|
isEnd = ie;
|
|
exits = e;
|
|
secrets = s;
|
|
monsters = m;
|
|
items = i;
|
|
inRoom=false;
|
|
newExits = e;
|
|
}
|
|
Room(){}
|
|
//facilitates opening and closing a door
|
|
|
|
int opencloseExit(int ex, int oc){
|
|
/* * * * * * * * * * * * * * *
|
|
* TO DO:
|
|
* FIX THE OPENING ALREADY OPEN/CLOSE
|
|
*
|
|
*
|
|
* * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
|
|
if (oc == 2){ //close
|
|
if((oExits() & ex ) == ex ){
|
|
if(newExits > exits ) {
|
|
|
|
newExits = exits;
|
|
}
|
|
|
|
newExits = newExits - ex;
|
|
|
|
return 1;
|
|
} else {
|
|
return 2;
|
|
}
|
|
}
|
|
|
|
if (oc==1){ //open
|
|
if((oExits() & ex ) == ex ){
|
|
|
|
newExits = newExits + ex;
|
|
|
|
if(newExits > exits ) {
|
|
|
|
newExits = exits;
|
|
|
|
}
|
|
return 1;
|
|
|
|
} else {
|
|
return 2;
|
|
}
|
|
}
|
|
}
|
|
void leaveRoom(){inRoom=false;}
|
|
void enterRoom(){inRoom = true;}
|
|
bool InRoom(){return inRoom;}
|
|
bool IsEnd(){return isEnd;}
|
|
int Exits(){return newExits;}
|
|
int nExits(){return newExits;}
|
|
int oExits(){return exits;}
|
|
int Secrets(){return secrets;}
|
|
int Monsters(){return monsters;}
|
|
int Items(){return items;}
|
|
};
|
|
#endif /*FUNCS_H_*/
|