Planeshift
pstrade.h
Go to the documentation of this file.
1 /*
2  * pstrade.h
3  *
4  * Copyright (C) 2003 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  * Defines crafting transformations, combinations, processes and patterns.
19  */
20 
21 #ifndef __PSTRADE_H__
22 #define __PSTRADE_H__
23 //=============================================================================
24 // Crystal Space Includes
25 //=============================================================================
26 #include <csutil/csstring.h>
27 
28 //=============================================================================
29 // Project Includes
30 //=============================================================================
31 #include <idal.h>
32 #include "util/mathscript.h"
33 
34 //=============================================================================
35 // Local Includes
36 //=============================================================================
37 
38 
40 
41 //-----------------------------------------------------------------------------
42 
51 {
52 public:
55 
56  bool Load(iResultRow &row);
57 
58  uint32 GetId() const
59  {
60  return id;
61  }
62  uint32 GetPatternId() const
63  {
64  return patternId;
65  }
66  uint32 GetResultId() const
67  {
68  return resultId;
69  }
70  int GetResultQty() const
71  {
72  return resultQty;
73  }
74  uint32 GetItemId() const
75  {
76  return itemId;
77  }
78  int GetMinQty() const
79  {
80  return minQty;
81  }
82  int GetMaxQty() const
83  {
84  return maxQty;
85  }
86 
87 protected:
88  uint32 id;
89  uint32 patternId;
90  uint32 resultId;
91  int resultQty;
92  uint32 itemId;
93  int minQty;
94  int maxQty;
95 };
96 
102 {
103 public:
105  psTradeTransformations(uint32 rId, int rQty, uint32 iId, int iQty, char* tPoints);
107 
108  bool Load(iResultRow &row);
109 
110  uint32 GetId() const
111  {
112  return id;
113  }
114  uint32 GetPatternId() const
115  {
116  return patternId;
117  }
118  uint32 GetProcessId() const
119  {
120  return processId;
121  }
122  uint32 GetResultId() const
123  {
124  return resultId;
125  }
126 
127  int GetResultQty() const
128  {
129  return resultQty;
130  }
131 
132  uint32 GetItemId() const
133  {
134  return itemId;
135  }
136  void SetItemId(uint32 newItemId)
137  {
138  itemId = newItemId;
139  }
140 
141  int GetItemQty() const
142  {
143  return itemQty;
144  }
145  void SetItemQty(int newItemQty)
146  {
147  itemQty = newItemQty;
148  }
149 
151  {
152  return penaltyPct;
153  }
154 
155  int GetTransPoints() const
156  {
157  MathEnvironment env;
158  return transPoints->Evaluate(&env);
159  }
160 
168  {
169  return transCached;
170  }
171 
175 
183  const char* ToString();
184 
190  double CalcFunction(MathEnvironment* env, const char* functionName, const double* params);
191 
201  double GetProperty(MathEnvironment* env, const char* ptr);
203 
204 protected:
205  uint32 id;
206  uint32 patternId;
207  uint32 processId;
208  uint32 resultId;
210  uint32 itemId;
211  int itemQty;
212  float penaltyPct;
214 
215 private:
222  bool transCached;
223 };
224 
231 {
232 public:
234  ~psTradeProcesses();
235 
236  bool Load(iResultRow &row);
237 
238  uint32 GetProcessId() const
239  {
240  return processId;
241  }
242 
243  csString GetName() const
244  {
245  return name;
246  }
247  csString GetAnimation() const
248  {
249  return animation;
250  }
251  uint32 GetWorkItemId() const
252  {
253  return workItemId;
254  }
255  uint32 GetEquipementId() const
256  {
257  return equipmentId;
258  }
259  const char* GetConstraintString() const
260  {
261  return constraints;
262  }
263  uint32 GetGarbageId() const
264  {
265  return garbageId;
266  }
267  int GetGarbageQty() const
268  {
269  return garbageQty;
270  }
271  int GetPrimarySkillId() const
272  {
273  return priSkillId;
274  }
275  int GetSubprocessId() const
276  {
277  return subprocess;
278  }
279  unsigned int GetMinPrimarySkill() const
280  {
281  return minPriSkill;
282  }
283  unsigned int GetMaxPrimarySkill() const
284  {
285  return maxPriSkill;
286  }
288  {
289  return priPracticePts;
290  } int GetPrimaryQualFactor() const
291  {
292  return priQualFactor;
293  }
295  {
296  return secSkillId;
297  }
298  unsigned int GetMinSecondarySkill() const
299  {
300  return minSecSkill;
301  }
302  unsigned int GetMaxSecondarySkill() const
303  {
304  return maxSecSkill;
305  }
307  {
308  return secPracticePts;
309  }
311  {
312  return secQualFactor;
313  }
314  csString &GetRenderEffect()
315  {
316  return renderEffect;
317  }
318 
327  {
328  return script;
329  }
330 
340  csString GetScriptName() const
341  {
342  return scriptName;
343  }
344 
348 
354  const char* ToString();
355 
361  double CalcFunction(MathEnvironment* env, const char* functionName, const double* params);
362 
372  double GetProperty(MathEnvironment* env, const char* ptr);
374 
375 protected:
376  uint32 processId;
378  csString name;
379  csString animation;
380  uint32 workItemId;
381  uint32 equipmentId;
382  csString constraints;
383  uint32 garbageId;
395  csString renderEffect;
396  csString scriptName;
398 };
399 
404 {
405 public:
406  psTradePatterns();
407  ~psTradePatterns();
408  bool Load(iResultRow &row);
409 
410  uint32 GetId() const
411  {
412  return id;
413  }
414  uint32 GetGroupPatternId() const
415  {
416  return groupPatternId;
417  }
418  const char* GetPatternString() const
419  {
420  return patternName;
421  }
422  uint32 GetDesignItemId() const
423  {
424  return designItemId;
425  }
426  float GetKFactor() const
427  {
428  return KFactor;
429  }
430 
431 protected:
432  uint32 id;
434  csString patternName;
435  uint32 designItemId;
436  float KFactor;
437 };
438 
439 //-----------------------------------------------------------------------------
440 
445 {
446  uint32 resultItem;
448  csPDelArray<psTradeCombinations> combinations;
449 };
450 
451 //-----------------------------------------------------------------------------
452 
457 {
462 };
463 
468 {
474 };
475 
480 {
481  csArray<CraftSkills*>* skillArray;
483 };
484 
487 #endif
int minPriSkill
Definition: pstrade.h:459
uint32 GetPatternId() const
Definition: pstrade.h:114
int GetTransformationCacheFlag()
Cache flag is used for garbage collection.
Definition: pstrade.h:167
int GetSecondarySkillId() const
Definition: pstrade.h:294
uint32 GetResultId() const
Definition: pstrade.h:122
int GetGarbageQty() const
Definition: pstrade.h:267
int GetPrimaryQualFactor() const
Definition: pstrade.h:290
int GetItemQty() const
Definition: pstrade.h:141
uint32 GetGarbageId() const
Definition: pstrade.h:263
This class holds the master list of all trade transformatations possible in the game.
Definition: pstrade.h:101
uint32 GetItemId() const
Definition: pstrade.h:132
A specific MathEnvironment to be used in a MathScript.
Definition: mathscript.h:188
uint32 GetResultId() const
Definition: pstrade.h:66
uint32 processId
Definition: pstrade.h:376
A MathScript is a mini-program to run.
Definition: mathscript.h:442
int priSkillId
Definition: pstrade.h:458
void SetItemQty(int newItemQty)
Definition: pstrade.h:145
int GetSecondaryPracticePts() const
Definition: pstrade.h:306
unsigned int GetMaxPrimarySkill() const
Definition: pstrade.h:283
uint32 GetId() const
Definition: pstrade.h:58
Each item contains the craft skills for the craft step.
Definition: pstrade.h:456
csString craftStepDescription
Definition: pstrade.h:473
uint32 designItemId
Definition: pstrade.h:435
int GetPrimaryPracticePts() const
Definition: pstrade.h:287
uint32 GetGroupPatternId() const
Definition: pstrade.h:414
int GetSubprocessId() const
Definition: pstrade.h:275
uint32 equipmentId
Definition: pstrade.h:381
int GetSecondaryQualFactor() const
Definition: pstrade.h:310
Each item contains craft information about a craft combination.
Definition: pstrade.h:479
int GetMinQty() const
Definition: pstrade.h:78
MathScript * GetScript()
Gets the script associated to this process.
Definition: pstrade.h:326
uint32 garbageId
Definition: pstrade.h:383
csString animation
Definition: pstrade.h:379
The base expression class.
Definition: mathscript.h:330
int priPracticePts
Definition: pstrade.h:388
csPDelArray< psTradeCombinations > combinations
Definition: pstrade.h:448
csString GetScriptName() const
Gets the name of the script associated to this process.
Definition: pstrade.h:340
csString renderEffect
Definition: pstrade.h:395
float GetItemQualityPenaltyPercent() const
Definition: pstrade.h:150
int GetTransPoints() const
Definition: pstrade.h:155
csString patternName
Definition: pstrade.h:434
MathExpression * transPoints
Definition: pstrade.h:213
uint32 GetProcessId() const
Definition: pstrade.h:238
unsigned int GetMinPrimarySkill() const
Definition: pstrade.h:279
csString GetAnimation() const
Definition: pstrade.h:247
csString constraints
Definition: pstrade.h:382
csString craftCombDescription
Definition: pstrade.h:482
csString GetName() const
Definition: pstrade.h:243
uint32 GetPatternId() const
Definition: pstrade.h:62
This class holds the master list of all trade patterns possible in the game.
Definition: pstrade.h:403
uint32 patternId
Definition: pstrade.h:89
Each item has a list of items required for its construction.
Definition: pstrade.h:444
uint32 GetItemId() const
Definition: pstrade.h:74
unsigned int GetMinSecondarySkill() const
Definition: pstrade.h:298
int minSecSkill
Definition: pstrade.h:461
const char * GetConstraintString() const
Definition: pstrade.h:259
csString name
Definition: pstrade.h:378
int GetResultQty() const
Definition: pstrade.h:70
int secSkillId
Definition: pstrade.h:471
float GetKFactor() const
Definition: pstrade.h:426
int minSecSkill
Definition: pstrade.h:472
csString & GetRenderEffect()
Definition: pstrade.h:314
This class holds the master list of all trade combinations possible in the game.
Definition: pstrade.h:50
This class holds the master list of all trade processes possible in the game.
Definition: pstrade.h:230
int priSkillId
Definition: pstrade.h:469
uint32 GetId() const
Definition: pstrade.h:110
void SetItemId(uint32 newItemId)
Definition: pstrade.h:136
uint32 GetProcessId() const
Definition: pstrade.h:118
int GetMaxQty() const
Definition: pstrade.h:82
bool Load(iResultRow &row)
uint32 GetWorkItemId() const
Definition: pstrade.h:251
int secPracticePts
Definition: pstrade.h:393
uint32 groupPatternId
Definition: pstrade.h:433
uint32 workItemId
Definition: pstrade.h:380
csString scriptName
Definition: pstrade.h:396
uint32 GetEquipementId() const
Definition: pstrade.h:255
const char * GetPatternString() const
Definition: pstrade.h:418
unsigned int GetMaxSecondarySkill() const
Definition: pstrade.h:302
int GetResultQty() const
Definition: pstrade.h:127
Each item contains craft information about a craft transformation step.
Definition: pstrade.h:467
int minPriSkill
Definition: pstrade.h:470
int secSkillId
Definition: pstrade.h:460
int GetPrimarySkillId() const
Definition: pstrade.h:271
float KFactor
Definition: pstrade.h:436
csArray< CraftSkills * > * skillArray
Definition: pstrade.h:481
MathScript * script
Definition: pstrade.h:397
uint32 GetDesignItemId() const
Definition: pstrade.h:422
uint32 GetId() const
Definition: pstrade.h:410