Merge pull request #20 from MikeHoffert/documentation
Documentation is always a good thing
This commit is contained in:
commit
ad5e978be9
1
source/.gitignore
vendored
1
source/.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
/windows_deps*/
|
/windows_deps*/
|
||||||
/glest_game/facilities/gitversion.h
|
/glest_game/facilities/gitversion.h
|
||||||
|
/glest_game/site/
|
2329
source/glest_game/Doxyfile
Normal file
2329
source/glest_game/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -101,6 +101,14 @@ using namespace Shared::Graphics::Gl;
|
||||||
using namespace Shared::Xml;
|
using namespace Shared::Xml;
|
||||||
using namespace Shared;
|
using namespace Shared;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @namespace Glest
|
||||||
|
* Namespace used for all %Glest related code.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @namespace Game
|
||||||
|
* Namespace used for game related code.
|
||||||
|
*/
|
||||||
namespace Glest { namespace Game {
|
namespace Glest { namespace Game {
|
||||||
|
|
||||||
static string tempDataLocation = getUserHome();
|
static string tempDataLocation = getUserHome();
|
||||||
|
|
|
@ -9,6 +9,13 @@
|
||||||
// License, or (at your option) any later version
|
// License, or (at your option) any later version
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Contains the Upgrade and UpgradeManager classes. This is what the factions need to manage
|
||||||
|
* upgrades (including starting, canceling, and finishing upgrades, figuring out which
|
||||||
|
* upgrades we have done, etc).
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _GLEST_GAME_UPGRADE_H_
|
#ifndef _GLEST_GAME_UPGRADE_H_
|
||||||
#define _GLEST_GAME_UPGRADE_H_
|
#define _GLEST_GAME_UPGRADE_H_
|
||||||
|
|
||||||
|
@ -33,25 +40,32 @@ class Unit;
|
||||||
class UpgradeType;
|
class UpgradeType;
|
||||||
class Faction;
|
class Faction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the state of the upgrade (whether or not the upgrading process is complete).
|
||||||
|
*/
|
||||||
|
// TODO: Don't make this global; move it inside Upgrade
|
||||||
enum UpgradeState {
|
enum UpgradeState {
|
||||||
usUpgrading,
|
usUpgrading, /**< The upgrade is currently in progress. */
|
||||||
usUpgraded,
|
usUpgraded, /**< The upgrade is completed. */
|
||||||
|
|
||||||
upgradeStateCount
|
upgradeStateCount // TODO: This should be unnecessary -- there's no need to iterate over this enum
|
||||||
};
|
};
|
||||||
|
|
||||||
class UpgradeManager;
|
class UpgradeManager;
|
||||||
class TotalUpgrade;
|
class TotalUpgrade;
|
||||||
|
|
||||||
// =====================================================
|
/**
|
||||||
// class Upgrade
|
* An instance of an upgrade. Factions will typically have one upgrade of each type. This object
|
||||||
//
|
* groups the type, faction, and upgrade state (ie, has the upgrade been obtained yet?).
|
||||||
/// A bonus to an UnitType
|
*/
|
||||||
// =====================================================
|
|
||||||
|
|
||||||
class Upgrade {
|
class Upgrade {
|
||||||
private:
|
private:
|
||||||
UpgradeState state;
|
UpgradeState state;
|
||||||
|
// TODO: I believe this is unnecessary. As far as I can tell, it's only used for checking
|
||||||
|
// that the unit we're applying UpgradeManager::computeTotalUpgrade to is in this faction. However,
|
||||||
|
// I don't see an circumstances when it wouldn't be (since the UpgradeManager already an aggregate
|
||||||
|
// of a faction and Unit directly gets the UpgradeManager from the faction (so it must have the
|
||||||
|
// same faction as the upgrades in the UpgradeManager).
|
||||||
int factionIndex;
|
int factionIndex;
|
||||||
const UpgradeType *type;
|
const UpgradeType *type;
|
||||||
|
|
||||||
|
@ -59,50 +73,136 @@ private:
|
||||||
|
|
||||||
Upgrade();
|
Upgrade();
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Creates an upgrade. The upgrade state will be set to UpgradeState::usUpgrading.
|
||||||
|
* @param upgradeType The type of the upgrade that this corresponds to. Upgrade types are
|
||||||
|
* essentially "classes" for upgrades.
|
||||||
|
* @param factionIndex The index of the faction that the upgrade belongs to.
|
||||||
|
*/
|
||||||
Upgrade(const UpgradeType *upgradeType, int factionIndex);
|
Upgrade(const UpgradeType *upgradeType, int factionIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//get
|
|
||||||
UpgradeState getState() const;
|
UpgradeState getState() const;
|
||||||
int getFactionIndex() const;
|
int getFactionIndex() const;
|
||||||
const UpgradeType * getType() const;
|
const UpgradeType * getType() const;
|
||||||
|
|
||||||
//set
|
|
||||||
void setState(UpgradeState state);
|
void setState(UpgradeState state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a string representation of the upgrade (detailing its state, type, and faction).
|
||||||
|
*/
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the object state into the given node.
|
||||||
|
* @param rootNode The UpgradeManager node to save object info to.
|
||||||
|
*/
|
||||||
void saveGame(XmlNode *rootNode);
|
void saveGame(XmlNode *rootNode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the object state from the given node.
|
||||||
|
* @param rootNode The UpgradeManager node to retrieve object info from.
|
||||||
|
* @param faction The faction that the upgrade belongs to. Used to convert the upgrade type from
|
||||||
|
* the XML string.
|
||||||
|
*/
|
||||||
static Upgrade * loadGame(const XmlNode *rootNode,Faction *faction);
|
static Upgrade * loadGame(const XmlNode *rootNode,Faction *faction);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
// ===============================
|
* Manages upgrades by starting, stopping, and finishing upgrades. Each faction has their own
|
||||||
// class UpgradeManager
|
* upgrade manager.
|
||||||
// ===============================
|
*/
|
||||||
|
|
||||||
class UpgradeManager{
|
class UpgradeManager{
|
||||||
private:
|
private:
|
||||||
typedef vector<Upgrade*> Upgrades;
|
typedef vector<Upgrade*> Upgrades;
|
||||||
typedef map<const UpgradeType *,int> UgradesLookup;
|
typedef map<const UpgradeType *,int> UgradesLookup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of upgrades that the upgrade manager is working with (either in progress or finished).
|
||||||
|
*/
|
||||||
Upgrades upgrades;
|
Upgrades upgrades;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps UpgradeType to the index of the upgrade in UpgradeManager::upgrades.
|
||||||
|
*/
|
||||||
UgradesLookup upgradesLookup;
|
UgradesLookup upgradesLookup;
|
||||||
public:
|
public:
|
||||||
~UpgradeManager();
|
~UpgradeManager();
|
||||||
|
|
||||||
int getUpgradeCount() const {return (int)upgrades.size();}
|
int getUpgradeCount() const {return (int)upgrades.size();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts an upgrade.
|
||||||
|
* @param upgradeType The type of the upgrade to start.
|
||||||
|
* @param factionIndex Passed to the constructor of the Upgrade.
|
||||||
|
*/
|
||||||
void startUpgrade(const UpgradeType *upgradeType, int factionIndex);
|
void startUpgrade(const UpgradeType *upgradeType, int factionIndex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels an upgrade before it is finished. The upgrade is removed from the UpgradeManager.
|
||||||
|
* @param upgradeType The type of the upgrade to remove.
|
||||||
|
* @throws megaglest_runtime_error If there is no upgrade of the desired type in the UpgradeManager.
|
||||||
|
*/
|
||||||
void cancelUpgrade(const UpgradeType *upgradeType);
|
void cancelUpgrade(const UpgradeType *upgradeType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets an Upgrade in the UpgradeManager as finished (ie, the state is UpgradeState::usUpgraded).
|
||||||
|
* @param upgradeType The type of the upgrade to complete.
|
||||||
|
* @throws megaglest_runtime_error If there is no upgrade of the desired type in the UpgradeManager.
|
||||||
|
*/
|
||||||
void finishUpgrade(const UpgradeType *upgradeType);
|
void finishUpgrade(const UpgradeType *upgradeType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if an Upgrade of the desired type has state UpgradeState::usUpgraded (ie, is
|
||||||
|
* finished upgrading).
|
||||||
|
* @param upgradeType The type of the upgrade in question.
|
||||||
|
*/
|
||||||
bool isUpgraded(const UpgradeType *upgradeType) const;
|
bool isUpgraded(const UpgradeType *upgradeType) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if an Upgrade of the desired type has state UpgradeState::usUpgrading (ie, is
|
||||||
|
* currently in progress).
|
||||||
|
* @param upgradeType The type of the upgrade in question.
|
||||||
|
*/
|
||||||
bool isUpgrading(const UpgradeType *upgradeType) const;
|
bool isUpgrading(const UpgradeType *upgradeType) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if an Upgrade of the desired type exists in the UpgradeManager.
|
||||||
|
* @param upgradeType The type of the upgrade in question.
|
||||||
|
*/
|
||||||
bool isUpgradingOrUpgraded(const UpgradeType *upgradeType) const;
|
bool isUpgradingOrUpgraded(const UpgradeType *upgradeType) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [Sums up](@ref TotalUpgrade::sum) the effect of all upgrades for this faction as they apply
|
||||||
|
* to a particular unit.
|
||||||
|
* @param unit The unit that the TotalUpgrade applies to. This is necessary because some
|
||||||
|
* upgrades provide percentage boosts.
|
||||||
|
* @param totalUpgrade The TotalUpgrade object to modify. Note that it is cleared before values
|
||||||
|
* are calculated.
|
||||||
|
*/
|
||||||
void computeTotalUpgrade(const Unit *unit, TotalUpgrade *totalUpgrade) const;
|
void computeTotalUpgrade(const Unit *unit, TotalUpgrade *totalUpgrade) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a string representation of the UpgradeManager. Contains the contents of
|
||||||
|
* Upgrade::toString for all upgrades in the UpgradeManager.
|
||||||
|
*/
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a node for the UpgradeManager that contains all the upgrade nodes, saving the object's
|
||||||
|
* state.
|
||||||
|
* @param rootNode The faction node to add the UpgradeManager node to.
|
||||||
|
* @see Upgrade::saveGame
|
||||||
|
*/
|
||||||
void saveGame(XmlNode *rootNode);
|
void saveGame(XmlNode *rootNode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads all the upgrades from the UpgradeManager node, effectively reloading the object's
|
||||||
|
* state.
|
||||||
|
* @param rootNode The faction node to get the UpgradeManager node from.
|
||||||
|
* @param faction Only passed to Upgrade::loadGame (which does the actual loading of each
|
||||||
|
* Upgrade object.
|
||||||
|
*/
|
||||||
void loadGame(const XmlNode *rootNode,Faction *faction);
|
void loadGame(const XmlNode *rootNode,Faction *faction);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,14 @@
|
||||||
// License, or (at your option) any later version
|
// License, or (at your option) any later version
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Classified the Upgrade type (which is sort of like a class for upgrades). Each upgrade has a
|
||||||
|
* type that details the stats that it boosts and the units that it affects. Also has TotalUpgrade,
|
||||||
|
* which is a sum of all upgrades applied to a particular unit (and is what determines how units
|
||||||
|
* stats are modified by an upgrade.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _GLEST_GAME_UPGRADETYPE_H_
|
#ifndef _GLEST_GAME_UPGRADETYPE_H_
|
||||||
#define _GLEST_GAME_UPGRADETYPE_H_
|
#define _GLEST_GAME_UPGRADETYPE_H_
|
||||||
|
|
||||||
|
@ -39,10 +47,9 @@ class MoveSkillType;
|
||||||
class ProduceSkillType;
|
class ProduceSkillType;
|
||||||
class Faction;
|
class Faction;
|
||||||
|
|
||||||
// ===============================
|
/**
|
||||||
// class UpgradeTypeBase
|
* Groups all information used for upgrades. Attack boosts also use this class for modifying stats.
|
||||||
// ===============================
|
*/
|
||||||
|
|
||||||
class UpgradeTypeBase {
|
class UpgradeTypeBase {
|
||||||
protected:
|
protected:
|
||||||
string upgradename;
|
string upgradename;
|
||||||
|
@ -64,23 +71,31 @@ protected:
|
||||||
|
|
||||||
int attackStrength;
|
int attackStrength;
|
||||||
bool attackStrengthIsMultiplier;
|
bool attackStrengthIsMultiplier;
|
||||||
|
/**
|
||||||
|
* List of the values (for each skill type) that the stat was boosted by. This is used so
|
||||||
|
* that we can restore the original values when the upgrade is removed (eg, an attack
|
||||||
|
* boost wears off).
|
||||||
|
*/
|
||||||
std::map<string,int> attackStrengthMultiplierValueList;
|
std::map<string,int> attackStrengthMultiplierValueList;
|
||||||
|
|
||||||
int attackRange;
|
int attackRange;
|
||||||
bool attackRangeIsMultiplier;
|
bool attackRangeIsMultiplier;
|
||||||
std::map<string,int> attackRangeMultiplierValueList;
|
std::map<string,int> attackRangeMultiplierValueList; /**< @see #attackStrengthMultiplierValueList */
|
||||||
|
|
||||||
int moveSpeed;
|
int moveSpeed;
|
||||||
bool moveSpeedIsMultiplier;
|
bool moveSpeedIsMultiplier;
|
||||||
std::map<string,int> moveSpeedIsMultiplierValueList;
|
std::map<string,int> moveSpeedIsMultiplierValueList; /**< @see #attackStrengthMultiplierValueList */
|
||||||
|
|
||||||
int prodSpeed;
|
int prodSpeed;
|
||||||
bool prodSpeedIsMultiplier;
|
bool prodSpeedIsMultiplier;
|
||||||
std::map<string,int> prodSpeedProduceIsMultiplierValueList;
|
std::map<string,int> prodSpeedProduceIsMultiplierValueList; /**< @see #attackStrengthMultiplierValueList */
|
||||||
std::map<string,int> prodSpeedUpgradeIsMultiplierValueList;
|
std::map<string,int> prodSpeedUpgradeIsMultiplierValueList; /**< @see #attackStrengthMultiplierValueList */
|
||||||
std::map<string,int> prodSpeedMorphIsMultiplierValueList;
|
std::map<string,int> prodSpeedMorphIsMultiplierValueList; /**< @see #attackStrengthMultiplierValueList */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Creates an UpgradeTypeBase with values such that there are no stat changes.
|
||||||
|
*/
|
||||||
UpgradeTypeBase() {
|
UpgradeTypeBase() {
|
||||||
maxHp = 0;;
|
maxHp = 0;;
|
||||||
maxHpIsMultiplier = false;
|
maxHpIsMultiplier = false;
|
||||||
|
@ -128,10 +143,26 @@ public:
|
||||||
int getProdSpeed(const SkillType *st) const;
|
int getProdSpeed(const SkillType *st) const;
|
||||||
bool getProdSpeedIsMultiplier() const {return prodSpeedIsMultiplier;}
|
bool getProdSpeedIsMultiplier() const {return prodSpeedIsMultiplier;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the upgrade values (stat boosts and whether or not the boosts use a multiplier) from an
|
||||||
|
* XML node.
|
||||||
|
* @param upgradeNode Node containing the stat boost elements (`max-hp`, `attack-strength`, etc).
|
||||||
|
* @param upgradename Unique identifier for the upgrade.
|
||||||
|
*/
|
||||||
void load(const XmlNode *upgradeNode, string upgradename);
|
void load(const XmlNode *upgradeNode, string upgradename);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a string representation of the upgrade. All stat boosts are detailed on their own line
|
||||||
|
* with their corresponding boosts.
|
||||||
|
* @param translatedValue If true, the description is translated. Otherwise the description uses
|
||||||
|
* names as they appear in the XMLs.
|
||||||
|
*/
|
||||||
virtual string getDesc(bool translatedValue) const;
|
virtual string getDesc(bool translatedValue) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string representation of this object. Lists all the value that the object stores.
|
||||||
|
* For debugging purposes, only.
|
||||||
|
*/
|
||||||
std::string toString() const {
|
std::string toString() const {
|
||||||
std::string result = "";
|
std::string result = "";
|
||||||
|
|
||||||
|
@ -163,9 +194,14 @@ public:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: It's not clear if these save game methods are being used, currently. I think
|
||||||
|
// attack boosts might use the few lines that aren't commented out.
|
||||||
virtual void saveGame(XmlNode *rootNode) const;
|
virtual void saveGame(XmlNode *rootNode) const;
|
||||||
static const UpgradeType * loadGame(const XmlNode *rootNode, Faction *faction);
|
static const UpgradeType * loadGame(const XmlNode *rootNode, Faction *faction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a checksum value for the upgrade.
|
||||||
|
*/
|
||||||
Checksum getCRC() {
|
Checksum getCRC() {
|
||||||
Checksum crcForUpgradeType;
|
Checksum crcForUpgradeType;
|
||||||
|
|
||||||
|
@ -212,53 +248,137 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ===============================
|
/**
|
||||||
// class UpgradeType
|
* Represents the type of upgrade. That is, the single upgrade as it appears in the faction's XML
|
||||||
// ===============================
|
* files. Each upgrade has a single `UpgradeType`. Contains information about what units are
|
||||||
|
* affected by the upgrade.
|
||||||
|
*/
|
||||||
class UpgradeType: public UpgradeTypeBase, public ProducibleType {
|
class UpgradeType: public UpgradeTypeBase, public ProducibleType {
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* List of unit types (the "classes" of units, eg, swordman) that are affected by this upgrade.
|
||||||
|
*/
|
||||||
vector<const UnitType*> effects;
|
vector<const UnitType*> effects;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Sets the upgrade name to the directory name (the base name of `dir`).
|
||||||
|
* @param dir Path of the upgrade directory.
|
||||||
|
*/
|
||||||
void preLoad(const string &dir);
|
void preLoad(const string &dir);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads an upgrade from an XML file.
|
||||||
|
* @param dir Path of the upgrade directory. The file name is determined from this.
|
||||||
|
* @param techTree The techtree that this upgrade is in. Used to access the common data
|
||||||
|
* directory and to access resources.
|
||||||
|
* @param factionType The faction type (a unique type for each faction) that the upgrade belongs
|
||||||
|
* to. Used for accessing unit types that are in the unit requirements list.
|
||||||
|
* @param checksum Will have the checksum of the upgrade path added to it (treated the same way
|
||||||
|
* as the `techtreeChecksum`).
|
||||||
|
* @param techtreeChecksum Cumulative checksum for the techtree. The path of loaded upgrades
|
||||||
|
* is added to this checksum.
|
||||||
|
*/
|
||||||
void load(const string &dir, const TechTree *techTree,
|
void load(const string &dir, const TechTree *techTree,
|
||||||
const FactionType *factionType, Checksum* checksum,
|
const FactionType *factionType, Checksum* checksum,
|
||||||
Checksum* techtreeChecksum,
|
Checksum* techtreeChecksum,
|
||||||
std::map<string,vector<pair<string, string> > > &loadedFileList,
|
std::map<string,vector<pair<string, string> > > &loadedFileList,
|
||||||
bool validationMode=false);
|
bool validationMode=false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains the upgrade name.
|
||||||
|
* @param translatedValue If true, the name is translated. Otherwise the name is returned as it
|
||||||
|
* appears in the XMLs.
|
||||||
|
*/
|
||||||
virtual string getName(bool translatedValue=false) const;
|
virtual string getName(bool translatedValue=false) const;
|
||||||
|
|
||||||
//get all
|
/**
|
||||||
|
* Returns the number of UnitTypes affected by this upgrade.
|
||||||
|
*/
|
||||||
int getEffectCount() const {return (int)effects.size();}
|
int getEffectCount() const {return (int)effects.size();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a particular unit type affected by this upgrade.
|
||||||
|
* @param i Index of the unit type in the #effects list.
|
||||||
|
*/
|
||||||
const UnitType * getEffect(int i) const {return effects[i];}
|
const UnitType * getEffect(int i) const {return effects[i];}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if a unit is affected by this upgrade.
|
||||||
|
* @param unitType The UnitType we are checking (to see if they're affected).
|
||||||
|
* @return True if the unit is affected, false otherwise.
|
||||||
|
*/
|
||||||
bool isAffected(const UnitType *unitType) const;
|
bool isAffected(const UnitType *unitType) const;
|
||||||
|
|
||||||
//other methods
|
/**
|
||||||
|
* Creates a description for this upgrade. Lists the affected units.
|
||||||
|
*/
|
||||||
virtual string getReqDesc(bool translatedValue) const;
|
virtual string getReqDesc(bool translatedValue) const;
|
||||||
|
|
||||||
//virtual void saveGame(XmlNode *rootNode) const;
|
//virtual void saveGame(XmlNode *rootNode) const;
|
||||||
//virtual void loadGame(const XmlNode *rootNode);
|
//virtual void loadGame(const XmlNode *rootNode);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ===============================
|
/**
|
||||||
// class TotalUpgrade
|
* Keeps track of the cumulative effects of upgrades on units. This allows us to apply multiple
|
||||||
// ===============================
|
* upgrades to a unit with the effects stacking.
|
||||||
|
*/
|
||||||
class TotalUpgrade: public UpgradeTypeBase {
|
class TotalUpgrade: public UpgradeTypeBase {
|
||||||
public:
|
public:
|
||||||
TotalUpgrade();
|
TotalUpgrade();
|
||||||
virtual ~TotalUpgrade() {}
|
virtual ~TotalUpgrade() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets all stat boosts (so there's effectively no upgrade).
|
||||||
|
*/
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an upgrade to this one, stacking the effects. Note that multipliers are stacked
|
||||||
|
* by multiplying by the original, unboosted amount, and then adding that to the TotalUpgrade.
|
||||||
|
* @param ut The upgrade to apply.
|
||||||
|
* @param unit The unit this TotalUpgrade is associated with (since when we use a multiplier,
|
||||||
|
* the stats raise by an amount relative to the unit's base stats).
|
||||||
|
*/
|
||||||
void sum(const UpgradeTypeBase *ut, const Unit *unit);
|
void sum(const UpgradeTypeBase *ut, const Unit *unit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increases the level of the unit. Doing so results in their HP, EP, and armour going up by
|
||||||
|
* 50% while their sight goes up by 20%.
|
||||||
|
* @param ut The unit type to get the original stats from (so we can determine just how much
|
||||||
|
* to increase the stats by on level up).
|
||||||
|
*/
|
||||||
void incLevel(const UnitType *ut);
|
void incLevel(const UnitType *ut);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies the upgrade. Just a delegate to TotalUpgrade::sum.
|
||||||
|
*/
|
||||||
void apply(const UpgradeTypeBase *ut, const Unit *unit);
|
void apply(const UpgradeTypeBase *ut, const Unit *unit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the effect of an upgrade to a specific unit. Using this after applying the upgrade
|
||||||
|
* is an invariant. ie,
|
||||||
|
*
|
||||||
|
* totalUpgrade->apply(upgrade, unit);
|
||||||
|
* totalUpgrade->deapply(upgrade, unit);
|
||||||
|
* // totalUpgrade is now the same as before the call to apply()
|
||||||
|
*
|
||||||
|
* @param ut The upgrade to remove.
|
||||||
|
* @param unit The unit this TotalUpgrade is associated with (since when we use a multiplier,
|
||||||
|
* the stats were raise by an amount relative to the unit's base stats).
|
||||||
|
*/
|
||||||
void deapply(const UpgradeTypeBase *ut, const Unit *unit);
|
void deapply(const UpgradeTypeBase *ut, const Unit *unit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the XML for the save game file. Essentially just stores everything about its state.
|
||||||
|
* @rootNode The node of the unit that this TotalUpgrade object belongs to.
|
||||||
|
*/
|
||||||
void saveGame(XmlNode *rootNode) const;
|
void saveGame(XmlNode *rootNode) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reloads the object's state from a saved game.
|
||||||
|
* @rootNode The node of the unit that this TotalUpgrade object belongs to.
|
||||||
|
*/
|
||||||
void loadGame(const XmlNode *rootNode);
|
void loadGame(const XmlNode *rootNode);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user