#include <fstream>
#include <string>
#include <map>
#include <list>
const char a=133;
const char e=138;
const char o=149;
const char u=151;
const char x=196;
#ifndef DICHIARAZIONI_H
#define DICHIARAZIONI_H
void help();
bool maiuscolizza(string& linea);
bool research(string& linea, string& right, string& left);
//______________________________________________________________________________
// Classe Luogo (Contenitore di oggetti)
class oggetto;
class oggcont;
class luogo{
protected:
friend fstream& operator>>(fstream&
s, luogo* &a);
static int luogocod;
int idluogo;
string sopranome;
string nome;
string descrizione;
map<string,oggetto*> oggetti;
luogo* nord; string ostr_nord;
luogo* sud; string ostr_sud;
luogo* est; string ostr_est;
luogo* ovest; string ostr_ovest;
luogo* alto; string ostr_alto;
luogo* basso; string ostr_basso;
bool stato;
bool illuminazione;
string suggest;
public:
luogo(string n, string sopran, string
d, bool i, bool st, string sugg);
~luogo();
void prnt_des();
luogo& operator+=(oggetto &ogg);
string name(){return nome;};
int id(){return idluogo;};
void pnord(luogo& n){nord =
&n;};
void psud(luogo& s){sud = &s;};
void pest(luogo& e){est = &e;};
void povest(luogo& o){ovest =
&o;};
void palto(luogo& a){alto =
&a;};
void pbasso(luogo& b){basso =
&b;};
void Onord(string StrN){ostr_nord =
StrN;};
void Osud(string StrS){ostr_sud = StrS;};
void Oest(string StrE){ostr_est = StrE;};
void Oovest(string StrO){ostr_ovest =
StrO;};
void Oalto(string StrA){ostr_alto =
StrA;};
void Obasso(string StrB){ostr_basso =
StrB;};
void delostr(string& direzione);
void guarda(string ogg="");
void cambiastato(){stato=true;};
luogo& prendi(string& ogg,
oggcont& zaino);
luogo* vai(luogo* &utente, string&
s);
luogo* sposta(luogo* &utente,
string& ogg1, string& ogg2);
luogo* lascia(luogo* &utente,
string& ogg, oggcont& zaino);
luogo* apri(luogo* &utente, oggcont&
zaino, string& ogg1, string& ogg2);
luogo* usa(luogo* &utente, oggcont&
zaino, string& ogg1, string& ogg2);
void accendi(oggcont& zaino, string&
ogg1, string& ogg2);
void ricerca(string nomeobj, unsigned
int&);
int salva(fstream& uscita);
int salvap(fstream& uscita);
};
//______________________________________________________________________________
// Classe Base Oggetto
class oggetto{
protected:
friend fstream& operator>>(fstream&
s, oggetto* &a);
static int CodOgg;
int idogg;
string nomeogg;
string desogg;
bool illuminabile;
bool acceso;
bool trasportabile;
bool spostabile;
bool apribile;
bool cnt;
string suggest;
string reagente;
public:
oggetto(string n, string d, bool i,
bool t, bool s, bool a, bool ac, string sugg, string r);
virtual ~oggetto(){;};
string nome()const {return nomeogg;};
string descrizione()const {return
desogg;};
int id()const {return idogg;};
bool prendi()const {return
trasportabile;};
bool lux()const {return acceso;};
bool contenitore()const {return cnt;};
bool sugg()const {return suggest==""?
false : true;};
string prntsugg()const {return suggest;};
virtual oggetto* estrai(string& ogg,
string& tipo){return NULL;};
void deletesugg(){suggest="";};
void virtual guarda(){cout<<"\n
"<<nomeogg<<" -
"<<desogg<<'\n';};
virtual luogo* sposta(luogo*
&utente, string& ogg);
virtual luogo* usa(luogo* &utente,
string& ogg);
virtual luogo* apri(luogo* &utente,
string& ogg);
void accendi(string& ogg);
void spegni(){acceso = false;};
virtual int salva(fstream& uscita);
};
//______________________________________________________________________________
// SottoClasse Oggetto Ostruttore
class oggostr:public oggetto{
protected:
string direzione;
bool stato;
friend fstream& operator>>(fstream&
s, oggostr* &a);
public:
oggostr(string n, string d, bool i,
bool t, bool s, bool a, bool ac, string sugg, string r, string dir,
bool aperto):oggetto(n, d, i, t, s, a, ac, sugg, r){direzione = dir;
stato = aperto;};
~oggostr(){;};
virtual luogo* usa(luogo* &utente,
string& ogg);
virtual luogo* apri(luogo* &utente,
string& ogg);
virtual int salva(fstream& uscita);
virtual luogo* sposta(luogo*
&utente, string& ogg);
};
//______________________________________________________________________________
// SottoClasse Oggetto Contenitore (Contenitore di oggetti)
class oggcont:public oggetto{
protected:
map<string,oggetto*> cont;
friend fstream& operator>>(fstream&
s, oggcont* &a);
bool stato;
public:
oggcont(string n, string d, bool i,
bool t, bool s, bool a, bool ac, string sugg, string r, bool st):oggetto(n,
d, i, t, s, a, ac, sugg, r){stato = st; cnt = true;};
~oggcont();
oggcont& operator+=(oggetto&
ogg);
virtual oggetto* estrai(string& ogg,
string& tipo);
bool search(string ogg);
virtual luogo* apri(luogo* &utente,
string& ogg);
void virtual guarda();
virtual luogo* usa(luogo* &utente,
string& ogg);
virtual int salva(fstream& uscita);
virtual void salvazaino(fstream&
uscita);
};
//______________________________________________________________________________
// SottoClasse Oggetto Nascondiglio (Contenitore di oggetti)
class oggnasc:public oggetto{
protected:
map<string,oggetto*>
nascondiglio;
friend fstream& operator>>(fstream&
s, oggnasc* &a);
public:
oggnasc(string n, string d, bool i,
bool t, bool s, bool a, bool ac, string sugg, string r):oggetto(n, d,
i, t, s, a, ac, sugg, r){;};
oggnasc& operator*=(oggetto &ogg);
~oggnasc();
virtual luogo* sposta(luogo*
&utente, string& ogg);
virtual luogo* usa(luogo* &utente,
string& ogg);
virtual int salva(fstream& uscita);
};
//______________________________________________________________________________
// Classe Ambiente (Contenitore di luoghi)
class ambiente{
protected:
map<string,luogo*> luoghi;
luogo* utente;
luogo* fine;
static oggcont zaino;
string titolo;
string finegioco;
list<string> dati;
public:
ambiente(luogo& ll);
~ambiente();
bool carica();
void setutente(luogo* & l){utente = l;};
string prntitolo(){return titolo;};
ambiente& operator+=(luogo& l);
void analizza(string s);
void start(){utente->guarda("");
utente->cambiastato();};
void end();
int salva();
};
#endif
|