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:
parent
17d3d663ee
commit
62cd8b12d4
@ -45,7 +45,7 @@ void CEmptyAI::yourTacticPhase(int distance)
|
||||
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);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
void yourTurn() override;
|
||||
void yourTacticPhase(int distance) 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 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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
@ -552,7 +552,7 @@ void AIGateway::yourTurn()
|
||||
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);
|
||||
NET_EVENT_HANDLER;
|
||||
|
@ -113,7 +113,7 @@ public:
|
||||
void initGameInterface(std::shared_ptr<Environment> env, std::shared_ptr<CCallback> CB) 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 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
|
||||
@ -144,7 +144,7 @@ public:
|
||||
void heroVisitsTown(const CGHeroInstance * hero, const CGTownInstance * town) override;
|
||||
void tileRevealed(const std::unordered_set<int3> & pos) 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 heroMovePointsChanged(const CGHeroInstance * hero) override;
|
||||
void garrisonsChanged(ObjectInstanceID id1, ObjectInstanceID id2) override;
|
||||
|
@ -241,7 +241,7 @@ bool isObjectPassable(const CGObjectInstance * obj)
|
||||
}
|
||||
|
||||
// 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)
|
||||
&& objectRelations != PlayerRelations::ENEMIES)
|
||||
|
@ -226,7 +226,7 @@ void foreach_neighbour(CCallback * cbp, const int3 & pos, const Func & foo) // a
|
||||
bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater);
|
||||
bool isObjectPassable(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 isWeeklyRevisitable(const CGObjectInstance * obj);
|
||||
|
@ -244,10 +244,10 @@ uint64_t evaluateArtifactArmyValue(CArtifactInstance * art)
|
||||
10 * art->valOfBonuses(BonusType::MOVEMENT, 1)
|
||||
+ 1200 * art->valOfBonuses(BonusType::STACKS_SPEED)
|
||||
+ 700 * art->valOfBonuses(BonusType::MORALE)
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK)
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE)
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, PrimarySkill::KNOWLEDGE)
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, PrimarySkill::SPELL_POWER)
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::ATTACK))
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::DEFENSE))
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::KNOWLEDGE))
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::SPELL_POWER))
|
||||
+ 500 * art->valOfBonuses(BonusType::LUCK);
|
||||
|
||||
auto classValue = 0;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
@ -618,7 +618,7 @@ void VCAI::yourTurn()
|
||||
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);
|
||||
NET_EVENT_HANDLER;
|
||||
|
@ -146,7 +146,7 @@ public:
|
||||
void initGameInterface(std::shared_ptr<Environment> ENV, std::shared_ptr<CCallback> CB) 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 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
|
||||
@ -177,7 +177,7 @@ public:
|
||||
void heroVisitsTown(const CGHeroInstance * hero, const CGTownInstance * town) override;
|
||||
void tileRevealed(const std::unordered_set<int3> & pos) 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 heroMovePointsChanged(const CGHeroInstance * hero) override;
|
||||
void garrisonsChanged(ObjectInstanceID id1, ObjectInstanceID id2) override;
|
||||
|
@ -242,12 +242,12 @@ void CCallback::buyArtifact(const CGHeroInstance *hero, ArtifactID aid)
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
pack.marketId = dynamic_cast<const CGObjectInstance *>(market)->id;
|
||||
|
@ -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 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::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, 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, 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 sendQueryReply(const JsonNode & reply, QueryID queryID) =0;
|
||||
@ -171,8 +171,8 @@ public:
|
||||
void endTurn() override;
|
||||
void swapGarrisonHero(const CGTownInstance *town) 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::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, ui32 id1, ui32 id2, 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 recruitHero(const CGObjectInstance *townOrTavern, const CGHeroInstance *hero) override;
|
||||
void save(const std::string &fname) override;
|
||||
|
@ -466,10 +466,10 @@ void CPlayerInterface::openTownWindow(const CGTownInstance * town)
|
||||
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;
|
||||
if (which == 4)
|
||||
if (which == PrimarySkill::EXPERIENCE)
|
||||
{
|
||||
for (auto ctw : GH.windows().findWindows<CAltarWindow>())
|
||||
ctw->setExpToLevel();
|
||||
@ -510,7 +510,7 @@ void CPlayerInterface::receivedResource()
|
||||
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;
|
||||
waitWhileDialog();
|
||||
|
@ -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 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 heroInGarrisonChange(const CGTownInstance *town) 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 heroManaPointsChanged(const CGHeroInstance * hero) override;
|
||||
void heroMovePointsChanged(const CGHeroInstance * hero) override;
|
||||
|
@ -165,7 +165,7 @@ public:
|
||||
bool removeObject(const CGObjectInstance * obj) override {return false;};
|
||||
void createObject(const int3 & visitablePosition, Obj type, int32_t subtype ) 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 showBlockingDialog(BlockingDialog * iw) override {};
|
||||
|
@ -483,7 +483,7 @@ void AdventureMapInterface::onTileLeftClicked(const int3 &mapPos)
|
||||
}
|
||||
//check if we can select this object
|
||||
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;
|
||||
if(LOCPLINT->localState->getCurrentArmy()->ID != Obj::HERO) //hero is not selected (presumably town)
|
||||
|
@ -222,7 +222,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded)
|
||||
//primary skills support
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ si64 InfoBoxHeroData::getValue()
|
||||
switch(type)
|
||||
{
|
||||
case HERO_PRIMARY_SKILL:
|
||||
return hero->getPrimSkillLevel(static_cast<PrimarySkill::PrimarySkill>(index));
|
||||
return hero->getPrimSkillLevel(static_cast<PrimarySkill>(index));
|
||||
case HERO_MANA:
|
||||
return hero->mana;
|
||||
case HERO_EXPERIENCE:
|
||||
|
@ -317,7 +317,7 @@ void CTradeWindow::CTradeableItem::setArtInstance(const CArtifactInstance *art)
|
||||
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),
|
||||
market(Market),
|
||||
hero(Hero),
|
||||
@ -585,7 +585,7 @@ void CTradeWindow::getEmptySlots(std::set<std::shared_ptr<CTradeableItem>> & toR
|
||||
toRemove.insert(item);
|
||||
}
|
||||
|
||||
void CTradeWindow::setMode(EMarketMode::EMarketMode Mode)
|
||||
void CTradeWindow::setMode(EMarketMode Mode)
|
||||
{
|
||||
const IMarket *m = market;
|
||||
const CGHeroInstance *h = hero;
|
||||
@ -616,7 +616,7 @@ void CTradeWindow::artifactSelected(CHeroArtPlace *slot)
|
||||
selectionChanged(true);
|
||||
}
|
||||
|
||||
std::string CMarketplaceWindow::getBackgroundForMode(EMarketMode::EMarketMode mode)
|
||||
std::string CMarketplaceWindow::getBackgroundForMode(EMarketMode mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
@ -635,7 +635,7 @@ std::string CMarketplaceWindow::getBackgroundForMode(EMarketMode::EMarketMode mo
|
||||
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)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
@ -870,7 +870,7 @@ void CMarketplaceWindow::selectionChanged(bool side)
|
||||
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 ));
|
||||
}
|
||||
@ -1075,7 +1075,7 @@ void CMarketplaceWindow::updateTraderText()
|
||||
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)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
std::shared_ptr<CTradeableItem> hRight;
|
||||
EType itemsType[2];
|
||||
|
||||
EMarketMode::EMarketMode mode;
|
||||
EMarketMode mode;
|
||||
std::shared_ptr<CButton> ok;
|
||||
std::shared_ptr<CButton> max;
|
||||
std::shared_ptr<CButton> deal;
|
||||
@ -83,7 +83,7 @@ public:
|
||||
std::shared_ptr<CSlider> slider; //for choosing amount to be exchanged
|
||||
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;
|
||||
|
||||
@ -95,7 +95,7 @@ public:
|
||||
void removeItems(const std::set<std::shared_ptr<CTradeableItem>> & toRemove);
|
||||
void removeItem(std::shared_ptr<CTradeableItem> item);
|
||||
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
|
||||
|
||||
@ -118,9 +118,9 @@ class CMarketplaceWindow : public CTradeWindow
|
||||
std::shared_ptr<CLabel> titleLabel;
|
||||
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:
|
||||
int r1, r2; //suggested amounts of traded resources
|
||||
bool madeTransaction; //if player made at least one transaction
|
||||
@ -130,7 +130,7 @@ public:
|
||||
void sliderMoved(int to);
|
||||
void makeDeal();
|
||||
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();
|
||||
|
||||
Point selectionOffset(bool Left) const override;
|
||||
@ -157,7 +157,7 @@ public:
|
||||
std::shared_ptr<CLabel> expOnAltar;
|
||||
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();
|
||||
|
||||
void getExpValues();
|
||||
|
@ -400,7 +400,7 @@ void CSplitWindow::sliderMoved(int to)
|
||||
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"),
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ class CLevelWindow : public CWindowObject
|
||||
void selectionChanged(unsigned to);
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
|
@ -15,11 +15,7 @@
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class BonusList;
|
||||
|
||||
namespace PrimarySkill
|
||||
{
|
||||
enum PrimarySkill : int8_t;
|
||||
}
|
||||
enum class PrimarySkill : int32_t;
|
||||
|
||||
class DLL_LINKAGE AFactionMember: public IConstBonusProvider, public INativeTerrainProvider
|
||||
{
|
||||
@ -51,7 +47,7 @@ public:
|
||||
/**
|
||||
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.
|
||||
For now, uses range from EGameSettings
|
||||
|
@ -54,7 +54,7 @@ int AFactionMember::getAttack(bool ranged) const
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -63,7 +63,7 @@ int AFactionMember::getDefense(bool ranged) const
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -82,12 +82,12 @@ int AFactionMember::getMaxDamage(bool ranged) const
|
||||
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 std::string keyAllSkills = "type_PRIMARY_SKILL";
|
||||
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;
|
||||
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
|
||||
|
@ -113,13 +113,13 @@ FactionID CCreature::getFaction() 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -345,10 +345,10 @@ void CCreature::updateFrom(const JsonNode & data)
|
||||
addBonus(configNode["speed"].Integer(), BonusType::STACKS_SPEED);
|
||||
|
||||
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())
|
||||
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())
|
||||
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["speed"].Integer(), BonusType::STACKS_SPEED);
|
||||
cre->addBonus(node["attack"].Integer(), BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK);
|
||||
cre->addBonus(node["defense"].Integer(), BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE);
|
||||
cre->addBonus(node["attack"].Integer(), BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::ATTACK));
|
||||
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"]["max"].Integer(), BonusType::CREATURE_DAMAGE, 2);
|
||||
@ -1030,11 +1030,11 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
|
||||
break;
|
||||
case 'A':
|
||||
b.type = BonusType::PRIMARY_SKILL;
|
||||
b.subtype = PrimarySkill::ATTACK;
|
||||
b.subtype = static_cast<int>(PrimarySkill::ATTACK);
|
||||
break;
|
||||
case 'D':
|
||||
b.type = BonusType::PRIMARY_SKILL;
|
||||
b.subtype = PrimarySkill::DEFENSE;
|
||||
b.subtype = static_cast<int>(PrimarySkill::DEFENSE);
|
||||
break;
|
||||
case 'M': //Max damage
|
||||
b.type = BonusType::CREATURE_DAMAGE;
|
||||
|
@ -631,7 +631,7 @@ bool CGameInfoCallback::hasAccess(std::optional<PlayerColor> playerId) const
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
PlayerRelations::PlayerRelations CGameInfoCallback::getPlayerRelations( PlayerColor color1, PlayerColor color2 ) const
|
||||
PlayerRelations CGameInfoCallback::getPlayerRelations( PlayerColor color1, PlayerColor color2 ) const
|
||||
{
|
||||
return gs->getPlayerRelations(color1, color2);
|
||||
}
|
||||
|
@ -60,9 +60,9 @@ public:
|
||||
virtual const Player * getPlayer(PlayerColor color) const = 0;
|
||||
// virtual int getResource(PlayerColor Player, EGameResID which) const = 0;
|
||||
// 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
|
||||
// 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
|
||||
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;
|
||||
@ -148,9 +148,9 @@ public:
|
||||
const Player * getPlayer(PlayerColor color) const override;
|
||||
virtual const PlayerState * getPlayerState(PlayerColor color, bool verbose = true) 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 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
|
||||
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;
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
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
|
||||
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;
|
||||
|
||||
// Show a dialog, player must take decision. If selection then he has to choose between one of given components,
|
||||
|
@ -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());
|
||||
//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;
|
||||
@ -333,13 +333,13 @@ std::vector<JsonNode> CHeroClassHandler::loadLegacyData()
|
||||
|
||||
parser.readNumber(); // unused aggression
|
||||
|
||||
for(const auto & name : PrimarySkill::names)
|
||||
for(const auto & name : NPrimarySkill::names)
|
||||
entry["primarySkills"][name].Float() = parser.readNumber();
|
||||
|
||||
for(const auto & name : PrimarySkill::names)
|
||||
for(const auto & name : NPrimarySkill::names)
|
||||
entry["lowLevelChance"][name].Float() = parser.readNumber();
|
||||
|
||||
for(const auto & name : PrimarySkill::names)
|
||||
for(const auto & name : NPrimarySkill::names)
|
||||
entry["highLevelChance"][name].Float() = parser.readNumber();
|
||||
|
||||
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>();
|
||||
bonus->type = BonusType::PRIMARY_SKILL;
|
||||
bonus->subtype = PrimarySkill::ATTACK;
|
||||
bonus->subtype = static_cast<int>(PrimarySkill::ATTACK);
|
||||
bonus->val = 0;
|
||||
bonus->limiter.reset(new CCreatureTypeLimiter(specCreature, false));
|
||||
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>();
|
||||
bonus->type = BonusType::PRIMARY_SKILL;
|
||||
bonus->subtype = PrimarySkill::DEFENSE;
|
||||
bonus->subtype = static_cast<int>(PrimarySkill::DEFENSE);
|
||||
bonus->val = 0;
|
||||
bonus->limiter.reset(new CCreatureTypeLimiter(specCreature, false));
|
||||
bonus->updater.reset(new GrowsWithLevelUpdater(specCreature.getDefense(false), stepSize));
|
||||
|
@ -212,7 +212,7 @@ public:
|
||||
|
||||
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:
|
||||
std::vector<JsonNode> loadLegacyData() override;
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
std::vector<QuestInfo> quests; //store info about all received quests
|
||||
|
||||
bool enteredWinningCheatCode, enteredLosingCheatCode; //if true, this player has entered cheat codes for loss / victory
|
||||
EPlayerStatus::EStatus status;
|
||||
EPlayerStatus status;
|
||||
std::optional<ui8> daysWithoutCastle;
|
||||
TurnTimerInfo turnTimer;
|
||||
|
||||
|
@ -527,13 +527,13 @@ void CTownHandler::addBonusesForVanilaBuilding(CBuilding * building) const
|
||||
b = createBonus(building, BonusType::LUCK, +2);
|
||||
break;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
case BuildingSubID::LIGHTHOUSE:
|
||||
b = createBonus(building, BonusType::MOVEMENT, +500, playerPropagator, 0);
|
||||
|
@ -412,11 +412,15 @@ class TeleportChannelID : public BaseForID<TeleportChannelID, si32>
|
||||
};
|
||||
|
||||
// Enum declarations
|
||||
namespace PrimarySkill
|
||||
enum class PrimarySkill : int32_t
|
||||
{
|
||||
enum PrimarySkill : int8_t { NONE = -1, ATTACK, DEFENSE, SPELL_POWER, KNOWLEDGE,
|
||||
EXPERIENCE = 4}; //for some reason changePrimSkill uses it
|
||||
}
|
||||
NONE = -1,
|
||||
ATTACK,
|
||||
DEFENSE,
|
||||
SPELL_POWER,
|
||||
KNOWLEDGE,
|
||||
EXPERIENCE = 4 //for some reason changePrimSkill uses it
|
||||
};
|
||||
|
||||
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,
|
||||
MARTKET_AFTER_LAST_PLACEHOLDER
|
||||
};
|
||||
}
|
||||
RESOURCE_RESOURCE, RESOURCE_PLAYER, CREATURE_RESOURCE, RESOURCE_ARTIFACT,
|
||||
ARTIFACT_RESOURCE, ARTIFACT_EXP, CREATURE_EXP, CREATURE_UNDEAD, RESOURCE_SKILL,
|
||||
MARTKET_AFTER_LAST_PLACEHOLDER
|
||||
};
|
||||
|
||||
namespace MappedKeys
|
||||
{
|
||||
@ -686,7 +687,7 @@ namespace MappedKeys
|
||||
{ "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-player", EMarketMode::RESOURCE_PLAYER },
|
||||
@ -1040,29 +1041,16 @@ enum class EActionType : int8_t
|
||||
|
||||
DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const EActionType actionType);
|
||||
|
||||
class DLL_LINKAGE EDiggingStatus
|
||||
enum class EDiggingStatus : int32_t
|
||||
{
|
||||
public:
|
||||
enum EEDiggingStatus
|
||||
{
|
||||
UNKNOWN = -1,
|
||||
CAN_DIG = 0,
|
||||
LACK_OF_MOVEMENT,
|
||||
WRONG_TERRAIN,
|
||||
TILE_OCCUPIED,
|
||||
BACKPACK_IS_FULL
|
||||
};
|
||||
|
||||
EDiggingStatus(EEDiggingStatus _num = UNKNOWN) : num(_num)
|
||||
{}
|
||||
|
||||
ID_LIKE_CLASS_COMMON(EDiggingStatus, EEDiggingStatus)
|
||||
|
||||
EEDiggingStatus num;
|
||||
UNKNOWN = -1,
|
||||
CAN_DIG = 0,
|
||||
LACK_OF_MOVEMENT,
|
||||
WRONG_TERRAIN,
|
||||
TILE_OCCUPIED,
|
||||
BACKPACK_IS_FULL
|
||||
};
|
||||
|
||||
ID_LIKE_OPERATORS(EDiggingStatus, EDiggingStatus::EEDiggingStatus)
|
||||
|
||||
class DLL_LINKAGE EPathfindingLayer
|
||||
{
|
||||
public:
|
||||
@ -1083,15 +1071,20 @@ DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const EPathfindingLayer
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ public:
|
||||
virtual bool removeObject(const CGObjectInstance * obj)=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 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 showBlockingDialog(BlockingDialog *iw) =0;
|
||||
virtual void showGarrisonDialog(ObjectInstanceID upobj, ObjectInstanceID hid, bool removableUnits) =0; //cb will be called when player closes garrison window
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
virtual void heroCreated(const CGHeroInstance*){};
|
||||
virtual void heroInGarrisonChange(const CGTownInstance *town){};
|
||||
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 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
|
||||
|
@ -119,7 +119,7 @@ namespace JsonRandom
|
||||
std::vector<si32> ret;
|
||||
if(value.isStruct())
|
||||
{
|
||||
for(const auto & name : PrimarySkill::names)
|
||||
for(const auto & name : NPrimarySkill::names)
|
||||
{
|
||||
ret.push_back(loadValue(value[name], rng));
|
||||
}
|
||||
@ -127,12 +127,12 @@ namespace JsonRandom
|
||||
if(value.isVector())
|
||||
{
|
||||
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())
|
||||
{
|
||||
auto key = loadKey(element, rng, defaultStats);
|
||||
defaultStats.erase(key);
|
||||
int id = vstd::find_pos(PrimarySkill::names, key);
|
||||
int id = vstd::find_pos(NPrimarySkill::names, key);
|
||||
if(id != -1)
|
||||
ret[id] += loadValue(element, rng);
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ struct DLL_LINKAGE SetPrimSkill : public CPackForClient
|
||||
|
||||
ui8 abs = 0; //0 - changes by value; 1 - sets to value
|
||||
ObjectInstanceID id;
|
||||
PrimarySkill::PrimarySkill which = PrimarySkill::ATTACK;
|
||||
PrimarySkill which = PrimarySkill::ATTACK;
|
||||
si64 val = 0;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h, const int version)
|
||||
@ -1318,7 +1318,7 @@ struct DLL_LINKAGE HeroLevelUp : public Query
|
||||
PlayerColor player;
|
||||
ObjectInstanceID heroId;
|
||||
|
||||
PrimarySkill::PrimarySkill primskill = PrimarySkill::ATTACK;
|
||||
PrimarySkill primskill = PrimarySkill::ATTACK;
|
||||
std::vector<SecondarySkill> skills;
|
||||
|
||||
void applyGs(CGameState * gs) const;
|
||||
@ -2425,7 +2425,7 @@ struct DLL_LINKAGE TradeOnMarketplace : public CPackForServer
|
||||
ObjectInstanceID marketId;
|
||||
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> val; //units of sold resource
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace GameConstants
|
||||
const std::string ALIGNMENT_NAMES [3] = {"good", "evil", "neutral"};
|
||||
}
|
||||
|
||||
namespace PrimarySkill
|
||||
namespace NPrimarySkill
|
||||
{
|
||||
const std::string names [GameConstants::PRIMARY_SKILLS] = { "attack", "defence", "spellpower", "knowledge" };
|
||||
}
|
||||
|
@ -475,8 +475,8 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const
|
||||
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::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, 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::ATTACK))->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
|
||||
|
@ -342,8 +342,8 @@ CUnitState::CUnitState():
|
||||
totalAttacks(this, Selector::type()(BonusType::ADDITIONAL_ATTACK), 1),
|
||||
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),
|
||||
attack(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK), 0),
|
||||
defence(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE), 0),
|
||||
attack(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::ATTACK)), 0),
|
||||
defence(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast<int>(PrimarySkill::DEFENSE)), 0),
|
||||
inFrenzy(this, Selector::type()(BonusType::IN_FRENZY)),
|
||||
cloneLifetimeMarker(this, Selector::type()(BonusType::NONE).And(Selector::source(BonusSource::SPELL_EFFECT, SpellID::CLONE))),
|
||||
cloneID(-1)
|
||||
|
@ -50,9 +50,9 @@ DamageRange DamageCalculator::getBaseDamageSingle() const
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -139,7 +139,7 @@ static JsonNode subtypeToJson(BonusType type, int subtype)
|
||||
switch(type)
|
||||
{
|
||||
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::SPECIFIC_SPELL_DAMAGE:
|
||||
case BonusType::SPELL:
|
||||
|
@ -1297,7 +1297,7 @@ UpgradeInfo CGameState::fillUpgradeInfo(const CStackInstance &stack) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
PlayerRelations::PlayerRelations CGameState::getPlayerRelations( PlayerColor color1, PlayerColor color2 ) const
|
||||
PlayerRelations CGameState::getPlayerRelations( PlayerColor color1, PlayerColor color2 ) const
|
||||
{
|
||||
if ( color1 == color2 )
|
||||
return PlayerRelations::SAME_PLAYER;
|
||||
|
@ -113,7 +113,7 @@ public:
|
||||
BattleField battleGetBattlefieldType(int3 tile, CRandomGenerator & rand);
|
||||
|
||||
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
|
||||
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;
|
||||
|
@ -125,7 +125,7 @@ void InfoAboutHero::initFromHero(const CGHeroInstance *h, InfoAboutHero::EInfoLe
|
||||
|
||||
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)
|
||||
details->manaLimit = h->manaLimit();
|
||||
|
@ -141,7 +141,7 @@ class MarketInstanceConstructor : public CDefaultObjectTypeHandler<CGMarket>
|
||||
protected:
|
||||
void initTypeData(const JsonNode & config) override;
|
||||
|
||||
std::set<EMarketMode::EMarketMode> marketModes;
|
||||
std::set<EMarketMode> marketModes;
|
||||
JsonNode predefinedOffer;
|
||||
int marketEfficiency;
|
||||
|
||||
|
@ -173,12 +173,12 @@ void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerRelations::PlayerRelations relations = cb->gameState()->getPlayerRelations( h->tempOwner, tempOwner );
|
||||
PlayerRelations relations = cb->gameState()->getPlayerRelations( h->tempOwner, tempOwner );
|
||||
|
||||
if ( relations == PlayerRelations::ALLIES )
|
||||
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);
|
||||
bd.player = h->tempOwner;
|
||||
@ -194,7 +194,7 @@ void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ void CGHeroInstance::initHero(CRandomGenerator & rand)
|
||||
{
|
||||
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
|
||||
@ -456,7 +456,7 @@ void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const
|
||||
|
||||
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
|
||||
cb->heroExchange(h->id, id);
|
||||
@ -997,11 +997,11 @@ int32_t CGHeroInstance::getSpellCost(const spells::Spell * sp) const
|
||||
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))));
|
||||
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
|
||||
@ -1314,7 +1314,7 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelUpProposedSecondarySkills()
|
||||
return skills;
|
||||
}
|
||||
|
||||
PrimarySkill::PrimarySkill CGHeroInstance::nextPrimarySkill(CRandomGenerator & rand) const
|
||||
PrimarySkill CGHeroInstance::nextPrimarySkill(CRandomGenerator & rand) const
|
||||
{
|
||||
assert(gainsLevel());
|
||||
int randomValue = rand.nextInt(99);
|
||||
@ -1338,7 +1338,7 @@ PrimarySkill::PrimarySkill CGHeroInstance::nextPrimarySkill(CRandomGenerator & r
|
||||
randomValue = 100 / GameConstants::PRIMARY_SKILLS;
|
||||
}
|
||||
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
|
||||
@ -1372,12 +1372,12 @@ std::optional<SecondarySkill> CGHeroInstance::nextSecondarySkill(CRandomGenerato
|
||||
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)
|
||||
{
|
||||
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)));
|
||||
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)));
|
||||
|
||||
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)
|
||||
{
|
||||
int value = 0;
|
||||
handler.serializeInt(PrimarySkill::names[i], value, 0);
|
||||
pushPrimSkill(static_cast<PrimarySkill::PrimarySkill>(i), value);
|
||||
handler.serializeInt(NPrimarySkill::names[i], value, 0);
|
||||
pushPrimSkill(static_cast<PrimarySkill>(i), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ public:
|
||||
bool gainsLevel() const;
|
||||
|
||||
/// 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.
|
||||
std::optional<SecondarySkill> nextSecondarySkill(CRandomGenerator & rand) const;
|
||||
@ -195,7 +195,7 @@ public:
|
||||
bool canLearnSkill() 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 levelUp(const std::vector<SecondarySkill> & skills);
|
||||
|
||||
@ -233,7 +233,7 @@ public:
|
||||
void removeArtifact(ArtifactPosition pos) override;
|
||||
void initExp(CRandomGenerator & rand);
|
||||
void initArmy(CRandomGenerator & rand, IArmyDescriptor *dst = nullptr);
|
||||
void pushPrimSkill(PrimarySkill::PrimarySkill which, int val);
|
||||
void pushPrimSkill(PrimarySkill which, int val);
|
||||
ui8 maxlevelsToMagicSchool() const;
|
||||
ui8 maxlevelsToWisdom() const;
|
||||
void recreateSecondarySkillsBonuses();
|
||||
|
@ -38,17 +38,17 @@ int CGMarket::getMarketEfficiency() const
|
||||
return marketEfficiency;
|
||||
}
|
||||
|
||||
bool CGMarket::allowsTrade(EMarketMode::EMarketMode mode) const
|
||||
bool CGMarket::allowsTrade(EMarketMode mode) const
|
||||
{
|
||||
return marketModes.count(mode);
|
||||
}
|
||||
|
||||
int CGMarket::availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const
|
||||
int CGMarket::availableUnits(EMarketMode mode, int marketItemSerial) const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::vector<int> CGMarket::availableItemsIds(EMarketMode::EMarketMode mode) const
|
||||
std::vector<int> CGMarket::availableItemsIds(EMarketMode mode) const
|
||||
{
|
||||
if(allowsTrade(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)
|
||||
{
|
||||
@ -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)
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ class DLL_LINKAGE CGMarket : public CGObjectInstance, public IMarket
|
||||
{
|
||||
public:
|
||||
|
||||
std::set<EMarketMode::EMarketMode> marketModes;
|
||||
std::set<EMarketMode> marketModes;
|
||||
int marketEfficiency;
|
||||
|
||||
//window variables
|
||||
@ -32,9 +32,9 @@ public:
|
||||
|
||||
///IMarket
|
||||
int getMarketEfficiency() const override;
|
||||
bool allowsTrade(EMarketMode::EMarketMode mode) const override;
|
||||
int availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const override; //-1 if unlimited
|
||||
std::vector<int> availableItemsIds(EMarketMode::EMarketMode mode) const override;
|
||||
bool allowsTrade(EMarketMode mode) const override;
|
||||
int availableUnits(EMarketMode mode, int marketItemSerial) const override; //-1 if unlimited
|
||||
std::vector<int> availableItemsIds(EMarketMode mode) const override;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
@ -52,7 +52,7 @@ public:
|
||||
std::vector<const CArtifact *> artifacts; //available artifacts
|
||||
|
||||
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)
|
||||
{
|
||||
@ -66,7 +66,7 @@ class DLL_LINKAGE CGUniversity : public CGMarket
|
||||
public:
|
||||
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 onHeroVisit(const CGHeroInstance * h) const override; //open window
|
||||
|
||||
|
@ -103,7 +103,7 @@ void CGPandoraBox::giveContentsUpToExp(const CGHeroInstance *h) const
|
||||
//give prim skills
|
||||
for(int i=0; i<primskills.size(); 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));
|
||||
|
||||
@ -385,7 +385,7 @@ void CGPandoraBox::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||
{
|
||||
auto s = handler.enterStruct("primarySkills");
|
||||
for(int idx = 0; idx < primskills.size(); idx ++)
|
||||
handler.serializeInt(PrimarySkill::names[idx], primskills[idx], 0);
|
||||
handler.serializeInt(NPrimarySkill::names[idx], primskills[idx], 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ void CTownBonus::onHeroVisit (const CGHeroInstance * h) const
|
||||
{
|
||||
si64 val = 0;
|
||||
InfoWindow iw;
|
||||
PrimarySkill::PrimarySkill what = PrimarySkill::NONE;
|
||||
PrimarySkill what = PrimarySkill::NONE;
|
||||
|
||||
switch(bType)
|
||||
{
|
||||
|
@ -270,7 +270,7 @@ void CGTownInstance::blockingDialogAnswered(const CGHeroInstance *hero, ui32 ans
|
||||
|
||||
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)
|
||||
{
|
||||
@ -701,7 +701,7 @@ int CGTownInstance::getMarketEfficiency() const
|
||||
return marketCount;
|
||||
}
|
||||
|
||||
bool CGTownInstance::allowsTrade(EMarketMode::EMarketMode mode) const
|
||||
bool CGTownInstance::allowsTrade(EMarketMode mode) const
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -138,8 +138,8 @@ public:
|
||||
EGeneratorState shipyardStatus() const override;
|
||||
const IObjectInterface * getObject() const override;
|
||||
int getMarketEfficiency() const override; //=market count
|
||||
bool allowsTrade(EMarketMode::EMarketMode mode) const override;
|
||||
std::vector<int> availableItemsIds(EMarketMode::EMarketMode mode) const override;
|
||||
bool allowsTrade(EMarketMode mode) const override;
|
||||
std::vector<int> availableItemsIds(EMarketMode mode) const override;
|
||||
|
||||
void setType(si32 ID, si32 subID) override;
|
||||
void updateAppearance();
|
||||
|
@ -131,7 +131,7 @@ bool CQuest::checkQuest(const CGHeroInstance * h) const
|
||||
case MISSION_PRIMARY_STAT:
|
||||
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 true;
|
||||
@ -503,7 +503,7 @@ void CQuest::serializeJson(JsonSerializeFormat & handler, const std::string & fi
|
||||
m2stats.resize(GameConstants::PRIMARY_SKILLS);
|
||||
|
||||
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;
|
||||
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);
|
||||
break;
|
||||
case PRIMARY_SKILL:
|
||||
cb->changePrimSkill(h, static_cast<PrimarySkill::PrimarySkill>(rID), rVal, false);
|
||||
cb->changePrimSkill(h, static_cast<PrimarySkill>(rID), rVal, false);
|
||||
break;
|
||||
case SECONDARY_SKILL:
|
||||
cb->changeSecSkill(h, SecondarySkill(rID), rVal, false);
|
||||
@ -982,7 +982,7 @@ void CGSeerHut::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||
identifier = GameConstants::RESOURCE_NAMES[rID];
|
||||
break;
|
||||
case PRIMARY_SKILL:
|
||||
identifier = PrimarySkill::names[rID];
|
||||
identifier = NPrimarySkill::names[rID];
|
||||
break;
|
||||
case SECONDARY_SKILL:
|
||||
identifier = CSkillHandler::encodeSkill(rID);
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
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)
|
||||
{
|
||||
@ -122,12 +122,12 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMar
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IMarket::allowsTrade(EMarketMode::EMarketMode mode) const
|
||||
bool IMarket::allowsTrade(EMarketMode mode) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int IMarket::availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const
|
||||
int IMarket::availableUnits(EMarketMode mode, int marketItemSerial) const
|
||||
{
|
||||
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;
|
||||
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;
|
||||
for (int i = 0; i < EMarketMode::MARTKET_AFTER_LAST_PLACEHOLDER; i++)
|
||||
if(allowsTrade(static_cast<EMarketMode::EMarketMode>(i)))
|
||||
ret.push_back(static_cast<EMarketMode::EMarketMode>(i));
|
||||
std::vector<EMarketMode> ret;
|
||||
for (EMarketMode i = static_cast<EMarketMode>(0); i < EMarketMode::MARTKET_AFTER_LAST_PLACEHOLDER; vstd::next(i, 1))
|
||||
if(allowsTrade(i))
|
||||
ret.push_back(i);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -22,12 +22,12 @@ public:
|
||||
virtual ~IMarket() {}
|
||||
|
||||
virtual int getMarketEfficiency() const = 0;
|
||||
virtual bool allowsTrade(EMarketMode::EMarketMode mode) const;
|
||||
virtual int availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const; //-1 if unlimited
|
||||
virtual std::vector<int> availableItemsIds(EMarketMode::EMarketMode mode) const;
|
||||
virtual bool allowsTrade(EMarketMode mode) const;
|
||||
virtual int availableUnits(EMarketMode mode, int marketItemSerial) const; //-1 if unlimited
|
||||
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
|
||||
std::vector<EMarketMode::EMarketMode> availableModes() const;
|
||||
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> availableModes() const;
|
||||
|
||||
static const IMarket *castFrom(const CGObjectInstance *obj, bool verbose = true);
|
||||
};
|
||||
|
@ -68,14 +68,14 @@ bool CTeamVisited::wasVisited(const TeamID & team) const
|
||||
//CGMine
|
||||
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);
|
||||
return;
|
||||
}
|
||||
else if (relations == 1)//ally
|
||||
else if (relations == PlayerRelations::ALLIES)//ally
|
||||
return;
|
||||
|
||||
if(stacksCount()) //Mine is guarded
|
||||
@ -1088,7 +1088,7 @@ void CGScholar::onHeroVisit( const CGHeroInstance * h ) const
|
||||
switch (type)
|
||||
{
|
||||
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);
|
||||
break;
|
||||
case SECONDARY_SKILL:
|
||||
@ -1143,7 +1143,7 @@ void CGScholar::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||
switch(bonusType)
|
||||
{
|
||||
case PRIM_SKILL:
|
||||
value = PrimarySkill::names[bonusID];
|
||||
value = NPrimarySkill::names[bonusID];
|
||||
handler.serializeString("rewardPrimSkill", value);
|
||||
break;
|
||||
case SECONDARY_SKILL:
|
||||
@ -1195,15 +1195,15 @@ void CGScholar::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||
|
||||
void CGGarrison::onHeroVisit (const CGHeroInstance *h) const
|
||||
{
|
||||
int ally = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner);
|
||||
if (!ally && stacksCount() > 0) {
|
||||
auto relations = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner);
|
||||
if (relations == PlayerRelations::ENEMIES && stacksCount() > 0) {
|
||||
//TODO: Find a way to apply magic garrison effects in battle.
|
||||
cb->startBattleI(h, this);
|
||||
return;
|
||||
}
|
||||
|
||||
//New owner.
|
||||
if (!ally)
|
||||
if (relations == PlayerRelations::ENEMIES)
|
||||
cb->setOwner(this, h->tempOwner);
|
||||
|
||||
cb->showGarrisonDialog(id, h->id, removableUnits);
|
||||
|
@ -861,7 +861,7 @@ void CMapLoaderH3M::readPredefinedHeroes()
|
||||
{
|
||||
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);
|
||||
@ -1029,7 +1029,7 @@ void CMapLoaderH3M::readBoxContent(CGPandoraBox * object, const int3 & mapPositi
|
||||
|
||||
object->primskills.resize(GameConstants::PRIMARY_SKILLS);
|
||||
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
|
||||
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)
|
||||
{
|
||||
object->pushPrimSkill(static_cast<PrimarySkill::PrimarySkill>(xx), reader->readUInt8());
|
||||
object->pushPrimSkill(static_cast<PrimarySkill>(xx), reader->readUInt8());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,8 +57,8 @@ CModHandler::CModHandler()
|
||||
|
||||
for(int i=0; i<GameConstants::PRIMARY_SKILLS; ++i)
|
||||
{
|
||||
identifiers->registerObject(ModScope::scopeBuiltin(), "primSkill", PrimarySkill::names[i], i);
|
||||
identifiers->registerObject(ModScope::scopeBuiltin(), "primarySkill", PrimarySkill::names[i], i);
|
||||
identifiers->registerObject(ModScope::scopeBuiltin(), "primSkill", NPrimarySkill::names[i], i);
|
||||
identifiers->registerObject(ModScope::scopeBuiltin(), "primarySkill", NPrimarySkill::names[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,8 +190,8 @@ struct DLL_LINKAGE PathNodeInfo
|
||||
const TerrainTile * tile;
|
||||
int3 coord;
|
||||
bool guarded;
|
||||
PlayerRelations::PlayerRelations objectRelations;
|
||||
PlayerRelations::PlayerRelations heroRelations;
|
||||
PlayerRelations objectRelations;
|
||||
PlayerRelations heroRelations;
|
||||
bool isInitialPosition;
|
||||
|
||||
PathNodeInfo();
|
||||
|
@ -57,7 +57,7 @@ void Rewardable::Interface::grantRewardBeforeLevelup(IGameCallback * cb, const R
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -74,7 +74,7 @@ bool Rewardable::Limiter::heroAllowed(const CGHeroInstance * hero) const
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ void QuestWidget::obtainData()
|
||||
case CQuest::Emission::MISSION_PRIMARY_STAT:
|
||||
activeId = true;
|
||||
activeAmount = true;
|
||||
for(auto s : PrimarySkill::names)
|
||||
for(auto s : NPrimarySkill::names)
|
||||
ui->targetId->addItem(QString::fromStdString(s));
|
||||
for(int i = 0; i < seerhut.quest->m2stats.size(); ++i)
|
||||
{
|
||||
@ -123,7 +123,7 @@ QString QuestWidget::commitChanges()
|
||||
seerhut.quest->m13489val = ui->targetAmount->text().toInt();
|
||||
return QString("Reach lvl ").append(ui->targetAmount->text());
|
||||
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();
|
||||
//TODO: support multiple stats
|
||||
return ui->targetId->currentText().append(ui->targetAmount->text());
|
||||
|
@ -67,7 +67,7 @@ QList<QString> RewardsWidget::getListForType(RewardType typeId)
|
||||
break;
|
||||
|
||||
case RewardType::PRIMARY_SKILL:
|
||||
for(auto s : PrimarySkill::names)
|
||||
for(auto s : NPrimarySkill::names)
|
||||
result.append(QString::fromStdString(s));
|
||||
break;
|
||||
|
||||
|
@ -248,11 +248,11 @@ void CGameHandler::levelUpCommander (const CCommanderInstance * c, int skill)
|
||||
{
|
||||
case ECommander::ATTACK:
|
||||
scp.accumulatedBonus.type = BonusType::PRIMARY_SKILL;
|
||||
scp.accumulatedBonus.subtype = PrimarySkill::ATTACK;
|
||||
scp.accumulatedBonus.subtype = static_cast<int>(PrimarySkill::ATTACK);
|
||||
break;
|
||||
case ECommander::DEFENSE:
|
||||
scp.accumulatedBonus.type = BonusType::PRIMARY_SKILL;
|
||||
scp.accumulatedBonus.subtype = PrimarySkill::DEFENSE;
|
||||
scp.accumulatedBonus.subtype = static_cast<int>(PrimarySkill::DEFENSE);
|
||||
break;
|
||||
case ECommander::HEALTH:
|
||||
scp.accumulatedBonus.type = BonusType::STACK_HEALTH;
|
||||
@ -368,7 +368,7 @@ void CGameHandler::expGiven(const CGHeroInstance *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
|
||||
{
|
||||
@ -1612,7 +1612,7 @@ void CGameHandler::heroExchange(ObjectInstanceID hero1, ObjectInstanceID 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);
|
||||
ExchangeDialog hex;
|
||||
@ -3590,7 +3590,7 @@ void CGameHandler::getVictoryLossMessage(PlayerColor player, const EVictoryLossC
|
||||
bool CGameHandler::dig(const CGHeroInstance *h)
|
||||
{
|
||||
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 );
|
||||
|
||||
|
@ -106,7 +106,7 @@ public:
|
||||
bool removeObject(const CGObjectInstance * obj) override;
|
||||
void createObject(const int3 & visitablePosition, Obj type, int32_t subtype ) 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 showBlockingDialog(BlockingDialog *iw) override;
|
||||
|
@ -159,11 +159,11 @@ bool BattleActionProcessor::doDefendAction(const BattleAction & ba)
|
||||
|
||||
//defensive stance, TODO: filter out spell boosts from bonus (stone skin etc.)
|
||||
SetStackEffect sse;
|
||||
Bonus defenseBonusToAdd(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 20, -1, 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 alternativeWeakCreatureBonus(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 1, -1, PrimarySkill::DEFENSE, BonusValueType::ADDITIVE_VALUE);
|
||||
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, static_cast<int32_t>(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();
|
||||
|
||||
defence.push_back(std::make_shared<Bonus>(defenseBonusToAdd));
|
||||
|
@ -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::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_DEFENCE, 0, PrimarySkill::DEFENSE));
|
||||
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, static_cast<int>(PrimarySkill::DEFENSE)));
|
||||
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, DEFAULT_HP, 0));
|
||||
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
bool removeObject(const CGObjectInstance * obj) override {return false;}
|
||||
void createObject(const int3 & visitablePosition, Obj type, int32_t subtype = 0) 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 showBlockingDialog(BlockingDialog *iw) override {}
|
||||
void showGarrisonDialog(ObjectInstanceID upobj, ObjectInstanceID hid, bool removableUnits) override {} //cb will be called when player closes garrison window
|
||||
|
@ -71,9 +71,9 @@ protected:
|
||||
|
||||
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;
|
||||
|
||||
JsonNode options(JsonNode::JsonType::DATA_STRUCT);
|
||||
|
Loading…
Reference in New Issue
Block a user