2011-01-20 16:56:30 +01:00
|
|
|
// ==============================================================
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
//
|
2011-12-14 08:40:48 +01:00
|
|
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
2011-01-20 16:56:30 +01:00
|
|
|
//
|
|
|
|
// You can redistribute this code and/or modify it under
|
|
|
|
// the terms of the GNU General Public License as published
|
|
|
|
// by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version
|
|
|
|
// ==============================================================
|
|
|
|
#ifndef _GLEST_GAME_RESOURCE_H_
|
|
|
|
#define _GLEST_GAME_RESOURCE_H_
|
|
|
|
|
2012-04-20 03:04:05 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <winsock.h>
|
|
|
|
#endif
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
#include <string>
|
|
|
|
#include "vec.h"
|
|
|
|
#include "platform_common.h"
|
2012-03-10 04:27:25 +01:00
|
|
|
#include "xml_parser.h"
|
2011-01-20 16:56:30 +01:00
|
|
|
#include "leak_dumper.h"
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::map;
|
2012-03-10 04:27:25 +01:00
|
|
|
using Shared::Xml::XmlNode;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
using Shared::Graphics::Vec2i;
|
|
|
|
using Shared::PlatformCommon::ValueCheckerVault;
|
|
|
|
|
|
|
|
class ResourceType;
|
2012-03-13 00:08:22 +01:00
|
|
|
class TechTree;
|
2011-01-20 16:56:30 +01:00
|
|
|
// =====================================================
|
|
|
|
// class Resource
|
|
|
|
//
|
|
|
|
/// Amount of a given ResourceType
|
|
|
|
// =====================================================
|
|
|
|
|
|
|
|
class Resource : public ValueCheckerVault {
|
|
|
|
private:
|
|
|
|
int amount;
|
|
|
|
const ResourceType *type;
|
|
|
|
Vec2i pos;
|
|
|
|
int balance;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Resource();
|
|
|
|
void init(const ResourceType *rt, int amount);
|
|
|
|
void init(const ResourceType *rt, const Vec2i &pos);
|
|
|
|
|
|
|
|
const ResourceType * getType() const {return type;}
|
|
|
|
Vec2i getPos() const {return pos;}
|
|
|
|
|
|
|
|
int getAmount() const;
|
|
|
|
int getBalance() const;
|
2013-06-13 10:55:48 +02:00
|
|
|
string getDescription(bool translatedValue) const;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
void setAmount(int amount);
|
|
|
|
void setBalance(int balance);
|
|
|
|
|
|
|
|
bool decAmount(int i);
|
2012-03-10 04:27:25 +01:00
|
|
|
|
|
|
|
void saveGame(XmlNode *rootNode) const;
|
2012-03-13 16:21:25 +01:00
|
|
|
void loadGame(const XmlNode *rootNode, int index,const TechTree *techTree);
|
2013-09-12 05:33:43 +02:00
|
|
|
|
2013-09-17 02:43:14 +02:00
|
|
|
std::string toString() const;
|
2013-09-12 05:33:43 +02:00
|
|
|
Checksum getCRC();
|
2011-01-20 16:56:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}}// end namespace
|
|
|
|
|
|
|
|
#endif
|