mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
replace hardcoded
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
#include "../../../lib/mapObjects/CGMarket.h"
|
#include "../../../lib/mapObjects/CGMarket.h"
|
||||||
#include "../../../lib/mapObjects/CGResource.h"
|
#include "../../../lib/mapObjects/CGResource.h"
|
||||||
#include "../../../lib/constants/StringConstants.h"
|
#include "../../../lib/constants/StringConstants.h"
|
||||||
|
#include "../../../lib/entities/ResourceTypeHandler.h"
|
||||||
|
|
||||||
using namespace Goals;
|
using namespace Goals;
|
||||||
|
|
||||||
@@ -171,7 +172,7 @@ TSubgoal CollectRes::whatToDoToTrade()
|
|||||||
const IMarket * m = markets.back();
|
const IMarket * m = markets.back();
|
||||||
//attempt trade at back (best prices)
|
//attempt trade at back (best prices)
|
||||||
int howManyCanWeBuy = 0;
|
int howManyCanWeBuy = 0;
|
||||||
for (GameResID i = EGameResID::WOOD; i <= EGameResID::GOLD; ++i)
|
for (auto & i : LIBRARY->resourceTypeHandler->getAllObjects())
|
||||||
{
|
{
|
||||||
if (i.getNum() == resID)
|
if (i.getNum() == resID)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ void CMinorResDataBar::showAll(Canvas & to)
|
|||||||
{
|
{
|
||||||
CIntObject::showAll(to);
|
CIntObject::showAll(to);
|
||||||
|
|
||||||
for (GameResID i=EGameResID::WOOD; i<=EGameResID::GOLD; ++i)
|
for (GameResID i=EGameResID::WOOD; i<=EGameResID::GOLD; ++i) //todo: configurable resource support
|
||||||
{
|
{
|
||||||
std::string text = std::to_string(GAME->interface()->cb->getResourceAmount(i));
|
std::string text = std::to_string(GAME->interface()->cb->getResourceAmount(i));
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include "../lib/entities/building/CBuilding.h"
|
#include "../lib/entities/building/CBuilding.h"
|
||||||
#include "../lib/entities/faction/CTownHandler.h"
|
#include "../lib/entities/faction/CTownHandler.h"
|
||||||
#include "../lib/entities/hero/CHeroHandler.h"
|
#include "../lib/entities/hero/CHeroHandler.h"
|
||||||
|
#include "../lib/entities/ResourceTypeHandler.h"
|
||||||
#include "../lib/mapObjectConstructors/CObjectClassesHandler.h"
|
#include "../lib/mapObjectConstructors/CObjectClassesHandler.h"
|
||||||
#include "../lib/mapObjectConstructors/CommonConstructors.h"
|
#include "../lib/mapObjectConstructors/CommonConstructors.h"
|
||||||
#include "../lib/mapObjects/CGHeroInstance.h"
|
#include "../lib/mapObjects/CGHeroInstance.h"
|
||||||
@@ -830,7 +831,7 @@ CShipyardWindow::CShipyardWindow(const TResources & cost, int state, BoatId boat
|
|||||||
build = std::make_shared<CButton>(Point(42, 312), AnimationPath::builtin("IBUY30"), CButton::tooltip(LIBRARY->generaltexth->allTexts[598]), std::bind(&CShipyardWindow::close, this), EShortcut::GLOBAL_ACCEPT);
|
build = std::make_shared<CButton>(Point(42, 312), AnimationPath::builtin("IBUY30"), CButton::tooltip(LIBRARY->generaltexth->allTexts[598]), std::bind(&CShipyardWindow::close, this), EShortcut::GLOBAL_ACCEPT);
|
||||||
build->addCallback(onBuy);
|
build->addCallback(onBuy);
|
||||||
|
|
||||||
for(GameResID i = EGameResID::WOOD; i <= EGameResID::GOLD; ++i)
|
for(auto & i : LIBRARY->resourceTypeHandler->getAllObjects())
|
||||||
{
|
{
|
||||||
if(cost[i] > GAME->interface()->cb->getResourceAmount(i))
|
if(cost[i] > GAME->interface()->cb->getResourceAmount(i))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,11 +18,7 @@
|
|||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
ResourceSet::ResourceSet()
|
ResourceSet::ResourceSet() = default;
|
||||||
{
|
|
||||||
for(int i = 0; i < GameConstants::RESOURCE_QUANTITY; i++)
|
|
||||||
container[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceSet::ResourceSet(const JsonNode & node)
|
ResourceSet::ResourceSet(const JsonNode & node)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ std::string StatisticDataSet::toCsv(std::string sep) const
|
|||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
auto resources = std::vector<EGameResID>{EGameResID::GOLD, EGameResID::WOOD, EGameResID::MERCURY, EGameResID::ORE, EGameResID::SULFUR, EGameResID::CRYSTAL, EGameResID::GEMS};
|
auto resources = std::vector<EGameResID>{EGameResID::GOLD, EGameResID::WOOD, EGameResID::MERCURY, EGameResID::ORE, EGameResID::SULFUR, EGameResID::CRYSTAL, EGameResID::GEMS}; //todo: configurable resource support
|
||||||
|
|
||||||
ss << "Map" << sep;
|
ss << "Map" << sep;
|
||||||
ss << "Timestamp" << sep;
|
ss << "Timestamp" << sep;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ void CGResource::pickRandomObject(IGameRandomizer & gameRandomizer)
|
|||||||
if (ID == Obj::RANDOM_RESOURCE)
|
if (ID == Obj::RANDOM_RESOURCE)
|
||||||
{
|
{
|
||||||
ID = Obj::RESOURCE;
|
ID = Obj::RESOURCE;
|
||||||
subID = gameRandomizer.getDefault().nextInt(EGameResID::WOOD, EGameResID::GOLD);
|
subID = gameRandomizer.getDefault().nextInt(EGameResID::WOOD, EGameResID::GOLD); //todo: configurable resource support
|
||||||
setType(ID, subID);
|
setType(ID, subID);
|
||||||
|
|
||||||
amount *= getAmountMultiplier();
|
amount *= getAmountMultiplier();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#include "../../lib/texts/MetaString.h"
|
#include "../../lib/texts/MetaString.h"
|
||||||
#include "../../lib/entities/ResourceTypeHandler.h"
|
#include "../../lib/entities/ResourceTypeHandler.h"
|
||||||
|
|
||||||
auto resourcesToShow = std::vector<EGameResID>{EGameResID::GOLD, EGameResID::WOOD, EGameResID::MERCURY, EGameResID::ORE, EGameResID::SULFUR, EGameResID::CRYSTAL, EGameResID::GEMS};
|
auto resourcesToShow = std::vector<EGameResID>{EGameResID::GOLD, EGameResID::WOOD, EGameResID::MERCURY, EGameResID::ORE, EGameResID::SULFUR, EGameResID::CRYSTAL, EGameResID::GEMS}; //todo: configurable resource support
|
||||||
|
|
||||||
MineSelector::MineSelector(std::map<TResource, ui16> & mines) :
|
MineSelector::MineSelector(std::map<TResource, ui16> & mines) :
|
||||||
ui(new Ui::MineSelector),
|
ui(new Ui::MineSelector),
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "../../lib/entities/artifact/CArtHandler.h"
|
#include "../../lib/entities/artifact/CArtHandler.h"
|
||||||
#include "../../lib/entities/building/CBuilding.h"
|
#include "../../lib/entities/building/CBuilding.h"
|
||||||
#include "../../lib/entities/hero/CHeroHandler.h"
|
#include "../../lib/entities/hero/CHeroHandler.h"
|
||||||
|
#include "../../lib/entities/ResourceTypeHandler.h"
|
||||||
#include "../../lib/gameState/CGameState.h"
|
#include "../../lib/gameState/CGameState.h"
|
||||||
#include "../../lib/mapObjects/CGTownInstance.h"
|
#include "../../lib/mapObjects/CGTownInstance.h"
|
||||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||||
@@ -593,7 +594,7 @@ void PlayerMessageProcessor::cheatResources(PlayerColor player, std::vector<std:
|
|||||||
|
|
||||||
TResources resources;
|
TResources resources;
|
||||||
resources[EGameResID::GOLD] = baseResourceAmount * 1000;
|
resources[EGameResID::GOLD] = baseResourceAmount * 1000;
|
||||||
for (GameResID i = EGameResID::WOOD; i < EGameResID::GOLD; ++i)
|
for (auto & i : LIBRARY->resourceTypeHandler->getAllObjects())
|
||||||
resources[i] = baseResourceAmount;
|
resources[i] = baseResourceAmount;
|
||||||
|
|
||||||
gameHandler->giveResources(player, resources);
|
gameHandler->giveResources(player, resources);
|
||||||
|
|||||||
Reference in New Issue
Block a user