mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
vcmi: use enum class for EComponentType
There is really no reason not to use it
This commit is contained in:
parent
2bd74e5c67
commit
bc228a938a
@ -632,7 +632,7 @@ void AIGateway::showBlockingDialog(const std::string & text, const std::vector<C
|
||||
// TODO: Find better way to understand it is Chest of Treasures
|
||||
if(hero.validAndSet()
|
||||
&& components.size() == 2
|
||||
&& components.front().id == Component::RESOURCE
|
||||
&& components.front().id == Component::EComponentType::RESOURCE
|
||||
&& (nullkiller->heroManager->getHeroRole(hero) != HeroRole::MAIN
|
||||
|| nullkiller->buildAnalyzer->getGoldPreasure() > MAX_GOLD_PEASURE))
|
||||
{
|
||||
|
@ -1719,7 +1719,7 @@ void CPlayerInterface::acceptTurn()
|
||||
auto playerColor = *cb->getPlayerID();
|
||||
|
||||
std::vector<Component> components;
|
||||
components.push_back(Component(Component::FLAG, playerColor.getNum(), 0, 0));
|
||||
components.emplace_back(Component::EComponentType::FLAG, playerColor.getNum(), 0, 0);
|
||||
MetaString text;
|
||||
|
||||
const auto & optDaysWithoutCastle = cb->getPlayerState(playerColor)->daysWithoutCastle;
|
||||
|
@ -336,15 +336,61 @@ void CInfoBar::pushComponents(const std::vector<Component> & components, std::st
|
||||
prepareComponents(components, message, timer);
|
||||
else
|
||||
{
|
||||
std::map<Component::EComponentType, std::vector<Component>> reward_map;
|
||||
std::array<std::pair<std::vector<Component>, int>, 10> reward_map;
|
||||
for(const auto & c : components)
|
||||
reward_map[static_cast<Component::EComponentType>(c.id)].push_back(c);
|
||||
{
|
||||
switch(c.id)
|
||||
{
|
||||
case Component::EComponentType::PRIM_SKILL:
|
||||
case Component::EComponentType::EXPERIENCE:
|
||||
reward_map.at(0).first.push_back(c);
|
||||
reward_map.at(0).second = 6; //At most 6, cannot be more
|
||||
break;
|
||||
case Component::EComponentType::SEC_SKILL:
|
||||
reward_map.at(1).first.push_back(c);
|
||||
reward_map.at(1).second = 8; //At most 8
|
||||
break;
|
||||
case Component::EComponentType::SPELL:
|
||||
reward_map.at(2).first.push_back(c);
|
||||
reward_map.at(2).second = 6; //At most 6
|
||||
break;
|
||||
case Component::EComponentType::ARTIFACT:
|
||||
reward_map.at(3).first.push_back(c);
|
||||
reward_map.at(3).second = 6; //At most 6
|
||||
break;
|
||||
case Component::EComponentType::CREATURE:
|
||||
reward_map.at(4).first.push_back(c);
|
||||
reward_map.at(4).second = 8; //At most 8
|
||||
break;
|
||||
case Component::EComponentType::RESOURCE:
|
||||
reward_map.at(5).first.push_back(c);
|
||||
reward_map.at(5).second = 7; //At most 7
|
||||
break;
|
||||
case Component::EComponentType::MORALE:
|
||||
case Component::EComponentType::LUCK:
|
||||
reward_map.at(6).first.push_back(c);
|
||||
reward_map.at(6).second = 2; //At most 2 - 1 for morale + 1 for luck
|
||||
break;
|
||||
case Component::EComponentType::BUILDING:
|
||||
reward_map.at(7).first.push_back(c);
|
||||
reward_map.at(7).second = 1; //At most 1 - only large icons available AFAIK
|
||||
break;
|
||||
case Component::EComponentType::HERO_PORTRAIT:
|
||||
reward_map.at(8).first.push_back(c);
|
||||
reward_map.at(8).second = 1; //I do not think than we even can get more than 1 hero
|
||||
break;
|
||||
case Component::EComponentType::FLAG:
|
||||
reward_map.at(9).first.push_back(c);
|
||||
reward_map.at(9).second = 1; //I do not think than we even can get more than 1 player in notification
|
||||
break;
|
||||
default:
|
||||
logGlobal->warn("Invalid component received!");
|
||||
}
|
||||
}
|
||||
|
||||
for(const auto & kv : reward_map)
|
||||
{
|
||||
auto vector = kv.second;
|
||||
actualPush(kv.second, message, timer, kv.first == Component::ARTIFACT ? 6 : 8);
|
||||
}
|
||||
if(!kv.first.empty())
|
||||
actualPush(kv.first, message, timer, kv.second);
|
||||
}
|
||||
popComponents();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ CComponent::CComponent(Etype Type, int Subtype, int Val, ESize imageSize, EFonts
|
||||
CComponent::CComponent(const Component & c, ESize imageSize, EFonts font)
|
||||
: perDay(false)
|
||||
{
|
||||
if(c.id == Component::RESOURCE && c.when==-1)
|
||||
if(c.id == Component::EComponentType::RESOURCE && c.when==-1)
|
||||
perDay = true;
|
||||
|
||||
init((Etype)c.id, c.subtype, c.val, imageSize, font);
|
||||
|
@ -197,8 +197,24 @@ public:
|
||||
|
||||
struct Component
|
||||
{
|
||||
enum EComponentType {PRIM_SKILL, SEC_SKILL, RESOURCE, CREATURE, ARTIFACT, EXPERIENCE, SPELL, MORALE, LUCK, BUILDING, HERO_PORTRAIT, FLAG};
|
||||
ui16 id = 0, subtype = 0; //id uses ^^^ enums, when id==EXPPERIENCE subtype==0 means exp points and subtype==1 levels)
|
||||
enum class EComponentType : uint8_t
|
||||
{
|
||||
PRIM_SKILL,
|
||||
SEC_SKILL,
|
||||
RESOURCE,
|
||||
CREATURE,
|
||||
ARTIFACT,
|
||||
EXPERIENCE,
|
||||
SPELL,
|
||||
MORALE,
|
||||
LUCK,
|
||||
BUILDING,
|
||||
HERO_PORTRAIT,
|
||||
FLAG,
|
||||
INVALID //should be last
|
||||
};
|
||||
EComponentType id = EComponentType::INVALID;
|
||||
ui16 subtype = 0; //id==EXPPERIENCE subtype==0 means exp points and subtype==1 levels
|
||||
si32 val = 0; // + give; - take
|
||||
si16 when = 0; // 0 - now; +x - within x days; -x - per x days
|
||||
|
||||
|
@ -2498,7 +2498,7 @@ void YourTurn::applyGs(CGameState * gs) const
|
||||
}
|
||||
|
||||
Component::Component(const CStackBasicDescriptor & stack)
|
||||
: id(CREATURE)
|
||||
: id(EComponentType::CREATURE)
|
||||
, subtype(stack.type->idNumber)
|
||||
, val(stack.count)
|
||||
{
|
||||
|
@ -190,7 +190,7 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
||||
break;
|
||||
}
|
||||
cb->giveHeroBonus(&gbonus);
|
||||
iw.components.emplace_back(Component::MORALE, 0, -1, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::MORALE, 0, -1, 0);
|
||||
iw.soundID = soundBase::GRAVEYARD;
|
||||
break;
|
||||
}
|
||||
@ -201,7 +201,7 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
||||
gb.id = hero->id.getNum();
|
||||
cb->giveHeroBonus(&gb);
|
||||
textID = 107;
|
||||
iw.components.emplace_back(Component::LUCK, 0, -2, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::LUCK, 0, -2, 0);
|
||||
break;
|
||||
}
|
||||
case Obj::CREATURE_BANK:
|
||||
@ -225,7 +225,7 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
||||
{
|
||||
if (bc->resources[it] != 0)
|
||||
{
|
||||
iw.components.emplace_back(Component::RESOURCE, it, bc->resources[it], 0);
|
||||
iw.components.emplace_back(Component::EComponentType::RESOURCE, it, bc->resources[it], 0);
|
||||
loot << "%d %s";
|
||||
loot.addReplacement(iw.components.back().val);
|
||||
loot.addReplacement(MetaString::RES_NAMES, iw.components.back().subtype);
|
||||
@ -235,7 +235,7 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
||||
//grant artifacts
|
||||
for (auto & elem : bc->artifacts)
|
||||
{
|
||||
iw.components.emplace_back(Component::ARTIFACT, elem, 0, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::ARTIFACT, elem, 0, 0);
|
||||
loot << "%s";
|
||||
loot.addReplacement(MetaString::ART_NAMES, elem);
|
||||
cb->giveHeroNewArtifact(hero, VLC->arth->objects[elem], ArtifactPosition::FIRST_AVAILABLE);
|
||||
@ -279,7 +279,7 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
||||
if(hero->canLearnSpell(spell))
|
||||
{
|
||||
spells.insert(spellId);
|
||||
iw.components.emplace_back(Component::SPELL, spellId, 0, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::SPELL, spellId, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -83,14 +83,14 @@ void CGPandoraBox::giveContentsUpToExp(const CGHeroInstance *h) const
|
||||
iw.text.addReplacement(h->getNameTranslated());
|
||||
|
||||
if(expVal)
|
||||
iw.components.emplace_back(Component::EXPERIENCE, 0, static_cast<si32>(expVal), 0);
|
||||
iw.components.emplace_back(Component::EComponentType::EXPERIENCE, 0, static_cast<si32>(expVal), 0);
|
||||
|
||||
for(int i=0; i<primskills.size(); i++)
|
||||
if(primskills[i])
|
||||
iw.components.emplace_back(Component::PRIM_SKILL, i, primskills[i], 0);
|
||||
iw.components.emplace_back(Component::EComponentType::PRIM_SKILL, i, primskills[i], 0);
|
||||
|
||||
for(const auto & abilityData : unpossessedAbilities)
|
||||
iw.components.emplace_back(Component::SEC_SKILL, abilityData.first, abilityData.second, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::SEC_SKILL, abilityData.first, abilityData.second, 0);
|
||||
|
||||
cb->showInfoDialog(&iw);
|
||||
|
||||
@ -144,7 +144,7 @@ void CGPandoraBox::giveContentsAfterExp(const CGHeroInstance *h) const
|
||||
const auto * spell = (*i).toSpell(VLC->spells());
|
||||
if(h->canLearnSpell(spell))
|
||||
{
|
||||
iw.components.emplace_back(Component::SPELL, *i, 0, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::SPELL, *i, 0, 0);
|
||||
spellsToGive.insert(*i);
|
||||
}
|
||||
if(spellsToGive.size() == 8) //display up to 8 spells at once
|
||||
@ -172,7 +172,7 @@ void CGPandoraBox::giveContentsAfterExp(const CGHeroInstance *h) const
|
||||
if(manaDiff)
|
||||
{
|
||||
getText(iw,hadGuardians,manaDiff,176,177,h);
|
||||
iw.components.emplace_back(Component::PRIM_SKILL, 5, manaDiff, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::PRIM_SKILL, 5, manaDiff, 0);
|
||||
cb->showInfoDialog(&iw);
|
||||
cb->setManaPoints(h->id, h->mana + manaDiff);
|
||||
}
|
||||
@ -180,7 +180,7 @@ void CGPandoraBox::giveContentsAfterExp(const CGHeroInstance *h) const
|
||||
if(moraleDiff)
|
||||
{
|
||||
getText(iw,hadGuardians,moraleDiff,178,179,h);
|
||||
iw.components.emplace_back(Component::MORALE, 0, moraleDiff, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::MORALE, 0, moraleDiff, 0);
|
||||
cb->showInfoDialog(&iw);
|
||||
GiveBonus gb;
|
||||
gb.bonus = Bonus(Bonus::ONE_BATTLE,Bonus::MORALE,Bonus::OBJECT,moraleDiff,id.getNum(),"");
|
||||
@ -191,7 +191,7 @@ void CGPandoraBox::giveContentsAfterExp(const CGHeroInstance *h) const
|
||||
if(luckDiff)
|
||||
{
|
||||
getText(iw,hadGuardians,luckDiff,180,181,h);
|
||||
iw.components.emplace_back(Component::LUCK, 0, luckDiff, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::LUCK, 0, luckDiff, 0);
|
||||
cb->showInfoDialog(&iw);
|
||||
GiveBonus gb;
|
||||
gb.bonus = Bonus(Bonus::ONE_BATTLE,Bonus::LUCK,Bonus::OBJECT,luckDiff,id.getNum(),"");
|
||||
@ -204,7 +204,7 @@ void CGPandoraBox::giveContentsAfterExp(const CGHeroInstance *h) const
|
||||
for(int i=0; i<resources.size(); i++)
|
||||
{
|
||||
if(resources[i] < 0)
|
||||
iw.components.emplace_back(Component::RESOURCE, i, resources[i], 0);
|
||||
iw.components.emplace_back(Component::EComponentType::RESOURCE, i, resources[i], 0);
|
||||
}
|
||||
if(!iw.components.empty())
|
||||
{
|
||||
@ -217,7 +217,7 @@ void CGPandoraBox::giveContentsAfterExp(const CGHeroInstance *h) const
|
||||
for(int i=0; i<resources.size(); i++)
|
||||
{
|
||||
if(resources[i] > 0)
|
||||
iw.components.emplace_back(Component::RESOURCE, i, resources[i], 0);
|
||||
iw.components.emplace_back(Component::EComponentType::RESOURCE, i, resources[i], 0);
|
||||
}
|
||||
if(!iw.components.empty())
|
||||
{
|
||||
@ -231,7 +231,7 @@ void CGPandoraBox::giveContentsAfterExp(const CGHeroInstance *h) const
|
||||
iw.text.addReplacement(h->getNameTranslated());
|
||||
for(const auto & elem : artifacts)
|
||||
{
|
||||
iw.components.emplace_back(Component::ARTIFACT, elem, 0, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::ARTIFACT, elem, 0, 0);
|
||||
if(iw.components.size() >= 14)
|
||||
{
|
||||
cb->showInfoDialog(&iw);
|
||||
|
@ -1735,31 +1735,31 @@ void CTownBonus::onHeroVisit (const CGHeroInstance * h) const
|
||||
case BuildingSubID::KNOWLEDGE_VISITING_BONUS: //wall of knowledge
|
||||
what = PrimarySkill::KNOWLEDGE;
|
||||
val = 1;
|
||||
iw.components.emplace_back(Component::PRIM_SKILL, 3, 1, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::PRIM_SKILL, 3, 1, 0);
|
||||
break;
|
||||
|
||||
case BuildingSubID::SPELL_POWER_VISITING_BONUS: //order of fire
|
||||
what = PrimarySkill::SPELL_POWER;
|
||||
val = 1;
|
||||
iw.components.emplace_back(Component::PRIM_SKILL, 2, 1, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::PRIM_SKILL, 2, 1, 0);
|
||||
break;
|
||||
|
||||
case BuildingSubID::ATTACK_VISITING_BONUS: //hall of Valhalla
|
||||
what = PrimarySkill::ATTACK;
|
||||
val = 1;
|
||||
iw.components.emplace_back(Component::PRIM_SKILL, 0, 1, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::PRIM_SKILL, 0, 1, 0);
|
||||
break;
|
||||
|
||||
case BuildingSubID::EXPERIENCE_VISITING_BONUS: //academy of battle scholars
|
||||
what = PrimarySkill::EXPERIENCE;
|
||||
val = static_cast<int>(h->calculateXp(1000));
|
||||
iw.components.emplace_back(Component::EXPERIENCE, 0, val, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::EXPERIENCE, 0, val, 0);
|
||||
break;
|
||||
|
||||
case BuildingSubID::DEFENSE_VISITING_BONUS: //cage of warlords
|
||||
what = PrimarySkill::DEFENSE;
|
||||
val = 1;
|
||||
iw.components.emplace_back(Component::PRIM_SKILL, 1, 1, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::PRIM_SKILL, 1, 1, 0);
|
||||
break;
|
||||
|
||||
case BuildingSubID::CUSTOM_VISITING_BONUS:
|
||||
|
@ -188,7 +188,7 @@ void CQuest::getVisitText(MetaString &iwText, std::vector<Component> &components
|
||||
switch (missionType)
|
||||
{
|
||||
case MISSION_LEVEL:
|
||||
components.emplace_back(Component::EXPERIENCE, 0, m13489val, 0);
|
||||
components.emplace_back(Component::EComponentType::EXPERIENCE, 0, m13489val, 0);
|
||||
if(!isCustom)
|
||||
iwText.addReplacement(m13489val);
|
||||
break;
|
||||
@ -199,7 +199,7 @@ void CQuest::getVisitText(MetaString &iwText, std::vector<Component> &components
|
||||
{
|
||||
if(m2stats[i])
|
||||
{
|
||||
components.emplace_back(Component::PRIM_SKILL, i, m2stats[i], 0);
|
||||
components.emplace_back(Component::EComponentType::PRIM_SKILL, i, m2stats[i], 0);
|
||||
loot << "%d %s";
|
||||
loot.addReplacement(m2stats[i]);
|
||||
loot.addReplacement(VLC->generaltexth->primarySkillNames[i]);
|
||||
@ -210,13 +210,13 @@ void CQuest::getVisitText(MetaString &iwText, std::vector<Component> &components
|
||||
}
|
||||
break;
|
||||
case MISSION_KILL_HERO:
|
||||
components.emplace_back(Component::HERO_PORTRAIT, heroPortrait, 0, 0);
|
||||
components.emplace_back(Component::EComponentType::HERO_PORTRAIT, heroPortrait, 0, 0);
|
||||
if(!isCustom)
|
||||
addReplacements(iwText, text);
|
||||
break;
|
||||
case MISSION_HERO:
|
||||
//FIXME: portrait may not match hero, if custom portrait was set in map editor
|
||||
components.emplace_back(Component::HERO_PORTRAIT, VLC->heroh->objects[m13489val]->imageIndex, 0, 0);
|
||||
components.emplace_back(Component::EComponentType::HERO_PORTRAIT, VLC->heroh->objects[m13489val]->imageIndex, 0, 0);
|
||||
if(!isCustom)
|
||||
iwText.addReplacement(VLC->heroh->objects[m13489val]->getNameTranslated());
|
||||
break;
|
||||
@ -234,7 +234,7 @@ void CQuest::getVisitText(MetaString &iwText, std::vector<Component> &components
|
||||
MetaString loot;
|
||||
for(const auto & elem : m5arts)
|
||||
{
|
||||
components.emplace_back(Component::ARTIFACT, elem, 0, 0);
|
||||
components.emplace_back(Component::EComponentType::ARTIFACT, elem, 0, 0);
|
||||
loot << "%s";
|
||||
loot.addReplacement(MetaString::ART_NAMES, elem);
|
||||
}
|
||||
@ -262,7 +262,7 @@ void CQuest::getVisitText(MetaString &iwText, std::vector<Component> &components
|
||||
{
|
||||
if(m7resources[i])
|
||||
{
|
||||
components.emplace_back(Component::RESOURCE, i, m7resources[i], 0);
|
||||
components.emplace_back(Component::EComponentType::RESOURCE, i, m7resources[i], 0);
|
||||
loot << "%d %s";
|
||||
loot.addReplacement(m7resources[i]);
|
||||
loot.addReplacement(MetaString::RES_NAMES, i);
|
||||
@ -273,7 +273,7 @@ void CQuest::getVisitText(MetaString &iwText, std::vector<Component> &components
|
||||
}
|
||||
break;
|
||||
case MISSION_PLAYER:
|
||||
components.emplace_back(Component::FLAG, m13489val, 0, 0);
|
||||
components.emplace_back(Component::EComponentType::FLAG, m13489val, 0, 0);
|
||||
if(!isCustom)
|
||||
iwText.addReplacement(VLC->generaltexth->colors[m13489val]);
|
||||
break;
|
||||
@ -646,34 +646,34 @@ void CGSeerHut::getCompletionText(MetaString &text, std::vector<Component> &comp
|
||||
switch(rewardType)
|
||||
{
|
||||
case EXPERIENCE:
|
||||
components.emplace_back(Component::EXPERIENCE, 0, static_cast<si32>(h->calculateXp(rVal)), 0);
|
||||
components.emplace_back(Component::EComponentType::EXPERIENCE, 0, static_cast<si32>(h->calculateXp(rVal)), 0);
|
||||
break;
|
||||
case MANA_POINTS:
|
||||
components.emplace_back(Component::PRIM_SKILL, 5, rVal, 0);
|
||||
components.emplace_back(Component::EComponentType::PRIM_SKILL, 5, rVal, 0);
|
||||
break;
|
||||
case MORALE_BONUS:
|
||||
components.emplace_back(Component::MORALE, 0, rVal, 0);
|
||||
components.emplace_back(Component::EComponentType::MORALE, 0, rVal, 0);
|
||||
break;
|
||||
case LUCK_BONUS:
|
||||
components.emplace_back(Component::LUCK, 0, rVal, 0);
|
||||
components.emplace_back(Component::EComponentType::LUCK, 0, rVal, 0);
|
||||
break;
|
||||
case RESOURCES:
|
||||
components.emplace_back(Component::RESOURCE, rID, rVal, 0);
|
||||
components.emplace_back(Component::EComponentType::RESOURCE, rID, rVal, 0);
|
||||
break;
|
||||
case PRIMARY_SKILL:
|
||||
components.emplace_back(Component::PRIM_SKILL, rID, rVal, 0);
|
||||
components.emplace_back(Component::EComponentType::PRIM_SKILL, rID, rVal, 0);
|
||||
break;
|
||||
case SECONDARY_SKILL:
|
||||
components.emplace_back(Component::SEC_SKILL, rID, rVal, 0);
|
||||
components.emplace_back(Component::EComponentType::SEC_SKILL, rID, rVal, 0);
|
||||
break;
|
||||
case ARTIFACT:
|
||||
components.emplace_back(Component::ARTIFACT, rID, 0, 0);
|
||||
components.emplace_back(Component::EComponentType::ARTIFACT, rID, 0, 0);
|
||||
break;
|
||||
case SPELL:
|
||||
components.emplace_back(Component::SPELL, rID, 0, 0);
|
||||
components.emplace_back(Component::EComponentType::SPELL, rID, 0, 0);
|
||||
break;
|
||||
case CREATURE:
|
||||
components.emplace_back(Component::CREATURE, rID, rVal, 0);
|
||||
components.emplace_back(Component::EComponentType::CREATURE, rID, rVal, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -116,9 +116,9 @@ void CRandomRewardObjectInfo::configureReward(CRewardableObject * object, CRando
|
||||
bonus.sid = object->ID;
|
||||
//TODO: bonus.description = object->getObjectName();
|
||||
if (bonus.type == Bonus::MORALE)
|
||||
reward.extraComponents.emplace_back(Component::MORALE, 0, bonus.val, 0);
|
||||
reward.extraComponents.emplace_back(Component::EComponentType::MORALE, 0, bonus.val, 0);
|
||||
if (bonus.type == Bonus::LUCK)
|
||||
reward.extraComponents.emplace_back(Component::LUCK, 0, bonus.val, 0);
|
||||
reward.extraComponents.emplace_back(Component::EComponentType::LUCK, 0, bonus.val, 0);
|
||||
}
|
||||
|
||||
reward.primary = JsonRandom::loadPrimary(source["primary"], rng);
|
||||
@ -137,7 +137,7 @@ void CRandomRewardObjectInfo::configureReward(CRewardableObject * object, CRando
|
||||
CreatureID from (VLC->modh->identifiers.getIdentifier (node.second.meta, "creature", node.first) .get());
|
||||
CreatureID dest (VLC->modh->identifiers.getIdentifier (node.second.meta, "creature", node.second.String()).get());
|
||||
|
||||
reward.extraComponents.emplace_back(Component::CREATURE, dest.getNum(), 0, 0);
|
||||
reward.extraComponents.emplace_back(Component::EComponentType::CREATURE, dest.getNum(), 0, 0);
|
||||
|
||||
reward.creaturesChange[from] = dest;
|
||||
}
|
||||
|
@ -432,36 +432,36 @@ void CRewardInfo::loadComponents(std::vector<Component> & comps,
|
||||
|
||||
if (heroExperience)
|
||||
{
|
||||
comps.emplace_back(Component::EXPERIENCE, 0, static_cast<si32>(h->calculateXp(heroExperience)), 0);
|
||||
comps.emplace_back(Component::EComponentType::EXPERIENCE, 0, static_cast<si32>(h->calculateXp(heroExperience)), 0);
|
||||
}
|
||||
if (heroLevel)
|
||||
comps.emplace_back(Component::EXPERIENCE, 1, heroLevel, 0);
|
||||
comps.emplace_back(Component::EComponentType::EXPERIENCE, 1, heroLevel, 0);
|
||||
|
||||
if (manaDiff || manaPercentage >= 0)
|
||||
comps.emplace_back(Component::PRIM_SKILL, 5, calculateManaPoints(h) - h->mana, 0);
|
||||
comps.emplace_back(Component::EComponentType::PRIM_SKILL, 5, calculateManaPoints(h) - h->mana, 0);
|
||||
|
||||
for (size_t i=0; i<primary.size(); i++)
|
||||
{
|
||||
if (primary[i] != 0)
|
||||
comps.emplace_back(Component::PRIM_SKILL, static_cast<ui16>(i), primary[i], 0);
|
||||
comps.emplace_back(Component::EComponentType::PRIM_SKILL, static_cast<ui16>(i), primary[i], 0);
|
||||
}
|
||||
|
||||
for(const auto & entry : secondary)
|
||||
comps.emplace_back(Component::SEC_SKILL, entry.first, entry.second, 0);
|
||||
comps.emplace_back(Component::EComponentType::SEC_SKILL, entry.first, entry.second, 0);
|
||||
|
||||
for(const auto & entry : artifacts)
|
||||
comps.emplace_back(Component::ARTIFACT, entry, 1, 0);
|
||||
comps.emplace_back(Component::EComponentType::ARTIFACT, entry, 1, 0);
|
||||
|
||||
for(const auto & entry : spells)
|
||||
comps.emplace_back(Component::SPELL, entry, 1, 0);
|
||||
comps.emplace_back(Component::EComponentType::SPELL, entry, 1, 0);
|
||||
|
||||
for(const auto & entry : creatures)
|
||||
comps.emplace_back(Component::CREATURE, entry.type->idNumber, entry.count, 0);
|
||||
comps.emplace_back(Component::EComponentType::CREATURE, entry.type->idNumber, entry.count, 0);
|
||||
|
||||
for (size_t i=0; i<resources.size(); i++)
|
||||
{
|
||||
if (resources[i] !=0)
|
||||
comps.emplace_back(Component::RESOURCE, static_cast<ui16>(i), resources[i], 0);
|
||||
comps.emplace_back(Component::EComponentType::RESOURCE, static_cast<ui16>(i), resources[i], 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -562,14 +562,14 @@ void CGCreature::giveReward(const CGHeroInstance * h) const
|
||||
for(int i = 0; i < resources.size(); i++)
|
||||
{
|
||||
if(resources[i] > 0)
|
||||
iw.components.emplace_back(Component::RESOURCE, i, resources[i], 0);
|
||||
iw.components.emplace_back(Component::EComponentType::RESOURCE, i, resources[i], 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(gainedArtifact != ArtifactID::NONE)
|
||||
{
|
||||
cb->giveHeroNewArtifact(h, VLC->arth->objects[gainedArtifact], ArtifactPosition::FIRST_AVAILABLE);
|
||||
iw.components.emplace_back(Component::ARTIFACT, gainedArtifact, 0, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::ARTIFACT, gainedArtifact, 0, 0);
|
||||
}
|
||||
|
||||
if(!iw.components.empty())
|
||||
@ -720,7 +720,7 @@ void CGMine::flagMine(const PlayerColor & player) const
|
||||
iw.soundID = soundBase::FLAGMINE;
|
||||
iw.text.addTxt(MetaString::MINE_EVNTS,producedResource); //not use subID, abandoned mines uses default mine texts
|
||||
iw.player = player;
|
||||
iw.components.emplace_back(Component::RESOURCE, producedResource, producedQuantity, -1);
|
||||
iw.components.emplace_back(Component::EComponentType::RESOURCE, producedResource, producedQuantity, -1);
|
||||
cb->showInfoDialog(&iw);
|
||||
}
|
||||
|
||||
@ -877,7 +877,7 @@ void CGResource::collectRes(const PlayerColor & player) const
|
||||
sii.text.addTxt(MetaString::ADVOB_TXT,113);
|
||||
sii.text.addReplacement(MetaString::RES_NAMES, subID);
|
||||
}
|
||||
sii.components.emplace_back(Component::RESOURCE,subID,amount,0);
|
||||
sii.components.emplace_back(Component::EComponentType::RESOURCE,subID,amount,0);
|
||||
sii.soundID = soundBase::pickup01 + CRandomGenerator::getDefault().nextInt(6);
|
||||
cb->showInfoDialog(&sii);
|
||||
cb->removeObject(this);
|
||||
@ -1303,7 +1303,7 @@ void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
|
||||
{
|
||||
case Obj::ARTIFACT:
|
||||
{
|
||||
iw.components.emplace_back(Component::ARTIFACT, subID, 0, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::ARTIFACT, subID, 0, 0);
|
||||
if(message.length())
|
||||
iw.text << message;
|
||||
else
|
||||
@ -1313,7 +1313,7 @@ void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
|
||||
case Obj::SPELL_SCROLL:
|
||||
{
|
||||
int spellID = storedArtifact->getGivenSpellID();
|
||||
iw.components.emplace_back(Component::SPELL, spellID, 0, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::SPELL, spellID, 0, 0);
|
||||
if(message.length())
|
||||
iw.text << message;
|
||||
else
|
||||
@ -1441,7 +1441,7 @@ void CGWitchHut::onHeroVisit( const CGHeroInstance * h ) const
|
||||
}
|
||||
else //give sec skill
|
||||
{
|
||||
iw.components.emplace_back(Component::SEC_SKILL, ability, 1, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::SEC_SKILL, ability, 1, 0);
|
||||
txt_id = 171;
|
||||
cb->changeSecSkill(h, SecondarySkill(ability), 1, true);
|
||||
}
|
||||
@ -1568,7 +1568,7 @@ void CGShrine::onHeroVisit( const CGHeroInstance * h ) const
|
||||
spells.insert(spell);
|
||||
cb->changeSpells(h, true, spells);
|
||||
|
||||
iw.components.emplace_back(Component::SPELL, spell, 0, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::SPELL, spell, 0, 0);
|
||||
}
|
||||
|
||||
cb->showInfoDialog(&iw);
|
||||
@ -1670,18 +1670,18 @@ void CGScholar::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
case PRIM_SKILL:
|
||||
cb->changePrimSkill(h,static_cast<PrimarySkill::PrimarySkill>(bid),+1);
|
||||
iw.components.emplace_back(Component::PRIM_SKILL, bid, +1, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::PRIM_SKILL, bid, +1, 0);
|
||||
break;
|
||||
case SECONDARY_SKILL:
|
||||
cb->changeSecSkill(h,SecondarySkill(bid),+1);
|
||||
iw.components.emplace_back(Component::SEC_SKILL, bid, ssl + 1, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::SEC_SKILL, bid, ssl + 1, 0);
|
||||
break;
|
||||
case SPELL:
|
||||
{
|
||||
std::set<SpellID> hlp;
|
||||
hlp.insert(SpellID(bid));
|
||||
cb->changeSpells(h,true,hlp);
|
||||
iw.components.emplace_back(Component::SPELL, bid, 0, 0);
|
||||
iw.components.emplace_back(Component::EComponentType::SPELL, bid, 0, 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -505,7 +505,7 @@ ESpellCastResult TownPortalMechanics::beginCast(SpellCastEnvironment * env, cons
|
||||
request.player = parameters.caster->getOwner();
|
||||
request.title.addTxt(MetaString::JK_TXT, 40);
|
||||
request.description.addTxt(MetaString::JK_TXT, 41);
|
||||
request.icon.id = Component::SPELL;
|
||||
request.icon.id = Component::EComponentType::SPELL;
|
||||
request.icon.subtype = owner->id.toEnum();
|
||||
|
||||
env->genericQuery(&request, request.player, queryCallback);
|
||||
|
@ -837,9 +837,9 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance * heroAttacker, con
|
||||
|
||||
for (auto art : arts) //TODO; separate function to display loot for various ojects?
|
||||
{
|
||||
iw.components.push_back(Component(
|
||||
Component::ARTIFACT, art->artType->getId(),
|
||||
art->artType->getId() == ArtifactID::SPELL_SCROLL? art->getGivenSpellID() : 0, 0));
|
||||
iw.components.emplace_back(
|
||||
Component::EComponentType::ARTIFACT, art->artType->getId(),
|
||||
art->artType->getId() == ArtifactID::SPELL_SCROLL? art->getGivenSpellID() : 0, 0);
|
||||
if (iw.components.size() >= 14)
|
||||
{
|
||||
sendAndApply(&iw);
|
||||
@ -881,7 +881,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance * heroAttacker, con
|
||||
iw.text.addReplacement(MetaString::SPELL_NAME, it->toEnum());
|
||||
if (i == cs.spells.size() - 2) //we just added pre-last name
|
||||
iw.text.addReplacement(MetaString::GENERAL_TXT, 141); // " and "
|
||||
iw.components.push_back(Component(Component::SPELL, *it, 0, 0));
|
||||
iw.components.emplace_back(Component::EComponentType::SPELL, *it, 0, 0);
|
||||
}
|
||||
sendAndApply(&iw);
|
||||
sendAndApply(&cs);
|
||||
@ -2818,7 +2818,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
||||
h2->getSecSkillLevel(SecondarySkill::SCHOLAR));
|
||||
InfoWindow iw;
|
||||
iw.player = h1->tempOwner;
|
||||
iw.components.push_back(Component(Component::SEC_SKILL, 18, ScholarSkillLevel, 0));
|
||||
iw.components.emplace_back(Component::EComponentType::SEC_SKILL, 18, ScholarSkillLevel, 0);
|
||||
|
||||
iw.text.addTxt(MetaString::GENERAL_TXT, 139);//"%s, who has studied magic extensively,
|
||||
iw.text.addReplacement(h1->getNameTranslated());
|
||||
@ -2829,7 +2829,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
||||
int size = static_cast<int>(cs2.spells.size());
|
||||
for (auto it : cs2.spells)
|
||||
{
|
||||
iw.components.push_back(Component(Component::SPELL, it, 1, 0));
|
||||
iw.components.emplace_back(Component::EComponentType::SPELL, it, 1, 0);
|
||||
iw.text.addTxt(MetaString::SPELL_NAME, it.toEnum());
|
||||
switch (size--)
|
||||
{
|
||||
@ -2854,7 +2854,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
||||
int size = static_cast<int>(cs1.spells.size());
|
||||
for (auto it : cs1.spells)
|
||||
{
|
||||
iw.components.push_back(Component(Component::SPELL, it, 1, 0));
|
||||
iw.components.emplace_back(Component::EComponentType::SPELL, it, 1, 0);
|
||||
iw.text.addTxt(MetaString::SPELL_NAME, it.toEnum());
|
||||
switch (size--)
|
||||
{
|
||||
@ -5578,7 +5578,7 @@ void CGameHandler::handleTimeEvents()
|
||||
for (int i=0; i<ev.resources.size(); i++)
|
||||
{
|
||||
if (ev.resources.at(i)) //if resource is changed, we add it to the dialog
|
||||
iw.components.push_back(Component(Component::RESOURCE,i,ev.resources.at(i),0));
|
||||
iw.components.emplace_back(Component::EComponentType::RESOURCE,i,ev.resources.at(i),0);
|
||||
}
|
||||
|
||||
sendAndApply(&iw); //show dialog
|
||||
@ -5636,7 +5636,7 @@ void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n)
|
||||
|
||||
for (int i=0; i<ev.resources.size(); i++)
|
||||
if (ev.resources.at(i) && pinfo->resources.at(i) != n.res.at(player).at(i)) //if resource had changed, we add it to the dialog
|
||||
iw.components.push_back(Component(Component::RESOURCE,i,n.res.at(player).at(i)-was.at(i),0));
|
||||
iw.components.emplace_back(Component::EComponentType::RESOURCE,i,n.res.at(player).at(i)-was.at(i),0);
|
||||
|
||||
}
|
||||
|
||||
@ -5645,7 +5645,7 @@ void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n)
|
||||
if (!town->hasBuilt(i))
|
||||
{
|
||||
buildStructure(town->id, i, true);
|
||||
iw.components.push_back(Component(Component::BUILDING, town->subID, i, 0));
|
||||
iw.components.emplace_back(Component::EComponentType::BUILDING, town->subID, i, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5661,8 +5661,8 @@ void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n)
|
||||
if (!town->creatures.at(i).second.empty() && ev.creatures.at(i) > 0)//there is dwelling
|
||||
{
|
||||
sac.creatures[i].first += ev.creatures.at(i);
|
||||
iw.components.push_back(Component(Component::CREATURE,
|
||||
town->creatures.at(i).second.back(), ev.creatures.at(i), 0));
|
||||
iw.components.emplace_back(Component::EComponentType::CREATURE,
|
||||
town->creatures.at(i).second.back(), ev.creatures.at(i), 0);
|
||||
}
|
||||
}
|
||||
sendAndApply(&iw); //show dialog
|
||||
@ -6024,7 +6024,7 @@ void CGameHandler::getVictoryLossMessage(PlayerColor player, const EVictoryLossC
|
||||
if (victoryLossCheckResult.messageToSelf.find("%s") != std::string::npos)
|
||||
out.text.addReplacement(MetaString::COLOR, player.getNum());
|
||||
|
||||
out.components.push_back(Component(Component::FLAG, player.getNum(), 0, 0));
|
||||
out.components.emplace_back(Component::EComponentType::FLAG, player.getNum(), 0, 0);
|
||||
}
|
||||
|
||||
bool CGameHandler::dig(const CGHeroInstance *h)
|
||||
|
Loading…
Reference in New Issue
Block a user