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
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
#include "upgrade_type.h"
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cassert>
|
2014-09-29 02:55:15 +02:00
|
|
|
#include <iterator>
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
#include "unit_type.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "logger.h"
|
|
|
|
#include "lang.h"
|
|
|
|
#include "xml_parser.h"
|
|
|
|
#include "tech_tree.h"
|
|
|
|
#include "faction_type.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "renderer.h"
|
|
|
|
#include "game_util.h"
|
2012-03-13 16:21:25 +01:00
|
|
|
#include "faction.h"
|
2011-01-20 16:56:30 +01:00
|
|
|
#include "leak_dumper.h"
|
|
|
|
|
|
|
|
using namespace Shared::Util;
|
|
|
|
using namespace Shared::Xml;
|
|
|
|
|
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class UpgradeType
|
|
|
|
// =====================================================
|
|
|
|
|
|
|
|
// ==================== get ====================
|
|
|
|
|
2011-07-02 02:20:28 +02:00
|
|
|
const string VALUE_PERCENT_MULTIPLIER_KEY_NAME = "value-percent-multiplier";
|
2011-07-22 09:05:47 +02:00
|
|
|
const string VALUE_REGEN_KEY_NAME = "regeneration";
|
|
|
|
|
2014-12-21 00:27:11 +01:00
|
|
|
void UpgradeTypeBase::copyDataFrom(UpgradeTypeBase *source) {
|
|
|
|
upgradename = source->upgradename;
|
|
|
|
maxHp = source->maxHp;
|
|
|
|
maxHpIsMultiplier = source->maxHpIsMultiplier;
|
|
|
|
maxHpRegeneration = source->maxHpRegeneration;
|
|
|
|
sight = source->sight;
|
|
|
|
sightIsMultiplier = source->sightIsMultiplier;
|
|
|
|
maxEp = source->maxEp;
|
|
|
|
maxEpIsMultiplier = source->maxEpIsMultiplier;
|
|
|
|
maxEpRegeneration = source->maxEpRegeneration;
|
|
|
|
armor = source->armor;
|
|
|
|
armorIsMultiplier = source->armorIsMultiplier;
|
|
|
|
attackStrength = source->attackStrength;
|
|
|
|
attackStrengthIsMultiplier = source->attackStrengthIsMultiplier;
|
|
|
|
attackStrengthMultiplierValueList = source->attackStrengthMultiplierValueList;
|
|
|
|
attackRange = source->attackRange;
|
|
|
|
attackRangeIsMultiplier = source->attackRangeIsMultiplier;
|
|
|
|
attackRangeMultiplierValueList = source->attackRangeMultiplierValueList;
|
|
|
|
moveSpeed = source->moveSpeed;
|
|
|
|
moveSpeedIsMultiplier = source->moveSpeedIsMultiplier;
|
|
|
|
moveSpeedIsMultiplierValueList = source->moveSpeedIsMultiplierValueList;
|
|
|
|
prodSpeed = source->prodSpeed;
|
|
|
|
prodSpeedIsMultiplier = source->prodSpeedIsMultiplier;
|
|
|
|
prodSpeedProduceIsMultiplierValueList = source->prodSpeedProduceIsMultiplierValueList;
|
|
|
|
prodSpeedUpgradeIsMultiplierValueList = source->prodSpeedUpgradeIsMultiplierValueList;
|
|
|
|
prodSpeedMorphIsMultiplierValueList = source->prodSpeedMorphIsMultiplierValueList;
|
|
|
|
attackSpeed = source->attackSpeed;
|
|
|
|
attackSpeedIsMultiplier = source->attackSpeedIsMultiplier;
|
|
|
|
attackSpeedIsMultiplierValueList = source->attackSpeedIsMultiplierValueList;
|
2014-12-20 23:25:42 +01:00
|
|
|
}
|
|
|
|
|
2012-03-13 16:21:25 +01:00
|
|
|
void UpgradeTypeBase::load(const XmlNode *upgradeNode, string upgradename) {
|
|
|
|
this->upgradename = upgradename;
|
2011-06-25 09:31:01 +02:00
|
|
|
//values
|
2011-06-26 09:06:32 +02:00
|
|
|
maxHpIsMultiplier = false;
|
2012-12-26 08:57:10 +01:00
|
|
|
if(upgradeNode->hasChild("max-hp") == true) {
|
|
|
|
maxHp = upgradeNode->getChild("max-hp")->getAttribute("value")->getIntValue();
|
|
|
|
if(upgradeNode->getChild("max-hp")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
|
|
|
maxHpIsMultiplier = upgradeNode->getChild("max-hp")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
2011-06-26 09:06:32 +02:00
|
|
|
|
2012-12-26 08:57:10 +01:00
|
|
|
//printf("Found maxHpIsMultiplier = %d\n",maxHpIsMultiplier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
maxHp = 0;
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
2011-07-22 09:05:47 +02:00
|
|
|
maxHpRegeneration = 0;
|
|
|
|
//maxHpRegenerationIsMultiplier = false;
|
2012-12-26 08:57:10 +01:00
|
|
|
if(upgradeNode->hasChild("max-hp") == true) {
|
|
|
|
if(upgradeNode->getChild("max-hp")->getAttribute(VALUE_REGEN_KEY_NAME,false) != NULL) {
|
|
|
|
maxHpRegeneration = upgradeNode->getChild("max-hp")->getAttribute(VALUE_REGEN_KEY_NAME)->getIntValue();
|
2011-07-22 09:05:47 +02:00
|
|
|
|
2012-12-26 08:57:10 +01:00
|
|
|
//printf("Found maxHpIsMultiplier = %d\n",maxHpIsMultiplier);
|
|
|
|
}
|
2011-07-22 09:05:47 +02:00
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
|
|
|
|
maxEpIsMultiplier = false;
|
2012-12-26 08:57:10 +01:00
|
|
|
if(upgradeNode->hasChild("max-ep") == true) {
|
|
|
|
maxEp = upgradeNode->getChild("max-ep")->getAttribute("value")->getIntValue();
|
|
|
|
if(upgradeNode->getChild("max-ep")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
|
|
|
maxEpIsMultiplier = upgradeNode->getChild("max-ep")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
2011-06-26 09:06:32 +02:00
|
|
|
|
2012-12-26 08:57:10 +01:00
|
|
|
//printf("Found maxEpIsMultiplier = %d\n",maxEpIsMultiplier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
maxEp = 0;
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
2011-07-22 09:05:47 +02:00
|
|
|
maxEpRegeneration = 0;
|
|
|
|
//maxEpRegenerationIsMultiplier = false;
|
2012-12-26 08:57:10 +01:00
|
|
|
if(upgradeNode->hasChild("max-ep") == true) {
|
|
|
|
if(upgradeNode->getChild("max-ep")->getAttribute(VALUE_REGEN_KEY_NAME,false) != NULL) {
|
|
|
|
maxEpRegeneration = upgradeNode->getChild("max-ep")->getAttribute(VALUE_REGEN_KEY_NAME)->getIntValue();
|
2011-07-22 09:05:47 +02:00
|
|
|
|
2012-12-26 08:57:10 +01:00
|
|
|
//printf("Found maxHpIsMultiplier = %d\n",maxHpIsMultiplier);
|
|
|
|
}
|
2011-07-22 09:05:47 +02:00
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
|
|
|
|
sightIsMultiplier = false;
|
2012-12-26 08:57:10 +01:00
|
|
|
if(upgradeNode->hasChild("sight") == true) {
|
|
|
|
sight= upgradeNode->getChild("sight")->getAttribute("value")->getIntValue();
|
|
|
|
if(upgradeNode->getChild("sight")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
|
|
|
sightIsMultiplier = upgradeNode->getChild("sight")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
2011-06-26 09:06:32 +02:00
|
|
|
|
2012-12-26 08:57:10 +01:00
|
|
|
//printf("Found sightIsMultiplier = %d\n",sightIsMultiplier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sight = 0;
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
attackStrengthIsMultiplier = false;
|
2013-10-03 16:51:26 +02:00
|
|
|
|
|
|
|
std::vector<string> attackStrengthXMLTags;
|
|
|
|
attackStrengthXMLTags.push_back("attack-strenght");
|
|
|
|
attackStrengthXMLTags.push_back("attack-strength");
|
|
|
|
if(upgradeNode->hasChildWithAliases(attackStrengthXMLTags) == true) {
|
|
|
|
attackStrength= upgradeNode->getChildWithAliases(attackStrengthXMLTags)->getAttribute("value")->getIntValue();
|
|
|
|
if(upgradeNode->getChildWithAliases(attackStrengthXMLTags)->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
|
|
|
attackStrengthIsMultiplier = upgradeNode->getChildWithAliases(attackStrengthXMLTags)->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
2011-06-26 09:06:32 +02:00
|
|
|
|
2012-12-26 08:57:10 +01:00
|
|
|
//printf("Found attackStrengthIsMultiplier = %d\n",attackStrengthIsMultiplier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
attackStrength = 0;
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
attackRangeIsMultiplier = false;
|
2012-12-26 08:57:10 +01:00
|
|
|
if(upgradeNode->hasChild("attack-range") == true) {
|
|
|
|
attackRange= upgradeNode->getChild("attack-range")->getAttribute("value")->getIntValue();
|
|
|
|
if(upgradeNode->getChild("attack-range")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
|
|
|
attackRangeIsMultiplier = upgradeNode->getChild("attack-range")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
2011-06-26 09:06:32 +02:00
|
|
|
|
2012-12-26 08:57:10 +01:00
|
|
|
//printf("Found attackRangeIsMultiplier = %d\n",attackRangeIsMultiplier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
attackRange = 0;
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
armorIsMultiplier = false;
|
2012-12-26 08:57:10 +01:00
|
|
|
if(upgradeNode->hasChild("armor") == true) {
|
|
|
|
armor= upgradeNode->getChild("armor")->getAttribute("value")->getIntValue();
|
|
|
|
if(upgradeNode->getChild("armor")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
|
|
|
armorIsMultiplier = upgradeNode->getChild("armor")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
2011-06-26 09:06:32 +02:00
|
|
|
|
2012-12-26 08:57:10 +01:00
|
|
|
//printf("Found armorIsMultiplier = %d\n",armorIsMultiplier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
armor = 0;
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
moveSpeedIsMultiplier = false;
|
2012-12-26 08:57:10 +01:00
|
|
|
if(upgradeNode->hasChild("move-speed") == true) {
|
|
|
|
moveSpeed= upgradeNode->getChild("move-speed")->getAttribute("value")->getIntValue();
|
|
|
|
if(upgradeNode->getChild("move-speed")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
|
|
|
moveSpeedIsMultiplier = upgradeNode->getChild("move-speed")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
2011-06-26 09:06:32 +02:00
|
|
|
|
2012-12-26 08:57:10 +01:00
|
|
|
//printf("Found moveSpeedIsMultiplier = %d\n",moveSpeedIsMultiplier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
moveSpeed= 0;
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
prodSpeedIsMultiplier = false;
|
2012-12-26 08:57:10 +01:00
|
|
|
if(upgradeNode->hasChild("production-speed") == true) {
|
|
|
|
prodSpeed= upgradeNode->getChild("production-speed")->getAttribute("value")->getIntValue();
|
|
|
|
if(upgradeNode->getChild("production-speed")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
|
|
|
prodSpeedIsMultiplier = upgradeNode->getChild("production-speed")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
2011-06-26 09:06:32 +02:00
|
|
|
|
2012-12-26 08:57:10 +01:00
|
|
|
//printf("Found prodSpeedIsMultiplier = %d\n",prodSpeedIsMultiplier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
prodSpeed = 0;
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
2014-08-10 00:15:23 +02:00
|
|
|
|
|
|
|
attackSpeedIsMultiplier = false;
|
|
|
|
if(upgradeNode->hasChild("attack-speed") == true) {
|
|
|
|
attackSpeed= upgradeNode->getChild("attack-speed")->getAttribute("value")->getIntValue();
|
|
|
|
if(upgradeNode->getChild("attack-speed")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
|
|
|
attackSpeedIsMultiplier = upgradeNode->getChild("attack-speed")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
|
|
|
|
|
|
|
//printf("Found prodSpeedIsMultiplier = %d\n",prodSpeedIsMultiplier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
attackSpeed = 0;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int UpgradeTypeBase::getAttackStrength(const AttackSkillType *st) const {
|
|
|
|
if(attackStrengthIsMultiplier == false || st == NULL) {
|
|
|
|
return attackStrength;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int result = 0;
|
|
|
|
if(attackStrengthMultiplierValueList.find(st->getName()) != attackStrengthMultiplierValueList.end()) {
|
|
|
|
result = attackStrengthMultiplierValueList.find(st->getName())->second;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int UpgradeTypeBase::getAttackRange(const AttackSkillType *st) const {
|
|
|
|
if(attackRangeIsMultiplier == false || st == NULL) {
|
|
|
|
return attackRange;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int result = 0;
|
|
|
|
if(attackRangeMultiplierValueList.find(st->getName()) != attackRangeMultiplierValueList.end()) {
|
|
|
|
result = attackRangeMultiplierValueList.find(st->getName())->second;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int UpgradeTypeBase::getMoveSpeed(const MoveSkillType *st) const {
|
|
|
|
if(moveSpeedIsMultiplier == false || st == NULL) {
|
|
|
|
//printf("getMoveSpeed moveSpeedIsMultiplier OFF st [%p]\n",st);
|
|
|
|
return moveSpeed;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int result = 0;
|
|
|
|
if(moveSpeedIsMultiplierValueList.find(st->getName()) != moveSpeedIsMultiplierValueList.end()) {
|
|
|
|
result = moveSpeedIsMultiplierValueList.find(st->getName())->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
//printf("getMoveSpeed moveSpeedIsMultiplier mst->getSpeed() = %d for skill [%s] result = %d\n",st->getSpeed(),st->getName().c_str(),result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-10 00:15:23 +02:00
|
|
|
int UpgradeTypeBase::getAttackSpeed(const AttackSkillType *st) const {
|
|
|
|
if(attackSpeedIsMultiplier == false || st == NULL) {
|
|
|
|
return attackSpeed;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int result = 0;
|
|
|
|
if(attackSpeedIsMultiplierValueList.find(st->getName()) != attackSpeedIsMultiplierValueList.end()) {
|
|
|
|
result = attackSpeedIsMultiplierValueList.find(st->getName())->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-26 09:06:32 +02:00
|
|
|
int UpgradeTypeBase::getProdSpeed(const SkillType *st) const {
|
|
|
|
if(prodSpeedIsMultiplier == false || st == NULL) {
|
|
|
|
return prodSpeed;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int result = 0;
|
|
|
|
if(dynamic_cast<const ProduceSkillType *>(st) != NULL) {
|
|
|
|
if(prodSpeedProduceIsMultiplierValueList.find(st->getName()) != prodSpeedProduceIsMultiplierValueList.end()) {
|
|
|
|
result = prodSpeedProduceIsMultiplierValueList.find(st->getName())->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(dynamic_cast<const UpgradeSkillType *>(st) != NULL) {
|
|
|
|
if(prodSpeedUpgradeIsMultiplierValueList.find(st->getName()) != prodSpeedUpgradeIsMultiplierValueList.end()) {
|
|
|
|
result = prodSpeedUpgradeIsMultiplierValueList.find(st->getName())->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(dynamic_cast<const MorphSkillType *>(st) != NULL) {
|
|
|
|
if(prodSpeedMorphIsMultiplierValueList.find(st->getName()) != prodSpeedMorphIsMultiplierValueList.end()) {
|
|
|
|
result = prodSpeedMorphIsMultiplierValueList.find(st->getName())->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-04-14 23:21:09 +02:00
|
|
|
throw megaglest_runtime_error("Unsupported skilltype in getProdSpeed!");
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2011-06-25 09:31:01 +02:00
|
|
|
}
|
|
|
|
|
2013-06-13 10:55:48 +02:00
|
|
|
string UpgradeTypeBase::getDesc(bool translatedValue) const{
|
2012-02-19 03:40:13 +01:00
|
|
|
|
|
|
|
string str="";
|
|
|
|
string indent="->";
|
|
|
|
Lang &lang= Lang::getInstance();
|
|
|
|
|
2015-02-16 20:28:10 +01:00
|
|
|
if(getMaxHp() != 0 || getMaxHpRegeneration() != 0) {
|
2014-12-21 01:26:14 +01:00
|
|
|
str += indent+lang.getString("Hp",(translatedValue == true ? "" : "english")) + " +" + intToStr(maxHp);
|
|
|
|
if(maxHpIsMultiplier) {
|
|
|
|
str += "%";
|
|
|
|
}
|
|
|
|
// if(getMaxHpFromBoosts() != 0) {
|
|
|
|
// str += " +" + intToStr(getMaxHpFromBoosts());
|
|
|
|
// }
|
2014-12-20 23:25:42 +01:00
|
|
|
if(getMaxHpRegeneration() != 0) {
|
2015-02-16 20:28:10 +01:00
|
|
|
str += " (" + lang.getString("Regeneration",(translatedValue == true ? "" : "english")) + ": +" + intToStr(maxHpRegeneration);
|
2014-12-21 01:26:14 +01:00
|
|
|
// if(getMaxHpRegenerationFromBoosts() != 0) {
|
|
|
|
// str += " +" + intToStr(getMaxHpRegenerationFromBoosts());
|
|
|
|
// }
|
2015-02-16 20:28:10 +01:00
|
|
|
str += ")";
|
2012-02-19 03:40:13 +01:00
|
|
|
}
|
|
|
|
}
|
2013-06-08 19:53:25 +02:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
if(getSight() != 0) {
|
2013-06-08 19:53:25 +02:00
|
|
|
if(str != "") {
|
|
|
|
str += "\n";
|
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
str += indent+lang.getString("Sight",(translatedValue == true ? "" : "english")) + " +" + intToStr(sight);
|
|
|
|
if(sightIsMultiplier) {
|
|
|
|
str += "%";
|
|
|
|
}
|
|
|
|
// if(getSightFromBoosts() != 0) {
|
|
|
|
// str += " +" + intToStr(getSightFromBoosts());
|
|
|
|
// }
|
2012-02-19 03:40:13 +01:00
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2015-02-16 20:28:10 +01:00
|
|
|
if(getMaxEp() != 0 || getMaxEpRegeneration() != 0) {
|
2013-06-08 19:53:25 +02:00
|
|
|
if(str != "") {
|
|
|
|
str += "\n";
|
|
|
|
}
|
|
|
|
|
2014-12-21 01:26:14 +01:00
|
|
|
str += indent+lang.getString("Ep",(translatedValue == true ? "" : "english")) + " +" + intToStr(maxEp);
|
|
|
|
if(maxEpIsMultiplier) {
|
|
|
|
str += "%";
|
|
|
|
}
|
|
|
|
// if(getMaxEpFromBoosts() != 0) {
|
|
|
|
// str += " +" + intToStr(getMaxEpFromBoosts());
|
|
|
|
// }
|
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
if(getMaxEpRegeneration() != 0) {
|
2015-02-16 20:28:10 +01:00
|
|
|
str += " (" + lang.getString("Regeneration",(translatedValue == true ? "" : "english")) + ": +" + intToStr(maxEpRegeneration);
|
2014-12-21 01:26:14 +01:00
|
|
|
// if(getMaxEpRegenerationFromBoosts() != 0) {
|
|
|
|
// str += " +" + intToStr(getMaxEpRegenerationFromBoosts());
|
|
|
|
// }
|
2015-02-16 20:28:10 +01:00
|
|
|
str += ")";
|
2012-02-19 03:40:13 +01:00
|
|
|
}
|
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
if(getAttackStrength() != 0) {
|
2013-06-08 19:53:25 +02:00
|
|
|
if(str != "") {
|
|
|
|
str += "\n";
|
|
|
|
}
|
|
|
|
|
2014-12-21 01:26:14 +01:00
|
|
|
str += indent+lang.getString("AttackStrenght",(translatedValue == true ? "" : "english")) + " +" + intToStr(attackStrength);
|
|
|
|
if(attackStrengthIsMultiplier) {
|
|
|
|
str += "%";
|
|
|
|
}
|
|
|
|
// if(getAttackStrengthFromBoosts(NULL) != 0) {
|
|
|
|
// str += " +" + intToStr(getAttackStrengthFromBoosts(NULL));
|
|
|
|
// }
|
2012-02-19 03:40:13 +01:00
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
if(getAttackRange() != 0) {
|
2013-06-08 19:53:25 +02:00
|
|
|
if(str != "") {
|
|
|
|
str += "\n";
|
|
|
|
}
|
|
|
|
|
2014-12-21 01:26:14 +01:00
|
|
|
str += indent+lang.getString("AttackDistance",(translatedValue == true ? "" : "english")) + " +" + intToStr(attackRange);
|
|
|
|
if(attackRangeIsMultiplier) {
|
|
|
|
str += "%";
|
|
|
|
}
|
|
|
|
// if(getAttackRangeFromBoosts(NULL) != 0) {
|
|
|
|
// str += " +" + intToStr(getAttackRangeFromBoosts(NULL));
|
|
|
|
// }
|
2012-02-19 03:40:13 +01:00
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
if(getArmor() != 0) {
|
2013-06-08 19:53:25 +02:00
|
|
|
if(str != "") {
|
|
|
|
str += "\n";
|
|
|
|
}
|
|
|
|
|
2014-12-21 01:26:14 +01:00
|
|
|
str += indent+lang.getString("Armor",(translatedValue == true ? "" : "english")) + " +" + intToStr(armor);
|
|
|
|
if(armorIsMultiplier) {
|
|
|
|
str += "%";
|
|
|
|
}
|
|
|
|
// if(getArmorFromBoosts() != 0) {
|
|
|
|
// str += " +" + intToStr(getArmorFromBoosts());
|
|
|
|
// }
|
2012-02-19 03:40:13 +01:00
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
if(getMoveSpeed() != 0) {
|
2013-06-08 19:53:25 +02:00
|
|
|
if(str != "") {
|
|
|
|
str += "\n";
|
|
|
|
}
|
|
|
|
|
2014-12-21 01:26:14 +01:00
|
|
|
str += indent+lang.getString("WalkSpeed",(translatedValue == true ? "" : "english")) + " +" + intToStr(moveSpeed);
|
|
|
|
if(moveSpeedIsMultiplier) {
|
|
|
|
str += "%";
|
|
|
|
}
|
|
|
|
// if(getMoveSpeedFromBoosts(NULL) != 0) {
|
|
|
|
// str += " +" + intToStr(getMoveSpeedFromBoosts(NULL));
|
|
|
|
// }
|
2012-02-19 03:40:13 +01:00
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
if(getProdSpeed() != 0) {
|
2013-06-08 19:53:25 +02:00
|
|
|
if(str != "") {
|
|
|
|
str += "\n";
|
|
|
|
}
|
|
|
|
|
2014-12-21 01:26:14 +01:00
|
|
|
str += indent+lang.getString("ProductionSpeed",(translatedValue == true ? "" : "english")) + " +" + intToStr(prodSpeed);
|
|
|
|
if(prodSpeedIsMultiplier) {
|
|
|
|
str += "%";
|
|
|
|
}
|
|
|
|
// if(getProdSpeedFromBoosts(NULL) != 0) {
|
|
|
|
// str += " +" + intToStr(getProdSpeedFromBoosts(NULL));
|
|
|
|
// }
|
2012-02-19 03:40:13 +01:00
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
if(getAttackSpeed() != 0) {
|
2014-08-10 00:15:23 +02:00
|
|
|
if(str != "") {
|
|
|
|
str += "\n";
|
|
|
|
}
|
|
|
|
|
2014-12-21 01:26:14 +01:00
|
|
|
str += indent+lang.getString("AttackSpeed",(translatedValue == true ? "" : "english")) + " +" + intToStr(attackSpeed);
|
|
|
|
if(attackSpeedIsMultiplier) {
|
|
|
|
str += "%";
|
|
|
|
}
|
|
|
|
// if(getAttackSpeedFromBoosts(NULL) != 0) {
|
|
|
|
// str += " +" + intToStr(getAttackSpeedFromBoosts(NULL));
|
|
|
|
// }
|
2014-08-10 00:15:23 +02:00
|
|
|
}
|
2013-06-08 19:53:25 +02:00
|
|
|
if(str != "") {
|
|
|
|
str += "\n";
|
|
|
|
}
|
2012-02-19 03:40:13 +01:00
|
|
|
|
|
|
|
return str;
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
|
|
|
|
2014-12-21 22:02:27 +01:00
|
|
|
void UpgradeTypeBase::saveGameBoost(XmlNode *rootNode) const {
|
|
|
|
std::map<string,string> mapTagReplacements;
|
|
|
|
XmlNode *upgradeTypeBaseNode = rootNode->addChild("UpgradeTypeBaseBoost");
|
|
|
|
|
|
|
|
upgradeTypeBaseNode->addAttribute("upgradename",upgradename, mapTagReplacements);
|
|
|
|
|
|
|
|
// int maxHp;
|
|
|
|
upgradeTypeBaseNode->addAttribute("maxHp",intToStr(maxHp), mapTagReplacements);
|
|
|
|
// bool maxHpIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("maxHpIsMultiplier",intToStr(maxHpIsMultiplier), mapTagReplacements);
|
|
|
|
// int maxHpRegeneration;
|
|
|
|
upgradeTypeBaseNode->addAttribute("maxHpRegeneration",intToStr(maxHpRegeneration), mapTagReplacements);
|
|
|
|
// //bool maxHpRegenerationIsMultiplier;
|
|
|
|
//
|
|
|
|
// int sight;
|
|
|
|
upgradeTypeBaseNode->addAttribute("sight",intToStr(sight), mapTagReplacements);
|
|
|
|
// bool sightIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("sightIsMultiplier",intToStr(sightIsMultiplier), mapTagReplacements);
|
|
|
|
// int maxEp;
|
|
|
|
upgradeTypeBaseNode->addAttribute("maxEp",intToStr(maxEp), mapTagReplacements);
|
|
|
|
// bool maxEpIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("maxEpIsMultiplier",intToStr(maxEpIsMultiplier), mapTagReplacements);
|
|
|
|
// int maxEpRegeneration;
|
|
|
|
upgradeTypeBaseNode->addAttribute("maxEpRegeneration",intToStr(maxEpRegeneration), mapTagReplacements);
|
|
|
|
// //bool maxEpRegenerationIsMultiplier;
|
|
|
|
// int armor;
|
|
|
|
upgradeTypeBaseNode->addAttribute("armor",intToStr(armor), mapTagReplacements);
|
|
|
|
// bool armorIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("armorIsMultiplier",intToStr(armorIsMultiplier), mapTagReplacements);
|
|
|
|
// int attackStrength;
|
|
|
|
upgradeTypeBaseNode->addAttribute("attackStrength",intToStr(attackStrength), mapTagReplacements);
|
|
|
|
// bool attackStrengthIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("attackStrengthIsMultiplier",intToStr(attackStrengthIsMultiplier), mapTagReplacements);
|
|
|
|
// std::map<string,int> attackStrengthMultiplierValueList;
|
|
|
|
for(std::map<string,int>::const_iterator iterMap = attackStrengthMultiplierValueList.begin();
|
|
|
|
iterMap != attackStrengthMultiplierValueList.end(); ++iterMap) {
|
|
|
|
XmlNode *attackStrengthMultiplierValueListNode = upgradeTypeBaseNode->addChild("attackStrengthMultiplierValueList");
|
|
|
|
|
|
|
|
attackStrengthMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
attackStrengthMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
}
|
|
|
|
// int attackRange;
|
|
|
|
upgradeTypeBaseNode->addAttribute("attackRange",intToStr(attackRange), mapTagReplacements);
|
|
|
|
// bool attackRangeIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("attackRangeIsMultiplier",intToStr(attackRangeIsMultiplier), mapTagReplacements);
|
|
|
|
// std::map<string,int> attackRangeMultiplierValueList;
|
|
|
|
for(std::map<string,int>::const_iterator iterMap = attackRangeMultiplierValueList.begin();
|
|
|
|
iterMap != attackRangeMultiplierValueList.end(); ++iterMap) {
|
|
|
|
XmlNode *attackRangeMultiplierValueListNode = upgradeTypeBaseNode->addChild("attackRangeMultiplierValueList");
|
|
|
|
|
|
|
|
attackRangeMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
attackRangeMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
}
|
|
|
|
|
|
|
|
// int moveSpeed;
|
|
|
|
upgradeTypeBaseNode->addAttribute("moveSpeed",intToStr(moveSpeed), mapTagReplacements);
|
|
|
|
// bool moveSpeedIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("moveSpeedIsMultiplier",intToStr(moveSpeedIsMultiplier), mapTagReplacements);
|
|
|
|
// std::map<string,int> moveSpeedIsMultiplierValueList;
|
|
|
|
for(std::map<string,int>::const_iterator iterMap = moveSpeedIsMultiplierValueList.begin();
|
|
|
|
iterMap != moveSpeedIsMultiplierValueList.end(); ++iterMap) {
|
|
|
|
XmlNode *moveSpeedIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("moveSpeedIsMultiplierValueList");
|
|
|
|
|
|
|
|
moveSpeedIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
moveSpeedIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
}
|
|
|
|
|
|
|
|
// int prodSpeed;
|
|
|
|
upgradeTypeBaseNode->addAttribute("prodSpeed",intToStr(prodSpeed), mapTagReplacements);
|
|
|
|
// bool prodSpeedIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("prodSpeedIsMultiplier",intToStr(prodSpeedIsMultiplier), mapTagReplacements);
|
|
|
|
// std::map<string,int> prodSpeedProduceIsMultiplierValueList;
|
|
|
|
for(std::map<string,int>::const_iterator iterMap = prodSpeedProduceIsMultiplierValueList.begin();
|
|
|
|
iterMap != prodSpeedProduceIsMultiplierValueList.end(); ++iterMap) {
|
|
|
|
XmlNode *prodSpeedProduceIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("prodSpeedProduceIsMultiplierValueList");
|
|
|
|
|
|
|
|
prodSpeedProduceIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
prodSpeedProduceIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
}
|
|
|
|
|
|
|
|
// std::map<string,int> prodSpeedUpgradeIsMultiplierValueList;
|
|
|
|
for(std::map<string,int>::const_iterator iterMap = prodSpeedUpgradeIsMultiplierValueList.begin();
|
|
|
|
iterMap != prodSpeedUpgradeIsMultiplierValueList.end(); ++iterMap) {
|
|
|
|
XmlNode *prodSpeedUpgradeIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("prodSpeedUpgradeIsMultiplierValueList");
|
|
|
|
|
|
|
|
prodSpeedUpgradeIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
prodSpeedUpgradeIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
}
|
|
|
|
|
|
|
|
// std::map<string,int> prodSpeedMorphIsMultiplierValueList;
|
|
|
|
for(std::map<string,int>::const_iterator iterMap = prodSpeedMorphIsMultiplierValueList.begin();
|
|
|
|
iterMap != prodSpeedMorphIsMultiplierValueList.end(); ++iterMap) {
|
|
|
|
XmlNode *prodSpeedMorphIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("prodSpeedMorphIsMultiplierValueList");
|
|
|
|
|
|
|
|
prodSpeedMorphIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
prodSpeedMorphIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-10 04:27:25 +01:00
|
|
|
void UpgradeTypeBase::saveGame(XmlNode *rootNode) const {
|
|
|
|
std::map<string,string> mapTagReplacements;
|
|
|
|
XmlNode *upgradeTypeBaseNode = rootNode->addChild("UpgradeTypeBase");
|
|
|
|
|
2012-03-13 16:21:25 +01:00
|
|
|
upgradeTypeBaseNode->addAttribute("upgradename",upgradename, mapTagReplacements);
|
|
|
|
|
|
|
|
//// int maxHp;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("maxHp",intToStr(maxHp), mapTagReplacements);
|
|
|
|
//// bool maxHpIsMultiplier;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("maxHpIsMultiplier",intToStr(maxHpIsMultiplier), mapTagReplacements);
|
|
|
|
//// int maxHpRegeneration;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("maxHpRegeneration",intToStr(maxHpRegeneration), mapTagReplacements);
|
|
|
|
//// //bool maxHpRegenerationIsMultiplier;
|
|
|
|
////
|
|
|
|
//// int sight;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("sight",intToStr(sight), mapTagReplacements);
|
|
|
|
//// bool sightIsMultiplier;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("sightIsMultiplier",intToStr(sightIsMultiplier), mapTagReplacements);
|
|
|
|
//// int maxEp;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("maxEp",intToStr(maxEp), mapTagReplacements);
|
|
|
|
//// bool maxEpIsMultiplier;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("maxEpIsMultiplier",intToStr(maxEpIsMultiplier), mapTagReplacements);
|
|
|
|
//// int maxEpRegeneration;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("maxEpRegeneration",intToStr(maxEpRegeneration), mapTagReplacements);
|
|
|
|
//// //bool maxEpRegenerationIsMultiplier;
|
|
|
|
//// int armor;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("armor",intToStr(armor), mapTagReplacements);
|
|
|
|
//// bool armorIsMultiplier;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("armorIsMultiplier",intToStr(armorIsMultiplier), mapTagReplacements);
|
|
|
|
//// int attackStrength;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("attackStrength",intToStr(attackStrength), mapTagReplacements);
|
|
|
|
//// bool attackStrengthIsMultiplier;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("attackStrengthIsMultiplier",intToStr(attackStrengthIsMultiplier), mapTagReplacements);
|
|
|
|
//// std::map<string,int> attackStrengthMultiplierValueList;
|
|
|
|
// for(std::map<string,int>::const_iterator iterMap = attackStrengthMultiplierValueList.begin();
|
|
|
|
// iterMap != attackStrengthMultiplierValueList.end(); ++iterMap) {
|
|
|
|
// XmlNode *attackStrengthMultiplierValueListNode = upgradeTypeBaseNode->addChild("attackStrengthMultiplierValueList");
|
2012-03-10 04:27:25 +01:00
|
|
|
//
|
2012-03-13 16:21:25 +01:00
|
|
|
// attackStrengthMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
// attackStrengthMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
// }
|
|
|
|
//// int attackRange;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("attackRange",intToStr(attackRange), mapTagReplacements);
|
|
|
|
//// bool attackRangeIsMultiplier;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("attackRangeIsMultiplier",intToStr(attackRangeIsMultiplier), mapTagReplacements);
|
|
|
|
//// std::map<string,int> attackRangeMultiplierValueList;
|
|
|
|
// for(std::map<string,int>::const_iterator iterMap = attackRangeMultiplierValueList.begin();
|
|
|
|
// iterMap != attackRangeMultiplierValueList.end(); ++iterMap) {
|
|
|
|
// XmlNode *attackRangeMultiplierValueListNode = upgradeTypeBaseNode->addChild("attackRangeMultiplierValueList");
|
|
|
|
//
|
|
|
|
// attackRangeMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
// attackRangeMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//// int moveSpeed;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("moveSpeed",intToStr(moveSpeed), mapTagReplacements);
|
|
|
|
//// bool moveSpeedIsMultiplier;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("moveSpeedIsMultiplier",intToStr(moveSpeedIsMultiplier), mapTagReplacements);
|
|
|
|
//// std::map<string,int> moveSpeedIsMultiplierValueList;
|
|
|
|
// for(std::map<string,int>::const_iterator iterMap = moveSpeedIsMultiplierValueList.begin();
|
|
|
|
// iterMap != moveSpeedIsMultiplierValueList.end(); ++iterMap) {
|
|
|
|
// XmlNode *moveSpeedIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("moveSpeedIsMultiplierValueList");
|
|
|
|
//
|
|
|
|
// moveSpeedIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
// moveSpeedIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//// int prodSpeed;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("prodSpeed",intToStr(prodSpeed), mapTagReplacements);
|
|
|
|
//// bool prodSpeedIsMultiplier;
|
|
|
|
// upgradeTypeBaseNode->addAttribute("prodSpeedIsMultiplier",intToStr(prodSpeedIsMultiplier), mapTagReplacements);
|
|
|
|
//// std::map<string,int> prodSpeedProduceIsMultiplierValueList;
|
|
|
|
// for(std::map<string,int>::const_iterator iterMap = prodSpeedProduceIsMultiplierValueList.begin();
|
|
|
|
// iterMap != prodSpeedProduceIsMultiplierValueList.end(); ++iterMap) {
|
|
|
|
// XmlNode *prodSpeedProduceIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("prodSpeedProduceIsMultiplierValueList");
|
|
|
|
//
|
|
|
|
// prodSpeedProduceIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
// prodSpeedProduceIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//// std::map<string,int> prodSpeedUpgradeIsMultiplierValueList;
|
|
|
|
// for(std::map<string,int>::const_iterator iterMap = prodSpeedUpgradeIsMultiplierValueList.begin();
|
|
|
|
// iterMap != prodSpeedUpgradeIsMultiplierValueList.end(); ++iterMap) {
|
|
|
|
// XmlNode *prodSpeedUpgradeIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("prodSpeedUpgradeIsMultiplierValueList");
|
|
|
|
//
|
|
|
|
// prodSpeedUpgradeIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
// prodSpeedUpgradeIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//// std::map<string,int> prodSpeedMorphIsMultiplierValueList;
|
|
|
|
// for(std::map<string,int>::const_iterator iterMap = prodSpeedMorphIsMultiplierValueList.begin();
|
|
|
|
// iterMap != prodSpeedMorphIsMultiplierValueList.end(); ++iterMap) {
|
|
|
|
// XmlNode *prodSpeedMorphIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("prodSpeedMorphIsMultiplierValueList");
|
|
|
|
//
|
|
|
|
// prodSpeedMorphIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
// prodSpeedMorphIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
// }
|
|
|
|
}
|
2012-03-10 04:27:25 +01:00
|
|
|
|
2014-12-21 22:02:27 +01:00
|
|
|
void UpgradeTypeBase::loadGameBoost(const XmlNode *rootNode) {
|
|
|
|
const XmlNode *upgradeTypeBaseNode = rootNode->getChild("UpgradeTypeBaseBoost");
|
|
|
|
|
|
|
|
//description = upgradeTypeBaseNode->getAttribute("description")->getValue();
|
|
|
|
|
|
|
|
upgradename = upgradeTypeBaseNode->getAttribute("upgradename")->getValue();
|
|
|
|
|
|
|
|
// int maxHp;
|
|
|
|
maxHp = upgradeTypeBaseNode->getAttribute("maxHp")->getIntValue();
|
|
|
|
// bool maxHpIsMultiplier;
|
2014-12-22 07:20:19 +01:00
|
|
|
maxHpIsMultiplier = (upgradeTypeBaseNode->getAttribute("maxHpIsMultiplier")->getIntValue() != 0);
|
2014-12-21 22:02:27 +01:00
|
|
|
// int maxHpRegeneration;
|
|
|
|
maxHpRegeneration = upgradeTypeBaseNode->getAttribute("maxHpRegeneration")->getIntValue();
|
|
|
|
// //bool maxHpRegenerationIsMultiplier;
|
|
|
|
//
|
|
|
|
// int sight;
|
|
|
|
sight = upgradeTypeBaseNode->getAttribute("sight")->getIntValue();
|
|
|
|
// bool sightIsMultiplier;
|
2014-12-22 07:20:19 +01:00
|
|
|
sightIsMultiplier = (upgradeTypeBaseNode->getAttribute("sightIsMultiplier")->getIntValue() != 0);
|
2014-12-21 22:02:27 +01:00
|
|
|
// int maxEp;
|
|
|
|
maxEp = upgradeTypeBaseNode->getAttribute("maxEp")->getIntValue();
|
|
|
|
// bool maxEpIsMultiplier;
|
2014-12-22 07:20:19 +01:00
|
|
|
maxEpIsMultiplier = (upgradeTypeBaseNode->getAttribute("maxEpIsMultiplier")->getIntValue() != 0);
|
2014-12-21 22:02:27 +01:00
|
|
|
// int maxEpRegeneration;
|
|
|
|
maxEpRegeneration = upgradeTypeBaseNode->getAttribute("maxEpRegeneration")->getIntValue();
|
|
|
|
// //bool maxEpRegenerationIsMultiplier;
|
|
|
|
// int armor;
|
|
|
|
armor = upgradeTypeBaseNode->getAttribute("armor")->getIntValue();
|
|
|
|
// bool armorIsMultiplier;
|
2014-12-22 07:20:19 +01:00
|
|
|
armorIsMultiplier = (upgradeTypeBaseNode->getAttribute("armorIsMultiplier")->getIntValue() != 0);
|
2014-12-21 22:02:27 +01:00
|
|
|
// int attackStrength;
|
|
|
|
attackStrength = upgradeTypeBaseNode->getAttribute("attackStrength")->getIntValue();
|
|
|
|
// bool attackStrengthIsMultiplier;
|
2014-12-22 07:20:19 +01:00
|
|
|
attackStrengthIsMultiplier = (upgradeTypeBaseNode->getAttribute("attackStrengthIsMultiplier")->getIntValue() != 0);
|
2014-12-21 22:02:27 +01:00
|
|
|
// std::map<string,int> attackStrengthMultiplierValueList;
|
|
|
|
vector<XmlNode *> attackStrengthMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("attackStrengthMultiplierValueList");
|
|
|
|
for(unsigned int i = 0; i < attackStrengthMultiplierValueNodeList.size(); ++i) {
|
|
|
|
XmlNode *node = attackStrengthMultiplierValueNodeList[i];
|
|
|
|
|
|
|
|
attackStrengthMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
node->getAttribute("value")->getIntValue();
|
|
|
|
}
|
|
|
|
// int attackRange;
|
|
|
|
attackRange = upgradeTypeBaseNode->getAttribute("attackRange")->getIntValue();
|
|
|
|
// bool attackRangeIsMultiplier;
|
2014-12-22 07:20:19 +01:00
|
|
|
attackRangeIsMultiplier = (upgradeTypeBaseNode->getAttribute("attackRangeIsMultiplier")->getIntValue() != 0);
|
2014-12-21 22:02:27 +01:00
|
|
|
// std::map<string,int> attackRangeMultiplierValueList;
|
|
|
|
vector<XmlNode *> attackRangeMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("attackRangeMultiplierValueList");
|
|
|
|
for(unsigned int i = 0; i < attackRangeMultiplierValueNodeList.size(); ++i) {
|
|
|
|
XmlNode *node = attackRangeMultiplierValueNodeList[i];
|
|
|
|
|
|
|
|
attackRangeMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
node->getAttribute("value")->getIntValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// int moveSpeed;
|
|
|
|
moveSpeed = upgradeTypeBaseNode->getAttribute("moveSpeed")->getIntValue();
|
|
|
|
// bool moveSpeedIsMultiplier;
|
2014-12-22 07:20:19 +01:00
|
|
|
moveSpeedIsMultiplier = (upgradeTypeBaseNode->getAttribute("moveSpeedIsMultiplier")->getIntValue() != 0);
|
2014-12-21 22:02:27 +01:00
|
|
|
// std::map<string,int> moveSpeedIsMultiplierValueList;
|
|
|
|
vector<XmlNode *> moveSpeedIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("moveSpeedIsMultiplierValueList");
|
|
|
|
for(unsigned int i = 0; i < moveSpeedIsMultiplierValueNodeList.size(); ++i) {
|
|
|
|
XmlNode *node = moveSpeedIsMultiplierValueNodeList[i];
|
|
|
|
|
|
|
|
moveSpeedIsMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
node->getAttribute("value")->getIntValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// int prodSpeed;
|
|
|
|
prodSpeed = upgradeTypeBaseNode->getAttribute("prodSpeed")->getIntValue();
|
|
|
|
// bool prodSpeedIsMultiplier;
|
2014-12-22 07:20:19 +01:00
|
|
|
prodSpeedIsMultiplier = (upgradeTypeBaseNode->getAttribute("prodSpeedIsMultiplier")->getIntValue() != 0);
|
2014-12-21 22:02:27 +01:00
|
|
|
// std::map<string,int> prodSpeedProduceIsMultiplierValueList;
|
|
|
|
vector<XmlNode *> prodSpeedProduceIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("prodSpeedProduceIsMultiplierValueList");
|
|
|
|
for(unsigned int i = 0; i < prodSpeedProduceIsMultiplierValueNodeList.size(); ++i) {
|
|
|
|
XmlNode *node = prodSpeedProduceIsMultiplierValueNodeList[i];
|
|
|
|
|
|
|
|
prodSpeedProduceIsMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
node->getAttribute("value")->getIntValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// std::map<string,int> prodSpeedUpgradeIsMultiplierValueList;
|
|
|
|
vector<XmlNode *> prodSpeedUpgradeIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("prodSpeedUpgradeIsMultiplierValueList");
|
|
|
|
for(unsigned int i = 0; i < prodSpeedUpgradeIsMultiplierValueNodeList.size(); ++i) {
|
|
|
|
XmlNode *node = prodSpeedUpgradeIsMultiplierValueNodeList[i];
|
|
|
|
|
|
|
|
prodSpeedUpgradeIsMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
node->getAttribute("value")->getIntValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// std::map<string,int> prodSpeedMorphIsMultiplierValueList;
|
|
|
|
vector<XmlNode *> prodSpeedMorphIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("prodSpeedMorphIsMultiplierValueList");
|
|
|
|
for(unsigned int i = 0; i < prodSpeedMorphIsMultiplierValueNodeList.size(); ++i) {
|
|
|
|
XmlNode *node = prodSpeedMorphIsMultiplierValueNodeList[i];
|
|
|
|
|
|
|
|
prodSpeedMorphIsMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
node->getAttribute("value")->getIntValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-13 16:21:25 +01:00
|
|
|
const UpgradeType * UpgradeTypeBase::loadGame(const XmlNode *rootNode, Faction *faction) {
|
|
|
|
const XmlNode *upgradeTypeBaseNode = rootNode->getChild("UpgradeTypeBase");
|
|
|
|
|
|
|
|
//description = upgradeTypeBaseNode->getAttribute("description")->getValue();
|
|
|
|
|
|
|
|
string upgradename = upgradeTypeBaseNode->getAttribute("upgradename")->getValue();
|
|
|
|
return faction->getType()->getUpgradeType(upgradename);
|
|
|
|
// int maxHp;
|
|
|
|
// maxHp = upgradeTypeBaseNode->getAttribute("maxHp")->getIntValue();
|
|
|
|
// // bool maxHpIsMultiplier;
|
|
|
|
// maxHpIsMultiplier = upgradeTypeBaseNode->getAttribute("maxHpIsMultiplier")->getIntValue();
|
|
|
|
// // int maxHpRegeneration;
|
|
|
|
// maxHpRegeneration = upgradeTypeBaseNode->getAttribute("maxHpRegeneration")->getIntValue();
|
|
|
|
// // //bool maxHpRegenerationIsMultiplier;
|
|
|
|
// //
|
|
|
|
// // int sight;
|
|
|
|
// sight = upgradeTypeBaseNode->getAttribute("sight")->getIntValue();
|
|
|
|
// // bool sightIsMultiplier;
|
|
|
|
// sightIsMultiplier = upgradeTypeBaseNode->getAttribute("sightIsMultiplier")->getIntValue();
|
|
|
|
// // int maxEp;
|
|
|
|
// maxEp = upgradeTypeBaseNode->getAttribute("maxEp")->getIntValue();
|
|
|
|
// // bool maxEpIsMultiplier;
|
|
|
|
// maxEpIsMultiplier = upgradeTypeBaseNode->getAttribute("maxEpIsMultiplier")->getIntValue();
|
|
|
|
// // int maxEpRegeneration;
|
|
|
|
// maxEpRegeneration = upgradeTypeBaseNode->getAttribute("maxEpRegeneration")->getIntValue();
|
|
|
|
// // //bool maxEpRegenerationIsMultiplier;
|
|
|
|
// // int armor;
|
|
|
|
// armor = upgradeTypeBaseNode->getAttribute("armor")->getIntValue();
|
|
|
|
// // bool armorIsMultiplier;
|
|
|
|
// armorIsMultiplier = upgradeTypeBaseNode->getAttribute("armorIsMultiplier")->getIntValue();
|
|
|
|
// // int attackStrength;
|
|
|
|
// attackStrength = upgradeTypeBaseNode->getAttribute("attackStrength")->getIntValue();
|
|
|
|
// // bool attackStrengthIsMultiplier;
|
|
|
|
// attackStrengthIsMultiplier = upgradeTypeBaseNode->getAttribute("attackStrengthIsMultiplier")->getIntValue();
|
|
|
|
// // std::map<string,int> attackStrengthMultiplierValueList;
|
|
|
|
// vector<XmlNode *> attackStrengthMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("attackStrengthMultiplierValueList");
|
|
|
|
// for(unsigned int i = 0; i < attackStrengthMultiplierValueNodeList.size(); ++i) {
|
|
|
|
// XmlNode *node = attackStrengthMultiplierValueNodeList[i];
|
|
|
|
//
|
|
|
|
// attackStrengthMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
// node->getAttribute("value")->getIntValue();
|
|
|
|
// }
|
|
|
|
// // int attackRange;
|
|
|
|
// attackRange = upgradeTypeBaseNode->getAttribute("attackRange")->getIntValue();
|
|
|
|
// // bool attackRangeIsMultiplier;
|
|
|
|
// attackRangeIsMultiplier = upgradeTypeBaseNode->getAttribute("attackRangeIsMultiplier")->getIntValue();
|
|
|
|
// // std::map<string,int> attackRangeMultiplierValueList;
|
|
|
|
// vector<XmlNode *> attackRangeMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("attackRangeMultiplierValueList");
|
|
|
|
// for(unsigned int i = 0; i < attackRangeMultiplierValueNodeList.size(); ++i) {
|
|
|
|
// XmlNode *node = attackRangeMultiplierValueNodeList[i];
|
|
|
|
//
|
|
|
|
// attackRangeMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
// node->getAttribute("value")->getIntValue();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // int moveSpeed;
|
|
|
|
// moveSpeed = upgradeTypeBaseNode->getAttribute("moveSpeed")->getIntValue();
|
|
|
|
// // bool moveSpeedIsMultiplier;
|
|
|
|
// moveSpeedIsMultiplier = upgradeTypeBaseNode->getAttribute("moveSpeedIsMultiplier")->getIntValue();
|
|
|
|
// // std::map<string,int> moveSpeedIsMultiplierValueList;
|
|
|
|
// vector<XmlNode *> moveSpeedIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("moveSpeedIsMultiplierValueList");
|
|
|
|
// for(unsigned int i = 0; i < moveSpeedIsMultiplierValueNodeList.size(); ++i) {
|
|
|
|
// XmlNode *node = moveSpeedIsMultiplierValueNodeList[i];
|
|
|
|
//
|
|
|
|
// moveSpeedIsMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
// node->getAttribute("value")->getIntValue();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // int prodSpeed;
|
|
|
|
// prodSpeed = upgradeTypeBaseNode->getAttribute("prodSpeed")->getIntValue();
|
|
|
|
// // bool prodSpeedIsMultiplier;
|
|
|
|
// prodSpeedIsMultiplier = upgradeTypeBaseNode->getAttribute("prodSpeedIsMultiplier")->getIntValue();
|
|
|
|
// // std::map<string,int> prodSpeedProduceIsMultiplierValueList;
|
|
|
|
// vector<XmlNode *> prodSpeedProduceIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("prodSpeedProduceIsMultiplierValueList");
|
|
|
|
// for(unsigned int i = 0; i < prodSpeedProduceIsMultiplierValueNodeList.size(); ++i) {
|
|
|
|
// XmlNode *node = prodSpeedProduceIsMultiplierValueNodeList[i];
|
|
|
|
//
|
|
|
|
// prodSpeedProduceIsMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
// node->getAttribute("value")->getIntValue();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // std::map<string,int> prodSpeedUpgradeIsMultiplierValueList;
|
|
|
|
// vector<XmlNode *> prodSpeedUpgradeIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("prodSpeedUpgradeIsMultiplierValueList");
|
|
|
|
// for(unsigned int i = 0; i < prodSpeedUpgradeIsMultiplierValueNodeList.size(); ++i) {
|
|
|
|
// XmlNode *node = prodSpeedUpgradeIsMultiplierValueNodeList[i];
|
|
|
|
//
|
|
|
|
// prodSpeedUpgradeIsMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
// node->getAttribute("value")->getIntValue();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // std::map<string,int> prodSpeedMorphIsMultiplierValueList;
|
|
|
|
// vector<XmlNode *> prodSpeedMorphIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("prodSpeedMorphIsMultiplierValueList");
|
|
|
|
// for(unsigned int i = 0; i < prodSpeedMorphIsMultiplierValueNodeList.size(); ++i) {
|
|
|
|
// XmlNode *node = prodSpeedMorphIsMultiplierValueNodeList[i];
|
|
|
|
//
|
|
|
|
// prodSpeedMorphIsMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
// node->getAttribute("value")->getIntValue();
|
|
|
|
// }
|
2012-03-10 04:27:25 +01:00
|
|
|
}
|
2012-02-19 03:40:13 +01:00
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
// ==================== misc ====================
|
|
|
|
|
2012-05-02 23:00:57 +02:00
|
|
|
string UpgradeType::getName(bool translatedValue) const {
|
|
|
|
if(translatedValue == false) return name;
|
|
|
|
|
|
|
|
Lang &lang = Lang::getInstance();
|
|
|
|
return lang.getTechTreeString("UpgradeTypeName_" + name,name.c_str());
|
|
|
|
}
|
|
|
|
|
2014-09-29 02:23:36 +02:00
|
|
|
string UpgradeType::getTagName(string tag, bool translatedValue) const {
|
|
|
|
if(translatedValue == false) return tag;
|
|
|
|
|
|
|
|
Lang &lang = Lang::getInstance();
|
|
|
|
return lang.getTechTreeString("TagName_" + tag, tag.c_str());
|
|
|
|
}
|
|
|
|
|
2013-06-13 10:55:48 +02:00
|
|
|
string UpgradeType::getReqDesc(bool translatedValue) const{
|
2012-02-19 03:40:13 +01:00
|
|
|
Lang &lang= Lang::getInstance();
|
2013-06-13 10:55:48 +02:00
|
|
|
string str= ProducibleType::getReqDesc(translatedValue);
|
2012-02-19 03:40:13 +01:00
|
|
|
string indent=" ";
|
2014-09-29 02:23:36 +02:00
|
|
|
if(!effects.empty() || !tags.empty()){
|
2013-10-29 07:13:38 +01:00
|
|
|
str+= "\n"+ lang.getString("Upgrades",(translatedValue == true ? "" : "english"))+"\n";
|
2012-02-19 03:40:13 +01:00
|
|
|
}
|
2013-06-13 10:55:48 +02:00
|
|
|
str+=UpgradeTypeBase::getDesc(translatedValue);
|
2014-09-29 02:23:36 +02:00
|
|
|
if(!effects.empty() || !tags.empty()){
|
2013-10-29 07:13:38 +01:00
|
|
|
str+= lang.getString("AffectedUnits",(translatedValue == true ? "" : "english"))+"\n";
|
2014-09-29 02:23:36 +02:00
|
|
|
|
|
|
|
// We want the output to be sorted, so convert the set to a vector and sort that
|
|
|
|
std::vector<const UnitType*> outputUnits(effects.begin(), effects.end());
|
|
|
|
std::sort(outputUnits.begin(), outputUnits.end(), UnitTypeSorter());
|
|
|
|
|
|
|
|
vector<const UnitType*>::iterator unitIter;
|
|
|
|
for (unitIter = outputUnits.begin(); unitIter != outputUnits.end(); ++unitIter) {
|
|
|
|
const UnitType *unit = *unitIter;
|
|
|
|
str+= indent+unit->getName(translatedValue)+"\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do the same for tags
|
|
|
|
std::vector<string> outputTags(tags.begin(), tags.end());
|
|
|
|
std::sort(outputTags.begin(), outputTags.end());
|
|
|
|
|
|
|
|
vector<string>::iterator tagIter;
|
|
|
|
for (tagIter = outputTags.begin(); tagIter != outputTags.end(); ++tagIter) {
|
|
|
|
string tag = *tagIter;
|
|
|
|
str+= indent + lang.getString("TagDesc", (translatedValue == true ? "" : "english")) +
|
|
|
|
" " + getTagName(tag,translatedValue) + "\n";
|
2012-02-19 03:40:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
void UpgradeType::preLoad(const string &dir){
|
|
|
|
name=lastDir(dir);
|
|
|
|
}
|
|
|
|
|
2011-03-15 16:30:28 +01:00
|
|
|
void UpgradeType::load(const string &dir, const TechTree *techTree,
|
|
|
|
const FactionType *factionType, Checksum* checksum,
|
2013-11-04 08:21:04 +01:00
|
|
|
Checksum* techtreeChecksum, std::map<string,
|
|
|
|
vector<pair<string, string> > > &loadedFileList,
|
|
|
|
bool validationMode) {
|
2011-03-28 05:54:23 +02:00
|
|
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2012-10-19 03:31:20 +02:00
|
|
|
char szBuf[8096]="";
|
2013-10-29 07:13:38 +01:00
|
|
|
snprintf(szBuf,8096,Lang::getInstance().getString("LogScreenGameLoadingUpgradeType","",true).c_str(),formatString(this->getName(true)).c_str());
|
2011-11-02 18:17:28 +01:00
|
|
|
Logger::getInstance().add(szBuf, true);
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2011-03-13 09:23:43 +01:00
|
|
|
string currentPath = dir;
|
|
|
|
endPathWithSlash(currentPath);
|
2011-03-15 16:30:28 +01:00
|
|
|
string path = currentPath + name + ".xml";
|
2011-05-05 22:18:38 +02:00
|
|
|
string sourceXMLFile = path;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2011-05-07 00:12:16 +02:00
|
|
|
try {
|
2011-01-09 05:49:21 +01:00
|
|
|
checksum->addFile(path);
|
2011-01-20 16:56:30 +01:00
|
|
|
techtreeChecksum->addFile(path);
|
|
|
|
|
|
|
|
XmlTree xmlTree;
|
2011-05-07 00:12:16 +02:00
|
|
|
std::map<string,string> mapExtraTagReplacementValues;
|
|
|
|
mapExtraTagReplacementValues["$COMMONDATAPATH"] = techTree->getPath() + "/commondata/";
|
|
|
|
xmlTree.load(path, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
|
2011-05-06 09:47:31 +02:00
|
|
|
loadedFileList[path].push_back(make_pair(currentPath,currentPath));
|
2011-01-20 16:56:30 +01:00
|
|
|
const XmlNode *upgradeNode= xmlTree.getRootNode();
|
|
|
|
|
|
|
|
//image
|
2013-06-08 01:33:35 +02:00
|
|
|
image = NULL; // Not used for upgrade types
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//image cancel
|
2013-06-08 01:33:35 +02:00
|
|
|
cancelImage = NULL; // Not used for upgrade types
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//upgrade time
|
|
|
|
const XmlNode *upgradeTimeNode= upgradeNode->getChild("time");
|
|
|
|
productionTime= upgradeTimeNode->getAttribute("value")->getIntValue();
|
|
|
|
|
2011-03-16 06:27:07 +01:00
|
|
|
std::map<string,int> sortedItems;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
//unit requirements
|
2011-11-10 23:36:44 +01:00
|
|
|
bool hasDup = false;
|
2011-01-20 16:56:30 +01:00
|
|
|
const XmlNode *unitRequirementsNode= upgradeNode->getChild("unit-requirements");
|
2013-11-19 07:14:06 +01:00
|
|
|
for(int i = 0; i < (int)unitRequirementsNode->getChildCount(); ++i) {
|
2011-01-20 16:56:30 +01:00
|
|
|
const XmlNode *unitNode= unitRequirementsNode->getChild("unit", i);
|
|
|
|
string name= unitNode->getAttribute("name")->getRestrictedValue();
|
2011-11-10 23:36:44 +01:00
|
|
|
|
|
|
|
if(sortedItems.find(name) != sortedItems.end()) {
|
|
|
|
hasDup = true;
|
|
|
|
}
|
|
|
|
|
2011-03-16 06:27:07 +01:00
|
|
|
sortedItems[name] = 0;
|
|
|
|
}
|
2011-11-10 23:36:44 +01:00
|
|
|
|
|
|
|
if(hasDup) {
|
|
|
|
printf("WARNING, upgrade type [%s] has one or more duplicate unit requirements\n",this->getName().c_str());
|
|
|
|
}
|
|
|
|
|
2011-03-16 06:27:07 +01:00
|
|
|
for(std::map<string,int>::iterator iterMap = sortedItems.begin();
|
|
|
|
iterMap != sortedItems.end(); ++iterMap) {
|
|
|
|
unitReqs.push_back(factionType->getUnitType(iterMap->first));
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
2011-03-16 06:27:07 +01:00
|
|
|
sortedItems.clear();
|
2011-11-10 23:36:44 +01:00
|
|
|
hasDup = false;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//upgrade requirements
|
|
|
|
const XmlNode *upgradeRequirementsNode= upgradeNode->getChild("upgrade-requirements");
|
2013-11-19 07:14:06 +01:00
|
|
|
for(int i = 0; i < (int)upgradeRequirementsNode->getChildCount(); ++i) {
|
2011-01-20 16:56:30 +01:00
|
|
|
const XmlNode *upgradeReqNode= upgradeRequirementsNode->getChild("upgrade", i);
|
|
|
|
string name= upgradeReqNode->getAttribute("name")->getRestrictedValue();
|
2011-11-10 23:36:44 +01:00
|
|
|
|
|
|
|
if(sortedItems.find(name) != sortedItems.end()) {
|
|
|
|
hasDup = true;
|
|
|
|
}
|
|
|
|
|
2011-03-16 06:27:07 +01:00
|
|
|
sortedItems[name] = 0;
|
|
|
|
}
|
2011-11-10 23:36:44 +01:00
|
|
|
|
|
|
|
if(hasDup) {
|
|
|
|
printf("WARNING, upgrade type [%s] has one or more duplicate upgrade requirements\n",this->getName().c_str());
|
|
|
|
}
|
|
|
|
|
2011-03-16 06:27:07 +01:00
|
|
|
for(std::map<string,int>::iterator iterMap = sortedItems.begin();
|
|
|
|
iterMap != sortedItems.end(); ++iterMap) {
|
|
|
|
upgradeReqs.push_back(factionType->getUpgradeType(iterMap->first));
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
2011-03-16 06:27:07 +01:00
|
|
|
sortedItems.clear();
|
2011-11-10 23:36:44 +01:00
|
|
|
hasDup = false;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//resource requirements
|
2011-03-16 06:27:07 +01:00
|
|
|
int index = 0;
|
2011-01-20 16:56:30 +01:00
|
|
|
const XmlNode *resourceRequirementsNode= upgradeNode->getChild("resource-requirements");
|
2012-10-06 09:06:40 +02:00
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
costs.resize(resourceRequirementsNode->getChildCount());
|
2013-11-19 07:14:06 +01:00
|
|
|
for(int i = 0; i < (int)costs.size(); ++i) {
|
2011-01-20 16:56:30 +01:00
|
|
|
const XmlNode *resourceNode= resourceRequirementsNode->getChild("resource", i);
|
|
|
|
string name= resourceNode->getAttribute("name")->getRestrictedValue();
|
|
|
|
int amount= resourceNode->getAttribute("amount")->getIntValue();
|
2011-11-10 23:36:44 +01:00
|
|
|
|
|
|
|
if(sortedItems.find(name) != sortedItems.end()) {
|
|
|
|
hasDup = true;
|
|
|
|
}
|
|
|
|
|
2011-03-16 06:27:07 +01:00
|
|
|
sortedItems[name] = amount;
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
2011-11-10 23:36:44 +01:00
|
|
|
|
|
|
|
//if(hasDup || sortedItems.size() != costs.size()) printf("Found duplicate resource requirement, costs.size() = %d sortedItems.size() = %d\n",costs.size(),sortedItems.size());
|
|
|
|
|
|
|
|
if(hasDup) {
|
|
|
|
printf("WARNING, upgrade type [%s] has one or more duplicate resource requirements\n",this->getName().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
if(sortedItems.size() < costs.size()) {
|
|
|
|
costs.resize(sortedItems.size());
|
|
|
|
}
|
|
|
|
|
2011-03-16 06:27:07 +01:00
|
|
|
index = 0;
|
|
|
|
for(std::map<string,int>::iterator iterMap = sortedItems.begin();
|
|
|
|
iterMap != sortedItems.end(); ++iterMap) {
|
2013-11-04 08:21:04 +01:00
|
|
|
try {
|
|
|
|
costs[index].init(techTree->getResourceType(iterMap->first), iterMap->second);
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
catch(megaglest_runtime_error& ex) {
|
|
|
|
if(validationMode == false) {
|
2013-11-05 21:59:28 +01:00
|
|
|
throw;
|
2013-11-04 08:21:04 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\nFor UpgradeType: %s Cost: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what(),name.c_str(),iterMap->second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-16 06:27:07 +01:00
|
|
|
}
|
|
|
|
sortedItems.clear();
|
2014-11-29 03:19:40 +01:00
|
|
|
//hasDup = false;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2014-09-29 02:23:36 +02:00
|
|
|
//effects -- get list of affected units
|
2011-01-20 16:56:30 +01:00
|
|
|
const XmlNode *effectsNode= upgradeNode->getChild("effects");
|
2014-09-29 02:23:36 +02:00
|
|
|
vector<XmlNode*> unitNodes= effectsNode->getChildList("unit");
|
|
|
|
for(size_t i = 0; i < unitNodes.size(); ++i) {
|
|
|
|
const XmlNode *unitNode= unitNodes.at(i);
|
2011-01-20 16:56:30 +01:00
|
|
|
string name= unitNode->getAttribute("name")->getRestrictedValue();
|
2011-11-10 23:36:44 +01:00
|
|
|
|
2014-09-29 02:23:36 +02:00
|
|
|
effects.insert(factionType->getUnitType(name));
|
2011-03-16 06:27:07 +01:00
|
|
|
}
|
2011-11-10 23:36:44 +01:00
|
|
|
|
2014-09-29 02:23:36 +02:00
|
|
|
//effects -- convert tags into units
|
|
|
|
vector<XmlNode*> tagNodes= effectsNode->getChildList("tag");
|
|
|
|
for(size_t i = 0; i < tagNodes.size(); ++i) {
|
|
|
|
const XmlNode *tagNode= tagNodes.at(i);
|
|
|
|
string name= tagNode->getAttribute("name")->getRestrictedValue();
|
|
|
|
tags.insert(name);
|
2011-11-10 23:36:44 +01:00
|
|
|
}
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
//values
|
2012-03-13 16:21:25 +01:00
|
|
|
UpgradeTypeBase::load(upgradeNode,name);
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
|
|
|
catch(const exception &e){
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
2012-04-14 23:21:09 +02:00
|
|
|
throw megaglest_runtime_error("Error loading UpgradeType: "+ dir + "\n" +e.what());
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
|
|
|
|
2011-03-28 05:54:23 +02:00
|
|
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
|
|
|
|
2012-02-19 03:40:13 +01:00
|
|
|
bool UpgradeType::isAffected(const UnitType *unitType) const{
|
2014-09-29 02:23:36 +02:00
|
|
|
if(std::find(effects.begin(), effects.end(), unitType)!=effects.end()) return true;
|
|
|
|
|
|
|
|
const set<string> unitTags = unitType->getTags();
|
|
|
|
set<string> intersect;
|
|
|
|
set_intersection(tags.begin(),tags.end(),unitTags.begin(),unitTags.end(),
|
|
|
|
std::inserter(intersect,intersect.begin()));
|
|
|
|
if(!intersect.empty()) return true;
|
|
|
|
|
|
|
|
return false;
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
|
|
|
|
2012-03-13 16:21:25 +01:00
|
|
|
//void UpgradeType::saveGame(XmlNode *rootNode) const {
|
|
|
|
// UpgradeTypeBase::saveGame(rootNode);
|
|
|
|
// ProducibleType::saveGame(rootNode);
|
|
|
|
//
|
|
|
|
// std::map<string,string> mapTagReplacements;
|
|
|
|
// XmlNode *upgradeTypeNode = rootNode->addChild("UpgradeType");
|
|
|
|
//
|
|
|
|
// //upgradeTypeNode->addAttribute("maxHp",intToStr(maxHp), mapTagReplacements);
|
|
|
|
// //vector<const UnitType*> effects;
|
|
|
|
// for(unsigned int i = 0; i < effects.size(); ++i) {
|
|
|
|
// XmlNode *unitTypeNode = rootNode->addChild("UnitType");
|
|
|
|
//
|
|
|
|
// const UnitType *ut = effects[i];
|
|
|
|
// unitTypeNode->addAttribute("name",ut->getName(), mapTagReplacements);
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void UpgradeType::loadGame(const XmlNode *rootNode, Faction *faction) {
|
|
|
|
// //UpgradeTypeBase::loadGame(rootNode);
|
|
|
|
// //ProducibleType::loadGame(rootNode);
|
|
|
|
//
|
|
|
|
// //const XmlNode *upgradeTypeNode = rootNode->getChild("UpgradeType");
|
|
|
|
//
|
|
|
|
// //maxHp = upgradeTypeNode->getAttribute("maxHp")->getIntValue();
|
|
|
|
//
|
|
|
|
//// vector<XmlNode *> unitTypeNodeList = upgradeTypeNode->getChildList("UnitType");
|
|
|
|
//// for(unsigned int i = 0; i < unitTypeNodeList.size(); ++i) {
|
|
|
|
//// XmlNode *node = unitTypeNodeList[i];
|
|
|
|
//// }
|
|
|
|
//}
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
// ===============================
|
|
|
|
// class TotalUpgrade
|
|
|
|
// ===============================
|
|
|
|
|
2011-06-25 10:53:53 +02:00
|
|
|
TotalUpgrade::TotalUpgrade() {
|
2011-01-20 16:56:30 +01:00
|
|
|
reset();
|
|
|
|
}
|
|
|
|
|
2011-06-25 10:53:53 +02:00
|
|
|
void TotalUpgrade::reset() {
|
2011-01-20 16:56:30 +01:00
|
|
|
maxHp= 0;
|
2011-07-22 09:05:47 +02:00
|
|
|
maxHpIsMultiplier=false;
|
|
|
|
maxHpRegeneration = 0;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
maxEp= 0;
|
2011-07-22 09:05:47 +02:00
|
|
|
maxEpIsMultiplier = false;
|
|
|
|
maxEpRegeneration = 0;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
sight=0;
|
2011-07-22 09:05:47 +02:00
|
|
|
sightIsMultiplier=false;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
armor= 0;
|
2011-07-22 09:05:47 +02:00
|
|
|
armorIsMultiplier=false;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
attackStrength= 0;
|
2011-07-22 09:05:47 +02:00
|
|
|
attackStrengthIsMultiplier=false;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
attackRange= 0;
|
2011-07-22 09:05:47 +02:00
|
|
|
attackRangeIsMultiplier=false;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
moveSpeed= 0;
|
2011-07-22 09:05:47 +02:00
|
|
|
moveSpeedIsMultiplier=false;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
prodSpeed=0;
|
2011-07-22 09:05:47 +02:00
|
|
|
prodSpeedIsMultiplier=false;
|
2014-08-10 00:15:23 +02:00
|
|
|
|
|
|
|
attackSpeed=0;
|
|
|
|
attackSpeedIsMultiplier=false;
|
2014-12-20 23:25:42 +01:00
|
|
|
|
|
|
|
boostUpgradeBase = NULL;
|
2014-12-21 22:02:27 +01:00
|
|
|
boostUpgradeSourceUnit = -1;
|
|
|
|
boostUpgradeDestUnit = -1;
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
|
|
|
|
2014-12-21 22:02:27 +01:00
|
|
|
void TotalUpgrade::sum(const UpgradeTypeBase *ut, const Unit *unit, bool boostMode) {
|
2011-06-26 09:06:32 +02:00
|
|
|
maxHpIsMultiplier = ut->getMaxHpIsMultiplier();
|
|
|
|
sightIsMultiplier = ut->getSightIsMultiplier();
|
|
|
|
maxEpIsMultiplier = ut->getMaxEpIsMultiplier();
|
|
|
|
armorIsMultiplier = ut->getArmorIsMultiplier();
|
|
|
|
attackStrengthIsMultiplier = ut->getAttackStrengthIsMultiplier();
|
|
|
|
attackRangeIsMultiplier = ut->getAttackRangeIsMultiplier();
|
|
|
|
moveSpeedIsMultiplier = ut->getMoveSpeedIsMultiplier();
|
|
|
|
prodSpeedIsMultiplier = ut->getProdSpeedIsMultiplier();
|
2014-08-10 00:15:23 +02:00
|
|
|
attackSpeedIsMultiplier = ut->getAttackSpeedIsMultiplier();
|
2011-06-26 09:06:32 +02:00
|
|
|
|
|
|
|
if(ut->getMaxHpIsMultiplier() == true) {
|
2011-07-02 02:20:28 +02:00
|
|
|
//printf("#1 Maxhp maxHp = %d, unit->getHp() = %d ut->getMaxHp() = %d\n",maxHp,unit->getHp(),ut->getMaxHp());
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ((double)unit->getHp() * ((double)ut->getMaxHp() / (double)100));
|
|
|
|
if(boostMode) {
|
|
|
|
maxHp = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
maxHp += newValue;
|
|
|
|
}
|
2011-07-22 09:05:47 +02:00
|
|
|
if(ut->getMaxHpRegeneration() != 0) {
|
2014-12-21 22:02:27 +01:00
|
|
|
newValue = ((double)unit->getType()->getHpRegeneration() + ((double)max(maxHp,unit->getHp()) * ((double)ut->getMaxHpRegeneration() / (double)100)));
|
|
|
|
if(boostMode) {
|
|
|
|
maxHpRegeneration = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
maxHpRegeneration += newValue;
|
|
|
|
}
|
2011-07-22 09:05:47 +02:00
|
|
|
}
|
2011-07-02 02:20:28 +02:00
|
|
|
//printf("#1.1 Maxhp maxHp = %d, unit->getHp() = %d ut->getMaxHp() = %d\n",maxHp,unit->getHp(),ut->getMaxHp());
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
else {
|
2011-07-02 02:20:28 +02:00
|
|
|
//printf("#2 Maxhp maxHp = %d, unit->getHp() = %d ut->getMaxHp() = %d\n",maxHp,unit->getHp(),ut->getMaxHp());
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ut->getMaxHp();
|
|
|
|
if(boostMode) {
|
|
|
|
maxHp = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
maxHp += newValue;
|
|
|
|
}
|
|
|
|
|
2011-07-22 09:05:47 +02:00
|
|
|
if(ut->getMaxHpRegeneration() != 0) {
|
2014-12-21 22:02:27 +01:00
|
|
|
newValue = ut->getMaxHpRegeneration();
|
|
|
|
if(boostMode) {
|
|
|
|
maxHpRegeneration = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
maxHpRegeneration += newValue;
|
|
|
|
}
|
2011-07-22 09:05:47 +02:00
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(ut->getMaxEpIsMultiplier() == true) {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ((double)unit->getEp() * ((double)ut->getMaxEp() / (double)100));
|
|
|
|
if(boostMode) {
|
|
|
|
maxEp = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
maxEp += newValue;
|
|
|
|
}
|
|
|
|
|
2014-01-27 20:21:22 +01:00
|
|
|
if(ut->getMaxEpRegeneration() != 0) {
|
2014-12-21 22:02:27 +01:00
|
|
|
newValue = ((double)unit->getType()->getEpRegeneration() + ((double)max(maxEp,unit->getEp()) * ((double)ut->getMaxEpRegeneration() / (double)100)));
|
|
|
|
if(boostMode) {
|
|
|
|
maxEpRegeneration = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
maxEpRegeneration += newValue;
|
|
|
|
}
|
2011-07-22 09:05:47 +02:00
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ut->getMaxEp();
|
|
|
|
if(boostMode) {
|
|
|
|
maxEp = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
maxEp += newValue;
|
|
|
|
}
|
|
|
|
|
2011-07-22 09:05:47 +02:00
|
|
|
if(ut->getMaxEpRegeneration() != 0) {
|
2014-12-21 22:02:27 +01:00
|
|
|
newValue = ut->getMaxEpRegeneration();
|
|
|
|
if(boostMode) {
|
|
|
|
maxEpRegeneration = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
maxEpRegeneration += newValue;
|
|
|
|
}
|
2011-07-22 09:05:47 +02:00
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(ut->getSightIsMultiplier() == true) {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ((double)unit->getType()->getSight() * ((double)ut->getSight() / (double)100));
|
|
|
|
if(boostMode) {
|
|
|
|
sight = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sight += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ut->getSight();
|
|
|
|
if(boostMode) {
|
|
|
|
sight = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sight += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(ut->getArmorIsMultiplier() == true) {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ((double)unit->getType()->getArmor() * ((double)ut->getArmor() / (double)100));
|
|
|
|
if(boostMode) {
|
|
|
|
armor = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
armor += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ut->getArmor();
|
|
|
|
if(boostMode) {
|
|
|
|
armor = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
armor += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(ut->getAttackStrengthIsMultiplier() == true) {
|
2013-11-19 07:14:06 +01:00
|
|
|
for(unsigned int i = 0; i < (unsigned int)unit->getType()->getSkillTypeCount(); ++i) {
|
2011-06-26 09:06:32 +02:00
|
|
|
const SkillType *skillType = unit->getType()->getSkillType(i);
|
|
|
|
const AttackSkillType *ast = dynamic_cast<const AttackSkillType *>(skillType);
|
|
|
|
if(ast != NULL) {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ((double)ast->getAttackStrength() * ((double)ut->getAttackStrength(NULL) / (double)100));
|
|
|
|
if(boostMode) {
|
|
|
|
attackStrengthMultiplierValueList[ast->getName()] = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
attackStrengthMultiplierValueList[ast->getName()] += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ut->getAttackStrength(NULL);
|
|
|
|
if(boostMode) {
|
|
|
|
attackStrength = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
attackStrength += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(ut->getAttackRangeIsMultiplier() == true) {
|
2013-11-19 07:14:06 +01:00
|
|
|
for(unsigned int i = 0; i < (unsigned int)unit->getType()->getSkillTypeCount(); ++i) {
|
2011-06-26 09:06:32 +02:00
|
|
|
const SkillType *skillType = unit->getType()->getSkillType(i);
|
|
|
|
const AttackSkillType *ast = dynamic_cast<const AttackSkillType *>(skillType);
|
|
|
|
if(ast != NULL) {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ((double)ast->getAttackRange() * ((double)ut->getAttackRange(NULL) / (double)100));
|
|
|
|
if(boostMode) {
|
|
|
|
attackRangeMultiplierValueList[ast->getName()] = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
attackRangeMultiplierValueList[ast->getName()] += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ut->getAttackRange(NULL);
|
|
|
|
if(boostMode) {
|
|
|
|
attackRange = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
attackRange += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(ut->getMoveSpeedIsMultiplier() == true) {
|
2013-11-19 07:14:06 +01:00
|
|
|
for(unsigned int i = 0; i < (unsigned int)unit->getType()->getSkillTypeCount(); ++i) {
|
2011-06-26 09:06:32 +02:00
|
|
|
const SkillType *skillType = unit->getType()->getSkillType(i);
|
|
|
|
const MoveSkillType *mst = dynamic_cast<const MoveSkillType *>(skillType);
|
|
|
|
if(mst != NULL) {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ((double)mst->getSpeed() * ((double)ut->getMoveSpeed(NULL) / (double)100));
|
|
|
|
if(boostMode) {
|
|
|
|
moveSpeedIsMultiplierValueList[mst->getName()] = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
moveSpeedIsMultiplierValueList[mst->getName()] += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ut->getMoveSpeed(NULL);
|
|
|
|
if(boostMode) {
|
|
|
|
moveSpeed = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
moveSpeed += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(ut->getProdSpeedIsMultiplier() == true) {
|
2013-11-19 07:14:06 +01:00
|
|
|
for(unsigned int i = 0; i < (unsigned int)unit->getType()->getSkillTypeCount(); ++i) {
|
2011-06-26 09:06:32 +02:00
|
|
|
const SkillType *skillType = unit->getType()->getSkillType(i);
|
|
|
|
const ProduceSkillType *pst = dynamic_cast<const ProduceSkillType *>(skillType);
|
|
|
|
if(pst != NULL) {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ((double)pst->getSpeed() * ((double)ut->getProdSpeed(NULL) / (double)100));
|
|
|
|
if(boostMode) {
|
|
|
|
prodSpeedProduceIsMultiplierValueList[pst->getName()] = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
prodSpeedProduceIsMultiplierValueList[pst->getName()] += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
const UpgradeSkillType *ust = dynamic_cast<const UpgradeSkillType *>(skillType);
|
|
|
|
if(ust != NULL) {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ((double)ust->getSpeed() * ((double)ut->getProdSpeed(NULL) / (double)100));
|
|
|
|
if(boostMode) {
|
|
|
|
prodSpeedUpgradeIsMultiplierValueList[ust->getName()] = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
prodSpeedUpgradeIsMultiplierValueList[ust->getName()] += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
const MorphSkillType *mst = dynamic_cast<const MorphSkillType *>(skillType);
|
|
|
|
if(mst != NULL) {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ((double)mst->getSpeed() * ((double)ut->getProdSpeed(NULL) / (double)100));
|
|
|
|
if(boostMode) {
|
|
|
|
prodSpeedMorphIsMultiplierValueList[mst->getName()] = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
prodSpeedMorphIsMultiplierValueList[mst->getName()] += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ut->getProdSpeed(NULL);
|
|
|
|
if(boostMode) {
|
|
|
|
prodSpeed = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
prodSpeed += newValue;
|
|
|
|
}
|
2011-06-26 09:06:32 +02:00
|
|
|
}
|
2014-08-10 00:15:23 +02:00
|
|
|
|
|
|
|
if(ut->getAttackSpeedIsMultiplier() == true) {
|
|
|
|
for(unsigned int i = 0; i < (unsigned int)unit->getType()->getSkillTypeCount(); ++i) {
|
|
|
|
const SkillType *skillType = unit->getType()->getSkillType(i);
|
|
|
|
const AttackSkillType *ast = dynamic_cast<const AttackSkillType *>(skillType);
|
|
|
|
if(ast != NULL) {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ((double)ast->getSpeed() * ((double)ut->getAttackSpeed(NULL) / (double)100));
|
|
|
|
if(boostMode) {
|
|
|
|
attackSpeedIsMultiplierValueList[ast->getName()] = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
attackSpeedIsMultiplierValueList[ast->getName()] += newValue;
|
|
|
|
}
|
2014-08-10 00:15:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-12-21 22:02:27 +01:00
|
|
|
int newValue = ut->getAttackSpeed(NULL);
|
|
|
|
if(boostMode) {
|
|
|
|
attackSpeed = newValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
attackSpeed += newValue;
|
|
|
|
}
|
2014-08-10 00:15:23 +02:00
|
|
|
}
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
|
|
|
|
2014-12-21 22:02:27 +01:00
|
|
|
void TotalUpgrade::apply(int sourceUnitId, const UpgradeTypeBase *ut, const Unit *unit) {
|
2014-12-20 23:25:42 +01:00
|
|
|
//sum(ut, unit);
|
|
|
|
|
|
|
|
//printf("====> About to apply boost: %s\nTo unit: %d\n\n",ut->toString().c_str(),unit->getId());
|
|
|
|
TotalUpgrade *boostUpgrade = new TotalUpgrade();
|
2014-12-21 00:27:11 +01:00
|
|
|
boostUpgrade->copyDataFrom(this);
|
2014-12-20 23:25:42 +01:00
|
|
|
boostUpgrade->boostUpgradeBase = ut;
|
2014-12-21 22:02:27 +01:00
|
|
|
boostUpgrade->boostUpgradeSourceUnit = sourceUnitId;
|
|
|
|
boostUpgrade->boostUpgradeDestUnit = unit->getId();
|
2014-12-20 23:25:42 +01:00
|
|
|
|
2014-12-21 22:02:27 +01:00
|
|
|
boostUpgrade->sum(ut,unit, true);
|
2014-12-20 23:25:42 +01:00
|
|
|
boostUpgrades.push_back(boostUpgrade);
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
|
|
|
|
2014-12-21 22:02:27 +01:00
|
|
|
void TotalUpgrade::deapply(int sourceUnitId, const UpgradeTypeBase *ut,int destUnitId) {
|
|
|
|
//printf("<****** About to de-apply boost: %s\nTo unit: %d\n\n",ut->toString().c_str(),destUnitId);
|
2014-12-20 23:25:42 +01:00
|
|
|
|
2014-12-21 22:02:27 +01:00
|
|
|
bool removedBoost = false;
|
2014-12-20 23:25:42 +01:00
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
2014-12-21 22:02:27 +01:00
|
|
|
if(boost->boostUpgradeSourceUnit == sourceUnitId &&
|
|
|
|
boost->boostUpgradeBase->getUpgradeName() == ut->getUpgradeName() &&
|
|
|
|
boost->boostUpgradeDestUnit == destUnitId) {
|
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
boostUpgrades.erase(boostUpgrades.begin() + index);
|
|
|
|
delete boost;
|
2014-12-21 22:02:27 +01:00
|
|
|
removedBoost = true;
|
2014-12-20 23:25:42 +01:00
|
|
|
|
2014-12-21 22:02:27 +01:00
|
|
|
//printf("de-apply boost FOUND!\n");
|
2014-12-20 23:25:42 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-12-21 22:02:27 +01:00
|
|
|
if(removedBoost == false) {
|
2014-12-21 23:47:58 +01:00
|
|
|
printf("\n\n!!!!!! de-apply boost NOT FOUND for sourceUnitId = %d, destUnitId = %d\n%s\n\nCurrent Boosts:\n",
|
|
|
|
sourceUnitId,destUnitId,ut->toString().c_str());
|
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
2014-12-22 06:07:24 +01:00
|
|
|
printf("\nBoost #%u\n%s\n",index,boost->toString().c_str());
|
2014-12-21 23:47:58 +01:00
|
|
|
}
|
2014-12-21 22:02:27 +01:00
|
|
|
}
|
2014-12-20 23:25:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int TotalUpgrade::getMaxHp() const {
|
2014-12-21 01:26:14 +01:00
|
|
|
return maxHp + getMaxHpFromBoosts();
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getMaxHpFromBoosts() const {
|
|
|
|
int result = 0;
|
2014-12-20 23:25:42 +01:00
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
result += boost->getMaxHp();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getMaxHpRegeneration() const {
|
2014-12-21 01:26:14 +01:00
|
|
|
return maxHpRegeneration + getMaxHpRegenerationFromBoosts();
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getMaxHpRegenerationFromBoosts() const {
|
|
|
|
int result = 0;
|
2014-12-20 23:25:42 +01:00
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
result += boost->getMaxHpRegeneration();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getSight() const {
|
2014-12-21 01:26:14 +01:00
|
|
|
return sight + getSightFromBoosts();
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getSightFromBoosts() const {
|
|
|
|
int result = 0;
|
2014-12-20 23:25:42 +01:00
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
result += boost->getSight();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getMaxEp() const {
|
2014-12-21 01:26:14 +01:00
|
|
|
return maxEp + getMaxEpFromBoosts();
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getMaxEpFromBoosts() const {
|
|
|
|
int result = 0;
|
2014-12-20 23:25:42 +01:00
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
result += boost->getMaxEp();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
int TotalUpgrade::getMaxEpRegeneration() const {
|
2014-12-21 01:26:14 +01:00
|
|
|
return maxEpRegeneration + getMaxEpRegenerationFromBoosts();
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getMaxEpRegenerationFromBoosts() const {
|
|
|
|
int result = 0;
|
2014-12-20 23:25:42 +01:00
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
result += boost->getMaxEpRegeneration();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
int TotalUpgrade::getArmor() const {
|
2014-12-21 01:26:14 +01:00
|
|
|
return armor + getArmorFromBoosts();
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getArmorFromBoosts() const {
|
|
|
|
int result = 0;
|
2014-12-20 23:25:42 +01:00
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
result += boost->getArmor();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
int TotalUpgrade::getAttackStrength(const AttackSkillType *st) const {
|
2014-12-21 01:26:14 +01:00
|
|
|
return UpgradeTypeBase::getAttackStrength(st) + getAttackStrengthFromBoosts(st);
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getAttackStrengthFromBoosts(const AttackSkillType *st) const {
|
|
|
|
int result = 0;
|
2014-12-20 23:25:42 +01:00
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
result += boost->getAttackStrength(st);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
int TotalUpgrade::getAttackRange(const AttackSkillType *st) const {
|
2014-12-21 01:26:14 +01:00
|
|
|
return UpgradeTypeBase::getAttackRange(st) + getAttackRangeFromBoosts(st);
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getAttackRangeFromBoosts(const AttackSkillType *st) const {
|
|
|
|
int result = 0;
|
2014-12-20 23:25:42 +01:00
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
result += boost->getAttackRange(st);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
int TotalUpgrade::getMoveSpeed(const MoveSkillType *st) const {
|
2014-12-21 01:26:14 +01:00
|
|
|
return UpgradeTypeBase::getMoveSpeed(st) + getMoveSpeedFromBoosts(st);
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getMoveSpeedFromBoosts(const MoveSkillType *st) const {
|
|
|
|
int result = 0;
|
2014-12-20 23:25:42 +01:00
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
result += boost->getMoveSpeed(st);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
int TotalUpgrade::getProdSpeed(const SkillType *st) const {
|
2014-12-21 01:26:14 +01:00
|
|
|
return UpgradeTypeBase::getProdSpeed(st) + getProdSpeedFromBoosts(st);
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getProdSpeedFromBoosts(const SkillType *st) const {
|
|
|
|
int result = 0;
|
2014-12-20 23:25:42 +01:00
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
result += boost->getProdSpeed(st);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2014-12-21 01:26:14 +01:00
|
|
|
|
2014-12-20 23:25:42 +01:00
|
|
|
int TotalUpgrade::getAttackSpeed(const AttackSkillType *st) const {
|
2014-12-21 01:26:14 +01:00
|
|
|
return UpgradeTypeBase::getAttackSpeed(st) + getAttackSpeedFromBoosts(st);
|
|
|
|
}
|
|
|
|
int TotalUpgrade::getAttackSpeedFromBoosts(const AttackSkillType *st) const {
|
|
|
|
int result = 0;
|
2014-12-20 23:25:42 +01:00
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
result += boost->getAttackSpeed(st);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-06-26 09:06:32 +02:00
|
|
|
void TotalUpgrade::incLevel(const UnitType *ut) {
|
|
|
|
maxHp += ut->getMaxHp()*50/100;
|
|
|
|
maxEp += ut->getMaxEp()*50/100;
|
|
|
|
sight += ut->getSight()*20/100;
|
|
|
|
armor += ut->getArmor()*50/100;
|
2014-12-21 00:27:11 +01:00
|
|
|
|
|
|
|
for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
boost->copyDataFrom(this);
|
|
|
|
}
|
2011-06-25 10:53:53 +02:00
|
|
|
}
|
|
|
|
|
2012-03-13 16:21:25 +01:00
|
|
|
void TotalUpgrade::saveGame(XmlNode *rootNode) const {
|
|
|
|
std::map<string,string> mapTagReplacements;
|
|
|
|
XmlNode *upgradeTypeBaseNode = rootNode->addChild("TotalUpgrade");
|
|
|
|
|
|
|
|
// int maxHp;
|
|
|
|
upgradeTypeBaseNode->addAttribute("maxHp",intToStr(maxHp), mapTagReplacements);
|
|
|
|
// bool maxHpIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("maxHpIsMultiplier",intToStr(maxHpIsMultiplier), mapTagReplacements);
|
|
|
|
// int maxHpRegeneration;
|
|
|
|
upgradeTypeBaseNode->addAttribute("maxHpRegeneration",intToStr(maxHpRegeneration), mapTagReplacements);
|
|
|
|
// //bool maxHpRegenerationIsMultiplier;
|
|
|
|
//
|
|
|
|
// int sight;
|
|
|
|
upgradeTypeBaseNode->addAttribute("sight",intToStr(sight), mapTagReplacements);
|
|
|
|
// bool sightIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("sightIsMultiplier",intToStr(sightIsMultiplier), mapTagReplacements);
|
|
|
|
// int maxEp;
|
|
|
|
upgradeTypeBaseNode->addAttribute("maxEp",intToStr(maxEp), mapTagReplacements);
|
|
|
|
// bool maxEpIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("maxEpIsMultiplier",intToStr(maxEpIsMultiplier), mapTagReplacements);
|
|
|
|
// int maxEpRegeneration;
|
|
|
|
upgradeTypeBaseNode->addAttribute("maxEpRegeneration",intToStr(maxEpRegeneration), mapTagReplacements);
|
|
|
|
// //bool maxEpRegenerationIsMultiplier;
|
|
|
|
// int armor;
|
|
|
|
upgradeTypeBaseNode->addAttribute("armor",intToStr(armor), mapTagReplacements);
|
|
|
|
// bool armorIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("armorIsMultiplier",intToStr(armorIsMultiplier), mapTagReplacements);
|
|
|
|
// int attackStrength;
|
|
|
|
upgradeTypeBaseNode->addAttribute("attackStrength",intToStr(attackStrength), mapTagReplacements);
|
|
|
|
// bool attackStrengthIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("attackStrengthIsMultiplier",intToStr(attackStrengthIsMultiplier), mapTagReplacements);
|
|
|
|
// std::map<string,int> attackStrengthMultiplierValueList;
|
|
|
|
for(std::map<string,int>::const_iterator iterMap = attackStrengthMultiplierValueList.begin();
|
|
|
|
iterMap != attackStrengthMultiplierValueList.end(); ++iterMap) {
|
|
|
|
XmlNode *attackStrengthMultiplierValueListNode = upgradeTypeBaseNode->addChild("attackStrengthMultiplierValueList");
|
|
|
|
|
|
|
|
attackStrengthMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
attackStrengthMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
}
|
|
|
|
// int attackRange;
|
|
|
|
upgradeTypeBaseNode->addAttribute("attackRange",intToStr(attackRange), mapTagReplacements);
|
|
|
|
// bool attackRangeIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("attackRangeIsMultiplier",intToStr(attackRangeIsMultiplier), mapTagReplacements);
|
|
|
|
// std::map<string,int> attackRangeMultiplierValueList;
|
|
|
|
for(std::map<string,int>::const_iterator iterMap = attackRangeMultiplierValueList.begin();
|
|
|
|
iterMap != attackRangeMultiplierValueList.end(); ++iterMap) {
|
|
|
|
XmlNode *attackRangeMultiplierValueListNode = upgradeTypeBaseNode->addChild("attackRangeMultiplierValueList");
|
|
|
|
|
|
|
|
attackRangeMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
attackRangeMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
}
|
|
|
|
|
|
|
|
// int moveSpeed;
|
|
|
|
upgradeTypeBaseNode->addAttribute("moveSpeed",intToStr(moveSpeed), mapTagReplacements);
|
|
|
|
// bool moveSpeedIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("moveSpeedIsMultiplier",intToStr(moveSpeedIsMultiplier), mapTagReplacements);
|
|
|
|
// std::map<string,int> moveSpeedIsMultiplierValueList;
|
|
|
|
for(std::map<string,int>::const_iterator iterMap = moveSpeedIsMultiplierValueList.begin();
|
|
|
|
iterMap != moveSpeedIsMultiplierValueList.end(); ++iterMap) {
|
|
|
|
XmlNode *moveSpeedIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("moveSpeedIsMultiplierValueList");
|
|
|
|
|
|
|
|
moveSpeedIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
moveSpeedIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
}
|
|
|
|
|
|
|
|
// int prodSpeed;
|
|
|
|
upgradeTypeBaseNode->addAttribute("prodSpeed",intToStr(prodSpeed), mapTagReplacements);
|
|
|
|
// bool prodSpeedIsMultiplier;
|
|
|
|
upgradeTypeBaseNode->addAttribute("prodSpeedIsMultiplier",intToStr(prodSpeedIsMultiplier), mapTagReplacements);
|
|
|
|
// std::map<string,int> prodSpeedProduceIsMultiplierValueList;
|
|
|
|
for(std::map<string,int>::const_iterator iterMap = prodSpeedProduceIsMultiplierValueList.begin();
|
|
|
|
iterMap != prodSpeedProduceIsMultiplierValueList.end(); ++iterMap) {
|
|
|
|
XmlNode *prodSpeedProduceIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("prodSpeedProduceIsMultiplierValueList");
|
|
|
|
|
|
|
|
prodSpeedProduceIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
prodSpeedProduceIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
}
|
|
|
|
|
|
|
|
// std::map<string,int> prodSpeedUpgradeIsMultiplierValueList;
|
|
|
|
for(std::map<string,int>::const_iterator iterMap = prodSpeedUpgradeIsMultiplierValueList.begin();
|
|
|
|
iterMap != prodSpeedUpgradeIsMultiplierValueList.end(); ++iterMap) {
|
|
|
|
XmlNode *prodSpeedUpgradeIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("prodSpeedUpgradeIsMultiplierValueList");
|
|
|
|
|
|
|
|
prodSpeedUpgradeIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
prodSpeedUpgradeIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
}
|
|
|
|
|
|
|
|
// std::map<string,int> prodSpeedMorphIsMultiplierValueList;
|
|
|
|
for(std::map<string,int>::const_iterator iterMap = prodSpeedMorphIsMultiplierValueList.begin();
|
|
|
|
iterMap != prodSpeedMorphIsMultiplierValueList.end(); ++iterMap) {
|
|
|
|
XmlNode *prodSpeedMorphIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("prodSpeedMorphIsMultiplierValueList");
|
|
|
|
|
|
|
|
prodSpeedMorphIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
prodSpeedMorphIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
}
|
2014-08-10 00:15:23 +02:00
|
|
|
|
|
|
|
upgradeTypeBaseNode->addAttribute("attackSpeed",intToStr(attackSpeed), mapTagReplacements);
|
|
|
|
upgradeTypeBaseNode->addAttribute("attackSpeedIsMultiplier",intToStr(attackSpeedIsMultiplier), mapTagReplacements);
|
|
|
|
for(std::map<string,int>::const_iterator iterMap = attackSpeedIsMultiplierValueList.begin();
|
|
|
|
iterMap != attackSpeedIsMultiplierValueList.end(); ++iterMap) {
|
|
|
|
XmlNode *attackSpeedIsMultiplierValueListNode = upgradeTypeBaseNode->addChild("attackSpeedIsMultiplierValueList");
|
|
|
|
|
|
|
|
attackSpeedIsMultiplierValueListNode->addAttribute("key",iterMap->first, mapTagReplacements);
|
|
|
|
attackSpeedIsMultiplierValueListNode->addAttribute("value",intToStr(iterMap->second), mapTagReplacements);
|
|
|
|
}
|
2014-12-21 22:02:27 +01:00
|
|
|
|
|
|
|
// for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
// TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
// XmlNode *attackBoostListNode = upgradeTypeBaseNode->addChild("attackBoostList");
|
|
|
|
// attackBoostListNode->addAttribute("unitId",intToStr(boost->boostUpgradeUnit->getId()), mapTagReplacements);
|
|
|
|
//
|
|
|
|
// std::map<string,string> mapTagReplacements;
|
|
|
|
// if(boost != NULL) {
|
|
|
|
// boost->saveGameBoost(attackBoostListNode);
|
|
|
|
// boost->boostUpgradeBase->saveGameBoost(attackBoostListNode);
|
|
|
|
// }
|
|
|
|
// }
|
2012-03-13 16:21:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TotalUpgrade::loadGame(const XmlNode *rootNode) {
|
|
|
|
const XmlNode *upgradeTypeBaseNode = rootNode->getChild("TotalUpgrade");
|
|
|
|
|
|
|
|
//description = upgradeTypeBaseNode->getAttribute("description")->getValue();
|
|
|
|
|
|
|
|
// int maxHp;
|
|
|
|
maxHp = upgradeTypeBaseNode->getAttribute("maxHp")->getIntValue();
|
|
|
|
// bool maxHpIsMultiplier;
|
2012-04-16 22:15:57 +02:00
|
|
|
maxHpIsMultiplier = upgradeTypeBaseNode->getAttribute("maxHpIsMultiplier")->getIntValue() != 0;
|
2012-03-13 16:21:25 +01:00
|
|
|
// int maxHpRegeneration;
|
|
|
|
maxHpRegeneration = upgradeTypeBaseNode->getAttribute("maxHpRegeneration")->getIntValue();
|
|
|
|
// //bool maxHpRegenerationIsMultiplier;
|
|
|
|
//
|
|
|
|
// int sight;
|
|
|
|
sight = upgradeTypeBaseNode->getAttribute("sight")->getIntValue();
|
|
|
|
// bool sightIsMultiplier;
|
2012-04-16 22:15:57 +02:00
|
|
|
sightIsMultiplier = upgradeTypeBaseNode->getAttribute("sightIsMultiplier")->getIntValue() != 0;
|
2012-03-13 16:21:25 +01:00
|
|
|
// int maxEp;
|
|
|
|
maxEp = upgradeTypeBaseNode->getAttribute("maxEp")->getIntValue();
|
|
|
|
// bool maxEpIsMultiplier;
|
2012-04-16 22:15:57 +02:00
|
|
|
maxEpIsMultiplier = upgradeTypeBaseNode->getAttribute("maxEpIsMultiplier")->getIntValue() != 0;
|
2012-03-13 16:21:25 +01:00
|
|
|
// int maxEpRegeneration;
|
|
|
|
maxEpRegeneration = upgradeTypeBaseNode->getAttribute("maxEpRegeneration")->getIntValue();
|
|
|
|
// //bool maxEpRegenerationIsMultiplier;
|
|
|
|
// int armor;
|
|
|
|
armor = upgradeTypeBaseNode->getAttribute("armor")->getIntValue();
|
|
|
|
// bool armorIsMultiplier;
|
2012-04-16 22:15:57 +02:00
|
|
|
armorIsMultiplier = upgradeTypeBaseNode->getAttribute("armorIsMultiplier")->getIntValue() != 0;
|
2012-03-13 16:21:25 +01:00
|
|
|
// int attackStrength;
|
|
|
|
attackStrength = upgradeTypeBaseNode->getAttribute("attackStrength")->getIntValue();
|
|
|
|
// bool attackStrengthIsMultiplier;
|
2012-04-16 22:15:57 +02:00
|
|
|
attackStrengthIsMultiplier = upgradeTypeBaseNode->getAttribute("attackStrengthIsMultiplier")->getIntValue() != 0;
|
2012-03-13 16:21:25 +01:00
|
|
|
// std::map<string,int> attackStrengthMultiplierValueList;
|
|
|
|
vector<XmlNode *> attackStrengthMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("attackStrengthMultiplierValueList");
|
|
|
|
for(unsigned int i = 0; i < attackStrengthMultiplierValueNodeList.size(); ++i) {
|
|
|
|
XmlNode *node = attackStrengthMultiplierValueNodeList[i];
|
|
|
|
|
|
|
|
attackStrengthMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
node->getAttribute("value")->getIntValue();
|
|
|
|
}
|
|
|
|
// int attackRange;
|
|
|
|
attackRange = upgradeTypeBaseNode->getAttribute("attackRange")->getIntValue();
|
|
|
|
// bool attackRangeIsMultiplier;
|
2012-04-16 22:15:57 +02:00
|
|
|
attackRangeIsMultiplier = upgradeTypeBaseNode->getAttribute("attackRangeIsMultiplier")->getIntValue() != 0;
|
2012-03-13 16:21:25 +01:00
|
|
|
// std::map<string,int> attackRangeMultiplierValueList;
|
|
|
|
vector<XmlNode *> attackRangeMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("attackRangeMultiplierValueList");
|
|
|
|
for(unsigned int i = 0; i < attackRangeMultiplierValueNodeList.size(); ++i) {
|
|
|
|
XmlNode *node = attackRangeMultiplierValueNodeList[i];
|
|
|
|
|
|
|
|
attackRangeMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
node->getAttribute("value")->getIntValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// int moveSpeed;
|
|
|
|
moveSpeed = upgradeTypeBaseNode->getAttribute("moveSpeed")->getIntValue();
|
|
|
|
// bool moveSpeedIsMultiplier;
|
2012-04-16 22:15:57 +02:00
|
|
|
moveSpeedIsMultiplier = upgradeTypeBaseNode->getAttribute("moveSpeedIsMultiplier")->getIntValue() != 0;
|
2012-03-13 16:21:25 +01:00
|
|
|
// std::map<string,int> moveSpeedIsMultiplierValueList;
|
|
|
|
vector<XmlNode *> moveSpeedIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("moveSpeedIsMultiplierValueList");
|
|
|
|
for(unsigned int i = 0; i < moveSpeedIsMultiplierValueNodeList.size(); ++i) {
|
|
|
|
XmlNode *node = moveSpeedIsMultiplierValueNodeList[i];
|
|
|
|
|
|
|
|
moveSpeedIsMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
node->getAttribute("value")->getIntValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// int prodSpeed;
|
|
|
|
prodSpeed = upgradeTypeBaseNode->getAttribute("prodSpeed")->getIntValue();
|
|
|
|
// bool prodSpeedIsMultiplier;
|
2012-04-16 22:15:57 +02:00
|
|
|
prodSpeedIsMultiplier = upgradeTypeBaseNode->getAttribute("prodSpeedIsMultiplier")->getIntValue() != 0;
|
2012-03-13 16:21:25 +01:00
|
|
|
// std::map<string,int> prodSpeedProduceIsMultiplierValueList;
|
|
|
|
vector<XmlNode *> prodSpeedProduceIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("prodSpeedProduceIsMultiplierValueList");
|
|
|
|
for(unsigned int i = 0; i < prodSpeedProduceIsMultiplierValueNodeList.size(); ++i) {
|
|
|
|
XmlNode *node = prodSpeedProduceIsMultiplierValueNodeList[i];
|
|
|
|
|
|
|
|
prodSpeedProduceIsMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
node->getAttribute("value")->getIntValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// std::map<string,int> prodSpeedUpgradeIsMultiplierValueList;
|
|
|
|
vector<XmlNode *> prodSpeedUpgradeIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("prodSpeedUpgradeIsMultiplierValueList");
|
|
|
|
for(unsigned int i = 0; i < prodSpeedUpgradeIsMultiplierValueNodeList.size(); ++i) {
|
|
|
|
XmlNode *node = prodSpeedUpgradeIsMultiplierValueNodeList[i];
|
|
|
|
|
|
|
|
prodSpeedUpgradeIsMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
node->getAttribute("value")->getIntValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// std::map<string,int> prodSpeedMorphIsMultiplierValueList;
|
|
|
|
vector<XmlNode *> prodSpeedMorphIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("prodSpeedMorphIsMultiplierValueList");
|
|
|
|
for(unsigned int i = 0; i < prodSpeedMorphIsMultiplierValueNodeList.size(); ++i) {
|
|
|
|
XmlNode *node = prodSpeedMorphIsMultiplierValueNodeList[i];
|
|
|
|
|
|
|
|
prodSpeedMorphIsMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
node->getAttribute("value")->getIntValue();
|
|
|
|
}
|
2014-08-10 00:15:23 +02:00
|
|
|
|
2014-11-18 18:59:45 +01:00
|
|
|
if(upgradeTypeBaseNode->hasAttribute("attackSpeed")){
|
|
|
|
attackSpeed = upgradeTypeBaseNode->getAttribute("attackSpeed")->getIntValue();
|
|
|
|
attackSpeedIsMultiplier = upgradeTypeBaseNode->getAttribute("attackSpeedIsMultiplier")->getIntValue() != 0;
|
|
|
|
vector<XmlNode *> attackSpeedIsMultiplierValueNodeList = upgradeTypeBaseNode->getChildList("attackSpeedIsMultiplierValueList");
|
|
|
|
for(unsigned int i = 0; i < attackSpeedIsMultiplierValueNodeList.size(); ++i) {
|
|
|
|
XmlNode *node = attackSpeedIsMultiplierValueNodeList[i];
|
2014-08-10 00:15:23 +02:00
|
|
|
|
2014-11-18 18:59:45 +01:00
|
|
|
attackSpeedIsMultiplierValueList[node->getAttribute("key")->getValue()] =
|
|
|
|
node->getAttribute("value")->getIntValue();
|
|
|
|
}
|
2014-08-10 00:15:23 +02:00
|
|
|
}
|
2014-12-21 22:02:27 +01:00
|
|
|
|
|
|
|
// vector<XmlNode *> boostNodeList = upgradeTypeBaseNode->getChildList("attackBoostList");
|
|
|
|
// for(unsigned int index = 0; index < boostNodeList.size(); ++index) {
|
|
|
|
// XmlNode *boostNode = boostNodeList[index];
|
|
|
|
//
|
|
|
|
// //for(unsigned int index = 0; index < boostUpgrades.size(); ++index) {
|
|
|
|
// // TotalUpgrade *boost = boostUpgrades[index];
|
|
|
|
// // XmlNode *attackBoostListNode = upgradeTypeBaseNode->addChild("attackBoostList");
|
|
|
|
//
|
|
|
|
//// std::map<string,string> mapTagReplacements;
|
|
|
|
//// if(boost != NULL) {
|
|
|
|
//// boost->saveGame(attackBoostListNode);
|
|
|
|
//// }
|
|
|
|
// int unitId = boostNode->getAttribute("unitId")->getIntValue();
|
|
|
|
// const Unit *unit = world->findUnitById(unitId);
|
|
|
|
//
|
|
|
|
// TotalUpgrade *boostUpgrade = new TotalUpgrade();
|
|
|
|
// //boostUpgrade->copyDataFrom(this);
|
|
|
|
// boostUpgrade->loadGameBoost(boostNode);
|
|
|
|
// boostUpgrade->loadGameBoost(boostNode);
|
|
|
|
//
|
|
|
|
// boostUpgrade->boostUpgradeBase = ut;
|
|
|
|
// boostUpgrade->boostUpgradeUnit = unit;
|
|
|
|
//
|
|
|
|
// //boostUpgrade->sum(ut,unit);
|
|
|
|
// boostUpgrades.push_back(boostUpgrade);
|
|
|
|
//
|
|
|
|
// //boost->saveGameBoost(attackBoostListNode);
|
|
|
|
// //boost->boostUpgradeBase->saveGameBoost(attackBoostListNode);
|
|
|
|
//
|
|
|
|
// //apply(const UpgradeTypeBase *ut, unit);
|
|
|
|
// }
|
|
|
|
|
2012-03-13 16:21:25 +01:00
|
|
|
}
|
|
|
|
|
2012-03-10 04:27:25 +01:00
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
}}//end namespace
|