Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List

Cost.h

Go to the documentation of this file.
00001 /*
00002 Copyright 2003 - 2005 Elliott Kleinrock, Dan Neely, Kurt W. Over, Damon Domjan
00003 
00004 This file is part of FreeStars, a free clone of the Stars! game.
00005 
00006 FreeStars is free software; you can redistribute it and/or modify
00007 it under the terms of the GNU General Public License as published by
00008 the Free Software Foundation; either version 2 of the License, or
00009 (at your option) any later version.
00010 
00011 FreeStars is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with FreeStars; if not, write to the Free Software
00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 The full GPL Copyright notice should be in the file COPYING.txt
00021 
00022 Contact:
00023 Email Elliott at 9jm0tjj02@sneakemail.com
00024 */
00025 
00030 #if !defined(Cost_h)
00031 #define Cost_h
00032 
00039 class Cost {
00040 public:
00041         Cost();
00042         Cost(const Cost & c);
00043 
00044         void ReadCosts(const TiXmlNode * node);
00045         TiXmlNode * WriteCosts(TiXmlNode * node, const char * name) const;
00046         long GetResources() const { return mResources; }
00047         long GetCrew() const { return mCrew; }
00048         void SetResources(unsigned long r) { mResources = r; }
00049         void SetCrew(unsigned long c) { mCrew = c; }
00050         void Zero();
00051         long & operator [](long ct);
00052         long operator [](long ct) const;
00053         Cost & operator = (const Cost & c);
00054         Cost & operator *= (double factor);
00055         Cost & operator += (const Cost & c);
00056         Cost & operator -= (const Cost & c);
00057         friend bool operator == (const Cost & a, const Cost & c); 
00058         friend Cost operator *(const Cost & c, double factor)   { Cost r(c); r *= factor; return r; }
00059         friend Cost operator +(const Cost & a, const Cost & b)  { Cost r(a); r += b; return r; }
00060         friend Cost operator -(const Cost & a, const Cost & b)  { Cost r(a); r -= b; return r; }
00061 
00062         void Cleanup()  { mMinerals.clear(); }
00063 
00064 protected:
00065         deque<long> mMinerals;
00066         long mResources;
00067         long mCrew;
00068 };
00069 
00070 #endif // !defined(Cost_h)

Generated on Mon Aug 8 21:33:42 2005 for Freestars by  doxygen 1.4.2-20050421