![]() |
PlayerFactory.hGo to the documentation of this file.00001 00006 /* 00007 Copyright (C) 2004 Anders Hedstrom 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 as published by the Free Software Foundation; either version 2 00012 of the License, or (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 */ 00023 #ifndef _PLAYERFACTORY_H 00024 #define _PLAYERFACTORY_H 00025 00026 #include <string> 00027 #include <vector> 00028 #include <Utility.h> 00029 #include "IPersist.h" 00030 #include "ItemFactory.h" 00031 00032 class SmallSocket; 00033 00034 00036 class PlayerFactory : public IPersist 00037 { 00038 public: 00040 struct PLAYER 00041 { 00042 PLAYER(long l,const std::string& n,const std::string& p) : nr(l),m_name(n),m_passwd(p) {} 00043 ~PLAYER() 00044 { 00045 for (item_v::iterator it = m_inventory.begin(); it != m_inventory.end(); it++) 00046 { 00047 ITEM *i = *it; 00048 delete i; 00049 } 00050 } 00051 void DisplayInventory(SmallSocket *p); 00052 item_v& GetInventory() { return m_inventory; } 00053 long nr; 00054 std::string m_name; 00055 std::string m_passwd; 00056 item_v m_inventory; 00057 }; 00058 typedef std::vector<PLAYER *> player_v; 00059 00060 public: 00061 PlayerFactory(); 00062 virtual ~PlayerFactory(); 00063 00064 void Load(); 00065 void Save(); 00066 00067 PLAYER *FindPlayer(const std::string& n,const std::string& p); 00068 PLAYER *AddPlayer(const std::string& n,const std::string& p); 00069 00070 private: 00071 player_v m_players; 00072 }; 00073 00074 00075 00076 00077 #endif // _PLAYERFACTORY_H |