1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Merge pull request #509 from godric3/bonusDescription

Skill and hero specialty bonus description
This commit is contained in:
Alexander Shishkin 2018-10-31 00:59:05 +03:00 committed by GitHub
commit 2a282c9a8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 6 deletions

View File

@ -564,11 +564,12 @@ std::vector<std::shared_ptr<Bonus>> SpecialtyInfoToBonuses(const SSpecialtyInfo
}
// convert deprecated format
std::vector<std::shared_ptr<Bonus>> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec)
std::vector<std::shared_ptr<Bonus>> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec, int sid)
{
std::vector<std::shared_ptr<Bonus>> result;
for(std::shared_ptr<Bonus> oldBonus : spec.bonuses)
{
oldBonus->sid = sid;
if(oldBonus->type == Bonus::SPECIAL_SPELL_LEV || oldBonus->type == Bonus::SPECIAL_BLESS_DAMAGE)
{
// these bonuses used to auto-scale with hero level
@ -860,6 +861,11 @@ void CHeroHandler::afterLoadFinalization()
{
for(ConstTransitivePtr<CHero> hero : heroes)
{
for(auto bonus : hero->specialty)
{
bonus->sid = hero->ID.getNum();
}
if(hero->specDeprecated.size() > 0 || hero->specialtyDeprecated.size() > 0)
{
logMod->debug("Converting specialty format for hero %s(%s)", hero->identifier, VLC->townh->encodeFaction(hero->heroClass->faction));
@ -871,7 +877,7 @@ void CHeroHandler::afterLoadFinalization()
}
for(const SSpecialtyBonus & spec : hero->specialtyDeprecated)
{
for(std::shared_ptr<Bonus> b : SpecialtyBonusToBonuses(spec))
for(std::shared_ptr<Bonus> b : SpecialtyBonusToBonuses(spec, hero->ID.getNum()))
convertedBonuses.push_back(b);
}
hero->specDeprecated.clear();

View File

@ -134,8 +134,8 @@ public:
};
// convert deprecated format
std::vector<std::shared_ptr<Bonus>> SpecialtyInfoToBonuses(const SSpecialtyInfo & spec, int sid);
std::vector<std::shared_ptr<Bonus>> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec);
std::vector<std::shared_ptr<Bonus>> SpecialtyInfoToBonuses(const SSpecialtyInfo & spec, int sid = 0);
std::vector<std::shared_ptr<Bonus>> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec, int sid = 0);
class DLL_LINKAGE CHeroClass
{

View File

@ -46,7 +46,7 @@ void CSkill::addNewBonus(const std::shared_ptr<Bonus> & b, int level)
b->source = Bonus::SECONDARY_SKILL;
b->sid = id;
b->duration = Bonus::PERMANENT;
b->description = identifier;
b->description = name;
levels[level-1].effects.push_back(b);
}

View File

@ -1250,6 +1250,9 @@ std::string Bonus::Description() const
case SECONDARY_SKILL:
str << VLC->skillh->skillName(sid);
break;
case HERO_SPECIAL:
str << VLC->heroh->heroes[sid]->name;
break;
default:
//todo: handle all possible sources
str << "Unknown";

View File

@ -552,7 +552,7 @@ void CGHeroInstance::recreateSpecialtyBonuses(std::vector<HeroSpecial *> & speci
for(HeroSpecial * hs : specialtyDeprecated)
{
for(std::shared_ptr<Bonus> b : SpecialtyBonusToBonuses(HeroSpecialToSpecialtyBonus(*hs)))
for(std::shared_ptr<Bonus> b : SpecialtyBonusToBonuses(HeroSpecialToSpecialtyBonus(*hs), type->ID.getNum()))
addNewBonus(b);
}
}