Logo
~Sockets~
~Examples~
~Contact~


ITEM Struct Reference

ITEM properties struct. More...

#include <ItemFactory.h>

Collaboration diagram for ITEM:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ITEM (const std::string &n, const std::string &p, const std::string &w)
 ITEM (const std::string &n, const std::string &p, const std::string &w, short ph, short ma, long am)
std::string GetDescription ()

Public Attributes

size_t m_vecno
cstring m_name
cstring m_plural
std::string m_wield_position
short m_physical
short m_magical
long m_amount

Detailed Description

ITEM properties struct.

Definition at line 43 of file ItemFactory.h.


Constructor & Destructor Documentation

ITEM::ITEM ( const std::string &  n,
const std::string &  p,
const std::string &  w 
)

Definition at line 113 of file ItemFactory.cpp.

References m_magical, m_name, m_physical, and m_plural.

00114 :m_vecno(0)
00115 ,m_wield_position(w),m_physical(20),m_magical(20),m_amount(1) 
00116 {
00117         std::string cols[10]; // nrgybmcw
00118         for (size_t i = 0; i < 10; i++)
00119         {
00120                 int nr = random() % 8;
00121                 if (!nr)
00122                 {
00123                         nr = random() % 15 + 1;
00124                 }
00125                 cols[i] = "&";
00126                 cols[i] += "nrgybmcwRGYBMCWL"[nr];
00127         }
00128         size_t col = 0;
00129         for (size_t i = 0; i < n.size(); i++)
00130         {
00131                 if (n[i] == ' ')
00132                 {
00133                         m_name += " ";
00134                         m_name += cols[col++];
00135                 }
00136                 else
00137                 {
00138                         m_name += n.substr(i,1); //n[i];
00139                 }
00140         }
00141         col = 0;
00142         m_plural += cols[col++];
00143         for (size_t i = 0; i < p.size(); i++)
00144         {
00145                 if (p[i] == ' ')
00146                 {
00147                         m_plural += " ";
00148                         m_plural += cols[col++];
00149                 }
00150                 else
00151                 {
00152                         m_plural += p.substr(i,1); //p[i];
00153                 }
00154         }
00155         if (!random() % 100)
00156         {
00157                 m_physical += random() % 80 + 1;
00158                 if (!random() % 100)
00159                 {
00160                         m_magical += random() % 80 + 1;
00161                 }
00162         }
00163         m_name += "&n";
00164         m_plural += "&n";
00165 }

ITEM::ITEM ( const std::string &  n,
const std::string &  p,
const std::string &  w,
short  ph,
short  ma,
long  am 
)

Definition at line 168 of file ItemFactory.cpp.

00169 :m_vecno(0)
00170 ,m_name(n)
00171 ,m_plural(p)
00172 ,m_wield_position(w),m_physical(ph),m_magical(ma),m_amount(am)
00173 {
00174 }


Member Function Documentation

std::string ITEM::GetDescription (  )  [inline]

Definition at line 46 of file ItemFactory.h.

References m_amount, m_name, m_plural, and m_vecno.

00047                 {
00048                         std::string str;
00049                         if (m_amount == 1)
00050                         {
00051                                 str = m_name;
00052                         }
00053                         else
00054                         {
00055                                 str = Utility::l2string(m_amount) + " " + m_plural;
00056                         }
00057                         if (m_vecno > 0)
00058                         {
00059                                 str += " (" + Utility::l2string(m_vecno) + ")";
00060                         }
00061                         return str;
00062                 }


Member Data Documentation

size_t ITEM::m_vecno

Definition at line 63 of file ItemFactory.h.

Referenced by GetDescription().

Definition at line 64 of file ItemFactory.h.

Referenced by GetDescription(), and ITEM().

Definition at line 65 of file ItemFactory.h.

Referenced by GetDescription(), and ITEM().

Definition at line 66 of file ItemFactory.h.

Definition at line 67 of file ItemFactory.h.

Referenced by ITEM().

Definition at line 68 of file ItemFactory.h.

Referenced by ITEM().

Definition at line 69 of file ItemFactory.h.

Referenced by GetDescription().


The documentation for this struct 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