1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-02 00:10:22 +02:00

Converted several namespace enums to enum class

This commit is contained in:
Ivan Savenko 2023-08-19 21:43:50 +03:00
parent 17d3d663ee
commit 62cd8b12d4
71 changed files with 227 additions and 238 deletions

View File

@ -45,7 +45,7 @@ void CEmptyAI::yourTacticPhase(int distance)
cb->battleMakeTacticAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide())); cb->battleMakeTacticAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide()));
} }
void CEmptyAI::heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) void CEmptyAI::heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID)
{ {
cb->selectionMade(CRandomGenerator::getDefault().nextInt((int)skills.size() - 1), queryID); cb->selectionMade(CRandomGenerator::getDefault().nextInt((int)skills.size() - 1), queryID);
} }

View File

@ -26,7 +26,7 @@ public:
void yourTurn() override; void yourTurn() override;
void yourTacticPhase(int distance) override; void yourTacticPhase(int distance) override;
void activeStack(const CStack * stack) override; void activeStack(const CStack * stack) override;
void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) override; void heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) override;
void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override; void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override;
void showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, const int soundID, bool selection, bool cancel) override; void showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, const int soundID, bool selection, bool cancel) override;
void showTeleportDialog(TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID) override; void showTeleportDialog(TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID) override;

View File

@ -314,9 +314,9 @@ void AIGateway::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID her
}); });
} }
void AIGateway::heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) void AIGateway::heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val)
{ {
LOG_TRACE_PARAMS(logAi, "which '%i', val '%i'", which % val); LOG_TRACE_PARAMS(logAi, "which '%i', val '%i'", static_cast<int>(which) % val);
NET_EVENT_HANDLER; NET_EVENT_HANDLER;
} }
@ -552,7 +552,7 @@ void AIGateway::yourTurn()
makingTurn = std::make_unique<boost::thread>(&AIGateway::makeTurn, this); makingTurn = std::make_unique<boost::thread>(&AIGateway::makeTurn, this);
} }
void AIGateway::heroGotLevel(const CGHeroInstance * hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> & skills, QueryID queryID) void AIGateway::heroGotLevel(const CGHeroInstance * hero, PrimarySkill pskill, std::vector<SecondarySkill> & skills, QueryID queryID)
{ {
LOG_TRACE_PARAMS(logAi, "queryID '%i'", queryID); LOG_TRACE_PARAMS(logAi, "queryID '%i'", queryID);
NET_EVENT_HANDLER; NET_EVENT_HANDLER;

View File

@ -113,7 +113,7 @@ public:
void initGameInterface(std::shared_ptr<Environment> env, std::shared_ptr<CCallback> CB) override; void initGameInterface(std::shared_ptr<Environment> env, std::shared_ptr<CCallback> CB) override;
void yourTurn() override; void yourTurn() override;
void heroGotLevel(const CGHeroInstance * hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> & skills, QueryID queryID) override; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id void heroGotLevel(const CGHeroInstance * hero, PrimarySkill pskill, std::vector<SecondarySkill> & skills, QueryID queryID) override; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id
void commanderGotLevel(const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override; //TODO void commanderGotLevel(const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override; //TODO
void showBlockingDialog(const std::string & text, const std::vector<Component> & components, QueryID askID, const int soundID, bool selection, bool cancel) override; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID. void showBlockingDialog(const std::string & text, const std::vector<Component> & components, QueryID askID, const int soundID, bool selection, bool cancel) override; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
void showGarrisonDialog(const CArmedInstance * up, const CGHeroInstance * down, bool removableUnits, QueryID queryID) override; //all stacks operations between these objects become allowed, interface has to call onEnd when done void showGarrisonDialog(const CArmedInstance * up, const CGHeroInstance * down, bool removableUnits, QueryID queryID) override; //all stacks operations between these objects become allowed, interface has to call onEnd when done
@ -144,7 +144,7 @@ public:
void heroVisitsTown(const CGHeroInstance * hero, const CGTownInstance * town) override; void heroVisitsTown(const CGHeroInstance * hero, const CGTownInstance * town) override;
void tileRevealed(const std::unordered_set<int3> & pos) override; void tileRevealed(const std::unordered_set<int3> & pos) override;
void heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query) override; void heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query) override;
void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) override; void heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val) override;
void showRecruitmentDialog(const CGDwelling * dwelling, const CArmedInstance * dst, int level) override; void showRecruitmentDialog(const CGDwelling * dwelling, const CArmedInstance * dst, int level) override;
void heroMovePointsChanged(const CGHeroInstance * hero) override; void heroMovePointsChanged(const CGHeroInstance * hero) override;
void garrisonsChanged(ObjectInstanceID id1, ObjectInstanceID id2) override; void garrisonsChanged(ObjectInstanceID id1, ObjectInstanceID id2) override;

View File

@ -241,7 +241,7 @@ bool isObjectPassable(const CGObjectInstance * obj)
} }
// Pathfinder internal helper // Pathfinder internal helper
bool isObjectPassable(const CGObjectInstance * obj, PlayerColor playerColor, PlayerRelations::PlayerRelations objectRelations) bool isObjectPassable(const CGObjectInstance * obj, PlayerColor playerColor, PlayerRelations objectRelations)
{ {
if((obj->ID == Obj::GARRISON || obj->ID == Obj::GARRISON2) if((obj->ID == Obj::GARRISON || obj->ID == Obj::GARRISON2)
&& objectRelations != PlayerRelations::ENEMIES) && objectRelations != PlayerRelations::ENEMIES)

View File

@ -226,7 +226,7 @@ void foreach_neighbour(CCallback * cbp, const int3 & pos, const Func & foo) // a
bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater); bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater);
bool isObjectPassable(const CGObjectInstance * obj); bool isObjectPassable(const CGObjectInstance * obj);
bool isObjectPassable(const Nullkiller * ai, const CGObjectInstance * obj); bool isObjectPassable(const Nullkiller * ai, const CGObjectInstance * obj);
bool isObjectPassable(const CGObjectInstance * obj, PlayerColor playerColor, PlayerRelations::PlayerRelations objectRelations); bool isObjectPassable(const CGObjectInstance * obj, PlayerColor playerColor, PlayerRelations objectRelations);
bool isBlockVisitObj(const int3 & pos); bool isBlockVisitObj(const int3 & pos);
bool isWeeklyRevisitable(const CGObjectInstance * obj); bool isWeeklyRevisitable(const CGObjectInstance * obj);

View File

@ -244,10 +244,10 @@ uint64_t evaluateArtifactArmyValue(CArtifactInstance * art)
10 * art->valOfBonuses(BonusType::MOVEMENT, 1) 10 * art->valOfBonuses(BonusType::MOVEMENT, 1)
+ 1200 * art->valOfBonuses(BonusType::STACKS_SPEED) + 1200 * art->valOfBonuses(BonusType::STACKS_SPEED)
+ 700 * art->valOfBonuses(BonusType::MORALE) + 700 * art->valOfBonuses(BonusType::MORALE)
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK) + 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::ATTACK))
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE) + 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::DEFENSE))
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, PrimarySkill::KNOWLEDGE) + 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::KNOWLEDGE))
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, PrimarySkill::SPELL_POWER) + 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::SPELL_POWER))
+ 500 * art->valOfBonuses(BonusType::LUCK); + 500 * art->valOfBonuses(BonusType::LUCK);
auto classValue = 0; auto classValue = 0;

View File

@ -351,9 +351,9 @@ void VCAI::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, Q
}); });
} }
void VCAI::heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) void VCAI::heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val)
{ {
LOG_TRACE_PARAMS(logAi, "which '%i', val '%i'", which % val); LOG_TRACE_PARAMS(logAi, "which '%i', val '%i'", static_cast<int>(which) % val);
NET_EVENT_HANDLER; NET_EVENT_HANDLER;
} }
@ -618,7 +618,7 @@ void VCAI::yourTurn()
makingTurn = std::make_unique<boost::thread>(&VCAI::makeTurn, this); makingTurn = std::make_unique<boost::thread>(&VCAI::makeTurn, this);
} }
void VCAI::heroGotLevel(const CGHeroInstance * hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> & skills, QueryID queryID) void VCAI::heroGotLevel(const CGHeroInstance * hero, PrimarySkill pskill, std::vector<SecondarySkill> & skills, QueryID queryID)
{ {
LOG_TRACE_PARAMS(logAi, "queryID '%i'", queryID); LOG_TRACE_PARAMS(logAi, "queryID '%i'", queryID);
NET_EVENT_HANDLER; NET_EVENT_HANDLER;

View File

@ -146,7 +146,7 @@ public:
void initGameInterface(std::shared_ptr<Environment> ENV, std::shared_ptr<CCallback> CB) override; void initGameInterface(std::shared_ptr<Environment> ENV, std::shared_ptr<CCallback> CB) override;
void yourTurn() override; void yourTurn() override;
void heroGotLevel(const CGHeroInstance * hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> & skills, QueryID queryID) override; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id void heroGotLevel(const CGHeroInstance * hero, PrimarySkill pskill, std::vector<SecondarySkill> & skills, QueryID queryID) override; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id
void commanderGotLevel(const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override; //TODO void commanderGotLevel(const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override; //TODO
void showBlockingDialog(const std::string & text, const std::vector<Component> & components, QueryID askID, const int soundID, bool selection, bool cancel) override; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID. void showBlockingDialog(const std::string & text, const std::vector<Component> & components, QueryID askID, const int soundID, bool selection, bool cancel) override; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
void showGarrisonDialog(const CArmedInstance * up, const CGHeroInstance * down, bool removableUnits, QueryID queryID) override; //all stacks operations between these objects become allowed, interface has to call onEnd when done void showGarrisonDialog(const CArmedInstance * up, const CGHeroInstance * down, bool removableUnits, QueryID queryID) override; //all stacks operations between these objects become allowed, interface has to call onEnd when done
@ -177,7 +177,7 @@ public:
void heroVisitsTown(const CGHeroInstance * hero, const CGTownInstance * town) override; void heroVisitsTown(const CGHeroInstance * hero, const CGTownInstance * town) override;
void tileRevealed(const std::unordered_set<int3> & pos) override; void tileRevealed(const std::unordered_set<int3> & pos) override;
void heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query) override; void heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query) override;
void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) override; void heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val) override;
void showRecruitmentDialog(const CGDwelling * dwelling, const CArmedInstance * dst, int level) override; void showRecruitmentDialog(const CGDwelling * dwelling, const CArmedInstance * dst, int level) override;
void heroMovePointsChanged(const CGHeroInstance * hero) override; void heroMovePointsChanged(const CGHeroInstance * hero) override;
void garrisonsChanged(ObjectInstanceID id1, ObjectInstanceID id2) override; void garrisonsChanged(ObjectInstanceID id1, ObjectInstanceID id2) override;

View File

@ -242,12 +242,12 @@ void CCallback::buyArtifact(const CGHeroInstance *hero, ArtifactID aid)
sendRequest(&pack); sendRequest(&pack);
} }
void CCallback::trade(const IMarket * market, EMarketMode::EMarketMode mode, ui32 id1, ui32 id2, ui32 val1, const CGHeroInstance * hero) void CCallback::trade(const IMarket * market, EMarketMode mode, ui32 id1, ui32 id2, ui32 val1, const CGHeroInstance * hero)
{ {
trade(market, mode, std::vector<ui32>(1, id1), std::vector<ui32>(1, id2), std::vector<ui32>(1, val1), hero); trade(market, mode, std::vector<ui32>(1, id1), std::vector<ui32>(1, id2), std::vector<ui32>(1, val1), hero);
} }
void CCallback::trade(const IMarket * market, EMarketMode::EMarketMode mode, const std::vector<ui32> & id1, const std::vector<ui32> & id2, const std::vector<ui32> & val1, const CGHeroInstance * hero) void CCallback::trade(const IMarket * market, EMarketMode mode, const std::vector<ui32> & id1, const std::vector<ui32> & id2, const std::vector<ui32> & val1, const CGHeroInstance * hero)
{ {
TradeOnMarketplace pack; TradeOnMarketplace pack;
pack.marketId = dynamic_cast<const CGObjectInstance *>(market)->id; pack.marketId = dynamic_cast<const CGObjectInstance *>(market)->id;

View File

@ -75,8 +75,8 @@ public:
virtual bool upgradeCreature(const CArmedInstance *obj, SlotID stackPos, CreatureID newID=CreatureID::NONE)=0; //if newID==-1 then best possible upgrade will be made virtual bool upgradeCreature(const CArmedInstance *obj, SlotID stackPos, CreatureID newID=CreatureID::NONE)=0; //if newID==-1 then best possible upgrade will be made
virtual void swapGarrisonHero(const CGTownInstance *town)=0; virtual void swapGarrisonHero(const CGTownInstance *town)=0;
virtual void trade(const IMarket * market, EMarketMode::EMarketMode mode, ui32 id1, ui32 id2, ui32 val1, const CGHeroInstance * hero = nullptr)=0; //mode==0: sell val1 units of id1 resource for id2 resiurce virtual void trade(const IMarket * market, EMarketMode mode, ui32 id1, ui32 id2, ui32 val1, const CGHeroInstance * hero = nullptr)=0; //mode==0: sell val1 units of id1 resource for id2 resiurce
virtual void trade(const IMarket * market, EMarketMode::EMarketMode mode, const std::vector<ui32> & id1, const std::vector<ui32> & id2, const std::vector<ui32> & val1, const CGHeroInstance * hero = nullptr)=0; virtual void trade(const IMarket * market, EMarketMode mode, const std::vector<ui32> & id1, const std::vector<ui32> & id2, const std::vector<ui32> & val1, const CGHeroInstance * hero = nullptr)=0;
virtual int selectionMade(int selection, QueryID queryID) =0; virtual int selectionMade(int selection, QueryID queryID) =0;
virtual int sendQueryReply(const JsonNode & reply, QueryID queryID) =0; virtual int sendQueryReply(const JsonNode & reply, QueryID queryID) =0;
@ -171,8 +171,8 @@ public:
void endTurn() override; void endTurn() override;
void swapGarrisonHero(const CGTownInstance *town) override; void swapGarrisonHero(const CGTownInstance *town) override;
void buyArtifact(const CGHeroInstance *hero, ArtifactID aid) override; void buyArtifact(const CGHeroInstance *hero, ArtifactID aid) override;
void trade(const IMarket * market, EMarketMode::EMarketMode mode, ui32 id1, ui32 id2, ui32 val1, const CGHeroInstance * hero = nullptr) override; void trade(const IMarket * market, EMarketMode mode, ui32 id1, ui32 id2, ui32 val1, const CGHeroInstance * hero = nullptr) override;
void trade(const IMarket * market, EMarketMode::EMarketMode mode, const std::vector<ui32> & id1, const std::vector<ui32> & id2, const std::vector<ui32> & val1, const CGHeroInstance * hero = nullptr) override; void trade(const IMarket * market, EMarketMode mode, const std::vector<ui32> & id1, const std::vector<ui32> & id2, const std::vector<ui32> & val1, const CGHeroInstance * hero = nullptr) override;
void setFormation(const CGHeroInstance * hero, bool tight) override; void setFormation(const CGHeroInstance * hero, bool tight) override;
void recruitHero(const CGObjectInstance *townOrTavern, const CGHeroInstance *hero) override; void recruitHero(const CGObjectInstance *townOrTavern, const CGHeroInstance *hero) override;
void save(const std::string &fname) override; void save(const std::string &fname) override;

View File

@ -466,10 +466,10 @@ void CPlayerInterface::openTownWindow(const CGTownInstance * town)
GH.windows().pushWindow(newCastleInt); GH.windows().pushWindow(newCastleInt);
} }
void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val)
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
if (which == 4) if (which == PrimarySkill::EXPERIENCE)
{ {
for (auto ctw : GH.windows().findWindows<CAltarWindow>()) for (auto ctw : GH.windows().findWindows<CAltarWindow>())
ctw->setExpToLevel(); ctw->setExpToLevel();
@ -510,7 +510,7 @@ void CPlayerInterface::receivedResource()
GH.windows().totalRedraw(); GH.windows().totalRedraw();
} }
void CPlayerInterface::heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill>& skills, QueryID queryID) void CPlayerInterface::heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector<SecondarySkill>& skills, QueryID queryID)
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
waitWhileDialog(); waitWhileDialog();

View File

@ -109,11 +109,11 @@ protected: // Call-ins from server, should not be called directly, but only via
void heroVisit(const CGHeroInstance * visitor, const CGObjectInstance * visitedObj, bool start) override; void heroVisit(const CGHeroInstance * visitor, const CGObjectInstance * visitedObj, bool start) override;
void heroCreated(const CGHeroInstance* hero) override; void heroCreated(const CGHeroInstance* hero) override;
void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) override; void heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) override;
void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override; void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override;
void heroInGarrisonChange(const CGTownInstance *town) override; void heroInGarrisonChange(const CGTownInstance *town) override;
void heroMoved(const TryMoveHero & details, bool verbose = true) override; void heroMoved(const TryMoveHero & details, bool verbose = true) override;
void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) override; void heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val) override;
void heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val) override; void heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val) override;
void heroManaPointsChanged(const CGHeroInstance * hero) override; void heroManaPointsChanged(const CGHeroInstance * hero) override;
void heroMovePointsChanged(const CGHeroInstance * hero) override; void heroMovePointsChanged(const CGHeroInstance * hero) override;

View File

@ -165,7 +165,7 @@ public:
bool removeObject(const CGObjectInstance * obj) override {return false;}; bool removeObject(const CGObjectInstance * obj) override {return false;};
void createObject(const int3 & visitablePosition, Obj type, int32_t subtype ) override {}; void createObject(const int3 & visitablePosition, Obj type, int32_t subtype ) override {};
void setOwner(const CGObjectInstance * obj, PlayerColor owner) override {}; void setOwner(const CGObjectInstance * obj, PlayerColor owner) override {};
void changePrimSkill(const CGHeroInstance * hero, PrimarySkill::PrimarySkill which, si64 val, bool abs = false) override {}; void changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, bool abs = false) override {};
void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs = false) override {}; void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs = false) override {};
void showBlockingDialog(BlockingDialog * iw) override {}; void showBlockingDialog(BlockingDialog * iw) override {};

View File

@ -483,7 +483,7 @@ void AdventureMapInterface::onTileLeftClicked(const int3 &mapPos)
} }
//check if we can select this object //check if we can select this object
bool canSelect = topBlocking && topBlocking->ID == Obj::HERO && topBlocking->tempOwner == LOCPLINT->playerID; bool canSelect = topBlocking && topBlocking->ID == Obj::HERO && topBlocking->tempOwner == LOCPLINT->playerID;
canSelect |= topBlocking && topBlocking->ID == Obj::TOWN && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, topBlocking->tempOwner); canSelect |= topBlocking && topBlocking->ID == Obj::TOWN && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, topBlocking->tempOwner) != PlayerRelations::ENEMIES;
bool isHero = false; bool isHero = false;
if(LOCPLINT->localState->getCurrentArmy()->ID != Obj::HERO) //hero is not selected (presumably town) if(LOCPLINT->localState->getCurrentArmy()->ID != Obj::HERO) //hero is not selected (presumably town)

View File

@ -222,7 +222,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded)
//primary skills support //primary skills support
for(size_t g=0; g<primSkillAreas.size(); ++g) for(size_t g=0; g<primSkillAreas.size(); ++g)
{ {
primSkillAreas[g]->bonusValue = curHero->getPrimSkillLevel(static_cast<PrimarySkill::PrimarySkill>(g)); primSkillAreas[g]->bonusValue = curHero->getPrimSkillLevel(static_cast<PrimarySkill>(g));
primSkillValues[g]->setText(std::to_string(primSkillAreas[g]->bonusValue)); primSkillValues[g]->setText(std::to_string(primSkillAreas[g]->bonusValue));
} }

View File

@ -315,7 +315,7 @@ si64 InfoBoxHeroData::getValue()
switch(type) switch(type)
{ {
case HERO_PRIMARY_SKILL: case HERO_PRIMARY_SKILL:
return hero->getPrimSkillLevel(static_cast<PrimarySkill::PrimarySkill>(index)); return hero->getPrimSkillLevel(static_cast<PrimarySkill>(index));
case HERO_MANA: case HERO_MANA:
return hero->mana; return hero->mana;
case HERO_EXPERIENCE: case HERO_EXPERIENCE:

View File

@ -317,7 +317,7 @@ void CTradeWindow::CTradeableItem::setArtInstance(const CArtifactInstance *art)
setID(-1); setID(-1);
} }
CTradeWindow::CTradeWindow(std::string bgName, const IMarket *Market, const CGHeroInstance *Hero, EMarketMode::EMarketMode Mode): CTradeWindow::CTradeWindow(std::string bgName, const IMarket *Market, const CGHeroInstance *Hero, EMarketMode Mode):
CWindowObject(PLAYER_COLORED, bgName), CWindowObject(PLAYER_COLORED, bgName),
market(Market), market(Market),
hero(Hero), hero(Hero),
@ -585,7 +585,7 @@ void CTradeWindow::getEmptySlots(std::set<std::shared_ptr<CTradeableItem>> & toR
toRemove.insert(item); toRemove.insert(item);
} }
void CTradeWindow::setMode(EMarketMode::EMarketMode Mode) void CTradeWindow::setMode(EMarketMode Mode)
{ {
const IMarket *m = market; const IMarket *m = market;
const CGHeroInstance *h = hero; const CGHeroInstance *h = hero;
@ -616,7 +616,7 @@ void CTradeWindow::artifactSelected(CHeroArtPlace *slot)
selectionChanged(true); selectionChanged(true);
} }
std::string CMarketplaceWindow::getBackgroundForMode(EMarketMode::EMarketMode mode) std::string CMarketplaceWindow::getBackgroundForMode(EMarketMode mode)
{ {
switch(mode) switch(mode)
{ {
@ -635,7 +635,7 @@ std::string CMarketplaceWindow::getBackgroundForMode(EMarketMode::EMarketMode mo
return ""; return "";
} }
CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInstance * Hero, EMarketMode::EMarketMode Mode) CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInstance * Hero, EMarketMode Mode)
: CTradeWindow(getBackgroundForMode(Mode), Market, Hero, Mode) : CTradeWindow(getBackgroundForMode(Mode), Market, Hero, Mode)
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
@ -870,7 +870,7 @@ void CMarketplaceWindow::selectionChanged(bool side)
redraw(); redraw();
} }
bool CMarketplaceWindow::printButtonFor(EMarketMode::EMarketMode M) const bool CMarketplaceWindow::printButtonFor(EMarketMode M) const
{ {
return market->allowsTrade(M) && M != mode && (hero || ( M != EMarketMode::CREATURE_RESOURCE && M != EMarketMode::RESOURCE_ARTIFACT && M != EMarketMode::ARTIFACT_RESOURCE )); return market->allowsTrade(M) && M != mode && (hero || ( M != EMarketMode::CREATURE_RESOURCE && M != EMarketMode::RESOURCE_ARTIFACT && M != EMarketMode::ARTIFACT_RESOURCE ));
} }
@ -1075,7 +1075,7 @@ void CMarketplaceWindow::updateTraderText()
traderText->setText(CGI->generaltexth->allTexts[gnrtxtnr]); traderText->setText(CGI->generaltexth->allTexts[gnrtxtnr]);
} }
CAltarWindow::CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero, EMarketMode::EMarketMode Mode) CAltarWindow::CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero, EMarketMode Mode)
: CTradeWindow((Mode == EMarketMode::CREATURE_EXP ? "ALTARMON.bmp" : "ALTRART2.bmp"), Market, Hero, Mode) : CTradeWindow((Mode == EMarketMode::CREATURE_EXP ? "ALTARMON.bmp" : "ALTRART2.bmp"), Market, Hero, Mode)
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);

View File

@ -75,7 +75,7 @@ public:
std::shared_ptr<CTradeableItem> hRight; std::shared_ptr<CTradeableItem> hRight;
EType itemsType[2]; EType itemsType[2];
EMarketMode::EMarketMode mode; EMarketMode mode;
std::shared_ptr<CButton> ok; std::shared_ptr<CButton> ok;
std::shared_ptr<CButton> max; std::shared_ptr<CButton> max;
std::shared_ptr<CButton> deal; std::shared_ptr<CButton> deal;
@ -83,7 +83,7 @@ public:
std::shared_ptr<CSlider> slider; //for choosing amount to be exchanged std::shared_ptr<CSlider> slider; //for choosing amount to be exchanged
bool readyToTrade; bool readyToTrade;
CTradeWindow(std::string bgName, const IMarket * Market, const CGHeroInstance * Hero, EMarketMode::EMarketMode Mode); //c CTradeWindow(std::string bgName, const IMarket * Market, const CGHeroInstance * Hero, EMarketMode Mode); //c
void showAll(Canvas & to) override; void showAll(Canvas & to) override;
@ -95,7 +95,7 @@ public:
void removeItems(const std::set<std::shared_ptr<CTradeableItem>> & toRemove); void removeItems(const std::set<std::shared_ptr<CTradeableItem>> & toRemove);
void removeItem(std::shared_ptr<CTradeableItem> item); void removeItem(std::shared_ptr<CTradeableItem> item);
void getEmptySlots(std::set<std::shared_ptr<CTradeableItem>> & toRemove); void getEmptySlots(std::set<std::shared_ptr<CTradeableItem>> & toRemove);
void setMode(EMarketMode::EMarketMode Mode); //mode setter void setMode(EMarketMode Mode); //mode setter
void artifactSelected(CHeroArtPlace *slot); //used when selling artifacts -> called when user clicked on artifact slot void artifactSelected(CHeroArtPlace *slot); //used when selling artifacts -> called when user clicked on artifact slot
@ -118,9 +118,9 @@ class CMarketplaceWindow : public CTradeWindow
std::shared_ptr<CLabel> titleLabel; std::shared_ptr<CLabel> titleLabel;
std::shared_ptr<CArtifactsOfHeroMarket> arts; std::shared_ptr<CArtifactsOfHeroMarket> arts;
bool printButtonFor(EMarketMode::EMarketMode M) const; bool printButtonFor(EMarketMode M) const;
std::string getBackgroundForMode(EMarketMode::EMarketMode mode); std::string getBackgroundForMode(EMarketMode mode);
public: public:
int r1, r2; //suggested amounts of traded resources int r1, r2; //suggested amounts of traded resources
bool madeTransaction; //if player made at least one transaction bool madeTransaction; //if player made at least one transaction
@ -130,7 +130,7 @@ public:
void sliderMoved(int to); void sliderMoved(int to);
void makeDeal(); void makeDeal();
void selectionChanged(bool side) override; //true == left void selectionChanged(bool side) override; //true == left
CMarketplaceWindow(const IMarket * Market, const CGHeroInstance * Hero = nullptr, EMarketMode::EMarketMode Mode = EMarketMode::RESOURCE_RESOURCE); CMarketplaceWindow(const IMarket * Market, const CGHeroInstance * Hero = nullptr, EMarketMode Mode = EMarketMode::RESOURCE_RESOURCE);
~CMarketplaceWindow(); ~CMarketplaceWindow();
Point selectionOffset(bool Left) const override; Point selectionOffset(bool Left) const override;
@ -157,7 +157,7 @@ public:
std::shared_ptr<CLabel> expOnAltar; std::shared_ptr<CLabel> expOnAltar;
std::shared_ptr<CArtifactsOfHeroAltar> arts; std::shared_ptr<CArtifactsOfHeroAltar> arts;
CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero, EMarketMode::EMarketMode Mode); CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero, EMarketMode Mode);
~CAltarWindow(); ~CAltarWindow();
void getExpValues(); void getExpValues();

View File

@ -400,7 +400,7 @@ void CSplitWindow::sliderMoved(int to)
setAmount(rightMin + to, false); setAmount(rightMin + to, false);
} }
CLevelWindow::CLevelWindow(const CGHeroInstance * hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> & skills, std::function<void(ui32)> callback) CLevelWindow::CLevelWindow(const CGHeroInstance * hero, PrimarySkill pskill, std::vector<SecondarySkill> & skills, std::function<void(ui32)> callback)
: CWindowObject(PLAYER_COLORED, "LVLUPBKG"), : CWindowObject(PLAYER_COLORED, "LVLUPBKG"),
cb(callback) cb(callback)
{ {
@ -434,9 +434,9 @@ CLevelWindow::CLevelWindow(const CGHeroInstance * hero, PrimarySkill::PrimarySki
levelTitle = std::make_shared<CLabel>(192, 162, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, levelTitleText); levelTitle = std::make_shared<CLabel>(192, 162, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, levelTitleText);
skillIcon = std::make_shared<CAnimImage>("PSKIL42", pskill, 0, 174, 190); skillIcon = std::make_shared<CAnimImage>("PSKIL42", static_cast<int>(pskill), 0, 174, 190);
skillValue = std::make_shared<CLabel>(192, 253, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->primarySkillNames[pskill] + " +1"); skillValue = std::make_shared<CLabel>(192, 253, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->primarySkillNames[static_cast<int>(pskill)] + " +1");
} }
@ -1029,7 +1029,7 @@ void CExchangeWindow::updateWidgets()
for(int m=0; m<GameConstants::PRIMARY_SKILLS; ++m) for(int m=0; m<GameConstants::PRIMARY_SKILLS; ++m)
{ {
auto value = heroInst[leftRight]->getPrimSkillLevel(static_cast<PrimarySkill::PrimarySkill>(m)); auto value = heroInst[leftRight]->getPrimSkillLevel(static_cast<PrimarySkill>(m));
primSkillValues[leftRight][m]->setText(std::to_string(value)); primSkillValues[leftRight][m]->setText(std::to_string(value));
} }

View File

@ -145,7 +145,7 @@ class CLevelWindow : public CWindowObject
void selectionChanged(unsigned to); void selectionChanged(unsigned to);
public: public:
CLevelWindow(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, std::function<void(ui32)> callback); CLevelWindow(const CGHeroInstance *hero, PrimarySkill pskill, std::vector<SecondarySkill> &skills, std::function<void(ui32)> callback);
~CLevelWindow(); ~CLevelWindow();
}; };

View File

@ -15,11 +15,7 @@
VCMI_LIB_NAMESPACE_BEGIN VCMI_LIB_NAMESPACE_BEGIN
class BonusList; class BonusList;
enum class PrimarySkill : int32_t;
namespace PrimarySkill
{
enum PrimarySkill : int8_t;
}
class DLL_LINKAGE AFactionMember: public IConstBonusProvider, public INativeTerrainProvider class DLL_LINKAGE AFactionMember: public IConstBonusProvider, public INativeTerrainProvider
{ {
@ -51,7 +47,7 @@ public:
/** /**
Returns primskill of creature or hero. Returns primskill of creature or hero.
*/ */
int getPrimSkillLevel(PrimarySkill::PrimarySkill id) const; int getPrimSkillLevel(PrimarySkill id) const;
/** /**
Returns morale of creature or hero. Taking absolute bonuses into account. Returns morale of creature or hero. Taking absolute bonuses into account.
For now, uses range from EGameSettings For now, uses range from EGameSettings

View File

@ -54,7 +54,7 @@ int AFactionMember::getAttack(bool ranged) const
{ {
const std::string cachingStr = "type_PRIMARY_SKILLs_ATTACK"; const std::string cachingStr = "type_PRIMARY_SKILLs_ATTACK";
static const auto selector = Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK); static const auto selector = Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::ATTACK));
return getBonusBearer()->valOfBonuses(selector, cachingStr); return getBonusBearer()->valOfBonuses(selector, cachingStr);
} }
@ -63,7 +63,7 @@ int AFactionMember::getDefense(bool ranged) const
{ {
const std::string cachingStr = "type_PRIMARY_SKILLs_DEFENSE"; const std::string cachingStr = "type_PRIMARY_SKILLs_DEFENSE";
static const auto selector = Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE); static const auto selector = Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::DEFENSE));
return getBonusBearer()->valOfBonuses(selector, cachingStr); return getBonusBearer()->valOfBonuses(selector, cachingStr);
} }
@ -82,12 +82,12 @@ int AFactionMember::getMaxDamage(bool ranged) const
return getBonusBearer()->valOfBonuses(selector, cachingStr); return getBonusBearer()->valOfBonuses(selector, cachingStr);
} }
int AFactionMember::getPrimSkillLevel(PrimarySkill::PrimarySkill id) const int AFactionMember::getPrimSkillLevel(PrimarySkill id) const
{ {
static const CSelector selectorAllSkills = Selector::type()(BonusType::PRIMARY_SKILL); static const CSelector selectorAllSkills = Selector::type()(BonusType::PRIMARY_SKILL);
static const std::string keyAllSkills = "type_PRIMARY_SKILL"; static const std::string keyAllSkills = "type_PRIMARY_SKILL";
auto allSkills = getBonusBearer()->getBonuses(selectorAllSkills, keyAllSkills); auto allSkills = getBonusBearer()->getBonuses(selectorAllSkills, keyAllSkills);
auto ret = allSkills->valOfBonuses(Selector::subtype()(id)); auto ret = allSkills->valOfBonuses(Selector::subtype()(static_cast<int>(id)));
auto minSkillValue = (id == PrimarySkill::SPELL_POWER || id == PrimarySkill::KNOWLEDGE) ? 1 : 0; auto minSkillValue = (id == PrimarySkill::SPELL_POWER || id == PrimarySkill::KNOWLEDGE) ? 1 : 0;
return std::max(ret, minSkillValue); //otherwise, some artifacts may cause negative skill value effect, sp=0 works in old saves return std::max(ret, minSkillValue); //otherwise, some artifacts may cause negative skill value effect, sp=0 works in old saves
} }
@ -183,4 +183,4 @@ bool ACreature::isLiving() const //TODO: theoreticaly there exists "LIVING" bonu
} }
VCMI_LIB_NAMESPACE_END VCMI_LIB_NAMESPACE_END

View File

@ -113,13 +113,13 @@ FactionID CCreature::getFaction() const
int32_t CCreature::getBaseAttack() const int32_t CCreature::getBaseAttack() const
{ {
static const auto SELECTOR = Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY)); static const auto SELECTOR = Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::ATTACK)).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY));
return getExportedBonusList().valOfBonuses(SELECTOR); return getExportedBonusList().valOfBonuses(SELECTOR);
} }
int32_t CCreature::getBaseDefense() const int32_t CCreature::getBaseDefense() const
{ {
static const auto SELECTOR = Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY)); static const auto SELECTOR = Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::DEFENSE)).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY));
return getExportedBonusList().valOfBonuses(SELECTOR); return getExportedBonusList().valOfBonuses(SELECTOR);
} }
@ -345,10 +345,10 @@ void CCreature::updateFrom(const JsonNode & data)
addBonus(configNode["speed"].Integer(), BonusType::STACKS_SPEED); addBonus(configNode["speed"].Integer(), BonusType::STACKS_SPEED);
if(!configNode["attack"].isNull()) if(!configNode["attack"].isNull())
addBonus(configNode["attack"].Integer(), BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK); addBonus(configNode["attack"].Integer(), BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::ATTACK));
if(!configNode["defense"].isNull()) if(!configNode["defense"].isNull())
addBonus(configNode["defense"].Integer(), BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE); addBonus(configNode["defense"].Integer(), BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::DEFENSE));
if(!configNode["damage"]["min"].isNull()) if(!configNode["damage"]["min"].isNull())
addBonus(configNode["damage"]["min"].Integer(), BonusType::CREATURE_DAMAGE, 1); addBonus(configNode["damage"]["min"].Integer(), BonusType::CREATURE_DAMAGE, 1);
@ -603,8 +603,8 @@ CCreature * CCreatureHandler::loadFromJson(const std::string & scope, const Json
cre->addBonus(node["hitPoints"].Integer(), BonusType::STACK_HEALTH); cre->addBonus(node["hitPoints"].Integer(), BonusType::STACK_HEALTH);
cre->addBonus(node["speed"].Integer(), BonusType::STACKS_SPEED); cre->addBonus(node["speed"].Integer(), BonusType::STACKS_SPEED);
cre->addBonus(node["attack"].Integer(), BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK); cre->addBonus(node["attack"].Integer(), BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::ATTACK));
cre->addBonus(node["defense"].Integer(), BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE); cre->addBonus(node["defense"].Integer(), BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::DEFENSE));
cre->addBonus(node["damage"]["min"].Integer(), BonusType::CREATURE_DAMAGE, 1); cre->addBonus(node["damage"]["min"].Integer(), BonusType::CREATURE_DAMAGE, 1);
cre->addBonus(node["damage"]["max"].Integer(), BonusType::CREATURE_DAMAGE, 2); cre->addBonus(node["damage"]["max"].Integer(), BonusType::CREATURE_DAMAGE, 2);
@ -1030,11 +1030,11 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
break; break;
case 'A': case 'A':
b.type = BonusType::PRIMARY_SKILL; b.type = BonusType::PRIMARY_SKILL;
b.subtype = PrimarySkill::ATTACK; b.subtype = static_cast<int>(PrimarySkill::ATTACK);
break; break;
case 'D': case 'D':
b.type = BonusType::PRIMARY_SKILL; b.type = BonusType::PRIMARY_SKILL;
b.subtype = PrimarySkill::DEFENSE; b.subtype = static_cast<int>(PrimarySkill::DEFENSE);
break; break;
case 'M': //Max damage case 'M': //Max damage
b.type = BonusType::CREATURE_DAMAGE; b.type = BonusType::CREATURE_DAMAGE;

View File

@ -631,7 +631,7 @@ bool CGameInfoCallback::hasAccess(std::optional<PlayerColor> playerId) const
return !player || player->isSpectator() || gs->getPlayerRelations(*playerId, *player) != PlayerRelations::ENEMIES; return !player || player->isSpectator() || gs->getPlayerRelations(*playerId, *player) != PlayerRelations::ENEMIES;
} }
EPlayerStatus::EStatus CGameInfoCallback::getPlayerStatus(PlayerColor player, bool verbose) const EPlayerStatus CGameInfoCallback::getPlayerStatus(PlayerColor player, bool verbose) const
{ {
const PlayerState *ps = gs->getPlayerState(player, verbose); const PlayerState *ps = gs->getPlayerState(player, verbose);
ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!ps, verbose, "No such player!", EPlayerStatus::WRONG); ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!ps, verbose, "No such player!", EPlayerStatus::WRONG);
@ -670,7 +670,7 @@ std::string CGameInfoCallback::getTavernRumor(const CGObjectInstance * townOrTav
return text; return text;
} }
PlayerRelations::PlayerRelations CGameInfoCallback::getPlayerRelations( PlayerColor color1, PlayerColor color2 ) const PlayerRelations CGameInfoCallback::getPlayerRelations( PlayerColor color1, PlayerColor color2 ) const
{ {
return gs->getPlayerRelations(color1, color2); return gs->getPlayerRelations(color1, color2);
} }

View File

@ -60,9 +60,9 @@ public:
virtual const Player * getPlayer(PlayerColor color) const = 0; virtual const Player * getPlayer(PlayerColor color) const = 0;
// virtual int getResource(PlayerColor Player, EGameResID which) const = 0; // virtual int getResource(PlayerColor Player, EGameResID which) const = 0;
// bool isVisible(int3 pos) const; // bool isVisible(int3 pos) const;
// PlayerRelations::PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const; // PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const;
// void getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj); //get thieves' guild info obtainable while visiting given object // void getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj); //get thieves' guild info obtainable while visiting given object
// EPlayerStatus::EStatus getPlayerStatus(PlayerColor player, bool verbose = true) const; //-1 if no such player // EPlayerStatus getPlayerStatus(PlayerColor player, bool verbose = true) const; //-1 if no such player
// PlayerColor getCurrentPlayer() const; //player that currently makes move // TODO synchronous turns // PlayerColor getCurrentPlayer() const; //player that currently makes move // TODO synchronous turns
virtual PlayerColor getLocalPlayer() const = 0; //player that is currently owning given client (if not a client, then returns current player) virtual PlayerColor getLocalPlayer() const = 0; //player that is currently owning given client (if not a client, then returns current player)
// const PlayerSettings * getPlayerSettings(PlayerColor color) const; // const PlayerSettings * getPlayerSettings(PlayerColor color) const;
@ -148,9 +148,9 @@ public:
const Player * getPlayer(PlayerColor color) const override; const Player * getPlayer(PlayerColor color) const override;
virtual const PlayerState * getPlayerState(PlayerColor color, bool verbose = true) const; virtual const PlayerState * getPlayerState(PlayerColor color, bool verbose = true) const;
virtual int getResource(PlayerColor Player, GameResID which) const; virtual int getResource(PlayerColor Player, GameResID which) const;
virtual PlayerRelations::PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const; virtual PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const;
virtual void getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj); //get thieves' guild info obtainable while visiting given object virtual void getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj); //get thieves' guild info obtainable while visiting given object
virtual EPlayerStatus::EStatus getPlayerStatus(PlayerColor player, bool verbose = true) const; //-1 if no such player virtual EPlayerStatus getPlayerStatus(PlayerColor player, bool verbose = true) const; //-1 if no such player
virtual PlayerColor getCurrentPlayer() const; //player that currently makes move // TODO synchronous turns virtual PlayerColor getCurrentPlayer() const; //player that currently makes move // TODO synchronous turns
PlayerColor getLocalPlayer() const override; //player that is currently owning given client (if not a client, then returns current player) PlayerColor getLocalPlayer() const override; //player that is currently owning given client (if not a client, then returns current player)
virtual const PlayerSettings * getPlayerSettings(PlayerColor color) const; virtual const PlayerSettings * getPlayerSettings(PlayerColor color) const;

View File

@ -91,7 +91,7 @@ public:
virtual void yourTurn(){}; //called AFTER playerStartsTurn(player) virtual void yourTurn(){}; //called AFTER playerStartsTurn(player)
//pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id
virtual void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID)=0; virtual void heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID)=0;
virtual void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID)=0; virtual void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID)=0;
// Show a dialog, player must take decision. If selection then he has to choose between one of given components, // Show a dialog, player must take decision. If selection then he has to choose between one of given components,

View File

@ -207,9 +207,9 @@ CHeroClass::CHeroClass():
{ {
} }
void CHeroClassHandler::fillPrimarySkillData(const JsonNode & node, CHeroClass * heroClass, PrimarySkill::PrimarySkill pSkill) const void CHeroClassHandler::fillPrimarySkillData(const JsonNode & node, CHeroClass * heroClass, PrimarySkill pSkill) const
{ {
const auto & skillName = PrimarySkill::names[pSkill]; const auto & skillName = NPrimarySkill::names[static_cast<int>(pSkill)];
auto currentPrimarySkillValue = static_cast<int>(node["primarySkills"][skillName].Integer()); auto currentPrimarySkillValue = static_cast<int>(node["primarySkills"][skillName].Integer());
//minimal value is 0 for attack and defense and 1 for spell power and knowledge //minimal value is 0 for attack and defense and 1 for spell power and knowledge
auto primarySkillLegalMinimum = (pSkill == PrimarySkill::ATTACK || pSkill == PrimarySkill::DEFENSE) ? 0 : 1; auto primarySkillLegalMinimum = (pSkill == PrimarySkill::ATTACK || pSkill == PrimarySkill::DEFENSE) ? 0 : 1;
@ -333,13 +333,13 @@ std::vector<JsonNode> CHeroClassHandler::loadLegacyData()
parser.readNumber(); // unused aggression parser.readNumber(); // unused aggression
for(const auto & name : PrimarySkill::names) for(const auto & name : NPrimarySkill::names)
entry["primarySkills"][name].Float() = parser.readNumber(); entry["primarySkills"][name].Float() = parser.readNumber();
for(const auto & name : PrimarySkill::names) for(const auto & name : NPrimarySkill::names)
entry["lowLevelChance"][name].Float() = parser.readNumber(); entry["lowLevelChance"][name].Float() = parser.readNumber();
for(const auto & name : PrimarySkill::names) for(const auto & name : NPrimarySkill::names)
entry["highLevelChance"][name].Float() = parser.readNumber(); entry["highLevelChance"][name].Float() = parser.readNumber();
for(const auto & name : NSecondarySkill::names) for(const auto & name : NSecondarySkill::names)
@ -547,7 +547,7 @@ static std::vector<std::shared_ptr<Bonus>> createCreatureSpecialty(CreatureID ba
{ {
std::shared_ptr<Bonus> bonus = std::make_shared<Bonus>(); std::shared_ptr<Bonus> bonus = std::make_shared<Bonus>();
bonus->type = BonusType::PRIMARY_SKILL; bonus->type = BonusType::PRIMARY_SKILL;
bonus->subtype = PrimarySkill::ATTACK; bonus->subtype = static_cast<int>(PrimarySkill::ATTACK);
bonus->val = 0; bonus->val = 0;
bonus->limiter.reset(new CCreatureTypeLimiter(specCreature, false)); bonus->limiter.reset(new CCreatureTypeLimiter(specCreature, false));
bonus->updater.reset(new GrowsWithLevelUpdater(specCreature.getAttack(false), stepSize)); bonus->updater.reset(new GrowsWithLevelUpdater(specCreature.getAttack(false), stepSize));
@ -557,7 +557,7 @@ static std::vector<std::shared_ptr<Bonus>> createCreatureSpecialty(CreatureID ba
{ {
std::shared_ptr<Bonus> bonus = std::make_shared<Bonus>(); std::shared_ptr<Bonus> bonus = std::make_shared<Bonus>();
bonus->type = BonusType::PRIMARY_SKILL; bonus->type = BonusType::PRIMARY_SKILL;
bonus->subtype = PrimarySkill::DEFENSE; bonus->subtype = static_cast<int>(PrimarySkill::DEFENSE);
bonus->val = 0; bonus->val = 0;
bonus->limiter.reset(new CCreatureTypeLimiter(specCreature, false)); bonus->limiter.reset(new CCreatureTypeLimiter(specCreature, false));
bonus->updater.reset(new GrowsWithLevelUpdater(specCreature.getDefense(false), stepSize)); bonus->updater.reset(new GrowsWithLevelUpdater(specCreature.getDefense(false), stepSize));

View File

@ -212,7 +212,7 @@ public:
class DLL_LINKAGE CHeroClassHandler : public CHandlerBase<HeroClassID, HeroClass, CHeroClass, HeroClassService> class DLL_LINKAGE CHeroClassHandler : public CHandlerBase<HeroClassID, HeroClass, CHeroClass, HeroClassService>
{ {
void fillPrimarySkillData(const JsonNode & node, CHeroClass * heroClass, PrimarySkill::PrimarySkill pSkill) const; void fillPrimarySkillData(const JsonNode & node, CHeroClass * heroClass, PrimarySkill pSkill) const;
public: public:
std::vector<JsonNode> loadLegacyData() override; std::vector<JsonNode> loadLegacyData() override;

View File

@ -38,7 +38,7 @@ public:
std::vector<QuestInfo> quests; //store info about all received quests std::vector<QuestInfo> quests; //store info about all received quests
bool enteredWinningCheatCode, enteredLosingCheatCode; //if true, this player has entered cheat codes for loss / victory bool enteredWinningCheatCode, enteredLosingCheatCode; //if true, this player has entered cheat codes for loss / victory
EPlayerStatus::EStatus status; EPlayerStatus status;
std::optional<ui8> daysWithoutCastle; std::optional<ui8> daysWithoutCastle;
TurnTimerInfo turnTimer; TurnTimerInfo turnTimer;

View File

@ -527,13 +527,13 @@ void CTownHandler::addBonusesForVanilaBuilding(CBuilding * building) const
b = createBonus(building, BonusType::LUCK, +2); b = createBonus(building, BonusType::LUCK, +2);
break; break;
case BuildingSubID::SPELL_POWER_GARRISON_BONUS: case BuildingSubID::SPELL_POWER_GARRISON_BONUS:
b = createBonus(building, BonusType::PRIMARY_SKILL, +2, PrimarySkill::SPELL_POWER); b = createBonus(building, BonusType::PRIMARY_SKILL, +2, static_cast<int>(PrimarySkill::SPELL_POWER));
break; break;
case BuildingSubID::ATTACK_GARRISON_BONUS: case BuildingSubID::ATTACK_GARRISON_BONUS:
b = createBonus(building, BonusType::PRIMARY_SKILL, +2, PrimarySkill::ATTACK); b = createBonus(building, BonusType::PRIMARY_SKILL, +2, static_cast<int>(PrimarySkill::ATTACK));
break; break;
case BuildingSubID::DEFENSE_GARRISON_BONUS: case BuildingSubID::DEFENSE_GARRISON_BONUS:
b = createBonus(building, BonusType::PRIMARY_SKILL, +2, PrimarySkill::DEFENSE); b = createBonus(building, BonusType::PRIMARY_SKILL, +2, static_cast<int>(PrimarySkill::DEFENSE));
break; break;
case BuildingSubID::LIGHTHOUSE: case BuildingSubID::LIGHTHOUSE:
b = createBonus(building, BonusType::MOVEMENT, +500, playerPropagator, 0); b = createBonus(building, BonusType::MOVEMENT, +500, playerPropagator, 0);

View File

@ -412,11 +412,15 @@ class TeleportChannelID : public BaseForID<TeleportChannelID, si32>
}; };
// Enum declarations // Enum declarations
namespace PrimarySkill enum class PrimarySkill : int32_t
{ {
enum PrimarySkill : int8_t { NONE = -1, ATTACK, DEFENSE, SPELL_POWER, KNOWLEDGE, NONE = -1,
EXPERIENCE = 4}; //for some reason changePrimSkill uses it ATTACK,
} DEFENSE,
SPELL_POWER,
KNOWLEDGE,
EXPERIENCE = 4 //for some reason changePrimSkill uses it
};
class SecondarySkillBase : public EntityBase class SecondarySkillBase : public EntityBase
{ {
@ -599,15 +603,12 @@ namespace BuildingSubID
}; };
} }
namespace EMarketMode enum class EMarketMode : int32_t
{ {
enum EMarketMode RESOURCE_RESOURCE, RESOURCE_PLAYER, CREATURE_RESOURCE, RESOURCE_ARTIFACT,
{ ARTIFACT_RESOURCE, ARTIFACT_EXP, CREATURE_EXP, CREATURE_UNDEAD, RESOURCE_SKILL,
RESOURCE_RESOURCE, RESOURCE_PLAYER, CREATURE_RESOURCE, RESOURCE_ARTIFACT, MARTKET_AFTER_LAST_PLACEHOLDER
ARTIFACT_RESOURCE, ARTIFACT_EXP, CREATURE_EXP, CREATURE_UNDEAD, RESOURCE_SKILL, };
MARTKET_AFTER_LAST_PLACEHOLDER
};
}
namespace MappedKeys namespace MappedKeys
{ {
@ -686,7 +687,7 @@ namespace MappedKeys
{ "treasury", BuildingSubID::TREASURY } { "treasury", BuildingSubID::TREASURY }
}; };
static const std::map<std::string, EMarketMode::EMarketMode> MARKET_NAMES_TO_TYPES = static const std::map<std::string, EMarketMode> MARKET_NAMES_TO_TYPES =
{ {
{ "resource-resource", EMarketMode::RESOURCE_RESOURCE }, { "resource-resource", EMarketMode::RESOURCE_RESOURCE },
{ "resource-player", EMarketMode::RESOURCE_PLAYER }, { "resource-player", EMarketMode::RESOURCE_PLAYER },
@ -1040,29 +1041,16 @@ enum class EActionType : int8_t
DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const EActionType actionType); DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const EActionType actionType);
class DLL_LINKAGE EDiggingStatus enum class EDiggingStatus : int32_t
{ {
public: UNKNOWN = -1,
enum EEDiggingStatus CAN_DIG = 0,
{ LACK_OF_MOVEMENT,
UNKNOWN = -1, WRONG_TERRAIN,
CAN_DIG = 0, TILE_OCCUPIED,
LACK_OF_MOVEMENT, BACKPACK_IS_FULL
WRONG_TERRAIN,
TILE_OCCUPIED,
BACKPACK_IS_FULL
};
EDiggingStatus(EEDiggingStatus _num = UNKNOWN) : num(_num)
{}
ID_LIKE_CLASS_COMMON(EDiggingStatus, EEDiggingStatus)
EEDiggingStatus num;
}; };
ID_LIKE_OPERATORS(EDiggingStatus, EDiggingStatus::EEDiggingStatus)
class DLL_LINKAGE EPathfindingLayer class DLL_LINKAGE EPathfindingLayer
{ {
public: public:
@ -1083,15 +1071,20 @@ DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const EPathfindingLayer
ID_LIKE_OPERATORS(EPathfindingLayer, EPathfindingLayer::EEPathfindingLayer) ID_LIKE_OPERATORS(EPathfindingLayer, EPathfindingLayer::EEPathfindingLayer)
namespace EPlayerStatus enum class EPlayerStatus
{ {
enum EStatus {WRONG = -1, INGAME, LOSER, WINNER}; WRONG = -1,
} INGAME,
LOSER,
WINNER
};
namespace PlayerRelations enum class PlayerRelations
{ {
enum PlayerRelations {ENEMIES, ALLIES, SAME_PLAYER}; ENEMIES,
} ALLIES,
SAME_PLAYER
};
class ArtifactPosition class ArtifactPosition
{ {

View File

@ -92,7 +92,7 @@ public:
virtual bool removeObject(const CGObjectInstance * obj)=0; virtual bool removeObject(const CGObjectInstance * obj)=0;
virtual void createObject(const int3 & visitablePosition, Obj type, int32_t subtype = 0) = 0; virtual void createObject(const int3 & visitablePosition, Obj type, int32_t subtype = 0) = 0;
virtual void setOwner(const CGObjectInstance * objid, PlayerColor owner)=0; virtual void setOwner(const CGObjectInstance * objid, PlayerColor owner)=0;
virtual void changePrimSkill(const CGHeroInstance * hero, PrimarySkill::PrimarySkill which, si64 val, bool abs=false)=0; virtual void changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, bool abs=false)=0;
virtual void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs=false)=0; virtual void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs=false)=0;
virtual void showBlockingDialog(BlockingDialog *iw) =0; virtual void showBlockingDialog(BlockingDialog *iw) =0;
virtual void showGarrisonDialog(ObjectInstanceID upobj, ObjectInstanceID hid, bool removableUnits) =0; //cb will be called when player closes garrison window virtual void showGarrisonDialog(ObjectInstanceID upobj, ObjectInstanceID hid, bool removableUnits) =0; //cb will be called when player closes garrison window

View File

@ -98,7 +98,7 @@ public:
virtual void heroCreated(const CGHeroInstance*){}; virtual void heroCreated(const CGHeroInstance*){};
virtual void heroInGarrisonChange(const CGTownInstance *town){}; virtual void heroInGarrisonChange(const CGTownInstance *town){};
virtual void heroMoved(const TryMoveHero & details, bool verbose = true){}; virtual void heroMoved(const TryMoveHero & details, bool verbose = true){};
virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val){}; virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val){};
virtual void heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val){}; virtual void heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val){};
virtual void heroManaPointsChanged(const CGHeroInstance * hero){} //not called at the beginning of turn and after spell casts virtual void heroManaPointsChanged(const CGHeroInstance * hero){} //not called at the beginning of turn and after spell casts
virtual void heroMovePointsChanged(const CGHeroInstance * hero){} //not called at the beginning of turn and after movement virtual void heroMovePointsChanged(const CGHeroInstance * hero){} //not called at the beginning of turn and after movement

View File

@ -119,7 +119,7 @@ namespace JsonRandom
std::vector<si32> ret; std::vector<si32> ret;
if(value.isStruct()) if(value.isStruct())
{ {
for(const auto & name : PrimarySkill::names) for(const auto & name : NPrimarySkill::names)
{ {
ret.push_back(loadValue(value[name], rng)); ret.push_back(loadValue(value[name], rng));
} }
@ -127,12 +127,12 @@ namespace JsonRandom
if(value.isVector()) if(value.isVector())
{ {
ret.resize(GameConstants::PRIMARY_SKILLS, 0); ret.resize(GameConstants::PRIMARY_SKILLS, 0);
std::set<std::string> defaultStats(std::begin(PrimarySkill::names), std::end(PrimarySkill::names)); std::set<std::string> defaultStats(std::begin(NPrimarySkill::names), std::end(NPrimarySkill::names));
for(const auto & element : value.Vector()) for(const auto & element : value.Vector())
{ {
auto key = loadKey(element, rng, defaultStats); auto key = loadKey(element, rng, defaultStats);
defaultStats.erase(key); defaultStats.erase(key);
int id = vstd::find_pos(PrimarySkill::names, key); int id = vstd::find_pos(NPrimarySkill::names, key);
if(id != -1) if(id != -1)
ret[id] += loadValue(element, rng); ret[id] += loadValue(element, rng);
} }

View File

@ -232,7 +232,7 @@ struct DLL_LINKAGE SetPrimSkill : public CPackForClient
ui8 abs = 0; //0 - changes by value; 1 - sets to value ui8 abs = 0; //0 - changes by value; 1 - sets to value
ObjectInstanceID id; ObjectInstanceID id;
PrimarySkill::PrimarySkill which = PrimarySkill::ATTACK; PrimarySkill which = PrimarySkill::ATTACK;
si64 val = 0; si64 val = 0;
template <typename Handler> void serialize(Handler & h, const int version) template <typename Handler> void serialize(Handler & h, const int version)
@ -1318,7 +1318,7 @@ struct DLL_LINKAGE HeroLevelUp : public Query
PlayerColor player; PlayerColor player;
ObjectInstanceID heroId; ObjectInstanceID heroId;
PrimarySkill::PrimarySkill primskill = PrimarySkill::ATTACK; PrimarySkill primskill = PrimarySkill::ATTACK;
std::vector<SecondarySkill> skills; std::vector<SecondarySkill> skills;
void applyGs(CGameState * gs) const; void applyGs(CGameState * gs) const;
@ -2425,7 +2425,7 @@ struct DLL_LINKAGE TradeOnMarketplace : public CPackForServer
ObjectInstanceID marketId; ObjectInstanceID marketId;
ObjectInstanceID heroId; ObjectInstanceID heroId;
EMarketMode::EMarketMode mode = EMarketMode::RESOURCE_RESOURCE; EMarketMode mode = EMarketMode::RESOURCE_RESOURCE;
std::vector<ui32> r1, r2; //mode 0: r1 - sold resource, r2 - bought res (exception: when sacrificing art r1 is art id [todo: make r2 preferred slot?] std::vector<ui32> r1, r2; //mode 0: r1 - sold resource, r2 - bought res (exception: when sacrificing art r1 is art id [todo: make r2 preferred slot?]
std::vector<ui32> val; //units of sold resource std::vector<ui32> val; //units of sold resource

View File

@ -29,7 +29,7 @@ namespace GameConstants
const std::string ALIGNMENT_NAMES [3] = {"good", "evil", "neutral"}; const std::string ALIGNMENT_NAMES [3] = {"good", "evil", "neutral"};
} }
namespace PrimarySkill namespace NPrimarySkill
{ {
const std::string names [GameConstants::PRIMARY_SKILLS] = { "attack", "defence", "spellpower", "knowledge" }; const std::string names [GameConstants::PRIMARY_SKILLS] = { "attack", "defence", "spellpower", "knowledge" };
} }

View File

@ -475,8 +475,8 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const
static auto nativeTerrain = std::make_shared<CreatureTerrainLimiter>(); static auto nativeTerrain = std::make_shared<CreatureTerrainLimiter>();
curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACKS_SPEED, BonusSource::TERRAIN_NATIVE, 1, 0, 0)->addLimiter(nativeTerrain)); curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACKS_SPEED, BonusSource::TERRAIN_NATIVE, 1, 0, 0)->addLimiter(nativeTerrain));
curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, 0, PrimarySkill::ATTACK)->addLimiter(nativeTerrain)); curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, 0, static_cast<int>(PrimarySkill::ATTACK))->addLimiter(nativeTerrain));
curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, 0, PrimarySkill::DEFENSE)->addLimiter(nativeTerrain)); curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, 0, static_cast<int>(PrimarySkill::DEFENSE))->addLimiter(nativeTerrain));
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
//tactics //tactics

View File

@ -342,8 +342,8 @@ CUnitState::CUnitState():
totalAttacks(this, Selector::type()(BonusType::ADDITIONAL_ATTACK), 1), totalAttacks(this, Selector::type()(BonusType::ADDITIONAL_ATTACK), 1),
minDamage(this, Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 0).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 1)), 0), minDamage(this, Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 0).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 1)), 0),
maxDamage(this, Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 0).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 2)), 0), maxDamage(this, Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 0).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 2)), 0),
attack(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK), 0), attack(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::ATTACK)), 0),
defence(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE), 0), defence(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::DEFENSE)), 0),
inFrenzy(this, Selector::type()(BonusType::IN_FRENZY)), inFrenzy(this, Selector::type()(BonusType::IN_FRENZY)),
cloneLifetimeMarker(this, Selector::type()(BonusType::NONE).And(Selector::source(BonusSource::SPELL_EFFECT, SpellID::CLONE))), cloneLifetimeMarker(this, Selector::type()(BonusType::NONE).And(Selector::source(BonusSource::SPELL_EFFECT, SpellID::CLONE))),
cloneID(-1) cloneID(-1)

View File

@ -50,9 +50,9 @@ DamageRange DamageCalculator::getBaseDamageSingle() const
if(info.attacker->hasBonus(selectorSiedgeWeapon, cachingStrSiedgeWeapon) && info.attacker->creatureIndex() != CreatureID::ARROW_TOWERS) if(info.attacker->hasBonus(selectorSiedgeWeapon, cachingStrSiedgeWeapon) && info.attacker->creatureIndex() != CreatureID::ARROW_TOWERS)
{ {
auto retrieveHeroPrimSkill = [&](int skill) -> int auto retrieveHeroPrimSkill = [&](PrimarySkill skill) -> int
{ {
std::shared_ptr<const Bonus> b = info.attacker->getBonus(Selector::sourceTypeSel(BonusSource::HERO_BASE_SKILL).And(Selector::typeSubtype(BonusType::PRIMARY_SKILL, skill))); std::shared_ptr<const Bonus> b = info.attacker->getBonus(Selector::sourceTypeSel(BonusSource::HERO_BASE_SKILL).And(Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast<int>(skill))));
return b ? b->val : 0; return b ? b->val : 0;
}; };

View File

@ -139,7 +139,7 @@ static JsonNode subtypeToJson(BonusType type, int subtype)
switch(type) switch(type)
{ {
case BonusType::PRIMARY_SKILL: case BonusType::PRIMARY_SKILL:
return JsonUtils::stringNode("primSkill." + PrimarySkill::names[subtype]); return JsonUtils::stringNode("primSkill." + NPrimarySkill::names[subtype]);
case BonusType::SPECIAL_SPELL_LEV: case BonusType::SPECIAL_SPELL_LEV:
case BonusType::SPECIFIC_SPELL_DAMAGE: case BonusType::SPECIFIC_SPELL_DAMAGE:
case BonusType::SPELL: case BonusType::SPELL:

View File

@ -1297,7 +1297,7 @@ UpgradeInfo CGameState::fillUpgradeInfo(const CStackInstance &stack) const
return ret; return ret;
} }
PlayerRelations::PlayerRelations CGameState::getPlayerRelations( PlayerColor color1, PlayerColor color2 ) const PlayerRelations CGameState::getPlayerRelations( PlayerColor color1, PlayerColor color2 ) const
{ {
if ( color1 == color2 ) if ( color1 == color2 )
return PlayerRelations::SAME_PLAYER; return PlayerRelations::SAME_PLAYER;

View File

@ -113,7 +113,7 @@ public:
BattleField battleGetBattlefieldType(int3 tile, CRandomGenerator & rand); BattleField battleGetBattlefieldType(int3 tile, CRandomGenerator & rand);
void fillUpgradeInfo(const CArmedInstance *obj, SlotID stackPos, UpgradeInfo &out) const override; void fillUpgradeInfo(const CArmedInstance *obj, SlotID stackPos, UpgradeInfo &out) const override;
PlayerRelations::PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const override; PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const override;
bool checkForVisitableDir(const int3 & src, const int3 & dst) const; //check if src tile is visitable from dst tile bool checkForVisitableDir(const int3 & src, const int3 & dst) const; //check if src tile is visitable from dst tile
void calculatePaths(const CGHeroInstance *hero, CPathsInfo &out) override; //calculates possible paths for hero, by default uses current hero position and movement left; returns pointer to newly allocated CPath or nullptr if path does not exists void calculatePaths(const CGHeroInstance *hero, CPathsInfo &out) override; //calculates possible paths for hero, by default uses current hero position and movement left; returns pointer to newly allocated CPath or nullptr if path does not exists
void calculatePaths(const std::shared_ptr<PathfinderConfig> & config) override; void calculatePaths(const std::shared_ptr<PathfinderConfig> & config) override;

View File

@ -125,7 +125,7 @@ void InfoAboutHero::initFromHero(const CGHeroInstance *h, InfoAboutHero::EInfoLe
for (int i = 0; i < GameConstants::PRIMARY_SKILLS ; i++) for (int i = 0; i < GameConstants::PRIMARY_SKILLS ; i++)
{ {
details->primskills[i] = h->getPrimSkillLevel(static_cast<PrimarySkill::PrimarySkill>(i)); details->primskills[i] = h->getPrimSkillLevel(static_cast<PrimarySkill>(i));
} }
if (infoLevel == EInfoLevel::INBATTLE) if (infoLevel == EInfoLevel::INBATTLE)
details->manaLimit = h->manaLimit(); details->manaLimit = h->manaLimit();

View File

@ -141,7 +141,7 @@ class MarketInstanceConstructor : public CDefaultObjectTypeHandler<CGMarket>
protected: protected:
void initTypeData(const JsonNode & config) override; void initTypeData(const JsonNode & config) override;
std::set<EMarketMode::EMarketMode> marketModes; std::set<EMarketMode> marketModes;
JsonNode predefinedOffer; JsonNode predefinedOffer;
int marketEfficiency; int marketEfficiency;

View File

@ -173,12 +173,12 @@ void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const
return; return;
} }
PlayerRelations::PlayerRelations relations = cb->gameState()->getPlayerRelations( h->tempOwner, tempOwner ); PlayerRelations relations = cb->gameState()->getPlayerRelations( h->tempOwner, tempOwner );
if ( relations == PlayerRelations::ALLIES ) if ( relations == PlayerRelations::ALLIES )
return;//do not allow recruiting or capturing return;//do not allow recruiting or capturing
if( !relations && stacksCount() > 0) //object is guarded, owned by enemy if(relations == PlayerRelations::ENEMIES && stacksCount() > 0) //object is guarded, owned by enemy
{ {
BlockingDialog bd(true,false); BlockingDialog bd(true,false);
bd.player = h->tempOwner; bd.player = h->tempOwner;
@ -194,7 +194,7 @@ void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const
} }
// TODO this shouldn't be hardcoded // TODO this shouldn't be hardcoded
if(!relations && ID != Obj::WAR_MACHINE_FACTORY && ID != Obj::REFUGEE_CAMP) if(relations == PlayerRelations::ENEMIES && ID != Obj::WAR_MACHINE_FACTORY && ID != Obj::REFUGEE_CAMP)
{ {
cb->setOwner(this, h->tempOwner); cb->setOwner(this, h->tempOwner);
} }

View File

@ -315,7 +315,7 @@ void CGHeroInstance::initHero(CRandomGenerator & rand)
{ {
for(int g=0; g<GameConstants::PRIMARY_SKILLS; ++g) for(int g=0; g<GameConstants::PRIMARY_SKILLS; ++g)
{ {
pushPrimSkill(static_cast<PrimarySkill::PrimarySkill>(g), type->heroClass->primarySkillInitial[g]); pushPrimSkill(static_cast<PrimarySkill>(g), type->heroClass->primarySkillInitial[g]);
} }
} }
if(secSkills.size() == 1 && secSkills[0] == std::pair<SecondarySkill,ui8>(SecondarySkill::DEFAULT, -1)) //set secondary skills to default if(secSkills.size() == 1 && secSkills[0] == std::pair<SecondarySkill,ui8>(SecondarySkill::DEFAULT, -1)) //set secondary skills to default
@ -456,7 +456,7 @@ void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const
if (ID == Obj::HERO) if (ID == Obj::HERO)
{ {
if( cb->gameState()->getPlayerRelations(tempOwner, h->tempOwner)) //our or ally hero if( cb->gameState()->getPlayerRelations(tempOwner, h->tempOwner) != PlayerRelations::ENEMIES)
{ {
//exchange //exchange
cb->heroExchange(h->id, id); cb->heroExchange(h->id, id);
@ -997,11 +997,11 @@ int32_t CGHeroInstance::getSpellCost(const spells::Spell * sp) const
return sp->getCost(getSpellSchoolLevel(sp)); return sp->getCost(getSpellSchoolLevel(sp));
} }
void CGHeroInstance::pushPrimSkill( PrimarySkill::PrimarySkill which, int val ) void CGHeroInstance::pushPrimSkill( PrimarySkill which, int val )
{ {
assert(!hasBonus(Selector::typeSubtype(BonusType::PRIMARY_SKILL, which) assert(!hasBonus(Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast<int>(which))
.And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL)))); .And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL))));
addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::HERO_BASE_SKILL, val, id.getNum(), which)); addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::HERO_BASE_SKILL, val, id.getNum(), static_cast<int>(which)));
} }
EAlignment CGHeroInstance::getAlignment() const EAlignment CGHeroInstance::getAlignment() const
@ -1314,7 +1314,7 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelUpProposedSecondarySkills()
return skills; return skills;
} }
PrimarySkill::PrimarySkill CGHeroInstance::nextPrimarySkill(CRandomGenerator & rand) const PrimarySkill CGHeroInstance::nextPrimarySkill(CRandomGenerator & rand) const
{ {
assert(gainsLevel()); assert(gainsLevel());
int randomValue = rand.nextInt(99); int randomValue = rand.nextInt(99);
@ -1338,7 +1338,7 @@ PrimarySkill::PrimarySkill CGHeroInstance::nextPrimarySkill(CRandomGenerator & r
randomValue = 100 / GameConstants::PRIMARY_SKILLS; randomValue = 100 / GameConstants::PRIMARY_SKILLS;
} }
logGlobal->trace("The hero gets the primary skill %d with a probability of %d %%.", primarySkill, randomValue); logGlobal->trace("The hero gets the primary skill %d with a probability of %d %%.", primarySkill, randomValue);
return static_cast<PrimarySkill::PrimarySkill>(primarySkill); return static_cast<PrimarySkill>(primarySkill);
} }
std::optional<SecondarySkill> CGHeroInstance::nextSecondarySkill(CRandomGenerator & rand) const std::optional<SecondarySkill> CGHeroInstance::nextSecondarySkill(CRandomGenerator & rand) const
@ -1372,12 +1372,12 @@ std::optional<SecondarySkill> CGHeroInstance::nextSecondarySkill(CRandomGenerato
return chosenSecondarySkill; return chosenSecondarySkill;
} }
void CGHeroInstance::setPrimarySkill(PrimarySkill::PrimarySkill primarySkill, si64 value, ui8 abs) void CGHeroInstance::setPrimarySkill(PrimarySkill primarySkill, si64 value, ui8 abs)
{ {
if(primarySkill < PrimarySkill::EXPERIENCE) if(primarySkill < PrimarySkill::EXPERIENCE)
{ {
auto skill = getBonusLocalFirst(Selector::type()(BonusType::PRIMARY_SKILL) auto skill = getBonusLocalFirst(Selector::type()(BonusType::PRIMARY_SKILL)
.And(Selector::subtype()(primarySkill)) .And(Selector::subtype()(static_cast<int>(primarySkill)))
.And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL))); .And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL)));
assert(skill); assert(skill);
@ -1578,7 +1578,7 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler)
{ {
int value = valOfBonuses(Selector::typeSubtype(BonusType::PRIMARY_SKILL, i).And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL))); int value = valOfBonuses(Selector::typeSubtype(BonusType::PRIMARY_SKILL, i).And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL)));
handler.serializeInt(PrimarySkill::names[i], value, 0); handler.serializeInt(NPrimarySkill::names[i], value, 0);
} }
} }
} }
@ -1591,8 +1591,8 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler)
for(int i = 0; i < GameConstants::PRIMARY_SKILLS; ++i) for(int i = 0; i < GameConstants::PRIMARY_SKILLS; ++i)
{ {
int value = 0; int value = 0;
handler.serializeInt(PrimarySkill::names[i], value, 0); handler.serializeInt(NPrimarySkill::names[i], value, 0);
pushPrimSkill(static_cast<PrimarySkill::PrimarySkill>(i), value); pushPrimSkill(static_cast<PrimarySkill>(i), value);
} }
} }
} }

View File

@ -181,7 +181,7 @@ public:
bool gainsLevel() const; bool gainsLevel() const;
/// Returns the next primary skill on level up. Can only be called if hero can gain a level up. /// Returns the next primary skill on level up. Can only be called if hero can gain a level up.
PrimarySkill::PrimarySkill nextPrimarySkill(CRandomGenerator & rand) const; PrimarySkill nextPrimarySkill(CRandomGenerator & rand) const;
/// Returns the next secondary skill randomly on level up. Can only be called if hero can gain a level up. /// Returns the next secondary skill randomly on level up. Can only be called if hero can gain a level up.
std::optional<SecondarySkill> nextSecondarySkill(CRandomGenerator & rand) const; std::optional<SecondarySkill> nextSecondarySkill(CRandomGenerator & rand) const;
@ -195,7 +195,7 @@ public:
bool canLearnSkill() const; bool canLearnSkill() const;
bool canLearnSkill(const SecondarySkill & which) const; bool canLearnSkill(const SecondarySkill & which) const;
void setPrimarySkill(PrimarySkill::PrimarySkill primarySkill, si64 value, ui8 abs); void setPrimarySkill(PrimarySkill primarySkill, si64 value, ui8 abs);
void setSecSkillLevel(const SecondarySkill & which, int val, bool abs); // abs == 0 - changes by value; 1 - sets to value void setSecSkillLevel(const SecondarySkill & which, int val, bool abs); // abs == 0 - changes by value; 1 - sets to value
void levelUp(const std::vector<SecondarySkill> & skills); void levelUp(const std::vector<SecondarySkill> & skills);
@ -233,7 +233,7 @@ public:
void removeArtifact(ArtifactPosition pos) override; void removeArtifact(ArtifactPosition pos) override;
void initExp(CRandomGenerator & rand); void initExp(CRandomGenerator & rand);
void initArmy(CRandomGenerator & rand, IArmyDescriptor *dst = nullptr); void initArmy(CRandomGenerator & rand, IArmyDescriptor *dst = nullptr);
void pushPrimSkill(PrimarySkill::PrimarySkill which, int val); void pushPrimSkill(PrimarySkill which, int val);
ui8 maxlevelsToMagicSchool() const; ui8 maxlevelsToMagicSchool() const;
ui8 maxlevelsToWisdom() const; ui8 maxlevelsToWisdom() const;
void recreateSecondarySkillsBonuses(); void recreateSecondarySkillsBonuses();

View File

@ -38,17 +38,17 @@ int CGMarket::getMarketEfficiency() const
return marketEfficiency; return marketEfficiency;
} }
bool CGMarket::allowsTrade(EMarketMode::EMarketMode mode) const bool CGMarket::allowsTrade(EMarketMode mode) const
{ {
return marketModes.count(mode); return marketModes.count(mode);
} }
int CGMarket::availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const int CGMarket::availableUnits(EMarketMode mode, int marketItemSerial) const
{ {
return -1; return -1;
} }
std::vector<int> CGMarket::availableItemsIds(EMarketMode::EMarketMode mode) const std::vector<int> CGMarket::availableItemsIds(EMarketMode mode) const
{ {
if(allowsTrade(mode)) if(allowsTrade(mode))
return IMarket::availableItemsIds(mode); return IMarket::availableItemsIds(mode);
@ -59,7 +59,7 @@ CGMarket::CGMarket()
{ {
} }
std::vector<int> CGBlackMarket::availableItemsIds(EMarketMode::EMarketMode mode) const std::vector<int> CGBlackMarket::availableItemsIds(EMarketMode mode) const
{ {
switch(mode) switch(mode)
{ {
@ -110,7 +110,7 @@ void CGUniversity::initObj(CRandomGenerator & rand)
} }
} }
std::vector<int> CGUniversity::availableItemsIds(EMarketMode::EMarketMode mode) const std::vector<int> CGUniversity::availableItemsIds(EMarketMode mode) const
{ {
switch (mode) switch (mode)
{ {

View File

@ -18,7 +18,7 @@ class DLL_LINKAGE CGMarket : public CGObjectInstance, public IMarket
{ {
public: public:
std::set<EMarketMode::EMarketMode> marketModes; std::set<EMarketMode> marketModes;
int marketEfficiency; int marketEfficiency;
//window variables //window variables
@ -32,9 +32,9 @@ public:
///IMarket ///IMarket
int getMarketEfficiency() const override; int getMarketEfficiency() const override;
bool allowsTrade(EMarketMode::EMarketMode mode) const override; bool allowsTrade(EMarketMode mode) const override;
int availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const override; //-1 if unlimited int availableUnits(EMarketMode mode, int marketItemSerial) const override; //-1 if unlimited
std::vector<int> availableItemsIds(EMarketMode::EMarketMode mode) const override; std::vector<int> availableItemsIds(EMarketMode mode) const override;
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
@ -52,7 +52,7 @@ public:
std::vector<const CArtifact *> artifacts; //available artifacts std::vector<const CArtifact *> artifacts; //available artifacts
void newTurn(CRandomGenerator & rand) const override; //reset artifacts for black market every month void newTurn(CRandomGenerator & rand) const override; //reset artifacts for black market every month
std::vector<int> availableItemsIds(EMarketMode::EMarketMode mode) const override; std::vector<int> availableItemsIds(EMarketMode mode) const override;
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
@ -66,7 +66,7 @@ class DLL_LINKAGE CGUniversity : public CGMarket
public: public:
std::vector<int> skills; //available skills std::vector<int> skills; //available skills
std::vector<int> availableItemsIds(EMarketMode::EMarketMode mode) const override; std::vector<int> availableItemsIds(EMarketMode mode) const override;
void initObj(CRandomGenerator & rand) override;//set skills for trade void initObj(CRandomGenerator & rand) override;//set skills for trade
void onHeroVisit(const CGHeroInstance * h) const override; //open window void onHeroVisit(const CGHeroInstance * h) const override; //open window

View File

@ -103,7 +103,7 @@ void CGPandoraBox::giveContentsUpToExp(const CGHeroInstance *h) const
//give prim skills //give prim skills
for(int i=0; i<primskills.size(); i++) for(int i=0; i<primskills.size(); i++)
if(primskills[i]) if(primskills[i])
cb->changePrimSkill(h,static_cast<PrimarySkill::PrimarySkill>(i),primskills[i],false); cb->changePrimSkill(h,static_cast<PrimarySkill>(i),primskills[i],false);
assert(!cb->isVisitCoveredByAnotherQuery(this, h)); assert(!cb->isVisitCoveredByAnotherQuery(this, h));
@ -385,7 +385,7 @@ void CGPandoraBox::serializeJsonOptions(JsonSerializeFormat & handler)
{ {
auto s = handler.enterStruct("primarySkills"); auto s = handler.enterStruct("primarySkills");
for(int idx = 0; idx < primskills.size(); idx ++) for(int idx = 0; idx < primskills.size(); idx ++)
handler.serializeInt(PrimarySkill::names[idx], primskills[idx], 0); handler.serializeInt(NPrimarySkill::names[idx], primskills[idx], 0);
} }
} }

View File

@ -199,7 +199,7 @@ void CTownBonus::onHeroVisit (const CGHeroInstance * h) const
{ {
si64 val = 0; si64 val = 0;
InfoWindow iw; InfoWindow iw;
PrimarySkill::PrimarySkill what = PrimarySkill::NONE; PrimarySkill what = PrimarySkill::NONE;
switch(bType) switch(bType)
{ {

View File

@ -270,7 +270,7 @@ void CGTownInstance::blockingDialogAnswered(const CGHeroInstance *hero, ui32 ans
void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const
{ {
if(!cb->gameState()->getPlayerRelations( getOwner(), h->getOwner() ))//if this is enemy if(cb->gameState()->getPlayerRelations( getOwner(), h->getOwner() ) == PlayerRelations::ENEMIES)
{ {
if(armedGarrison() || visitingHero) if(armedGarrison() || visitingHero)
{ {
@ -701,7 +701,7 @@ int CGTownInstance::getMarketEfficiency() const
return marketCount; return marketCount;
} }
bool CGTownInstance::allowsTrade(EMarketMode::EMarketMode mode) const bool CGTownInstance::allowsTrade(EMarketMode mode) const
{ {
switch(mode) switch(mode)
{ {
@ -727,7 +727,7 @@ bool CGTownInstance::allowsTrade(EMarketMode::EMarketMode mode) const
} }
} }
std::vector<int> CGTownInstance::availableItemsIds(EMarketMode::EMarketMode mode) const std::vector<int> CGTownInstance::availableItemsIds(EMarketMode mode) const
{ {
if(mode == EMarketMode::RESOURCE_ARTIFACT) if(mode == EMarketMode::RESOURCE_ARTIFACT)
{ {

View File

@ -138,8 +138,8 @@ public:
EGeneratorState shipyardStatus() const override; EGeneratorState shipyardStatus() const override;
const IObjectInterface * getObject() const override; const IObjectInterface * getObject() const override;
int getMarketEfficiency() const override; //=market count int getMarketEfficiency() const override; //=market count
bool allowsTrade(EMarketMode::EMarketMode mode) const override; bool allowsTrade(EMarketMode mode) const override;
std::vector<int> availableItemsIds(EMarketMode::EMarketMode mode) const override; std::vector<int> availableItemsIds(EMarketMode mode) const override;
void setType(si32 ID, si32 subID) override; void setType(si32 ID, si32 subID) override;
void updateAppearance(); void updateAppearance();

View File

@ -131,7 +131,7 @@ bool CQuest::checkQuest(const CGHeroInstance * h) const
case MISSION_PRIMARY_STAT: case MISSION_PRIMARY_STAT:
for(int i = 0; i < GameConstants::PRIMARY_SKILLS; ++i) for(int i = 0; i < GameConstants::PRIMARY_SKILLS; ++i)
{ {
if(h->getPrimSkillLevel(static_cast<PrimarySkill::PrimarySkill>(i)) < static_cast<int>(m2stats[i])) if(h->getPrimSkillLevel(static_cast<PrimarySkill>(i)) < static_cast<int>(m2stats[i]))
return false; return false;
} }
return true; return true;
@ -503,7 +503,7 @@ void CQuest::serializeJson(JsonSerializeFormat & handler, const std::string & fi
m2stats.resize(GameConstants::PRIMARY_SKILLS); m2stats.resize(GameConstants::PRIMARY_SKILLS);
for(int i = 0; i < GameConstants::PRIMARY_SKILLS; ++i) for(int i = 0; i < GameConstants::PRIMARY_SKILLS; ++i)
handler.serializeInt(PrimarySkill::names[i], m2stats[i], 0); handler.serializeInt(NPrimarySkill::names[i], m2stats[i], 0);
} }
break; break;
case MISSION_KILL_HERO: case MISSION_KILL_HERO:
@ -865,7 +865,7 @@ void CGSeerHut::completeQuest (const CGHeroInstance * h) const //reward
cb->giveResource(h->getOwner(), static_cast<EGameResID>(rID), rVal); cb->giveResource(h->getOwner(), static_cast<EGameResID>(rID), rVal);
break; break;
case PRIMARY_SKILL: case PRIMARY_SKILL:
cb->changePrimSkill(h, static_cast<PrimarySkill::PrimarySkill>(rID), rVal, false); cb->changePrimSkill(h, static_cast<PrimarySkill>(rID), rVal, false);
break; break;
case SECONDARY_SKILL: case SECONDARY_SKILL:
cb->changeSecSkill(h, SecondarySkill(rID), rVal, false); cb->changeSecSkill(h, SecondarySkill(rID), rVal, false);
@ -982,7 +982,7 @@ void CGSeerHut::serializeJsonOptions(JsonSerializeFormat & handler)
identifier = GameConstants::RESOURCE_NAMES[rID]; identifier = GameConstants::RESOURCE_NAMES[rID];
break; break;
case PRIMARY_SKILL: case PRIMARY_SKILL:
identifier = PrimarySkill::names[rID]; identifier = NPrimarySkill::names[rID];
break; break;
case SECONDARY_SKILL: case SECONDARY_SKILL:
identifier = CSkillHandler::encodeSkill(rID); identifier = CSkillHandler::encodeSkill(rID);

View File

@ -20,7 +20,7 @@
VCMI_LIB_NAMESPACE_BEGIN VCMI_LIB_NAMESPACE_BEGIN
bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMarketMode mode) const bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) const
{ {
switch(mode) switch(mode)
{ {
@ -122,12 +122,12 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMar
return true; return true;
} }
bool IMarket::allowsTrade(EMarketMode::EMarketMode mode) const bool IMarket::allowsTrade(EMarketMode mode) const
{ {
return false; return false;
} }
int IMarket::availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const int IMarket::availableUnits(EMarketMode mode, int marketItemSerial) const
{ {
switch(mode) switch(mode)
{ {
@ -140,7 +140,7 @@ int IMarket::availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial)
} }
} }
std::vector<int> IMarket::availableItemsIds(EMarketMode::EMarketMode mode) const std::vector<int> IMarket::availableItemsIds(EMarketMode mode) const
{ {
std::vector<int> ret; std::vector<int> ret;
switch(mode) switch(mode)
@ -166,12 +166,12 @@ IMarket::IMarket()
{ {
} }
std::vector<EMarketMode::EMarketMode> IMarket::availableModes() const std::vector<EMarketMode> IMarket::availableModes() const
{ {
std::vector<EMarketMode::EMarketMode> ret; std::vector<EMarketMode> ret;
for (int i = 0; i < EMarketMode::MARTKET_AFTER_LAST_PLACEHOLDER; i++) for (EMarketMode i = static_cast<EMarketMode>(0); i < EMarketMode::MARTKET_AFTER_LAST_PLACEHOLDER; vstd::next(i, 1))
if(allowsTrade(static_cast<EMarketMode::EMarketMode>(i))) if(allowsTrade(i))
ret.push_back(static_cast<EMarketMode::EMarketMode>(i)); ret.push_back(i);
return ret; return ret;
} }

View File

@ -22,12 +22,12 @@ public:
virtual ~IMarket() {} virtual ~IMarket() {}
virtual int getMarketEfficiency() const = 0; virtual int getMarketEfficiency() const = 0;
virtual bool allowsTrade(EMarketMode::EMarketMode mode) const; virtual bool allowsTrade(EMarketMode mode) const;
virtual int availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const; //-1 if unlimited virtual int availableUnits(EMarketMode mode, int marketItemSerial) const; //-1 if unlimited
virtual std::vector<int> availableItemsIds(EMarketMode::EMarketMode mode) const; virtual std::vector<int> availableItemsIds(EMarketMode mode) const;
bool getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMarketMode mode) const; //val1 - how many units of id1 player has to give to receive val2 units bool getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) const; //val1 - how many units of id1 player has to give to receive val2 units
std::vector<EMarketMode::EMarketMode> availableModes() const; std::vector<EMarketMode> availableModes() const;
static const IMarket *castFrom(const CGObjectInstance *obj, bool verbose = true); static const IMarket *castFrom(const CGObjectInstance *obj, bool verbose = true);
}; };

View File

@ -68,14 +68,14 @@ bool CTeamVisited::wasVisited(const TeamID & team) const
//CGMine //CGMine
void CGMine::onHeroVisit( const CGHeroInstance * h ) const void CGMine::onHeroVisit( const CGHeroInstance * h ) const
{ {
int relations = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner); auto relations = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner);
if(relations == 2) //we're visiting our mine if(relations == PlayerRelations::SAME_PLAYER) //we're visiting our mine
{ {
cb->showGarrisonDialog(id,h->id,true); cb->showGarrisonDialog(id,h->id,true);
return; return;
} }
else if (relations == 1)//ally else if (relations == PlayerRelations::ALLIES)//ally
return; return;
if(stacksCount()) //Mine is guarded if(stacksCount()) //Mine is guarded
@ -1088,7 +1088,7 @@ void CGScholar::onHeroVisit( const CGHeroInstance * h ) const
switch (type) switch (type)
{ {
case PRIM_SKILL: case PRIM_SKILL:
cb->changePrimSkill(h,static_cast<PrimarySkill::PrimarySkill>(bid),+1); cb->changePrimSkill(h,static_cast<PrimarySkill>(bid),+1);
iw.components.emplace_back(Component::EComponentType::PRIM_SKILL, bid, +1, 0); iw.components.emplace_back(Component::EComponentType::PRIM_SKILL, bid, +1, 0);
break; break;
case SECONDARY_SKILL: case SECONDARY_SKILL:
@ -1143,7 +1143,7 @@ void CGScholar::serializeJsonOptions(JsonSerializeFormat & handler)
switch(bonusType) switch(bonusType)
{ {
case PRIM_SKILL: case PRIM_SKILL:
value = PrimarySkill::names[bonusID]; value = NPrimarySkill::names[bonusID];
handler.serializeString("rewardPrimSkill", value); handler.serializeString("rewardPrimSkill", value);
break; break;
case SECONDARY_SKILL: case SECONDARY_SKILL:
@ -1195,15 +1195,15 @@ void CGScholar::serializeJsonOptions(JsonSerializeFormat & handler)
void CGGarrison::onHeroVisit (const CGHeroInstance *h) const void CGGarrison::onHeroVisit (const CGHeroInstance *h) const
{ {
int ally = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner); auto relations = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner);
if (!ally && stacksCount() > 0) { if (relations == PlayerRelations::ENEMIES && stacksCount() > 0) {
//TODO: Find a way to apply magic garrison effects in battle. //TODO: Find a way to apply magic garrison effects in battle.
cb->startBattleI(h, this); cb->startBattleI(h, this);
return; return;
} }
//New owner. //New owner.
if (!ally) if (relations == PlayerRelations::ENEMIES)
cb->setOwner(this, h->tempOwner); cb->setOwner(this, h->tempOwner);
cb->showGarrisonDialog(id, h->id, removableUnits); cb->showGarrisonDialog(id, h->id, removableUnits);

View File

@ -861,7 +861,7 @@ void CMapLoaderH3M::readPredefinedHeroes()
{ {
for(int skillID = 0; skillID < GameConstants::PRIMARY_SKILLS; skillID++) for(int skillID = 0; skillID < GameConstants::PRIMARY_SKILLS; skillID++)
{ {
hero->pushPrimSkill(static_cast<PrimarySkill::PrimarySkill>(skillID), reader->readUInt8()); hero->pushPrimSkill(static_cast<PrimarySkill>(skillID), reader->readUInt8());
} }
} }
map->predefinedHeroes.emplace_back(hero); map->predefinedHeroes.emplace_back(hero);
@ -1029,7 +1029,7 @@ void CMapLoaderH3M::readBoxContent(CGPandoraBox * object, const int3 & mapPositi
object->primskills.resize(GameConstants::PRIMARY_SKILLS); object->primskills.resize(GameConstants::PRIMARY_SKILLS);
for(int x = 0; x < GameConstants::PRIMARY_SKILLS; ++x) for(int x = 0; x < GameConstants::PRIMARY_SKILLS; ++x)
object->primskills[x] = static_cast<PrimarySkill::PrimarySkill>(reader->readUInt8()); object->primskills[x] = reader->readUInt8();
int gabn = reader->readUInt8(); //number of gained abilities int gabn = reader->readUInt8(); //number of gained abilities
for(int oo = 0; oo < gabn; ++oo) for(int oo = 0; oo < gabn; ++oo)
@ -1768,7 +1768,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(const int3 & mapPosition, const Objec
for(int xx = 0; xx < GameConstants::PRIMARY_SKILLS; ++xx) for(int xx = 0; xx < GameConstants::PRIMARY_SKILLS; ++xx)
{ {
object->pushPrimSkill(static_cast<PrimarySkill::PrimarySkill>(xx), reader->readUInt8()); object->pushPrimSkill(static_cast<PrimarySkill>(xx), reader->readUInt8());
} }
} }
} }

View File

@ -57,8 +57,8 @@ CModHandler::CModHandler()
for(int i=0; i<GameConstants::PRIMARY_SKILLS; ++i) for(int i=0; i<GameConstants::PRIMARY_SKILLS; ++i)
{ {
identifiers->registerObject(ModScope::scopeBuiltin(), "primSkill", PrimarySkill::names[i], i); identifiers->registerObject(ModScope::scopeBuiltin(), "primSkill", NPrimarySkill::names[i], i);
identifiers->registerObject(ModScope::scopeBuiltin(), "primarySkill", PrimarySkill::names[i], i); identifiers->registerObject(ModScope::scopeBuiltin(), "primarySkill", NPrimarySkill::names[i], i);
} }
} }

View File

@ -190,8 +190,8 @@ struct DLL_LINKAGE PathNodeInfo
const TerrainTile * tile; const TerrainTile * tile;
int3 coord; int3 coord;
bool guarded; bool guarded;
PlayerRelations::PlayerRelations objectRelations; PlayerRelations objectRelations;
PlayerRelations::PlayerRelations heroRelations; PlayerRelations heroRelations;
bool isInitialPosition; bool isInitialPosition;
PathNodeInfo(); PathNodeInfo();

View File

@ -57,7 +57,7 @@ void Rewardable::Interface::grantRewardBeforeLevelup(IGameCallback * cb, const R
} }
for(int i=0; i< info.reward.primary.size(); i++) for(int i=0; i< info.reward.primary.size(); i++)
cb->changePrimSkill(hero, static_cast<PrimarySkill::PrimarySkill>(i), info.reward.primary[i], false); cb->changePrimSkill(hero, static_cast<PrimarySkill>(i), info.reward.primary[i], false);
si64 expToGive = 0; si64 expToGive = 0;

View File

@ -74,7 +74,7 @@ bool Rewardable::Limiter::heroAllowed(const CGHeroInstance * hero) const
for(size_t i=0; i<primary.size(); i++) for(size_t i=0; i<primary.size(); i++)
{ {
if(primary[i] > hero->getPrimSkillLevel(static_cast<PrimarySkill::PrimarySkill>(i))) if(primary[i] > hero->getPrimSkillLevel(static_cast<PrimarySkill>(i)))
return false; return false;
} }

View File

@ -46,7 +46,7 @@ void QuestWidget::obtainData()
case CQuest::Emission::MISSION_PRIMARY_STAT: case CQuest::Emission::MISSION_PRIMARY_STAT:
activeId = true; activeId = true;
activeAmount = true; activeAmount = true;
for(auto s : PrimarySkill::names) for(auto s : NPrimarySkill::names)
ui->targetId->addItem(QString::fromStdString(s)); ui->targetId->addItem(QString::fromStdString(s));
for(int i = 0; i < seerhut.quest->m2stats.size(); ++i) for(int i = 0; i < seerhut.quest->m2stats.size(); ++i)
{ {
@ -123,7 +123,7 @@ QString QuestWidget::commitChanges()
seerhut.quest->m13489val = ui->targetAmount->text().toInt(); seerhut.quest->m13489val = ui->targetAmount->text().toInt();
return QString("Reach lvl ").append(ui->targetAmount->text()); return QString("Reach lvl ").append(ui->targetAmount->text());
case CQuest::Emission::MISSION_PRIMARY_STAT: case CQuest::Emission::MISSION_PRIMARY_STAT:
seerhut.quest->m2stats.resize(sizeof(PrimarySkill::names), 0); seerhut.quest->m2stats.resize(sizeof(NPrimarySkill::names), 0);
seerhut.quest->m2stats[ui->targetId->currentIndex()] = ui->targetAmount->text().toInt(); seerhut.quest->m2stats[ui->targetId->currentIndex()] = ui->targetAmount->text().toInt();
//TODO: support multiple stats //TODO: support multiple stats
return ui->targetId->currentText().append(ui->targetAmount->text()); return ui->targetId->currentText().append(ui->targetAmount->text());

View File

@ -67,7 +67,7 @@ QList<QString> RewardsWidget::getListForType(RewardType typeId)
break; break;
case RewardType::PRIMARY_SKILL: case RewardType::PRIMARY_SKILL:
for(auto s : PrimarySkill::names) for(auto s : NPrimarySkill::names)
result.append(QString::fromStdString(s)); result.append(QString::fromStdString(s));
break; break;

View File

@ -248,11 +248,11 @@ void CGameHandler::levelUpCommander (const CCommanderInstance * c, int skill)
{ {
case ECommander::ATTACK: case ECommander::ATTACK:
scp.accumulatedBonus.type = BonusType::PRIMARY_SKILL; scp.accumulatedBonus.type = BonusType::PRIMARY_SKILL;
scp.accumulatedBonus.subtype = PrimarySkill::ATTACK; scp.accumulatedBonus.subtype = static_cast<int>(PrimarySkill::ATTACK);
break; break;
case ECommander::DEFENSE: case ECommander::DEFENSE:
scp.accumulatedBonus.type = BonusType::PRIMARY_SKILL; scp.accumulatedBonus.type = BonusType::PRIMARY_SKILL;
scp.accumulatedBonus.subtype = PrimarySkill::DEFENSE; scp.accumulatedBonus.subtype = static_cast<int>(PrimarySkill::DEFENSE);
break; break;
case ECommander::HEALTH: case ECommander::HEALTH:
scp.accumulatedBonus.type = BonusType::STACK_HEALTH; scp.accumulatedBonus.type = BonusType::STACK_HEALTH;
@ -368,7 +368,7 @@ void CGameHandler::expGiven(const CGHeroInstance *hero)
// levelUpHero(hero); // levelUpHero(hero);
} }
void CGameHandler::changePrimSkill(const CGHeroInstance * hero, PrimarySkill::PrimarySkill which, si64 val, bool abs) void CGameHandler::changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, bool abs)
{ {
if (which == PrimarySkill::EXPERIENCE) // Check if scenario limit reached if (which == PrimarySkill::EXPERIENCE) // Check if scenario limit reached
{ {
@ -1612,7 +1612,7 @@ void CGameHandler::heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2)
{ {
auto h1 = getHero(hero1), h2 = getHero(hero2); auto h1 = getHero(hero1), h2 = getHero(hero2);
if (getPlayerRelations(h1->getOwner(), h2->getOwner())) if (getPlayerRelations(h1->getOwner(), h2->getOwner()) != PlayerRelations::ENEMIES)
{ {
auto exchange = std::make_shared<CGarrisonDialogQuery>(this, h1, h2); auto exchange = std::make_shared<CGarrisonDialogQuery>(this, h1, h2);
ExchangeDialog hex; ExchangeDialog hex;
@ -3590,7 +3590,7 @@ void CGameHandler::getVictoryLossMessage(PlayerColor player, const EVictoryLossC
bool CGameHandler::dig(const CGHeroInstance *h) bool CGameHandler::dig(const CGHeroInstance *h)
{ {
if (h->diggingStatus() != EDiggingStatus::CAN_DIG) //checks for terrain and movement if (h->diggingStatus() != EDiggingStatus::CAN_DIG) //checks for terrain and movement
COMPLAIN_RETF("Hero cannot dig (error code %d)!", h->diggingStatus()); COMPLAIN_RETF("Hero cannot dig (error code %d)!", static_cast<int>(h->diggingStatus()));
createObject(h->visitablePos(), Obj::HOLE, 0 ); createObject(h->visitablePos(), Obj::HOLE, 0 );

View File

@ -106,7 +106,7 @@ public:
bool removeObject(const CGObjectInstance * obj) override; bool removeObject(const CGObjectInstance * obj) override;
void createObject(const int3 & visitablePosition, Obj type, int32_t subtype ) override; void createObject(const int3 & visitablePosition, Obj type, int32_t subtype ) override;
void setOwner(const CGObjectInstance * obj, PlayerColor owner) override; void setOwner(const CGObjectInstance * obj, PlayerColor owner) override;
void changePrimSkill(const CGHeroInstance * hero, PrimarySkill::PrimarySkill which, si64 val, bool abs=false) override; void changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, bool abs=false) override;
void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs=false) override; void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs=false) override;
void showBlockingDialog(BlockingDialog *iw) override; void showBlockingDialog(BlockingDialog *iw) override;

View File

@ -159,11 +159,11 @@ bool BattleActionProcessor::doDefendAction(const BattleAction & ba)
//defensive stance, TODO: filter out spell boosts from bonus (stone skin etc.) //defensive stance, TODO: filter out spell boosts from bonus (stone skin etc.)
SetStackEffect sse; SetStackEffect sse;
Bonus defenseBonusToAdd(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 20, -1, PrimarySkill::DEFENSE, BonusValueType::PERCENT_TO_ALL); Bonus defenseBonusToAdd(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 20, -1, static_cast<int32_t>(PrimarySkill::DEFENSE), BonusValueType::PERCENT_TO_ALL);
Bonus bonus2(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, stack->valOfBonuses(BonusType::DEFENSIVE_STANCE), -1, PrimarySkill::DEFENSE, BonusValueType::ADDITIVE_VALUE); Bonus bonus2(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, stack->valOfBonuses(BonusType::DEFENSIVE_STANCE), -1, static_cast<int32_t>(PrimarySkill::DEFENSE), BonusValueType::ADDITIVE_VALUE);
Bonus alternativeWeakCreatureBonus(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 1, -1, PrimarySkill::DEFENSE, BonusValueType::ADDITIVE_VALUE); Bonus alternativeWeakCreatureBonus(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 1, -1, static_cast<int32_t>(PrimarySkill::DEFENSE), BonusValueType::ADDITIVE_VALUE);
BonusList defence = *stack->getBonuses(Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE)); BonusList defence = *stack->getBonuses(Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast<int32_t>(PrimarySkill::DEFENSE)));
int oldDefenceValue = defence.totalValue(); int oldDefenceValue = defence.totalValue();
defence.push_back(std::make_shared<Bonus>(defenseBonusToAdd)); defence.push_back(std::make_shared<Bonus>(defenseBonusToAdd));

View File

@ -53,8 +53,8 @@ public:
{ {
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACKS_SPEED, BonusSource::CREATURE_ABILITY, DEFAULT_SPEED, 0)); bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACKS_SPEED, BonusSource::CREATURE_ABILITY, DEFAULT_SPEED, 0));
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CREATURE_ABILITY, DEFAULT_ATTACK, 0, PrimarySkill::ATTACK)); bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CREATURE_ABILITY, DEFAULT_ATTACK, 0, static_cast<int>(PrimarySkill::ATTACK)));
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CREATURE_ABILITY, DEFAULT_DEFENCE, 0, PrimarySkill::DEFENSE)); bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CREATURE_ABILITY, DEFAULT_DEFENCE, 0, static_cast<int>(PrimarySkill::DEFENSE)));
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, DEFAULT_HP, 0)); bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, DEFAULT_HP, 0));

View File

@ -43,7 +43,7 @@ public:
bool removeObject(const CGObjectInstance * obj) override {return false;} bool removeObject(const CGObjectInstance * obj) override {return false;}
void createObject(const int3 & visitablePosition, Obj type, int32_t subtype = 0) override {}; void createObject(const int3 & visitablePosition, Obj type, int32_t subtype = 0) override {};
void setOwner(const CGObjectInstance * objid, PlayerColor owner) override {} void setOwner(const CGObjectInstance * objid, PlayerColor owner) override {}
void changePrimSkill(const CGHeroInstance * hero, PrimarySkill::PrimarySkill which, si64 val, bool abs=false) override {} void changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, bool abs=false) override {}
void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs=false) override {} void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs=false) override {}
void showBlockingDialog(BlockingDialog *iw) override {} void showBlockingDialog(BlockingDialog *iw) override {}
void showGarrisonDialog(ObjectInstanceID upobj, ObjectInstanceID hid, bool removableUnits) override {} //cb will be called when player closes garrison window void showGarrisonDialog(ObjectInstanceID upobj, ObjectInstanceID hid, bool removableUnits) override {} //cb will be called when player closes garrison window

View File

@ -71,9 +71,9 @@ protected:
TEST_P(TimedApplyTest, ChangesBonuses) TEST_P(TimedApplyTest, ChangesBonuses)
{ {
Bonus testBonus1(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, 0, PrimarySkill::KNOWLEDGE); Bonus testBonus1(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, 0, static_cast<int>(PrimarySkill::KNOWLEDGE));
Bonus testBonus2(BonusDuration::N_TURNS, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, 0, PrimarySkill::KNOWLEDGE); Bonus testBonus2(BonusDuration::N_TURNS, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, 0, static_cast<int>(PrimarySkill::KNOWLEDGE));
testBonus2.turnsRemain = 4; testBonus2.turnsRemain = 4;
JsonNode options(JsonNode::JsonType::DATA_STRUCT); JsonNode options(JsonNode::JsonType::DATA_STRUCT);