Planeshift
hiresession.h
Go to the documentation of this file.
1 /*
2  * hiresession.h creator <andersr@pvv.org>
3  *
4  * Copyright (C) 2013 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 #ifndef HIRE_SESSION_HEADER
20 #define HIRE_SESSION_HEADER
21 //====================================================================================
22 // Crystal Space Includes
23 //====================================================================================
24 
25 //====================================================================================
26 // Project Includes
27 //====================================================================================
28 
29 //====================================================================================
30 // Local Includes
31 //====================================================================================
32 #include <gem.h>
33 
34 //------------------------------------------------------------------------------------
35 // Forward Declarations
36 //------------------------------------------------------------------------------------
37 
46 {
47 public:
50  HireSession();
51 
56  HireSession(gemActor* owner);
57 
60  virtual ~HireSession();
61 
64  bool Load(iResultRow &row);
65 
70  bool Save(bool newSession = false);
71 
74  bool Delete();
75 
81  void SetHireType(const csString &name, const csString &npcType);
82 
87  const csString &GetHireTypeName() const;
88 
93  const csString &GetHireTypeNPCType() const;
94 
99  void SetMasterPID(PID masterPID);
100 
105  PID GetMasterPID() const;
106 
111  void SetOwner(gemActor* owner);
112 
115  gemActor* GetOwner() const;
116 
121  void SetHiredNPC(gemNPC* hiredNPC);
122 
125  gemNPC* GetHiredNPC() const;
126 
132 
137  PID GetOwnerPID();
138 
143  PID GetHiredPID();
144 
147  const csString &GetScript() const;
148 
151  void SetScript(const csString &newScript);
152 
155  int GetWorkLocationId();
156 
160 
163  void SetWorkLocation(Location* location);
164 
167  bool IsVerified();
168 
171  void SetVerified(bool state);
172 
173 
176  const csString &GetVerifiedScript() const;
177 
180  void SetVerifiedScript(const csString &newVerifiedScript);
181 
184  csString GetWorkLocationString();
185 
188  csString GetTempWorkLocationString();
189 
193 
196  void SetTempWorkLocation(Location* location);
197 
200  void SetTempWorkLocationValid(bool valid);
201 
205 
208  int ApplyScript();
209 
212  bool ShouldLoad();
213 
214 protected:
215 private:
216  PID ownerPID;
217  PID hiredPID;
218  bool guild;
219  csString script;
220  int workLocationID;
221 
222  // Data for pending hires.
223  csString hireTypeName;
224  csString hireTypeNPCType;
225  PID masterPID;
226 
227  // Data for pending confirmation of verified scripts.
228  bool verified;
229  csString verifiedScript;
230  Location* tempWorkLocation;
231  bool tempWorkLocationValid;
232 
233  csWeakRef<gemActor> owner;
234  csWeakRef<gemNPC> hiredNPC;
235  Location* workLocation;
236  bool shouldLoad;
237 };
238 
239 #endif
The Hire Sessin will manage all aspects related to a specefic hiring of a NPC.
Definition: hiresession.h:45
Location * GetWorkLocation()
Get work postion.
const csString & GetHireTypeName() const
Get hire type.
void SetWorkLocation(Location *location)
Set a new working location.
void SetMasterPID(PID masterPID)
Set pending hire master NPC PID.
bool VerifyPendingHireConfigured()
Verify if all requirments for hire is ok.
void SetVerified(bool state)
Set verified.
bool IsVerified()
Check if the script is verified.
bool Save(bool newSession=false)
Save to db.
void SetHiredNPC(gemNPC *hiredNPC)
Set hired NPC.
void SetTempWorkLocationValid(bool valid)
Set validity of temp work postion.
void SetScript(const csString &newScript)
Set the hired NPC script.
HireSession()
Constructor.
const csString & GetScript() const
Return the hired NPC script.
Any semi-autonomous object, either a player or an NPC.
Definition: gem.h:1170
PID GetMasterPID() const
Get Master PID.
bool GetTempWorkLocationValid()
Get validity of temp work postion.
int GetWorkLocationId()
Get work postion.
void SetOwner(gemActor *owner)
Set owner.
int ApplyScript()
Apply the script to the server.
void SetTempWorkLocation(Location *location)
Set a new working location.
void SetVerifiedScript(const csString &newVerifiedScript)
Save a verified script.
void SetHireType(const csString &name, const csString &npcType)
Set pending hire type.
Definition: gem.h:1910
const csString & GetHireTypeNPCType() const
Get hire type.
bool Delete()
Delete from db.
csString GetWorkLocationString()
Get work locaiton string.
Location * GetTempWorkLocation()
Get work postion.
PID GetOwnerPID()
Return the PID of the owner.
bool Load(iResultRow &row)
Load from db.
const csString & GetVerifiedScript() const
Return the verified hired NPC script.
bool ShouldLoad()
Indicate if script should be loaded upon hired npc attach after first load.
gemNPC * GetHiredNPC() const
Get hired NPC.
A Location is a named place on the map, located dynamically by NPCs as scripted.
Definition: location.h:48
csString GetTempWorkLocationString()
Get work postion string.
PID GetHiredPID()
Return the PID of the hired NPC.
virtual ~HireSession()
Destructor.
gemActor * GetOwner() const
Get owner.