mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
replace hardcoded
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "../../../lib/mapObjects/CGMarket.h"
|
||||
#include "../../../lib/mapObjects/CGResource.h"
|
||||
#include "../../../lib/constants/StringConstants.h"
|
||||
#include "../../../lib/entities/ResourceTypeHandler.h"
|
||||
|
||||
using namespace Goals;
|
||||
|
||||
@@ -171,7 +172,7 @@ TSubgoal CollectRes::whatToDoToTrade()
|
||||
const IMarket * m = markets.back();
|
||||
//attempt trade at back (best prices)
|
||||
int howManyCanWeBuy = 0;
|
||||
for (GameResID i = EGameResID::WOOD; i <= EGameResID::GOLD; ++i)
|
||||
for (auto & i : LIBRARY->resourceTypeHandler->getAllObjects())
|
||||
{
|
||||
if (i.getNum() == resID)
|
||||
continue;
|
||||
|
||||
@@ -227,7 +227,7 @@ void CMinorResDataBar::showAll(Canvas & 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));
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "../lib/entities/building/CBuilding.h"
|
||||
#include "../lib/entities/faction/CTownHandler.h"
|
||||
#include "../lib/entities/hero/CHeroHandler.h"
|
||||
#include "../lib/entities/ResourceTypeHandler.h"
|
||||
#include "../lib/mapObjectConstructors/CObjectClassesHandler.h"
|
||||
#include "../lib/mapObjectConstructors/CommonConstructors.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->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))
|
||||
{
|
||||
|
||||
@@ -18,11 +18,7 @@
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
ResourceSet::ResourceSet()
|
||||
{
|
||||
for(int i = 0; i < GameConstants::RESOURCE_QUANTITY; i++)
|
||||
container[i] = 0;
|
||||
}
|
||||
ResourceSet::ResourceSet() = default;
|
||||
|
||||
ResourceSet::ResourceSet(const JsonNode & node)
|
||||
{
|
||||
|
||||
@@ -159,7 +159,7 @@ std::string StatisticDataSet::toCsv(std::string sep) const
|
||||
{
|
||||
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 << "Timestamp" << sep;
|
||||
|
||||
@@ -61,7 +61,7 @@ void CGResource::pickRandomObject(IGameRandomizer & gameRandomizer)
|
||||
if (ID == Obj::RANDOM_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);
|
||||
|
||||
amount *= getAmountMultiplier();
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "../../lib/texts/MetaString.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) :
|
||||
ui(new Ui::MineSelector),
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "../../lib/entities/artifact/CArtHandler.h"
|
||||
#include "../../lib/entities/building/CBuilding.h"
|
||||
#include "../../lib/entities/hero/CHeroHandler.h"
|
||||
#include "../../lib/entities/ResourceTypeHandler.h"
|
||||
#include "../../lib/gameState/CGameState.h"
|
||||
#include "../../lib/mapObjects/CGTownInstance.h"
|
||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||
@@ -593,7 +594,7 @@ void PlayerMessageProcessor::cheatResources(PlayerColor player, std::vector<std:
|
||||
|
||||
TResources resources;
|
||||
resources[EGameResID::GOLD] = baseResourceAmount * 1000;
|
||||
for (GameResID i = EGameResID::WOOD; i < EGameResID::GOLD; ++i)
|
||||
for (auto & i : LIBRARY->resourceTypeHandler->getAllObjects())
|
||||
resources[i] = baseResourceAmount;
|
||||
|
||||
gameHandler->giveResources(player, resources);
|
||||
|
||||
Reference in New Issue
Block a user