Planeshift
|
00001 /* 00002 * psmoney.h by Anders Reggestad <[email protected]> 00003 * 00004 * Copyright (C) 2001 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 PS_MONEY 00021 #define PS_MONEY 00022 00023 //CS includes 00024 #include <csutil/csstring.h> 00025 00026 // Value of coins in other coins 00027 #define CIRCLES_VALUE_TRIAS 250 00028 #define OCTAS_VALUE_TRIAS 50 00029 #define HEXAS_VALUE_TRIAS 10 00030 00031 #define CIRCLES_VALUE_HEXAS (CIRCLES_VALUE_TRIAS / HEXAS_VALUE_TRIAS) 00032 #define CIRCLES_VALUE_OCTAS (CIRCLES_VALUE_TRIAS / OCTAS_VALUE_TRIAS) 00033 #define OCTAS_VALUE_HEXAS (OCTAS_VALUE_TRIAS / HEXAS_VALUE_TRIAS) 00034 00035 typedef enum 00036 { 00037 MONEY_TRIAS, 00038 MONEY_HEXAS, 00039 MONEY_OCTAS, 00040 MONEY_CIRCLES 00041 } Money_Slots; 00042 00043 00044 class psMoney 00045 { 00046 public: 00047 psMoney(); 00048 psMoney(int trias); 00049 psMoney(int circles, int octas, int hexas, int trias); 00050 00054 psMoney(const char * moneyString); 00055 00056 00057 void Set(const char * moneyString); 00058 void Set(int type, int value); 00059 void Set(int circles, int octas, int hexas, int trias); 00060 00063 void SetCircles(int c) { circles = c; } 00064 void AdjustCircles( int c ); 00065 00069 int GetCircles() const { return circles; } 00070 00073 void SetOctas(int o) { octas = o; } 00074 void AdjustOctas(int o); 00078 int GetOctas() const { return octas; } 00079 00082 void SetHexas(int h) { hexas = h; } 00083 void AdjustHexas( int h ); 00087 int GetHexas() const { return hexas; } 00088 00091 void SetTrias(int t) { trias = t; } 00092 void AdjustTrias( int t ); 00093 00097 int GetTrias() const { return trias; } 00098 00102 int GetTotal() const; 00103 00107 csString ToString() const; 00108 00112 csString ToUserString() const; 00113 00117 psMoney Normalized() const; 00118 00119 bool operator > (const psMoney& other) const; 00120 psMoney operator - (const psMoney& other) const; 00121 psMoney operator - (void) const; 00122 psMoney operator + (const psMoney& other) const; 00123 psMoney operator +=(const psMoney& other); 00124 psMoney operator * (const int mult) const; 00125 00126 void Adjust( int type, int value ); 00127 int Get( int type ) const; 00128 00129 bool EnsureTrias(int minValue); 00130 bool EnsureHexas(int minValue); 00131 bool EnsureOctas(int minValue); 00132 bool EnsureCircles(int minValue); 00133 00134 protected: 00135 int circles; 00136 int octas; 00137 int hexas; 00138 int trias; 00139 }; 00140 00141 00142 #endif