diff --git a/source/glest_game/types/command_type.cpp b/source/glest_game/types/command_type.cpp index fac32b1f..83ec8c9d 100644 --- a/source/glest_game/types/command_type.cpp +++ b/source/glest_game/types/command_type.cpp @@ -106,6 +106,7 @@ string StopCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ str+= lang.get("EpCost")+": "+intToStr(stopSkillType->getEpCost())+"\n"; if(stopSkillType->getHpCost()!=0) str+= lang.get("HpCost")+": "+intToStr(stopSkillType->getHpCost())+"\n"; + str+=stopSkillType->getBoostDesc(); return str; } @@ -167,7 +168,7 @@ string MoveCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ if(moveSkillType->getHpCost()!=0){ str+= lang.get("HpCost")+": "+intToStr(moveSkillType->getHpCost())+"\n"; } - + str+=moveSkillType->getBoostDesc(); return str; } @@ -261,7 +262,7 @@ string AttackCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ str+="\n"; str+= lang.get("AttackSpeed")+": "+ intToStr(attackSkillType->getSpeed()) +"\n"; - + str+=attackSkillType->getBoostDesc(); return str; } @@ -345,7 +346,7 @@ string AttackStoppedCommandType::getDesc(const TotalUpgrade *totalUpgrade) const } } str+="\n"; - + str+=attackSkillType->getBoostDesc(); return str; } @@ -448,7 +449,7 @@ string BuildCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ if(buildSkillType->getHpCost()!=0){ str+= lang.get("HpCost")+": "+intToStr(buildSkillType->getHpCost())+"\n"; } - + str+=buildSkillType->getBoostDesc(); return str; } @@ -528,7 +529,7 @@ string HarvestCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ for(int i=0; igetName()+"\n"; } - + str+=harvestSkillType->getBoostDesc(); return str; } @@ -602,7 +603,7 @@ string RepairCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ for(int i=0; i(repairableUnits[i]))->getName()+"\n"; } - + str+=repairSkillType->getBoostDesc(); return str; } @@ -673,7 +674,7 @@ string ProduceCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ str+= lang.get("hpCost")+": "+intToStr(produceSkillType->getHpCost())+"\n"; } str+= "\n" + getProducedUnit()->getReqDesc(); - + str+=produceSkillType->getBoostDesc(); return str; } @@ -732,7 +733,7 @@ string UpgradeCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ if(upgradeSkillType->getHpCost()!=0) str+= lang.get("HpCost")+": "+intToStr(upgradeSkillType->getHpCost())+"\n"; str+= "\n"+getProducedUpgrade()->getReqDesc(); - + str+=upgradeSkillType->getBoostDesc(); return str; } @@ -806,7 +807,7 @@ string MorphCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ } str+= "\n"+getProduced()->getReqDesc(); - + str+=morphSkillType->getBoostDesc(); return str; } diff --git a/source/glest_game/types/skill_type.cpp b/source/glest_game/types/skill_type.cpp index 4fed5d2e..218099fc 100644 --- a/source/glest_game/types/skill_type.cpp +++ b/source/glest_game/types/skill_type.cpp @@ -150,6 +150,60 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const { return result; } +string AttackBoost::getDesc() const{ + Lang &lang= Lang::getInstance(); + string str= ""; + string indent=" "; + if(enabled){ + if(boostUnitList.size()>0){ + str+= "\n"+ lang.get("Effects")+":\n"; + } + + str += indent+lang.get("effectRadius") + ": " + intToStr(radius) +"\n"; + if(allowMultipleBoosts==false) { + string allowIt=lang.get("No"); + if(allowMultipleBoosts==true) + allowIt=lang.get("False"); + str += indent+lang.get("allowMultiBoost") + ": " + allowIt +"\n"; + } + str+=boostUpgrade.getDesc(); + + if(targetType==abtAlly) + { + str+= lang.get("AffectedUnitsFromTeam") +":\n"; + } + else if(targetType==abtFoe) + { + str+= lang.get("AffectedUnitsFromFoe") +":\n"; + } + else if(targetType==abtFaction) + { + str+= lang.get("AffectedUnitsFromYourFaction") +":\n"; + } + else if(targetType==abtUnitTypes) + { + str+= lang.get("AffectedUnitsFromAll") +":\n"; + } + else if(targetType==abtAll) + { + str+= lang.get("AffectedUnitsFromAll") +":\n"; + } + + if(boostUnitList.size()>0){ + for(int i=0; igetName()+"\n"; + } + } + else + { + str+= lang.get("All")+"\n"; + } + + return str; + } + else + return ""; +} // ===================================================== // class SkillType diff --git a/source/glest_game/types/skill_type.h b/source/glest_game/types/skill_type.h index ae598502..6205ade8 100644 --- a/source/glest_game/types/skill_type.h +++ b/source/glest_game/types/skill_type.h @@ -75,11 +75,11 @@ typedef list UnitParticleSystemTypes; // ===================================================== enum AttackBoostTargetType { - abtAlly, - abtFoe, - abtFaction, - abtUnitTypes, - abtAll + abtAlly, // Only ally units are affected + abtFoe, // Only foe units are affected + abtFaction, // Only same faction units are affected + abtUnitTypes, // Specify which units are affected ( in general same as abtAll ) + abtAll // All units are affected (including enemies) }; class AttackBoost { @@ -100,6 +100,7 @@ public: string name; bool isAffected(const Unit *source, const Unit *dest) const; + virtual string getDesc() const; }; class AnimationAttributes { @@ -169,12 +170,14 @@ public: bool isAttackBoostEnabled() const { return attackBoost.enabled; } const AttackBoost * getAttackBoost() const { return &attackBoost; } + //virtual string getDesc(const TotalUpgrade *totalUpgrade) const= 0; //other virtual string toString() const= 0; virtual int getTotalSpeed(const TotalUpgrade *) const {return speed;} static string skillClassToStr(SkillClass skillClass); static string fieldToStr(Field field); + virtual string getBoostDesc() const {return attackBoost.getDesc();} }; // =============================== diff --git a/source/glest_game/types/upgrade_type.cpp b/source/glest_game/types/upgrade_type.cpp index 77f6226f..d96d8f36 100644 --- a/source/glest_game/types/upgrade_type.cpp +++ b/source/glest_game/types/upgrade_type.cpp @@ -192,12 +192,108 @@ int UpgradeTypeBase::getProdSpeed(const SkillType *st) const { } } -bool UpgradeType::isAffected(const UnitType *unitType) const{ - return find(effects.begin(), effects.end(), unitType)!=effects.end(); +string UpgradeTypeBase::getDesc() const{ + + string str=""; + string indent="->"; + //int i; + Lang &lang= Lang::getInstance(); + + if(maxHp != 0) { + if(maxHpIsMultiplier) { + str += indent+lang.get("Hp") + " *" + intToStr(maxHp); + } + else { + str += indent+lang.get("Hp") + " +" + intToStr(maxHp); + } + + if(maxHpRegeneration != 0) { + str += " [" + intToStr(maxHpRegeneration) + "]"; + } + } + if(sight != 0) { + if(sightIsMultiplier) { + str+= indent+lang.get("Sight") + " *" + intToStr(sight); + } + else { + str+= indent+lang.get("Sight") + " +" + intToStr(sight); + } + } + if(maxEp != 0) { + if(maxEpIsMultiplier) { + str+= indent+lang.get("Ep") + " *" + intToStr(maxEp)+"\n"; + } + else { + str+= indent+lang.get("Ep") + " +" + intToStr(maxEp)+"\n"; + } + if(maxEpRegeneration != 0) { + str += " [" + intToStr(maxEpRegeneration) + "]"; + } + } + if(attackStrength != 0) { + if(attackStrengthIsMultiplier) { + str+= indent+lang.get("AttackStrenght") + " *" + intToStr(attackStrength)+"\n"; + } + else { + str+= indent+lang.get("AttackStrenght") + " +" + intToStr(attackStrength)+"\n"; + } + } + if(attackRange != 0) { + if(attackRangeIsMultiplier) { + str+= indent+lang.get("AttackDistance") + " *" + intToStr(attackRange)+"\n"; + } + else { + str+= indent+lang.get("AttackDistance") + " +" + intToStr(attackRange)+"\n"; + } + } + if(armor != 0) { + if(armorIsMultiplier) { + str+= indent+lang.get("Armor") + " *" + intToStr(armor)+"\n"; + } + else { + str+= indent+lang.get("Armor") + " +" + intToStr(armor)+"\n"; + } + } + if(moveSpeed != 0) { + if(moveSpeedIsMultiplier) { + str+= indent+lang.get("WalkSpeed") + " *" + intToStr(moveSpeed)+"\n"; + } + else { + str+= indent+lang.get("WalkSpeed") + " +" + intToStr(moveSpeed)+"\n"; + } + } + if(prodSpeed != 0) { + if(prodSpeedIsMultiplier) { + str+= indent+lang.get("ProductionSpeed") + " *" + intToStr(prodSpeed)+"\n"; + } + else { + str+= indent+lang.get("ProductionSpeed") + " +" + intToStr(prodSpeed)+"\n"; + } + } + + return str; } + // ==================== misc ==================== +string UpgradeType::getReqDesc() const{ + Lang &lang= Lang::getInstance(); + string str= ProducibleType::getReqDesc(); + string indent=" "; + if(getEffectCount()>0){ + str+= "\n"+ lang.get("Upgrades")+"\n"; + } + str+=UpgradeTypeBase::getDesc(); + if(getEffectCount()>0){ + str+= lang.get("AffectedUnits")+"\n"; + for(int i=0; igetName()+"\n"; + } + } + return str; +} + void UpgradeType::preLoad(const string &dir){ name=lastDir(dir); } @@ -376,97 +472,11 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } -string UpgradeType::getReqDesc() const{ - - string str; - //int i; - Lang &lang= Lang::getInstance(); - - str= ProducibleType::getReqDesc(); - if(getEffectCount()>0){ - str+= "\n"+ lang.get("Upgrades")+":\n"; - for(int i=0; igetName()+"\n"; - } - } - - if(maxHp != 0) { - if(maxHpIsMultiplier) { - str += lang.get("Hp") + " *" + intToStr(maxHp); - } - else { - str += lang.get("Hp") + " +" + intToStr(maxHp); - } - - if(maxHpRegeneration != 0) { - str += " [" + intToStr(maxHpRegeneration) + "]"; - } - } - if(sight != 0) { - if(sightIsMultiplier) { - str+= lang.get("Sight") + " *" + intToStr(sight); - } - else { - str+= lang.get("Sight") + " +" + intToStr(sight); - } - } - if(maxEp != 0) { - if(maxEpIsMultiplier) { - str+= lang.get("Ep") + " *" + intToStr(maxEp)+"\n"; - } - else { - str+= lang.get("Ep") + " +" + intToStr(maxEp)+"\n"; - } - if(maxEpRegeneration != 0) { - str += " [" + intToStr(maxEpRegeneration) + "]"; - } - } - if(attackStrength != 0) { - if(attackStrengthIsMultiplier) { - str+= lang.get("AttackStrenght") + " *" + intToStr(attackStrength)+"\n"; - } - else { - str+= lang.get("AttackStrenght") + " +" + intToStr(attackStrength)+"\n"; - } - } - if(attackRange != 0) { - if(attackRangeIsMultiplier) { - str+= lang.get("AttackDistance") + " *" + intToStr(attackRange)+"\n"; - } - else { - str+= lang.get("AttackDistance") + " +" + intToStr(attackRange)+"\n"; - } - } - if(armor != 0) { - if(armorIsMultiplier) { - str+= lang.get("Armor") + " *" + intToStr(armor)+"\n"; - } - else { - str+= lang.get("Armor") + " +" + intToStr(armor)+"\n"; - } - } - if(moveSpeed != 0) { - if(moveSpeedIsMultiplier) { - str+= lang.get("WalkSpeed") + " *" + intToStr(moveSpeed)+"\n"; - } - else { - str+= lang.get("WalkSpeed") + " +" + intToStr(moveSpeed)+"\n"; - } - } - if(prodSpeed != 0) { - if(prodSpeedIsMultiplier) { - str+= lang.get("ProductionSpeed") + " *" + intToStr(prodSpeed)+"\n"; - } - else { - str+= lang.get("ProductionSpeed") + " +" + intToStr(prodSpeed)+"\n"; - } - } - - return str; +bool UpgradeType::isAffected(const UnitType *unitType) const{ + return find(effects.begin(), effects.end(), unitType)!=effects.end(); } - // =============================== // class TotalUpgrade // =============================== diff --git a/source/glest_game/types/upgrade_type.h b/source/glest_game/types/upgrade_type.h index 9f706885..16498cb6 100644 --- a/source/glest_game/types/upgrade_type.h +++ b/source/glest_game/types/upgrade_type.h @@ -101,6 +101,7 @@ public: void load(const XmlNode *upgradeNode); + virtual string getDesc() const; std::string toString() const { std::string result = "";