Browse Source

Add hero gold cost to GameConstants

ArseniyShestakov 10 years ago
parent
commit
03e9dd3bab
6 changed files with 9 additions and 10 deletions
  1. 0 1
      AI/VCAI/AIUtility.h
  2. 2 2
      AI/VCAI/Goals.cpp
  3. 2 2
      AI/VCAI/VCAI.cpp
  4. 2 2
      client/windows/GUIClasses.cpp
  5. 1 0
      lib/GameConstants.h
  6. 2 3
      server/CGameHandler.cpp

+ 0 - 1
AI/VCAI/AIUtility.h

@@ -23,7 +23,6 @@ class CCallback;
 typedef const int3& crint3;
 typedef const int3& crint3;
 typedef const std::string& crstring;
 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 GOLD_MINE_PRODUCTION = 1000, WOOD_ORE_MINE_PRODUCTION = 2, RESOURCE_MINE_PRODUCTION = 1;
 const int ACTUAL_RESOURCE_COUNT = 7;
 const int ACTUAL_RESOURCE_COUNT = 7;
 const int ALLOWED_ROAMING_HEROES = 8;
 const int ALLOWED_ROAMING_HEROES = 8;

+ 2 - 2
AI/VCAI/Goals.cpp

@@ -693,8 +693,8 @@ TSubgoal RecruitHero::whatToDoToAchieve()
 	if(!t)
 	if(!t)
 		return sptr (Goals::BuildThis(BuildingID::TAVERN));
 		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();
 	return iAmElementar();
 }
 }

+ 2 - 2
AI/VCAI/VCAI.cpp

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

+ 2 - 2
client/windows/GUIClasses.cpp

@@ -704,7 +704,7 @@ CTavernWindow::CTavernWindow(const CGObjectInstance *TavernObj):
 	oldSelected = -1;
 	oldSelected = -1;
 
 
 	new CLabel(200, 35, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[37]);
 	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));
 	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);
 	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);
 	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);
 	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->addHoverText(CButton::NORMAL, CGI->generaltexth->tavernInfo[0]); //Cannot afford a Hero
 		recruit->block(true);
 		recruit->block(true);

+ 1 - 0
lib/GameConstants.h

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

+ 2 - 3
server/CGameHandler.cpp

@@ -3313,12 +3313,11 @@ bool CGameHandler::hireHero(const CGObjectInstance *obj, ui8 hid, PlayerColor pl
 {
 {
 	const PlayerState *p = gs->getPlayer(player);
 	const PlayerState *p = gs->getPlayer(player);
 	const CGTownInstance *t = gs->getTown(obj->id);
 	const CGTownInstance *t = gs->getTown(obj->id);
-	static const int GOLD_NEEDED = 2500;
 
 
 	//common preconditions
 	//common preconditions
 //	if( (p->resources.at(Res::GOLD)<GOLD_NEEDED  && complain("Not enough gold for buying hero!"))
 //	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!")))
 //		|| (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, 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!"))) )
 			|| ((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;
 	SetResource sr;
 	sr.player = player;
 	sr.player = player;
 	sr.resid = Res::GOLD;
 	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);
 	sendAndApply(&sr);
 
 
 	if(t)
 	if(t)