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

Added "produce" section in "building" structure. Changed dailyIncome.

This commit is contained in:
Macron1Robot 2014-04-26 18:23:35 +04:00
parent 9123c7a787
commit 907caedb13
20 changed files with 200 additions and 109 deletions

View File

@ -6,6 +6,7 @@
#include "../../lib/CConfigHandler.h"
#include "../../lib/CHeroHandler.h"
/*
* CCreatureHandler.h, part of VCMI engine
*
@ -1142,7 +1143,8 @@ void VCAI::buildStructure(const CGTownInstance * t)
//Possible - allow "locking" on specific building (build prerequisites and then building itself)
TResources currentRes = cb->getResourceAmount();
int townIncome = t->dailyIncome();
TResources currentIncome = t->dailyIncome();
int townIncome = currentIncome[Res::GOLD];
if (tryBuildAnyStructure(t, std::vector<BuildingID>(essential, essential + ARRAY_COUNT(essential))))
return;
@ -2343,24 +2345,16 @@ TResources VCAI::estimateIncome() const
TResources ret;
for(const CGTownInstance *t : cb->getTownsInfo())
{
ret[Res::GOLD] += t->dailyIncome();
//TODO duplikuje newturn
if(t->hasBuilt(BuildingID::RESOURCE_SILO)) //there is resource silo
{
if(t->town->primaryRes == Res::WOOD_AND_ORE) //we'll give wood and ore
{
ret[Res::WOOD] ++;
ret[Res::ORE] ++;
}
else
{
if (t->town->primaryRes != Res::GOLD)
ret[t->town->primaryRes]++;
}
}
// TResources townIncome = t->dailyIncome();
ret = ret + t->dailyIncome();
// for (auto i = Res::WOOD; i <= Res::GOLD; vstd::advance(i, 1))
// {
// ret[i] += townIncome[i];
// }
}
for(const CGObjectInstance *obj : getFlaggedObjects())
{
if(obj->ID == Obj::MINE)

View File

@ -114,7 +114,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
#include <boost/range/algorithm.hpp>
#include <boost/thread.hpp>
#include <boost/variant.hpp>
#include <boost/foreach.hpp>
#include <boost/math/special_functions/round.hpp>

View File

@ -966,7 +966,8 @@ void CCastleInterface::recreateIcons()
size_t iconIndex = town->town->clientInfo.icons[town->hasFort()][town->builded >= CGI->modh->settings.MAX_BUILDING_PER_TURN];
icon->setFrame(iconIndex);
income->setText(boost::lexical_cast<std::string>(town->dailyIncome()));
TResources townIncome = town->dailyIncome();
income->setText(boost::lexical_cast<std::string>(townIncome[Res::GOLD]));
hall = new CTownInfo( 80, 413, town, true);
fort = new CTownInfo(122, 413, town, false);

View File

@ -580,7 +580,8 @@ void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstan
std::vector<const CGTownInstance*> towns = LOCPLINT->cb->getTownsInfo(true);
for(auto & town : towns)
{
totalIncome += town->dailyIncome();
TResources income = town->dailyIncome();
totalIncome += income[Res::GOLD];
}
for (int i=0; i<7; i++)
{
@ -778,8 +779,8 @@ CTownItem::CTownItem(const CGTownInstance* Town):
OBJ_CONSTRUCTION_CAPTURING_ALL;
background = new CAnimImage("OVSLOT", 6);
name = new CLabel(74, 8, FONT_SMALL, TOPLEFT, Colors::WHITE, town->name);
income = new CLabel( 190, 60, FONT_SMALL, CENTER, Colors::WHITE, boost::lexical_cast<std::string>(town->dailyIncome()));
TResources townIncome = town->dailyIncome();
income = new CLabel(190, 60, FONT_SMALL, CENTER, Colors::WHITE, boost::lexical_cast<std::string>(townIncome[Res::GOLD]));
hall = new CTownInfo( 69, 31, town, true);
fort = new CTownInfo(111, 31, town, false);
@ -810,7 +811,8 @@ void CTownItem::updateGarrisons()
void CTownItem::update()
{
std::string incomeVal = boost::lexical_cast<std::string>(town->dailyIncome());
TResources townIncome = town->dailyIncome();
std::string incomeVal = boost::lexical_cast<std::string>(townIncome[Res::GOLD]);
if (incomeVal != income->text)
income->setText(incomeVal);

View File

@ -144,7 +144,7 @@
"mageGuild" : 4,
"warMachine" : "ballista",
"moatDamage" : 70,
"primaryResource": "ore",
"buildings" :
{
"mageGuild1": { "id" : 0 },
@ -156,12 +156,12 @@
"fort": { "id" : 7 },
"citadel": { "id" : 8, "upgrades" : "fort" },
"castle": { "id" : 9, "upgrades" : "citadel" },
"villageHall": { "id" : 10, "mode" : "auto" },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ] },
"villageHall": { "id" : 10, "mode" : "auto", "produce": { "gold": 500 } },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ], "produce": { "gold": 1000 } },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ], "produce": { "gold": 2000 } },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ], "produce": { "gold": 4000 } },
"marketplace": { "id" : 14 },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ] },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ], "produce": { "ore": 1, "wood": 1 } },
"blacksmith": { "id" : 16 },
"special1": { "id" : 17, "requires" : [ "shipyard" ] },
@ -170,7 +170,7 @@
"ship": { "id" : 20, "upgrades" : "shipyard" },
"special2": { "id" : 21, "requires" : [ "dwellingLvl4" ] },
"special3": { "id" : 22, "upgrades" : "tavern" },
"grail": { "id" : 26, "mode" : "grail"},
"grail": { "id" : 26, "mode" : "grail", "produce": { "gold": 5000 }},
"dwellingLvl1": { "id" : 30, "requires" : [ "fort" ] },
"dwellingLvl2": { "id" : 31, "requires" : [ "dwellingLvl1" ] },

View File

@ -162,12 +162,12 @@
"fort": { "id" : 7 },
"citadel": { "id" : 8, "upgrades" : "fort" },
"castle": { "id" : 9, "upgrades" : "citadel" },
"villageHall": { "id" : 10, "mode" : "auto" },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ] },
"villageHall": { "id" : 10, "mode" : "auto", "produce": { "gold": 500 } },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ], "produce": { "gold": 1000 } },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ], "produce": { "gold": 2000 } },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ], "produce": { "gold": 4000 } },
"marketplace": { "id" : 14 },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ] },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ], "produce": { "mercury": 1 } },
"blacksmith": { "id" : 16 },
"special1": { "id" : 17, "requires" : [ "marketplace" ] },
@ -175,7 +175,7 @@
"horde1Upgr": { "id" : 19, "upgrades" : "dwellingUpLvl1", "requires" : [ "horde1" ], "mode" : "auto" },
"ship": { "id" : 20, "upgrades" : "shipyard" },
"special2": { "id" : 21, "requires" : [ "mageGuild1" ] },
"grail": { "id" : 26, "mode" : "grail"},
"grail": { "id" : 26, "mode" : "grail", "produce": { "gold": 5000 }},
"extraTownHall": { "id" : 27, "requires" : [ "townHall" ], "mode" : "auto" },
"extraCityHall": { "id" : 28, "requires" : [ "cityHall" ], "mode" : "auto" },
"extraCapitol": { "id" : 29, "requires" : [ "capitol" ], "mode" : "auto" },

View File

@ -156,10 +156,10 @@
"fort": { "id" : 7 },
"citadel": { "id" : 8, "upgrades" : "fort" },
"castle": { "id" : 9, "upgrades" : "citadel" },
"villageHall": { "id" : 10, "mode" : "auto" },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ] },
"villageHall": { "id" : 10, "mode" : "auto", "produce": { "gold": 500 } },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ], "produce": { "gold": 1000 } },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ], "produce": { "gold": 2000 } },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ], "produce": { "gold": 4000 } },
"marketplace": { "id" : 14 },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ] },
"blacksmith": { "id" : 16 },
@ -170,7 +170,7 @@
"special2": { "id" : 21, "requires" : [ "mageGuild1" ] },
"special3": { "id" : 22 },
"special4": { "id" : 23 },
"grail": { "id" : 26, "mode" : "grail"},
"grail": { "id" : 26, "mode" : "grail", "produce": { "gold": 5000 }},
"dwellingLvl1": { "id" : 30, "requires" : [ "fort" ] },
"dwellingLvl2": { "id" : 31, "requires" : [ "dwellingLvl1" ] },

View File

@ -144,7 +144,7 @@
"mageGuild" : 3,
"warMachine" : "firstAidTent",
"moatDamage" : 90,
"primaryResource":"ore",
"buildings" :
{
"mageGuild1": { "id" : 0 },
@ -155,12 +155,12 @@
"fort": { "id" : 7 },
"citadel": { "id" : 8, "upgrades" : "fort" },
"castle": { "id" : 9, "upgrades" : "citadel" },
"villageHall": { "id" : 10, "mode" : "auto" },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ] },
"villageHall": { "id" : 10, "mode" : "auto", "produce": { "gold": 500 } },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ], "produce": { "gold": 1000 } },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ], "produce": { "gold": 2000 } },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ], "produce": { "gold": 4000 } },
"marketplace": { "id" : 14 },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ] },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ], "produce": { "wood": 1, "ore": 1 } },
"blacksmith": { "id" : 16 },
"special1": { "id" : 17, "requires" : [ "allOf", [ "townHall" ], [ "special2" ] ] },
@ -169,7 +169,7 @@
"ship": { "id" : 20, "upgrades" : "shipyard" },
"special2": { "id" : 21, "requires" : [ "fort" ] },
"special3": { "id" : 22, "requires" : [ "special2" ] },
"grail": { "id" : 26, "mode" : "grail"},
"grail": { "id" : 26, "mode" : "grail", "produce": { "gold": 5000 }},
"extraCapitol": { "id" : 29, "requires" : [ "capitol" ], "mode" : "auto" },
"dwellingLvl1": { "id" : 30, "requires" : [ "fort" ] },

View File

@ -157,12 +157,12 @@
"fort": { "id" : 7 },
"citadel": { "id" : 8, "upgrades" : "fort" },
"castle": { "id" : 9, "upgrades" : "citadel" },
"villageHall": { "id" : 10, "mode" : "auto" },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ] },
"villageHall": { "id" : 10, "mode" : "auto", "produce": { "gold": 500 } },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ], "produce": { "gold": 1000 } },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ], "produce": { "gold": 2000 } },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ], "produce": { "gold": 4000 } },
"marketplace": { "id" : 14 },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ] },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ], "produce": { "mercury": 1 } },
"blacksmith": { "id" : 16 },
"horde1": { "id" : 18, "upgrades" : "dwellingLvl1" },
@ -172,7 +172,7 @@
"special4": { "id" : 23, "requires" : [ "mageGuild1" ] },
"horde2": { "id" : 24, "upgrades" : "dwellingLvl3" },
"horde2Upgr": { "id" : 25, "upgrades" : "dwellingUpLvl3", "requires" : [ "horde2" ], "mode" : "auto" },
"grail": { "id" : 26, "mode" : "grail"},
"grail": { "id" : 26, "mode" : "grail", "produce": { "gold": 5000 }},
"dwellingLvl1": { "id" : 30, "requires" : [ "fort" ] },
"dwellingLvl2": { "id" : 31, "requires" : [ "dwellingLvl1" ] },

View File

@ -148,6 +148,7 @@
"mageGuild" : 5,
"warMachine" : "firstAidTent",
"moatDamage" : 70,
"primaryResource": "ore",
"buildings" :
{
@ -161,12 +162,12 @@
"fort": { "id" : 7 },
"citadel": { "id" : 8, "upgrades" : "fort" },
"castle": { "id" : 9, "upgrades" : "citadel" },
"villageHall": { "id" : 10, "mode" : "auto" },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ] },
"villageHall": { "id" : 10, "mode" : "auto", "produce": { "gold": 500 } },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ], "produce": { "gold": 1000 } },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ], "produce": { "gold": 2000 } },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ], "produce": { "gold": 4000 } },
"marketplace": { "id" : 14 },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ] },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ], "produce": { "ore": 1, "wood": 1 } },
"blacksmith": { "id" : 16 },
"special1": { "id" : 17, "requires" : [ "fort" ] },
@ -175,7 +176,7 @@
"ship": { "id" : 20, "upgrades" : "shipyard" },
"special2": { "id" : 21, "requires" : [ "mageGuild1" ] },
"special3": { "id" : 22, "requires" : [ "dwellingLvl1" ] },
"grail": { "id" : 26, "mode" : "grail"},
"grail": { "id" : 26, "mode" : "grail", "produce": { "gold": 5000 }},
"extraTownHall": { "id" : 27, "requires" : [ "townHall" ], "mode" : "auto" },
"extraCityHall": { "id" : 28, "requires" : [ "cityHall" ], "mode" : "auto" },
"extraCapitol": { "id" : 29, "requires" : [ "capitol" ], "mode" : "auto" },

View File

@ -161,12 +161,12 @@
"fort": { "id" : 7 },
"citadel": { "id" : 8, "upgrades" : "fort" },
"castle": { "id" : 9, "upgrades" : "citadel" },
"villageHall": { "id" : 10, "mode" : "auto" },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ] },
"villageHall": { "id" : 10, "mode" : "auto", "produce": { "gold": 500 } },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ], "produce": { "gold": 1000 } },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ], "produce": { "gold": 2000 } },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ], "produce": { "gold": 4000 } },
"marketplace": { "id" : 14 },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ] },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ], "produce": { "crystal": 1 } },
"blacksmith": { "id" : 16 },
"special1": { "id" : 17 },
@ -176,7 +176,7 @@
"special3": { "id" : 22, "requires" : [ "horde1" ] },
"horde2": { "id" : 24, "upgrades" : "dwellingLvl5" },
"horde2Upgr": { "id" : 25, "upgrades" : "dwellingUpLvl5", "requires" : [ "horde2" ], "mode" : "auto" },
"grail": { "id" : 26, "mode" : "grail"},
"grail": { "id" : 26, "mode" : "grail", "produce": { "gold": 5000 }},
"extraTownHall": { "id" : 27, "requires" : [ "townHall" ], "mode" : "auto" },
"extraCityHall": { "id" : 28, "requires" : [ "cityHall" ], "mode" : "auto" },
"extraCapitol": { "id" : 29, "requires" : [ "capitol" ], "mode" : "auto" },

View File

@ -116,6 +116,7 @@
"defaultTavern" : 5,
"tavernVideo" : "TAVERN.BIK",
"guildBackground" : "TPMAGE.bmp",
"primaryResource": "ore",
"townBackground": "TBSTBACK.bmp",
"guildWindow": "TPMAGEST.bmp",
"buildingsIcons": "HALLSTRN.DEF",
@ -152,12 +153,12 @@
"fort": { "id" : 7 },
"citadel": { "id" : 8, "upgrades" : "fort" },
"castle": { "id" : 9, "upgrades" : "citadel" },
"villageHall": { "id" : 10, "mode" : "auto" },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ] },
"villageHall": { "id" : 10, "mode" : "auto", "produce": { "gold": 500 } },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ], "produce": { "gold": 1000 } },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ], "produce": { "gold": 2000 } },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ], "produce": { "gold": 4000 } },
"marketplace": { "id" : 14 },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ] },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ], "produce": { "ore": 1, "wood": 1 } },
"blacksmith": { "id" : 16 },
"special1": { "id" : 17, "requires" : [ "fort" ] },
@ -166,7 +167,7 @@
"special2": { "id" : 21, "requires" : [ "marketplace" ] },
"special3": { "id" : 22, "requires" : [ "blacksmith" ] },
"special4": { "id" : 23, "requires" : [ "fort" ] },
"grail": { "id" : 26, "mode" : "grail"},
"grail": { "id" : 26, "mode" : "grail", "produce": { "gold": 5000 }},
"dwellingLvl1": { "id" : 30, "requires" : [ "fort" ] },
"dwellingLvl2": { "id" : 31, "requires" : [ "dwellingLvl1" ] },

View File

@ -156,12 +156,12 @@
"fort": { "id" : 7 },
"citadel": { "id" : 8, "upgrades" : "fort" },
"castle": { "id" : 9, "upgrades" : "citadel" },
"villageHall": { "id" : 10, "mode" : "auto" },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ] },
"villageHall": { "id" : 10, "mode" : "auto", "produce": { "gold": 500 } },
"townHall": { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ], "produce": { "gold": 1000 } },
"cityHall": { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ], "produce": { "gold": 2000 } },
"capitol": { "id" : 13, "upgrades" : "cityHall", "requires" : [ "castle" ], "produce": { "gold": 4000 } },
"marketplace": { "id" : 14 },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ] },
"resourceSilo": { "id" : 15, "requires" : [ "marketplace" ], "produce": { "gems": 1 } },
"blacksmith": { "id" : 16 },
"special1": { "id" : 17, "requires" : [ "marketplace" ] },
@ -170,7 +170,7 @@
"special2": { "id" : 21, "requires" : [ "fort" ] },
"special3": { "id" : 22, "requires" : [ "mageGuild1" ] },
"special4": { "id" : 23, "requires" : [ "mageGuild1" ] },
"grail": { "id" : 26, "mode" : "grail"},
"grail": { "id" : 26, "mode" : "grail", "produce": { "gold": 5000 }},
"dwellingLvl1": { "id" : 30, "requires" : [ "fort" ] },
"dwellingLvl2": { "id" : 31, "requires" : [ "dwellingLvl1" ] },

View File

@ -63,6 +63,21 @@
"gems": { "type":"number"},
"gold": { "type":"number"}
}
},
"produce": {
"type":"object",
"additionalProperties" : false,
"description": "Resources this building produce each day",
"properties":{
"wood": { "type":"number"},
"mercury": { "type":"number"},
"ore": { "type":"number"},
"sulfur": { "type":"number"},
"crystal": { "type":"number"},
"gems": { "type":"number"},
"gold": { "type":"number"}
}
}
}
}

View File

@ -3118,7 +3118,8 @@ void InfoAboutTown::initFromTown(const CGTownInstance *t, bool detailed)
{
//include details about hero
details = new Details;
details->goldIncome = t->dailyIncome();
TResources income = t->dailyIncome();
details->goldIncome = income[Res::GOLD];
details->customRes = t->hasBuilt(BuildingID::RESOURCE_SILO);
details->hallLevel = t->hallLevel();
details->garrisonedHero = t->garrisonHero;

View File

@ -2179,6 +2179,7 @@ CGTownInstance::EFortLevel CGTownInstance::fortLevel() const //0 - none, 1 - for
int CGTownInstance::hallLevel() const // -1 - none, 0 - village, 1 - town, 2 - city, 3 - capitol
{
if (hasBuilt(BuildingID::CAPITOL))
return 3;
if (hasBuilt(BuildingID::CITY_HALL))
@ -2269,22 +2270,47 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const
return ret;
}
int CGTownInstance::dailyIncome() const
TResources CGTownInstance::dailyIncome() const
{
int ret = 0;
if (hasBuilt(BuildingID::GRAIL))
ret+=5000;
TResources ret;
for (auto i = Res::WOOD; i <= Res::GOLD; vstd::advance(i, 1))
{
ret[i] = 0;
}
BOOST_FOREACH(TPairCBuilding p, town->buildings)
{
BuildingID buildingUpgrade;
BOOST_FOREACH(TPairCBuilding p2, town->buildings)
{
if (p2.second->upgrade == p.first)
{
buildingUpgrade = p2.first;
}
}
if (hasBuilt(BuildingID::CAPITOL))
ret+=4000;
else if (hasBuilt(BuildingID::CITY_HALL))
ret+=2000;
else if (hasBuilt(BuildingID::TOWN_HALL))
ret+=1000;
else if (hasBuilt(BuildingID::VILLAGE_HALL))
ret+=500;
if (hasBuilt(BuildingID::RESOURCE_SILO)&&(town->primaryRes==Res::GOLD))
ret += 500;
if (!hasBuilt(buildingUpgrade)&&(hasBuilt(p.first)))
{
for (auto i = Res::WOOD; i <= Res::GOLD; vstd::advance(i, 1))
{
ret[i] += p.second->produce[i];
}
}
}
// if (hasBuilt(BuildingID::GRAIL))
// ret+=5000;
// if (hasBuilt(BuildingID::CAPITOL))
// ret+=4000;
// else if (hasBuilt(BuildingID::CITY_HALL))
// ret+=2000;
// else if (hasBuilt(BuildingID::TOWN_HALL))
// ret+=1000;
// else if (hasBuilt(BuildingID::VILLAGE_HALL))
// ret+=500;
// if (hasBuilt(BuildingID::RESOURCE_SILO)&&(town->primaryRes==Res::GOLD))
// ret += 500;
return ret;
}
bool CGTownInstance::hasFort() const

View File

@ -748,7 +748,7 @@ public:
//checks if building is constructed and town has same subID
bool hasBuilt(BuildingID buildingID) const;
bool hasBuilt(BuildingID buildingID, int townID) const;
int dailyIncome() const; //calculates daily income of this town
TResources dailyIncome() const; //calculates daily income of this town
int spellsAtLevel(int level, bool checkGuild) const; //levels are counted from 1 (1 - 5)
bool armedGarrison() const; //true if town has creatures in garrison or garrisoned hero
int getTownLevel() const;

View File

@ -105,9 +105,12 @@ JsonNode readBuilding(CLegacyConfigParser & parser)
for(const std::string & resID : GameConstants::RESOURCE_NAMES)
cost[resID].Float() = parser.readNumber();
cost.Struct().erase("mithril"); // erase mithril to avoid confusing validator
parser.endLine();
return ret;
}
@ -303,6 +306,39 @@ void CTownHandler::loadBuilding(CTown &town, const std::string & stringID, const
ret->name = source["name"].String();
ret->description = source["description"].String();
ret->resources = TResources(source["cost"]);
ret->produce = TResources(source["produce"]);
//for compatibility with older town mods
if ((ret->bid == BuildingID::VILLAGE_HALL) && (ret->produce[Res::WOOD] == 0) && (ret->produce[Res::MERCURY] == 0) && (ret->produce[Res::ORE] == 0)
&& (ret->produce[Res::SULFUR] == 0) && (ret->produce[Res::CRYSTAL] == 0) && (ret->produce[Res::GEMS] == 0) && (ret->produce[Res::GOLD] == 0)) ret->produce[Res::GOLD] = 500;
if ((ret->bid == BuildingID::TOWN_HALL) && (ret->produce[Res::WOOD] == 0) && (ret->produce[Res::MERCURY] == 0) && (ret->produce[Res::ORE] == 0)
&& (ret->produce[Res::SULFUR] == 0) && (ret->produce[Res::CRYSTAL] == 0) && (ret->produce[Res::GEMS] == 0) && (ret->produce[Res::GOLD] == 0)) ret->produce[Res::GOLD] = 1000;
if ((ret->bid == BuildingID::CITY_HALL) && (ret->produce[Res::WOOD] == 0) && (ret->produce[Res::MERCURY] == 0) && (ret->produce[Res::ORE] == 0)
&& (ret->produce[Res::SULFUR] == 0) && (ret->produce[Res::CRYSTAL] == 0) && (ret->produce[Res::GEMS] == 0) && (ret->produce[Res::GOLD] == 0)) ret->produce[Res::GOLD] = 2000;
if ((ret->bid == BuildingID::CAPITOL) && (ret->produce[Res::WOOD] == 0) && (ret->produce[Res::MERCURY] == 0) && (ret->produce[Res::ORE] == 0)
&& (ret->produce[Res::SULFUR] == 0) && (ret->produce[Res::CRYSTAL] == 0) && (ret->produce[Res::GEMS] == 0) && (ret->produce[Res::GOLD] == 0)) ret->produce[Res::GOLD] = 4000;
if ((ret->bid == BuildingID::GRAIL) && (ret->produce[Res::WOOD] == 0) && (ret->produce[Res::MERCURY] == 0) && (ret->produce[Res::ORE] == 0)
&& (ret->produce[Res::SULFUR] == 0) && (ret->produce[Res::CRYSTAL] == 0) && (ret->produce[Res::GEMS] == 0) && (ret->produce[Res::GOLD] == 0)) ret->produce[Res::GOLD] = 5000;
//
if ((ret->bid == BuildingID::RESOURCE_SILO) && (ret->produce[Res::WOOD] == 0) && (ret->produce[Res::MERCURY] == 0) && (ret->produce[Res::ORE] == 0)
&& (ret->produce[Res::SULFUR] == 0) && (ret->produce[Res::CRYSTAL] == 0) && (ret->produce[Res::GEMS] == 0) && (ret->produce[Res::GOLD] == 0))
{
if ((ret->town->primaryRes != Res::WOOD) && (ret->town->primaryRes != Res::ORE) && (ret->town->primaryRes != Res::GOLD))
ret->produce[ret->town->primaryRes] = 1;
else
{
if (ret->town->primaryRes == Res::GOLD) ret->produce[ret->town->primaryRes] = 500;
if ((ret->town->primaryRes == Res::WOOD) || (ret->town->primaryRes == Res::ORE))
{
ret->produce[Res::WOOD] = 1;
ret->produce[Res::ORE] = 1;
}
}
}
loadBuildingRequirements(town, *ret, source["requires"]);
@ -688,6 +724,7 @@ CFaction * CTownHandler::loadFromJson(const JsonNode &source, std::string identi
void CTownHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
{
auto object = loadFromJson(data, name);
object->index = factions.size();
if (object->town)
{

View File

@ -25,6 +25,9 @@ class CFaction;
/// a typical building encountered in every castle ;]
/// this is structure available to both client and server
/// contains all mechanics-related data about town structures
class DLL_LINKAGE CBuilding
{
@ -36,6 +39,7 @@ public:
CTown * town; // town this building belongs to
TResources resources;
TResources produce;
TRequired requirements;
std::string identifier;
@ -61,12 +65,14 @@ public:
template <typename Handler> void serialize(Handler &h, const int version)
{
h & identifier & town & bid & resources & name & description & requirements & upgrade & mode;
h & identifier & town & bid & resources & produce & name & description & requirements & upgrade & mode;
}
friend class CTownHandler;
};
typedef std::pair<BuildingID, ConstTransitivePtr<CBuilding>> TPairCBuilding;
/// This is structure used only by client
/// Consists of all gui-related data about town structures
/// Should be moved from lib to client

View File

@ -1330,21 +1330,28 @@ void CGameHandler::newTurn()
}
if(!firstTurn && player < PlayerColor::PLAYER_LIMIT)//not the first day and town not neutral
{
if(t->hasBuilt(BuildingID::RESOURCE_SILO)) //there is resource silo
{
if(t->town->primaryRes == Res::WOOD_AND_ORE) //we'll give wood and ore
{
n.res[player][Res::WOOD] ++;
n.res[player][Res::ORE] ++;
}
else
{
if (t->town->primaryRes != Res::GOLD)
n.res[player][t->town->primaryRes] ++;
}
}
n.res[player] = n.res[player] + t->dailyIncome();
// TResources townIncome = t->dailyIncome();
// for (auto i = Res::WOOD; i <= Res::GOLD; vstd::advance(i, 1))
// {
// n.res[player][i] += townIncome[i];
// }
// if(t->hasBuilt(BuildingID::RESOURCE_SILO)) //there is resource silo
// {
// if(t->town->primaryRes == Res::WOOD_AND_ORE) //we'll give wood and ore
// {
// n.res[player][Res::WOOD] ++;
// n.res[player][Res::ORE] ++;
// }
// else
// {
// if (t->town->primaryRes != Res::GOLD)
// n.res[player][t->town->primaryRes] ++;
// }
// }
n.res[player][Res::GOLD] += t->dailyIncome();
// n.res[player][Res::GOLD] += t->dailyIncome();
}
if(t->hasBuilt(BuildingID::GRAIL, ETownType::TOWER))
{