Planeshift

pstrade.h

Go to the documentation of this file.
00001 /*
00002  * pstrade.h
00003  *
00004  * Copyright (C) 2003 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 __PSTRADE_H__
00021 #define __PSTRADE_H__
00022 //=============================================================================
00023 // Crystal Space Includes
00024 //=============================================================================
00025 #include <csutil/csstring.h>
00026 
00027 //=============================================================================
00028 // Project Includes
00029 //=============================================================================
00030 #include <idal.h>
00031 #include "util/mathscript.h"
00032 
00033 //=============================================================================
00034 // Local Includes
00035 //=============================================================================
00036 
00037 
00038 class psTradeCombinations;
00039 
00040 //-----------------------------------------------------------------------------
00041 
00049 class psTradeCombinations
00050 {
00051 public:
00052     psTradeCombinations();
00053     ~psTradeCombinations();
00054 
00055     bool Load(iResultRow &row);
00056 
00057     uint32 GetId() const
00058     {
00059         return id;
00060     }
00061     uint32 GetPatternId() const
00062     {
00063         return patternId;
00064     }
00065     uint32 GetResultId() const
00066     {
00067         return resultId;
00068     }
00069     int GetResultQty() const
00070     {
00071         return resultQty;
00072     }
00073     uint32 GetItemId() const
00074     {
00075         return itemId;
00076     }
00077     int GetMinQty() const
00078     {
00079         return minQty;
00080     }
00081     int GetMaxQty() const
00082     {
00083         return maxQty;
00084     }
00085 
00086 protected:
00087     uint32 id;
00088     uint32 patternId;
00089     uint32 resultId;
00090     int resultQty;
00091     uint32 itemId;
00092     int minQty;
00093     int maxQty;
00094 };
00095 
00100 class psTradeTransformations : public iScriptableVar
00101 {
00102 public:
00103     psTradeTransformations();
00104     psTradeTransformations(uint32 rId, int rQty, uint32 iId, int iQty, char* tPoints);
00105     ~psTradeTransformations();
00106 
00107     bool Load(iResultRow &row);
00108 
00109     uint32 GetId() const
00110     {
00111         return id;
00112     }
00113     uint32 GetPatternId() const
00114     {
00115         return patternId;
00116     }
00117     uint32 GetProcessId() const
00118     {
00119         return processId;
00120     }
00121     uint32 GetResultId() const
00122     {
00123         return resultId;
00124     }
00125 
00126     int GetResultQty() const
00127     {
00128         return resultQty;
00129     }
00130 
00131     uint32 GetItemId() const
00132     {
00133         return itemId;
00134     }
00135     void SetItemId(uint32 newItemId)
00136     {
00137         itemId = newItemId;
00138     }
00139 
00140     int GetItemQty() const
00141     {
00142         return itemQty;
00143     }
00144     void SetItemQty(int newItemQty)
00145     {
00146         itemQty = newItemQty;
00147     }
00148 
00149     float GetItemQualityPenaltyPercent() const
00150     {
00151         return penaltyPct;
00152     }
00153 
00154     int GetTransPoints() const
00155     {
00156         MathEnvironment env;
00157         return transPoints->Evaluate(&env);
00158     }
00159 
00166     int GetTransformationCacheFlag()
00167     {
00168         return transCached;
00169     }
00170 
00174 
00175 
00182     const char* ToString();
00183 
00189     double CalcFunction(MathEnvironment* env, const char* functionName, const double* params);
00190 
00200     double GetProperty(MathEnvironment* env, const char* ptr);
00202 
00203 protected:
00204     uint32 id;
00205     uint32 patternId;
00206     uint32 processId;
00207     uint32 resultId;
00208     int resultQty;
00209     uint32 itemId;
00210     int itemQty;
00211     float penaltyPct;
00212     MathExpression* transPoints;
00213 
00214 private:
00221     bool transCached;
00222 };
00223 
00229 class psTradeProcesses : public iScriptableVar
00230 {
00231 public:
00232     psTradeProcesses();
00233     ~psTradeProcesses();
00234 
00235     bool Load(iResultRow &row);
00236 
00237     uint32 GetProcessId() const
00238     {
00239         return processId;
00240     }
00241 
00242     csString GetName() const
00243     {
00244         return name;
00245     }
00246     csString GetAnimation() const
00247     {
00248         return animation;
00249     }
00250     uint32 GetWorkItemId() const
00251     {
00252         return workItemId;
00253     }
00254     uint32 GetEquipementId() const
00255     {
00256         return equipmentId;
00257     }
00258     const char* GetConstraintString() const
00259     {
00260         return constraints;
00261     }
00262     uint32 GetGarbageId() const
00263     {
00264         return garbageId;
00265     }
00266     int GetGarbageQty() const
00267     {
00268         return garbageQty;
00269     }
00270     int GetPrimarySkillId() const
00271     {
00272         return priSkillId;
00273     }
00274     int GetSubprocessId() const
00275     {
00276         return subprocess;
00277     }
00278     unsigned int GetMinPrimarySkill() const
00279     {
00280         return minPriSkill;
00281     }
00282     unsigned int GetMaxPrimarySkill() const
00283     {
00284         return maxPriSkill;
00285     }
00286     int GetPrimaryPracticePts() const
00287     {
00288         return priPracticePts;
00289     }    int GetPrimaryQualFactor() const
00290     {
00291         return priQualFactor;
00292     }
00293     int GetSecondarySkillId() const
00294     {
00295         return secSkillId;
00296     }
00297     unsigned int GetMinSecondarySkill() const
00298     {
00299         return minSecSkill;
00300     }
00301     unsigned int GetMaxSecondarySkill() const
00302     {
00303         return maxSecSkill;
00304     }
00305     int GetSecondaryPracticePts() const
00306     {
00307         return secPracticePts;
00308     }
00309     int GetSecondaryQualFactor() const
00310     {
00311         return secQualFactor;
00312     }
00313     csString &GetRenderEffect()
00314     {
00315         return renderEffect;
00316     }
00317 
00325     MathScript* GetScript()
00326     {
00327         return script;
00328     }
00329 
00339     csString GetScriptName() const
00340     {
00341         return scriptName;
00342     }
00343 
00347 
00348 
00353     const char* ToString();
00354 
00360     double CalcFunction(MathEnvironment* env, const char* functionName, const double* params);
00361 
00371     double GetProperty(MathEnvironment* env, const char* ptr);
00373 
00374 protected:
00375     uint32 processId;
00376     int subprocess;
00377     csString name;
00378     csString animation;
00379     uint32 workItemId;
00380     uint32 equipmentId;
00381     csString constraints;
00382     uint32 garbageId;
00383     int garbageQty;
00384     int priSkillId;
00385     int minPriSkill;
00386     int maxPriSkill;
00387     int priPracticePts;
00388     int priQualFactor;
00389     int secSkillId;
00390     int minSecSkill;
00391     int maxSecSkill;
00392     int secPracticePts;
00393     int secQualFactor;
00394     csString renderEffect;
00395     csString scriptName;
00396     MathScript* script;
00397 };
00398 
00402 class psTradePatterns
00403 {
00404 public:
00405     psTradePatterns();
00406     ~psTradePatterns();
00407     bool Load(iResultRow &row);
00408 
00409     uint32 GetId() const
00410     {
00411         return id;
00412     }
00413     uint32 GetGroupPatternId() const
00414     {
00415         return groupPatternId;
00416     }
00417     const char* GetPatternString() const
00418     {
00419         return patternName;
00420     }
00421     uint32 GetDesignItemId() const
00422     {
00423         return designItemId;
00424     }
00425     float GetKFactor() const
00426     {
00427         return KFactor;
00428     }
00429 
00430 protected:
00431     uint32 id;
00432     uint32 groupPatternId;
00433     csString patternName;
00434     uint32 designItemId;
00435     float KFactor;
00436 };
00437 
00438 //-----------------------------------------------------------------------------
00439 
00443 struct CombinationConstruction
00444 {
00445     uint32 resultItem;
00446     int resultQuantity;
00447     csPDelArray<psTradeCombinations> combinations;
00448 };
00449 
00450 //-----------------------------------------------------------------------------
00451 
00455 struct CraftSkills
00456 {
00457     int priSkillId;
00458     int minPriSkill;
00459     int secSkillId;
00460     int minSecSkill;
00461 };
00462 
00466 struct CraftTransInfo
00467 {
00468     int priSkillId;
00469     int minPriSkill;
00470     int secSkillId;
00471     int minSecSkill;
00472     csString craftStepDescription;
00473 };
00474 
00478 struct CraftComboInfo
00479 {
00480     csArray<CraftSkills*>* skillArray;
00481     csString craftCombDescription;
00482 };
00483 
00486 #endif