Planeshift

pscharquestmgr.h

Go to the documentation of this file.
00001 /*
00002  * pscharquestmgr.h
00003  *
00004  * Copyright (C) 2011 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 
00020 #ifndef __PSCHARQUESTMGR_H__
00021 #define __PSCHARQUESTMGR_H__
00022 
00023 //=============================================================================
00024 // Crystal Space Includes
00025 //=============================================================================
00026 #include <csutil/weakref.h>
00027 
00028 //=============================================================================
00029 // Project Includes
00030 //=============================================================================
00031 #include "net/charmessages.h"
00032 
00033 //=============================================================================
00034 // Local Includes
00035 //=============================================================================
00036 #include "psquest.h"
00037 
00038 
00039 class gemObject;
00040 
00041 #define PSQUEST_DELETE   'D'
00042 #define PSQUEST_ASSIGNED 'A'
00043 #define PSQUEST_COMPLETE 'C'
00044 
00048 struct QuestAssignment
00049 {
00051     PID assigner_id;
00053     char status;
00055     bool dirty;
00057     unsigned long lockout_end;
00059     int last_response;
00061     PID last_response_from_npc_pid;
00062 
00064     unsigned int completionOrder;
00065 
00067     csWeakRef<psQuest> &GetQuest();
00068 
00074     bool IsCompleted();
00075 
00076     void SetQuest(psQuest* q);
00077 protected:
00078 
00080     int quest_id;
00081 
00083     csWeakRef<psQuest> quest;
00084 };
00085 
00086 
00087 //-----------------------------------------------------------------------------
00090 class psCharacterQuestManager
00091 {
00092 public:
00095     ~psCharacterQuestManager();
00096 
00101     void Initialize(psCharacter* owner);
00102 
00107     bool LoadQuestAssignments();
00108 
00116     QuestAssignment* IsQuestAssigned(int id);
00117 
00128     QuestAssignment* AssignQuest(psQuest* quest, PID assignerId);
00129 
00136     bool CompleteQuest(psQuest* quest);
00137 
00143     void DiscardQuest(QuestAssignment* q, bool force = false);
00144 
00151     bool DiscardQuest(psQuest* quest, bool force = false);
00152 
00161     bool SetAssignedQuestLastResponse(psQuest* quest, int response, gemObject* npc);
00162 
00167     size_t GetNumAssignedQuests()
00168     {
00169         return assignedQuests.GetSize();
00170     }
00171 
00178     int GetAssignedQuestLastResponse(size_t i);
00179 
00190     bool UpdateQuestAssignments(bool forceUpdate = false);
00191 
00199     size_t GetAssignedQuests(psQuestListMessage &quests, int cNum);
00200 
00205     csArray<QuestAssignment*> &GetAssignedQuests()
00206     {
00207         return assignedQuests;
00208     }
00209 
00216     bool CheckQuestAssigned(psQuest* quest);
00217 
00224     bool CheckQuestCompleted(psQuest* quest);
00225 
00234     bool CheckQuestAvailable(psQuest* quest, PID assignerId);
00235 
00242     int NumberOfQuestsCompleted(csString category);
00243 
00244 
00245 
00246 private:
00247     csArray<QuestAssignment*> assignedQuests;   
00248 
00249     psCharacter* owner;                         
00250 };
00251 //-----------------------------------------------------------------------------
00252 
00253 #endif