2010-05-18 05:53:57 +02: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
|
2010-05-18 05:53:57 +02:00
|
|
|
//
|
2011-01-09 05:49:21 +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
|
2010-05-18 05:53:57 +02:00
|
|
|
// License, or (at your option) any later version
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
#ifndef _GLEST_GAME_UPGRADETYPE_H_
|
|
|
|
#define _GLEST_GAME_UPGRADETYPE_H_
|
|
|
|
|
2012-04-20 03:04:05 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <winsock.h>
|
|
|
|
#endif
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
#include "element_type.h"
|
|
|
|
#include "checksum.h"
|
|
|
|
#include "conversion.h"
|
2011-06-25 09:31:01 +02:00
|
|
|
#include "xml_parser.h"
|
2010-09-07 07:25:40 +02:00
|
|
|
#include "leak_dumper.h"
|
2010-05-18 05:53:57 +02:00
|
|
|
|
|
|
|
using Shared::Util::Checksum;
|
|
|
|
using namespace Shared::Util;
|
2011-06-25 09:31:01 +02:00
|
|
|
using namespace Shared::Xml;
|
2010-05-18 05:53:57 +02:00
|
|
|
|
2011-06-25 10:53:53 +02:00
|
|
|
namespace Glest { namespace Game {
|
2010-05-18 05:53:57 +02:00
|
|
|
|
|
|
|
class TechTree;
|
|
|
|
class FactionType;
|
|
|
|
class UnitType;
|
2011-06-26 09:06:32 +02:00
|
|
|
class Unit;
|
|
|
|
class SkillType;
|
|
|
|
class AttackSkillType;
|
|
|
|
class MoveSkillType;
|
|
|
|
class ProduceSkillType;
|
2012-03-13 16:21:25 +01:00
|
|
|
class Faction;
|
2010-05-18 05:53:57 +02:00
|
|
|
|
|
|
|
// ===============================
|
2011-01-09 05:49:21 +01:00
|
|
|
// class UpgradeTypeBase
|
2010-05-18 05:53:57 +02:00
|
|
|
// ===============================
|
|
|
|
|
2011-06-25 09:31:01 +02:00
|
|
|
class UpgradeTypeBase {
|
2010-05-18 05:53:57 +02:00
|
|
|
protected:
|
2012-03-13 16:21:25 +01:00
|
|
|
string upgradename;
|
2010-05-18 05:53:57 +02:00
|
|
|
int maxHp;
|
2011-06-26 09:06:32 +02:00
|
|
|
bool maxHpIsMultiplier;
|
2011-07-22 09:05:47 +02:00
|
|
|
int maxHpRegeneration;
|
|
|
|
//bool maxHpRegenerationIsMultiplier;
|
2011-06-26 09:06:32 +02:00
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
int sight;
|
2011-06-26 09:06:32 +02:00
|
|
|
bool sightIsMultiplier;
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
int maxEp;
|
2011-06-26 09:06:32 +02:00
|
|
|
bool maxEpIsMultiplier;
|
2011-07-22 09:05:47 +02:00
|
|
|
int maxEpRegeneration;
|
|
|
|
//bool maxEpRegenerationIsMultiplier;
|
2011-06-26 09:06:32 +02:00
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
int armor;
|
2011-06-26 09:06:32 +02:00
|
|
|
bool armorIsMultiplier;
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
int attackStrength;
|
2011-06-26 09:06:32 +02:00
|
|
|
bool attackStrengthIsMultiplier;
|
|
|
|
std::map<string,int> attackStrengthMultiplierValueList;
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
int attackRange;
|
2011-06-26 09:06:32 +02:00
|
|
|
bool attackRangeIsMultiplier;
|
|
|
|
std::map<string,int> attackRangeMultiplierValueList;
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
int moveSpeed;
|
2011-06-26 09:06:32 +02:00
|
|
|
bool moveSpeedIsMultiplier;
|
|
|
|
std::map<string,int> moveSpeedIsMultiplierValueList;
|
|
|
|
|
2011-01-09 05:49:21 +01:00
|
|
|
int prodSpeed;
|
2011-06-26 09:06:32 +02:00
|
|
|
bool prodSpeedIsMultiplier;
|
|
|
|
std::map<string,int> prodSpeedProduceIsMultiplierValueList;
|
|
|
|
std::map<string,int> prodSpeedUpgradeIsMultiplierValueList;
|
|
|
|
std::map<string,int> prodSpeedMorphIsMultiplierValueList;
|
2010-05-18 05:53:57 +02:00
|
|
|
|
|
|
|
public:
|
2012-09-22 22:13:57 +02:00
|
|
|
virtual ~UpgradeTypeBase() {}
|
2012-05-02 23:00:57 +02:00
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
int getMaxHp() const {return maxHp;}
|
2011-06-26 09:06:32 +02:00
|
|
|
bool getMaxHpIsMultiplier() const {return maxHpIsMultiplier;}
|
2011-07-22 09:05:47 +02:00
|
|
|
int getMaxHpRegeneration() const {return maxHpRegeneration;}
|
|
|
|
//bool getMaxHpRegenerationIsMultiplier() const {return maxHpRegenerationIsMultiplier;}
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
int getSight() const {return sight;}
|
2011-06-26 09:06:32 +02:00
|
|
|
bool getSightIsMultiplier() const {return sightIsMultiplier;}
|
2011-07-22 09:05:47 +02:00
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
int getMaxEp() const {return maxEp;}
|
2011-06-26 09:06:32 +02:00
|
|
|
bool getMaxEpIsMultiplier() const {return maxEpIsMultiplier;}
|
2011-07-22 09:05:47 +02:00
|
|
|
int getMaxEpRegeneration() const {return maxEpRegeneration;}
|
|
|
|
//bool getMaxEpRegenerationIsMultiplier() const {return maxEpRegenerationIsMultiplier;}
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
int getArmor() const {return armor;}
|
2011-06-26 09:06:32 +02:00
|
|
|
bool getArmorIsMultiplier() const {return armorIsMultiplier;}
|
|
|
|
|
|
|
|
int getAttackStrength(const AttackSkillType *st) const;
|
|
|
|
bool getAttackStrengthIsMultiplier() const {return attackStrengthIsMultiplier;}
|
|
|
|
int getAttackRange(const AttackSkillType *st) const;
|
|
|
|
bool getAttackRangeIsMultiplier() const {return attackRangeIsMultiplier;}
|
|
|
|
int getMoveSpeed(const MoveSkillType *st) const;
|
|
|
|
bool getMoveSpeedIsMultiplier() const {return moveSpeedIsMultiplier;}
|
|
|
|
int getProdSpeed(const SkillType *st) const;
|
|
|
|
bool getProdSpeedIsMultiplier() const {return prodSpeedIsMultiplier;}
|
2010-05-18 05:53:57 +02:00
|
|
|
|
2012-03-13 16:21:25 +01:00
|
|
|
void load(const XmlNode *upgradeNode, string upgradename);
|
2011-06-25 09:31:01 +02:00
|
|
|
|
2012-02-19 03:40:13 +01:00
|
|
|
virtual string getDesc() const;
|
2010-05-18 05:53:57 +02:00
|
|
|
std::string toString() const {
|
|
|
|
std::string result = "";
|
|
|
|
|
2012-03-13 16:21:25 +01:00
|
|
|
result += "upgradename =" + upgradename;
|
2010-05-18 05:53:57 +02:00
|
|
|
result += "maxHp = " + intToStr(maxHp);
|
2011-06-26 09:06:32 +02:00
|
|
|
result += "maxHpIsMultiplier = " + intToStr(maxHpIsMultiplier);
|
2011-07-22 09:05:47 +02:00
|
|
|
result += "maxHpRegeneration = " + intToStr(maxHpRegeneration);
|
|
|
|
//result += "maxHpRegenerationIsMultiplier = " + intToStr(maxHpRegenerationIsMultiplier);
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
result += " sight = " + intToStr(sight);
|
2011-06-26 09:06:32 +02:00
|
|
|
result += "sightIsMultiplier = " + intToStr(sightIsMultiplier);
|
2011-07-22 09:05:47 +02:00
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
result += " maxEp = " + intToStr(maxEp);
|
2011-06-26 09:06:32 +02:00
|
|
|
result += "maxEpIsMultiplier = " + intToStr(maxEpIsMultiplier);
|
2011-07-22 09:05:47 +02:00
|
|
|
result += " maxEpRegeneration = " + intToStr(maxEpRegeneration);
|
|
|
|
//result += "maxEpRegenerationIsMultiplier = " + intToStr(maxEpRegenerationIsMultiplier);
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
result += " armor = " + intToStr(armor);
|
2011-06-26 09:06:32 +02:00
|
|
|
result += "armorIsMultiplier = " + intToStr(armorIsMultiplier);
|
2010-05-18 05:53:57 +02:00
|
|
|
result += " attackStrength = " + intToStr(attackStrength);
|
2011-06-26 09:06:32 +02:00
|
|
|
result += "attackStrengthIsMultiplier = " + intToStr(attackStrengthIsMultiplier);
|
2010-05-18 05:53:57 +02:00
|
|
|
result += " attackRange = " + intToStr(attackRange);
|
2011-06-26 09:06:32 +02:00
|
|
|
result += "attackRangeIsMultiplier = " + intToStr(attackRangeIsMultiplier);
|
2010-05-18 05:53:57 +02:00
|
|
|
result += " moveSpeed = " + intToStr(moveSpeed);
|
2011-06-26 09:06:32 +02:00
|
|
|
result += "moveSpeedIsMultiplier = " + intToStr(moveSpeedIsMultiplier);
|
2010-05-18 05:53:57 +02:00
|
|
|
result += " prodSpeed = " + intToStr(prodSpeed);
|
2011-06-26 09:06:32 +02:00
|
|
|
result += "prodSpeedIsMultiplier = " + intToStr(prodSpeedIsMultiplier);
|
2010-05-18 05:53:57 +02:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2012-03-10 04:27:25 +01:00
|
|
|
|
|
|
|
virtual void saveGame(XmlNode *rootNode) const;
|
2012-03-13 16:21:25 +01:00
|
|
|
static const UpgradeType * loadGame(const XmlNode *rootNode, Faction *faction);
|
2010-05-18 05:53:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// ===============================
|
2011-01-09 05:49:21 +01:00
|
|
|
// class UpgradeType
|
2010-05-18 05:53:57 +02:00
|
|
|
// ===============================
|
|
|
|
|
2011-06-25 10:53:53 +02:00
|
|
|
class UpgradeType: public UpgradeTypeBase, public ProducibleType {
|
2010-05-18 05:53:57 +02:00
|
|
|
private:
|
2011-01-09 05:49:21 +01:00
|
|
|
vector<const UnitType*> effects;
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
public:
|
|
|
|
void preLoad(const string &dir);
|
2011-03-15 16:30:28 +01:00
|
|
|
void load(const string &dir, const TechTree *techTree,
|
|
|
|
const FactionType *factionType, Checksum* checksum,
|
2011-05-06 09:47:31 +02:00
|
|
|
Checksum* techtreeChecksum, std::map<string,vector<pair<string, string> > > &loadedFileList);
|
2010-05-18 05:53:57 +02:00
|
|
|
|
2012-05-02 23:00:57 +02:00
|
|
|
virtual string getName(bool translatedValue=false) const;
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
//get all
|
|
|
|
int getEffectCount() const {return effects.size();}
|
|
|
|
const UnitType * getEffect(int i) const {return effects[i];}
|
2011-01-09 05:49:21 +01:00
|
|
|
bool isAffected(const UnitType *unitType) const;
|
2010-05-18 05:53:57 +02:00
|
|
|
|
|
|
|
//other methods
|
|
|
|
virtual string getReqDesc() const;
|
2012-03-10 04:27:25 +01:00
|
|
|
|
2012-03-13 16:21:25 +01:00
|
|
|
//virtual void saveGame(XmlNode *rootNode) const;
|
|
|
|
//virtual void loadGame(const XmlNode *rootNode);
|
2010-05-18 05:53:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// ===============================
|
2011-01-09 05:49:21 +01:00
|
|
|
// class TotalUpgrade
|
2010-05-18 05:53:57 +02:00
|
|
|
// ===============================
|
|
|
|
|
2011-06-25 10:53:53 +02:00
|
|
|
class TotalUpgrade: public UpgradeTypeBase {
|
2010-05-18 05:53:57 +02:00
|
|
|
public:
|
|
|
|
TotalUpgrade();
|
2012-09-22 22:13:57 +02:00
|
|
|
virtual ~TotalUpgrade() {}
|
2010-05-18 05:53:57 +02:00
|
|
|
|
|
|
|
void reset();
|
2011-06-26 09:06:32 +02:00
|
|
|
void sum(const UpgradeTypeBase *ut, const Unit *unit);
|
2010-05-18 05:53:57 +02:00
|
|
|
void incLevel(const UnitType *ut);
|
2011-06-25 10:53:53 +02:00
|
|
|
|
2011-06-26 09:06:32 +02:00
|
|
|
void apply(const UpgradeTypeBase *ut, const Unit *unit);
|
|
|
|
void deapply(const UpgradeTypeBase *ut, const Unit *unit);
|
2012-03-13 16:21:25 +01:00
|
|
|
|
|
|
|
void saveGame(XmlNode *rootNode) const;
|
|
|
|
void loadGame(const XmlNode *rootNode);
|
2010-05-18 05:53:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}}//end namespace
|
|
|
|
|
|
|
|
#endif
|