Logo
~Sockets~
~Examples~
~Contact~


World Class Reference

Room (CELL) container. More...

#include <World.h>

Collaboration diagram for World:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 World (SmallHandler &)
 ~World ()
void GetRandomLocation (int &, int &, std::string &)
bool FindAt (int, int, std::string &)
bool GetAt (int, int, std::string &, bool &, bool &, bool &, bool &)
void AddAt (int, int, const std::string &)
SmallHandlerHandler ()
void Open (int, int, const std::string &)
size_t NumberOfCells ()

Private Types

typedef std::vector< CELL * > cell_v

Private Attributes

SmallHandlerm_handler
cell_v m_cells

Classes

struct  CELL
 Room properties struct. More...

Detailed Description

Room (CELL) container.

Definition at line 33 of file World.h.


Member Typedef Documentation

typedef std::vector<CELL *> World::cell_v [private]

Definition at line 51 of file World.h.


Constructor & Destructor Documentation

World::World ( SmallHandler  ) 

Definition at line 28 of file World.cpp.

References m_cells.

00028                             : m_handler(h)
00029 {
00030         CELL *p = new CELL(1000,1000,"The Beginning");
00031         m_cells.push_back(p);
00032 }

World::~World (  ) 

Definition at line 35 of file World.cpp.

References m_cells.

00036 {
00037         for (cell_v::iterator it = m_cells.begin(); it != m_cells.end(); it++)
00038         {
00039                 CELL *p = *it;
00040                 delete p;
00041         }
00042 }


Member Function Documentation

void World::GetRandomLocation ( int &  ,
int &  ,
std::string &   
)

Definition at line 60 of file World.cpp.

References m_cells.

Referenced by SmallSocket::OnLine(), MobFactory::Spawn(), and ItemFactory::Spawn().

00061 {
00062         int i = random() % m_cells.size();
00063         CELL *p = m_cells[i];
00064         x = p -> m_x;
00065         y = p -> m_y;
00066         name = p -> m_name;
00067 }

bool World::FindAt ( int  ,
int  ,
std::string &   
)

Definition at line 45 of file World.cpp.

References m_cells.

Referenced by MobFactory::MOB::Create(), and MobFactory::MOB::Move().

00046 {
00047         for (cell_v::iterator it = m_cells.begin(); it != m_cells.end(); it++)
00048         {
00049                 CELL *p = *it;
00050                 if (p -> m_x == x && p -> m_y == y)
00051                 {
00052                         str = p -> m_name;
00053                         return true;
00054                 }
00055         }
00056         return false;
00057 }

bool World::GetAt ( int  ,
int  ,
std::string &  ,
bool &  ,
bool &  ,
bool &  ,
bool &   
)

Definition at line 77 of file World.cpp.

References m_cells.

Referenced by MobFactory::MOB::Move(), SmallHandler::ShowCell(), and SmallSocket::try_move().

00078 {
00079         for (cell_v::iterator it = m_cells.begin(); it != m_cells.end(); it++)
00080         {
00081                 CELL *p = *it;
00082                 if (p -> m_x == x && p -> m_y == y)
00083                 {
00084                         str = p -> m_name;
00085                         n = p -> m_n;
00086                         s = p -> m_s;
00087                         e = p -> m_e;
00088                         w = p -> m_w;
00089                         return true;
00090                 }
00091         }
00092         return false;
00093 }

void World::AddAt ( int  ,
int  ,
const std::string &   
)

Definition at line 70 of file World.cpp.

References m_cells.

Referenced by MobFactory::MOB::Create().

00071 {
00072         CELL *p = new CELL(x,y,name);
00073         m_cells.push_back(p);
00074 }

SmallHandler& World::Handler (  )  [inline]

Definition at line 62 of file World.h.

References m_handler.

Referenced by MobFactory::MOB::Create(), and MobFactory::MOB::Move().

00062 { return m_handler; }

void World::Open ( int  ,
int  ,
const std::string &   
)

Definition at line 96 of file World.cpp.

References m_cells.

Referenced by MobFactory::MOB::Create().

00097 {
00098         for (cell_v::iterator it = m_cells.begin(); it != m_cells.end(); it++)
00099         {
00100                 CELL *p = *it;
00101                 if (p -> m_x == x && p -> m_y == y)
00102                 {
00103                         if (dir == "north")
00104                                 p -> m_n = true;
00105                         else
00106                         if (dir == "south")
00107                                 p -> m_s = true;
00108                         else
00109                         if (dir == "east")
00110                                 p -> m_e = true;
00111                         else
00112                         if (dir == "west")
00113                                 p -> m_w = true;
00114                         break;
00115                 }
00116         }
00117 }

size_t World::NumberOfCells (  )  [inline]

Definition at line 66 of file World.h.

References m_cells.

Referenced by SmallHandler::ShowStatus().

00066 { return m_cells.size(); }


Member Data Documentation

Definition at line 69 of file World.h.

Referenced by Handler().

Definition at line 70 of file World.h.

Referenced by AddAt(), FindAt(), GetAt(), GetRandomLocation(), NumberOfCells(), Open(), World(), and ~World().


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4