Planeshift

psquestprereqops.h

Go to the documentation of this file.
00001 /*
00002  * psquest.h
00003  *
00004  * Copyright (C) 2005 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 __PSQUESTPREREQOPS_H__
00021 #define __PSQUESTPREREQOPS_H__
00022 
00023 //=============================================================================
00024 // Crystal Space Includes
00025 //=============================================================================
00026 #include <csutil/refarr.h>
00027 #include <csutil/refcount.h>
00028 
00029 //=============================================================================
00030 // Project Includes
00031 //=============================================================================
00032 
00033 #include "pstrait.h"
00034 
00035 //=============================================================================
00036 // Local Includes
00037 //=============================================================================
00038 #include "psattack.h"
00039 
00040 class psCharacter;
00041 class psQuest;
00042 class psSkillInfo;
00043 struct Faction;
00044 
00055 class psQuestPrereqOp : public csRefCount
00056 {
00057 public:
00062     virtual ~psQuestPrereqOp() {};
00063 
00073     virtual bool Check(psCharacter* character) = 0;
00074 
00082     virtual csString GetScript();
00083 
00092     virtual csString GetScriptOp() = 0;
00093 
00102     virtual csPtr<psQuestPrereqOp> Copy() = 0;
00103 };
00104 
00112 class psQuestPrereqOpList: public psQuestPrereqOp
00113 {
00114 protected:
00118     csRefArray<psQuestPrereqOp> prereqlist;
00119 public:
00120 
00127     virtual ~psQuestPrereqOpList() {}
00128 
00137     virtual void Push(csRef<psQuestPrereqOp> prereqOp);
00138 
00148     virtual void Insert(size_t n, csRef<psQuestPrereqOp> prereqOp);
00149 
00150 };
00151 
00158 class psQuestPrereqOpAnd: public psQuestPrereqOpList
00159 {
00160 public:
00161 
00165     virtual ~psQuestPrereqOpAnd() {}
00166 
00175     virtual bool Check(psCharacter* character);
00176 
00185     virtual csString GetScriptOp();
00186 
00195     virtual csPtr<psQuestPrereqOp> Copy();
00196 };
00197 
00198 
00205 class psQuestPrereqOpOr: public psQuestPrereqOpList
00206 {
00207 public:
00208 
00212     virtual ~psQuestPrereqOpOr() {}
00213 
00222     virtual bool Check(psCharacter* character);
00223 
00232     virtual csString GetScriptOp();
00233 
00242     virtual csPtr<psQuestPrereqOp> Copy();
00243 };
00244 
00251 class psQuestPrereqOpRequire: public psQuestPrereqOpList
00252 {
00253     int min,max;
00254 public:
00255 
00264     psQuestPrereqOpRequire(int min_required,int max_required);
00265 
00269     virtual ~psQuestPrereqOpRequire() {}
00270 
00282     virtual bool Check(psCharacter* character);
00283 
00292     virtual csString GetScriptOp();
00293 
00302     virtual csPtr<psQuestPrereqOp> Copy();
00303 };
00304 
00310 class psQuestPrereqOpNot: public psQuestPrereqOpList
00311 {
00312 public:
00313 
00317     virtual ~psQuestPrereqOpNot() {}
00318 
00327     virtual bool Check(psCharacter* character);
00328 
00337     virtual csString GetScriptOp();
00338 
00347     virtual csPtr<psQuestPrereqOp> Copy();
00348 };
00349 
00356 class psQuestPrereqOpQuestCompleted: public psQuestPrereqOp
00357 {
00358 protected:
00362     csWeakRef<psQuest> quest;
00363     csString name;
00364 
00365 public:
00366 
00372     psQuestPrereqOpQuestCompleted(psQuest* quest):quest(quest) { GetQuestName(); };
00373 
00379     psQuestPrereqOpQuestCompleted(csString questName);
00380 
00384     virtual ~psQuestPrereqOpQuestCompleted() {}
00385 
00394     virtual bool Check(psCharacter* character);
00395 
00404     virtual csString GetScriptOp();
00405 
00414     virtual csPtr<psQuestPrereqOp> Copy();
00415     
00422     virtual psQuest* GetQuest();
00423     
00430     virtual csString GetQuestName();
00431 };
00432 
00439 class psQuestPrereqOpQuestAssigned: public psQuestPrereqOp
00440 {
00441 protected:
00445     csWeakRef<psQuest> quest;
00446     csString questName; 
00447 public:
00448 
00454     psQuestPrereqOpQuestAssigned(psQuest* quest):quest(quest) { GetQuestName(); };
00455 
00458     virtual ~psQuestPrereqOpQuestAssigned() {}
00459 
00468     virtual bool Check(psCharacter* character);
00469 
00478     virtual csString GetScriptOp();
00479 
00488     virtual csPtr<psQuestPrereqOp> Copy();
00489     
00496     virtual psQuest* GetQuest();
00497     
00504     virtual csString GetQuestName();
00505 };
00506 
00512 class psQuestPrereqOpQuestCompletedCategory: public psQuestPrereqOp
00513 {
00514 protected:
00515 
00519     int min;
00520 
00524     int max;
00525 
00529     csString category;
00530 public:
00531 
00541     psQuestPrereqOpQuestCompletedCategory(csString quest_category,
00542                                           int min_required,int max_required)
00543         : min(min_required),max(max_required),category(quest_category) {};
00544 
00548     virtual ~psQuestPrereqOpQuestCompletedCategory() {}
00549 
00559     virtual bool Check(psCharacter* character);
00560 
00568     virtual csString GetScriptOp();
00569 
00578     virtual csPtr<psQuestPrereqOp> Copy();
00579 };
00580 
00587 class psQuestPrereqOpFaction: public psQuestPrereqOp
00588 {
00589 protected:
00593     Faction* faction;
00594 
00598     int value;
00599     bool max;
00600 public:
00601 
00609     psQuestPrereqOpFaction(Faction* faction, int value, bool max):faction(faction),value(value),max(max) {};
00610 
00614     virtual ~psQuestPrereqOpFaction() {}
00615 
00624     virtual bool Check(psCharacter* character);
00625 
00634     virtual csString GetScriptOp();
00635 
00644     virtual csPtr<psQuestPrereqOp> Copy();
00645 };
00646 
00653 class psQuestPrereqOpItem : public psQuestPrereqOp
00654 {
00655 protected:
00656     csString itemName;          
00657     csString categoryName;      
00658     bool includeInventory;      
00659     int amountMin;              
00660     int amountMax;              
00661     float qualityMin;           
00662     float qualityMax;           
00663     
00664 public:
00665 
00678     psQuestPrereqOpItem(const char* itemName, const char* categoryName, bool includeInventory, int amountMin, int amountMax, float qualityMin, float qualityMax):
00679         itemName(itemName), categoryName(categoryName), includeInventory(includeInventory),
00680         amountMin(amountMin), amountMax(amountMax), qualityMin(qualityMin), qualityMax(qualityMax) {};
00681 
00685     virtual ~psQuestPrereqOpItem() {}
00686 
00693     virtual bool Check(psCharacter* character);
00694 
00703     virtual csString GetScriptOp();
00704 
00713     virtual csPtr<psQuestPrereqOp> Copy();
00714 };
00715 
00721 class psQuestPrereqOpActiveMagic : public psQuestPrereqOp
00722 {
00723 protected:
00724     csString activeMagic;
00725 
00726 public:
00727 
00733     psQuestPrereqOpActiveMagic(const char* activeMagic):activeMagic(activeMagic) {};
00734 
00735     virtual ~psQuestPrereqOpActiveMagic() {}
00736 
00743     virtual bool Check(psCharacter* character);
00744 
00753     virtual csString GetScriptOp();
00754 
00763     virtual csPtr<psQuestPrereqOp> Copy();
00764 };
00765 
00771 class psQuestPrereqOpTrait : public psQuestPrereqOp
00772 {
00773 protected:
00774     csString traitName;
00775     PSTRAIT_LOCATION traitLocation;
00776 
00777 public:
00778 
00783     psQuestPrereqOpTrait(const char* traitName, csString traitLocationString):traitName(traitName)
00784     {
00785         for(int position = PSTRAIT_LOCATION_NONE; position < PSTRAIT_LOCATION_COUNT; position++)
00786         {
00787             if((csString)psTrait::locationString[position] == traitLocationString)
00788             {
00789                 traitLocation = (PSTRAIT_LOCATION) position;
00790                 break;
00791             }
00792         }
00793         // TraitLocation = (PSTRAIT_LOCATION)1;
00794 
00795     };
00796 
00797     virtual ~psQuestPrereqOpTrait() {}
00798 
00805     virtual bool Check(psCharacter* character);
00806 
00815     virtual csString GetScriptOp();
00816 
00825     virtual csPtr<psQuestPrereqOp> Copy();
00826 };
00827 
00833 class psQuestPrereqOpRace : public psQuestPrereqOp
00834 {
00835 protected:
00836     csString race;
00837 
00838 public:
00839 
00845     psQuestPrereqOpRace(const char* race):race(race) {};
00846 
00847     virtual ~psQuestPrereqOpRace() {}
00848 
00855     virtual bool Check(psCharacter* character);
00856 
00865     virtual csString GetScriptOp();
00866 
00875     virtual csPtr<psQuestPrereqOp> Copy();
00876 };
00877 
00883 class psQuestPrereqOpGender : public psQuestPrereqOp
00884 {
00885 protected:
00886     csString gender;
00887 
00888 public:
00889 
00895     psQuestPrereqOpGender(const char* gender):gender(gender) {};
00896 
00897     virtual ~psQuestPrereqOpGender() {}
00898 
00905     virtual bool Check(psCharacter* character);
00906 
00915     virtual csString GetScriptOp();
00916 
00925     virtual csPtr<psQuestPrereqOp> Copy();
00926 };
00927 
00933 class psQuestPrereqOpKnownSpell : public psQuestPrereqOp
00934 {
00935 protected:
00936     csString spell;
00937 
00938 public:
00939 
00945     psQuestPrereqOpKnownSpell(const char* spell):spell(spell) {};
00946 
00947     virtual ~psQuestPrereqOpKnownSpell() {}
00948 
00955     virtual bool Check(psCharacter* character);
00956 
00965     virtual csString GetScriptOp();
00966 
00975     virtual csPtr<psQuestPrereqOp> Copy();
00976 };
00977 
00983 class psQuestPrereqOpGuild : public psQuestPrereqOp
00984 {
00985 protected:
00986     csString guildtype;
00987     csString guildName;
00988 
00989 public:
00990 
00997     psQuestPrereqOpGuild(const char* guildtype, const char* guildName):guildtype(guildtype),guildName(guildName) {};
00998 
00999     virtual ~psQuestPrereqOpGuild() {}
01000 
01007     virtual bool Check(psCharacter* character);
01008 
01017     virtual csString GetScriptOp();
01018 
01027     virtual csPtr<psQuestPrereqOp> Copy();
01028 };
01029 
01035 class psQuestPrereqOpMarriage : public psQuestPrereqOp
01036 {
01037 public:
01038 
01042     psQuestPrereqOpMarriage() {};
01043 
01044     virtual ~psQuestPrereqOpMarriage() {}
01045 
01052     virtual bool Check(psCharacter* character);
01053 
01062     virtual csString GetScriptOp();
01063 
01072     virtual csPtr<psQuestPrereqOp> Copy();
01073 };
01074 
01080 class psQuestPrereqOpAdvisorPoints : public psQuestPrereqOp
01081 {
01082 protected:
01083     int minPoints, maxPoints;
01084     csString type;
01085 
01086 public:
01087 
01095     psQuestPrereqOpAdvisorPoints(int minPoints, int maxPoints, csString type):minPoints(minPoints),maxPoints(maxPoints),type(type) {};
01096 
01097     virtual ~psQuestPrereqOpAdvisorPoints() {}
01098 
01105     virtual bool Check(psCharacter* character);
01106 
01115     virtual csString GetScriptOp();
01116 
01125     virtual csPtr<psQuestPrereqOp> Copy();
01126 };
01127 
01133 class psQuestPrereqOpTimeOnline : public psQuestPrereqOp
01134 {
01135 protected:
01136     unsigned int minTime, maxTime;
01137 
01138 public:
01139 
01146     psQuestPrereqOpTimeOnline(int minTime, int maxTime):minTime(minTime),maxTime(maxTime) {};
01147 
01148     virtual ~psQuestPrereqOpTimeOnline() {}
01149 
01156     virtual bool Check(psCharacter* character);
01157 
01166     virtual csString GetScriptOp();
01167 
01176     virtual csPtr<psQuestPrereqOp> Copy();
01177 };
01178 
01184 class psQuestPrereqOpTimeOfDay : public psQuestPrereqOp
01185 {
01186 protected:
01187     int minTime, maxTime;
01188 
01189 public:
01190 
01197     psQuestPrereqOpTimeOfDay(int minTime, int maxTime):minTime(minTime),maxTime(maxTime) {};
01198 
01199     virtual ~psQuestPrereqOpTimeOfDay() {}
01200 
01207     virtual bool Check(psCharacter* character);
01208 
01217     virtual csString GetScriptOp();
01218 
01227     virtual csPtr<psQuestPrereqOp> Copy();
01228 };
01229 
01235 class psQuestPrereqOpVariable : public psQuestPrereqOp
01236 {
01237 protected:
01238     csString variableName;
01239     csString variableValue;
01240     double min, max;
01241 
01242 public:
01243 
01249     psQuestPrereqOpVariable(const char* name)
01250         : variableName(name), min(0), max(0)
01251     {
01252     }
01253     psQuestPrereqOpVariable(const char* name, const char* value)
01254         : variableName(name), variableValue(value), min(0), max(0)
01255     {
01256     }
01257     psQuestPrereqOpVariable(const char* name, double minv, double maxv)
01258         : variableName(name), min(minv), max(maxv)
01259     {
01260     }
01261     psQuestPrereqOpVariable(const psQuestPrereqOpVariable& other)
01262         : variableName(other.variableName), variableValue(other.variableValue),
01263           min(other.min), max(other.max)
01264     {
01265     }
01266 
01267     virtual ~psQuestPrereqOpVariable() {}
01268 
01275     virtual bool Check(psCharacter* character);
01276 
01285     virtual csString GetScriptOp();
01286 
01295     virtual csPtr<psQuestPrereqOp> Copy();
01296 };
01297 
01304 class psQuestPrereqOpXor: public psQuestPrereqOpList
01305 {
01306 public:
01307 
01311     virtual ~psQuestPrereqOpXor() {}
01312 
01321     virtual bool Check(psCharacter* character);
01322 
01331     virtual csString GetScriptOp();
01332 
01341     virtual csPtr<psQuestPrereqOp> Copy();
01342 };
01343 
01350 class psQuestPrereqOpSkill: public psQuestPrereqOp
01351 {
01352 protected:
01356     psSkillInfo* skill;
01357 
01358     int min;          
01359     int max;          
01360     bool allowBuffed; 
01361 public:
01362 
01371     psQuestPrereqOpSkill(psSkillInfo* skill, unsigned int min, unsigned int max, bool allowBuffed):skill(skill),min(min),max(max),allowBuffed(allowBuffed) {};
01372 
01376     virtual ~psQuestPrereqOpSkill() {}
01377 
01384     virtual bool Check(psCharacter* character);
01385 
01394     virtual csString GetScriptOp();
01395 
01404     virtual csPtr<psQuestPrereqOp> Copy();
01405 };
01406 
01413 class psPrereqOpAttackType: public psQuestPrereqOp
01414 {
01415  protected:
01416      psAttackType* attackType; 
01417 
01418  public:
01419 
01424     psPrereqOpAttackType(psAttackType* attackType) : attackType(attackType) {}
01425 
01429     virtual ~psPrereqOpAttackType() {}
01430 
01437     virtual bool Check(psCharacter* character);
01438 
01447     virtual csString GetScriptOp();
01448 
01449 
01458     virtual csPtr<psQuestPrereqOp> Copy();
01459 
01460 private:
01465     bool checkWeapon(psCharacter* character, int slot);
01466 
01467     
01472     bool checkWType(psCharacter* character, psItem* weapon);
01473 };
01474 
01475 
01481 class psPrereqOpStance: public psQuestPrereqOp
01482 {
01483  protected:
01484      csString stance;
01485 
01486  public:
01487 
01493     psPrereqOpStance(csString stance):stance(stance){};
01494 
01498     virtual ~psPrereqOpStance() {}
01499 
01500 
01507     virtual bool Check(psCharacter * character);
01508 
01509 
01518     virtual csString GetScriptOp();
01519 
01520 
01521 
01530     virtual csPtr<psQuestPrereqOp> Copy();
01531 
01532 };
01533 
01537 #endif