1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Add hero gold cost to GameConstants

This commit is contained in:
ArseniyShestakov 2015-12-07 00:13:58 +03:00
parent 807fd6391b
commit 03e9dd3bab
6 changed files with 9 additions and 10 deletions

View File

@ -23,7 +23,6 @@ class CCallback;
typedef const int3& crint3;
typedef const std::string& crstring;
const int HERO_GOLD_COST = 2500;
const int GOLD_MINE_PRODUCTION = 1000, WOOD_ORE_MINE_PRODUCTION = 2, RESOURCE_MINE_PRODUCTION = 1;
const int ACTUAL_RESOURCE_COUNT = 7;
const int ALLOWED_ROAMING_HEROES = 8;

View File

@ -693,8 +693,8 @@ TSubgoal RecruitHero::whatToDoToAchieve()
if(!t)
return sptr (Goals::BuildThis(BuildingID::TAVERN));
if(cb->getResourceAmount(Res::GOLD) < HERO_GOLD_COST)
return sptr (Goals::CollectRes(Res::GOLD, HERO_GOLD_COST));
if(cb->getResourceAmount(Res::GOLD) < GameConstants::HERO_GOLD_COST)
return sptr (Goals::CollectRes(Res::GOLD, GameConstants::HERO_GOLD_COST));
return iAmElementar();
}

View File

@ -1445,7 +1445,7 @@ bool VCAI::canRecruitAnyHero (const CGTownInstance * t) const
if (!t)
t = findTownWithTavern();
if (t)
return cb->getResourceAmount(Res::GOLD) >= HERO_GOLD_COST &&
return cb->getResourceAmount(Res::GOLD) >= GameConstants::HERO_GOLD_COST &&
cb->getHeroesInfo().size() < ALLOWED_ROAMING_HEROES &&
cb->getAvailableHeroes(t).size();
else
@ -1530,7 +1530,7 @@ void VCAI::wander(HeroPtr h)
}
break;
}
else if(cb->getResourceAmount(Res::GOLD) >= HERO_GOLD_COST)
else if(cb->getResourceAmount(Res::GOLD) >= GameConstants::HERO_GOLD_COST)
{
std::vector<const CGTownInstance *> towns = cb->getTownsInfo();
erase_if(towns, [](const CGTownInstance *t) -> bool

View File

@ -704,7 +704,7 @@ CTavernWindow::CTavernWindow(const CGObjectInstance *TavernObj):
oldSelected = -1;
new CLabel(200, 35, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[37]);
new CLabel(320, 328, FONT_SMALL, CENTER, Colors::WHITE, "2500");
new CLabel(320, 328, FONT_SMALL, CENTER, Colors::WHITE, boost::lexical_cast<std::string>(GameConstants::HERO_GOLD_COST));
auto rumorText = boost::str(boost::format(CGI->generaltexth->allTexts[216]) % LOCPLINT->cb->getTavernRumor(tavernObj));
new CTextBox(rumorText, Rect(32, 190, 330, 68), 0, FONT_SMALL, CENTER, Colors::WHITE);
@ -714,7 +714,7 @@ CTavernWindow::CTavernWindow(const CGObjectInstance *TavernObj):
recruit = new CButton(Point(272, 355), "TPTAV01.DEF", CButton::tooltip(), std::bind(&CTavernWindow::recruitb, this), SDLK_RETURN);
thiefGuild = new CButton(Point(22, 428), "TPTAV02.DEF", CButton::tooltip(CGI->generaltexth->tavernInfo[5]), std::bind(&CTavernWindow::thievesguildb, this), SDLK_t);
if(LOCPLINT->cb->getResourceAmount(Res::GOLD) < 2500) //not enough gold
if(LOCPLINT->cb->getResourceAmount(Res::GOLD) < GameConstants::HERO_GOLD_COST) //not enough gold
{
recruit->addHoverText(CButton::NORMAL, CGI->generaltexth->tavernInfo[0]); //Cannot afford a Hero
recruit->block(true);

View File

@ -33,6 +33,7 @@ namespace GameConstants
const int SPELL_SCHOOL_LEVELS = 4;
const int CRE_LEVELS = 10; // number of creature experience levels
const int HERO_GOLD_COST = 2500;
const int SPELLBOOK_GOLD_COST = 500;
const int BATTLE_PENALTY_DISTANCE = 10; //if the distance is > than this, then shooting stack has distance penalty
const int ARMY_SIZE = 7;

View File

@ -3313,12 +3313,11 @@ bool CGameHandler::hireHero(const CGObjectInstance *obj, ui8 hid, PlayerColor pl
{
const PlayerState *p = gs->getPlayer(player);
const CGTownInstance *t = gs->getTown(obj->id);
static const int GOLD_NEEDED = 2500;
//common preconditions
// if( (p->resources.at(Res::GOLD)<GOLD_NEEDED && complain("Not enough gold for buying hero!"))
// || (getHeroCount(player, false) >= GameConstants::MAX_HEROES_PER_PLAYER && complain("Cannot hire hero, only 8 wandering heroes are allowed!")))
if( (p->resources.at(Res::GOLD)<GOLD_NEEDED && complain("Not enough gold for buying hero!"))
if((p->resources.at(Res::GOLD) < GameConstants::HERO_GOLD_COST && complain("Not enough gold for buying hero!"))
|| ((!t) && (getHeroCount(player, false) >= VLC->modh->settings.MAX_HEROES_ON_MAP_PER_PLAYER && complain("Cannot hire hero, too many wandering heroes already!")))
|| ((t) && (getHeroCount(player, true) >= VLC->modh->settings.MAX_HEROES_AVAILABLE_PER_PLAYER && complain("Cannot hire hero, too many heroes garrizoned and wandering already!"))) )
@ -3377,7 +3376,7 @@ bool CGameHandler::hireHero(const CGObjectInstance *obj, ui8 hid, PlayerColor pl
SetResource sr;
sr.player = player;
sr.resid = Res::GOLD;
sr.val = p->resources.at(Res::GOLD) - GOLD_NEEDED;
sr.val = p->resources.at(Res::GOLD) - GameConstants::HERO_GOLD_COST;
sendAndApply(&sr);
if(t)