CGDwelling.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. /*
  2. * CGDwelling.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "CGDwelling.h"
  12. #include "../callback/IGameInfoCallback.h"
  13. #include "../callback/IGameEventCallback.h"
  14. #include "../callback/IGameRandomizer.h"
  15. #include "../serializer/JsonSerializeFormat.h"
  16. #include "../entities/faction/CTownHandler.h"
  17. #include "../mapping/CMap.h"
  18. #include "../mapObjectConstructors/AObjectTypeHandler.h"
  19. #include "../mapObjectConstructors/CObjectClassesHandler.h"
  20. #include "../mapObjectConstructors/DwellingInstanceConstructor.h"
  21. #include "../mapObjects/CGHeroInstance.h"
  22. #include "../mapObjects/CGTownInstance.h"
  23. #include "../networkPacks/StackLocation.h"
  24. #include "../networkPacks/PacksForClient.h"
  25. #include "../networkPacks/PacksForClientBattle.h"
  26. #include "../gameState/CGameState.h"
  27. #include "../CPlayerState.h"
  28. #include "../IGameSettings.h"
  29. #include "../CConfigHandler.h"
  30. #include "../texts/CGeneralTextHandler.h"
  31. #include <vstd/RNG.h>
  32. VCMI_LIB_NAMESPACE_BEGIN
  33. void CGDwellingRandomizationInfo::serializeJson(JsonSerializeFormat & handler)
  34. {
  35. handler.serializeString("sameAsTown", instanceId);
  36. handler.serializeIdArray("allowedFactions", allowedFactions);
  37. handler.serializeInt("minLevel", minLevel, static_cast<uint8_t>(1));
  38. handler.serializeInt("maxLevel", maxLevel, static_cast<uint8_t>(7));
  39. if(!handler.saving)
  40. {
  41. //todo: safely allow any level > 7
  42. vstd::abetween<uint8_t>(minLevel, 1, 7);
  43. vstd::abetween<uint8_t>(maxLevel, minLevel, 7);
  44. }
  45. }
  46. CGDwelling::CGDwelling(IGameInfoCallback *cb):
  47. CArmedInstance(cb)
  48. {}
  49. CGDwelling::~CGDwelling() = default;
  50. FactionID CGDwelling::randomizeFaction(IGameRandomizer & gameRandomizer)
  51. {
  52. if (ID == Obj::RANDOM_DWELLING_FACTION)
  53. return FactionID(subID.getNum());
  54. assert(ID == Obj::RANDOM_DWELLING || ID == Obj::RANDOM_DWELLING_LVL);
  55. assert(randomizationInfo.has_value());
  56. if (!randomizationInfo)
  57. return FactionID::CASTLE;
  58. CGTownInstance * linkedTown = nullptr;
  59. if (!randomizationInfo->instanceId.empty())
  60. {
  61. auto iter = cb->gameState().getMap().instanceNames.find(randomizationInfo->instanceId);
  62. if(iter == cb->gameState().getMap().instanceNames.end())
  63. logGlobal->error("Map object not found: %s", randomizationInfo->instanceId);
  64. linkedTown = dynamic_cast<CGTownInstance *>(iter->second.get());
  65. }
  66. if (randomizationInfo->identifier != 0)
  67. {
  68. for(auto & townID : cb->gameState().getMap().getAllTowns())
  69. {
  70. auto town = cb->gameState().getTown(townID);
  71. if(town && town->identifier == randomizationInfo->identifier)
  72. {
  73. linkedTown = town;
  74. break;
  75. }
  76. }
  77. }
  78. if (linkedTown)
  79. {
  80. if(linkedTown->ID==Obj::RANDOM_TOWN)
  81. linkedTown->pickRandomObject(gameRandomizer); //we have to randomize the castle first
  82. assert(linkedTown->ID == Obj::TOWN);
  83. if(linkedTown->ID==Obj::TOWN)
  84. return linkedTown->getFactionID();
  85. }
  86. if(!randomizationInfo->allowedFactions.empty())
  87. return *RandomGeneratorUtil::nextItem(randomizationInfo->allowedFactions, gameRandomizer.getDefault());
  88. std::vector<FactionID> potentialPicks;
  89. for (FactionID faction(0); faction < FactionID(LIBRARY->townh->size()); ++faction)
  90. if (LIBRARY->factions()->getById(faction)->hasTown())
  91. potentialPicks.push_back(faction);
  92. assert(!potentialPicks.empty());
  93. return *RandomGeneratorUtil::nextItem(potentialPicks, gameRandomizer.getDefault());
  94. }
  95. int CGDwelling::randomizeLevel(vstd::RNG & rand)
  96. {
  97. if (ID == Obj::RANDOM_DWELLING_LVL)
  98. return subID.getNum();
  99. assert(ID == Obj::RANDOM_DWELLING || ID == Obj::RANDOM_DWELLING_FACTION);
  100. assert(randomizationInfo.has_value());
  101. if (!randomizationInfo)
  102. return rand.nextInt(1, 7) - 1;
  103. if(randomizationInfo->minLevel == randomizationInfo->maxLevel)
  104. return randomizationInfo->minLevel - 1;
  105. return rand.nextInt(randomizationInfo->minLevel, randomizationInfo->maxLevel) - 1;
  106. }
  107. void CGDwelling::pickRandomObject(IGameRandomizer & gameRandomizer)
  108. {
  109. if (ID == Obj::RANDOM_DWELLING || ID == Obj::RANDOM_DWELLING_LVL || ID == Obj::RANDOM_DWELLING_FACTION)
  110. {
  111. FactionID faction = randomizeFaction(gameRandomizer);
  112. int level = randomizeLevel(gameRandomizer.getDefault());
  113. assert(faction != FactionID::NONE && faction != FactionID::NEUTRAL);
  114. assert(level >= 0 && level <= 6);
  115. randomizationInfo.reset();
  116. CreatureID cid = (*LIBRARY->townh)[faction]->town->creatures[level][0];
  117. //NOTE: this will pick last dwelling with this creature (Mantis #900)
  118. //check for block map equality is better but more complex solution
  119. auto testID = [&](const Obj & primaryID) -> MapObjectSubID
  120. {
  121. auto dwellingIDs = LIBRARY->objtypeh->knownSubObjects(primaryID);
  122. for (MapObjectSubID entry : dwellingIDs)
  123. {
  124. const auto * handler = dynamic_cast<const DwellingInstanceConstructor *>(LIBRARY->objtypeh->getHandlerFor(primaryID, entry).get());
  125. if (!handler->isBannedForRandomDwelling() && handler->producesCreature(cid.toCreature()))
  126. return MapObjectSubID(entry);
  127. }
  128. return MapObjectSubID();
  129. };
  130. ID = Obj::CREATURE_GENERATOR1;
  131. subID = testID(Obj::CREATURE_GENERATOR1);
  132. if (subID == MapObjectSubID())
  133. {
  134. ID = Obj::CREATURE_GENERATOR4;
  135. subID = testID(Obj::CREATURE_GENERATOR4);
  136. }
  137. if (subID == MapObjectSubID())
  138. {
  139. logGlobal->error("Error: failed to find dwelling for %s of level %d", (*LIBRARY->townh)[faction]->getNameTranslated(), int(level));
  140. ID = Obj::CREATURE_GENERATOR1;
  141. subID = *RandomGeneratorUtil::nextItem(LIBRARY->objtypeh->knownSubObjects(Obj::CREATURE_GENERATOR1), gameRandomizer.getDefault());
  142. }
  143. setType(ID, subID);
  144. }
  145. }
  146. void CGDwelling::initObj(IGameRandomizer & gameRandomizer)
  147. {
  148. switch(ID.toEnum())
  149. {
  150. case Obj::CREATURE_GENERATOR1:
  151. case Obj::CREATURE_GENERATOR4:
  152. case Obj::WAR_MACHINE_FACTORY:
  153. {
  154. getObjectHandler()->configureObject(this, gameRandomizer);
  155. assert(!creatures.empty());
  156. assert(!creatures[0].second.empty());
  157. break;
  158. }
  159. case Obj::REFUGEE_CAMP:
  160. //is handled within newturn func
  161. break;
  162. default:
  163. assert(0);
  164. break;
  165. }
  166. }
  167. void CGDwelling::setPropertyDer(ObjProperty what, ObjPropertyID identifier)
  168. {
  169. switch (what)
  170. {
  171. case ObjProperty::AVAILABLE_CREATURE:
  172. creatures.resize(1);
  173. creatures[0].second.resize(1);
  174. creatures[0].second[0] = identifier.as<CreatureID>();
  175. break;
  176. }
  177. }
  178. void CGDwelling::onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance * h) const
  179. {
  180. if(ID == Obj::REFUGEE_CAMP && !creatures[0].first) //Refugee Camp, no available cres
  181. {
  182. InfoWindow iw;
  183. iw.type = EInfoWindowMode::AUTO;
  184. iw.player = h->tempOwner;
  185. iw.text.appendLocalString(EMetaText::ADVOB_TXT, 44); //{%s} \n\n The camp is deserted. Perhaps you should try next week.
  186. iw.text.replaceName(ID, subID);
  187. gameEvents.sendAndApply(iw);
  188. return;
  189. }
  190. PlayerRelations relations = cb->getPlayerRelations( h->tempOwner, tempOwner );
  191. if ( relations == PlayerRelations::ALLIES )
  192. return;//do not allow recruiting or capturing
  193. if(relations == PlayerRelations::ENEMIES && stacksCount() > 0) //object is guarded, owned by enemy
  194. {
  195. BlockingDialog bd(true,false);
  196. bd.player = h->tempOwner;
  197. bd.text.appendLocalString(EMetaText::GENERAL_TXT, 421); //Much to your dismay, the %s is guarded by %s %s. Do you wish to fight the guards?
  198. bd.text.replaceTextID(getObjectHandler()->getNameTextID());
  199. if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
  200. bd.text.replaceRawString(CCreature::getQuantityRangeStringForId(Slots().begin()->second->getQuantityID()));
  201. else
  202. bd.text.replaceLocalString(EMetaText::ARRAY_TXT, 173 + (int)Slots().begin()->second->getQuantityID()*3);
  203. bd.text.replaceName(*Slots().begin()->second);
  204. gameEvents.showBlockingDialog(this, &bd);
  205. return;
  206. }
  207. // TODO this shouldn't be hardcoded
  208. if(relations == PlayerRelations::ENEMIES && ID != Obj::WAR_MACHINE_FACTORY && ID != Obj::REFUGEE_CAMP)
  209. {
  210. gameEvents.setOwner(this, h->tempOwner);
  211. }
  212. BlockingDialog bd (true,false);
  213. bd.player = h->tempOwner;
  214. if(ID == Obj::CREATURE_GENERATOR1 || ID == Obj::CREATURE_GENERATOR4)
  215. {
  216. const size_t count = creatures.size();
  217. if (count == 1)
  218. bd.text.appendLocalString(EMetaText::ADVOB_TXT, 35); // {%s} Would you like to recruit %s?
  219. else if (count == 2)
  220. bd.text.appendRawString(LIBRARY->generaltexth->translate("vcmi.adventureMap.dwelling2"));
  221. else if (count == 3)
  222. bd.text.appendRawString(LIBRARY->generaltexth->translate("vcmi.adventureMap.dwelling3"));
  223. else if (count == 4)
  224. bd.text.appendLocalString(EMetaText::ADVOB_TXT, 36); // {%s} Would you like to recruit %s, %s, %s, or %s?
  225. else
  226. bd.text.appendLocalString(EMetaText::ADVOB_TXT, 36);
  227. bd.text.replaceTextID(getObjectHandler()->getNameTextID());
  228. for(const auto & elem : creatures)
  229. bd.text.replaceNamePlural(elem.second[0]);
  230. }
  231. else if(ID == Obj::REFUGEE_CAMP)
  232. {
  233. bd.text.appendLocalString(EMetaText::ADVOB_TXT, 35); //{%s} Would you like to recruit %s?
  234. bd.text.replaceName(ID, subID);
  235. for(const auto & elem : creatures)
  236. bd.text.replaceNamePlural(elem.second[0]);
  237. }
  238. else if(ID == Obj::WAR_MACHINE_FACTORY)
  239. bd.text.appendLocalString(EMetaText::ADVOB_TXT, 157); //{War Machine Factory} Would you like to purchase War Machines?
  240. else
  241. throw std::runtime_error("Illegal dwelling!");
  242. if(ID == Obj::REFUGEE_CAMP || (ID == Obj::CREATURE_GENERATOR1 && LIBRARY->creatures()->getById(creatures[0].second[0])->getLevel() != 1))
  243. {
  244. bd.flags |= BlockingDialog::SAFE_TO_AUTOACCEPT;
  245. }
  246. gameEvents.showBlockingDialog(this, &bd);
  247. }
  248. void CGDwelling::newTurn(IGameEventCallback & gameEvents, IGameRandomizer & gameRandomizer) const
  249. {
  250. if(cb->getDate(Date::DAY_OF_WEEK) != 1) //not first day of week
  251. return;
  252. //town growths and War Machines Factories are handled separately
  253. if(ID == Obj::TOWN || ID == Obj::WAR_MACHINE_FACTORY)
  254. return;
  255. if(ID == Obj::REFUGEE_CAMP) //if it's a refugee camp, we need to pick an available creature
  256. {
  257. gameEvents.setObjPropertyID(id, ObjProperty::AVAILABLE_CREATURE, gameRandomizer.rollCreature());
  258. }
  259. bool change = false;
  260. SetAvailableCreatures sac;
  261. sac.creatures = creatures;
  262. sac.tid = id;
  263. for (size_t i = 0; i < creatures.size(); i++)
  264. {
  265. if(!creatures[i].second.empty())
  266. {
  267. bool creaturesAccumulate = false;
  268. if (tempOwner.isValidPlayer())
  269. creaturesAccumulate = cb->getSettings().getBoolean(EGameSettings::DWELLINGS_ACCUMULATE_WHEN_OWNED);
  270. else
  271. creaturesAccumulate = cb->getSettings().getBoolean(EGameSettings::DWELLINGS_ACCUMULATE_WHEN_NEUTRAL);
  272. const CCreature * cre =creatures[i].second[0].toCreature();
  273. TQuantity amount = cre->getGrowth() * (1 + cre->valOfBonuses(BonusType::CREATURE_GROWTH_PERCENT)/100) + cre->valOfBonuses(BonusType::CREATURE_GROWTH, BonusCustomSubtype::creatureLevel(cre->getLevel()));
  274. if (creaturesAccumulate && ID != Obj::REFUGEE_CAMP) //camp should not try to accumulate different kinds of creatures
  275. sac.creatures[i].first += amount;
  276. else
  277. sac.creatures[i].first = amount;
  278. change = true;
  279. }
  280. }
  281. if(change)
  282. gameEvents.sendAndApply(sac);
  283. updateGuards(gameEvents);
  284. }
  285. std::vector<Component> CGDwelling::getPopupComponents(PlayerColor player) const
  286. {
  287. bool visitedByOwner = getOwner() == player;
  288. std::vector<Component> result;
  289. if (ID == Obj::CREATURE_GENERATOR1 && !creatures.empty())
  290. {
  291. for (auto const & creature : creatures.front().second)
  292. {
  293. if (visitedByOwner)
  294. result.emplace_back(ComponentType::CREATURE, creature, creatures.front().first);
  295. else
  296. result.emplace_back(ComponentType::CREATURE, creature);
  297. }
  298. }
  299. if (ID == Obj::CREATURE_GENERATOR4)
  300. {
  301. for (auto const & creatureLevel : creatures)
  302. {
  303. if (!creatureLevel.second.empty())
  304. {
  305. if (visitedByOwner)
  306. result.emplace_back(ComponentType::CREATURE, creatureLevel.second.back(), creatureLevel.first);
  307. else
  308. result.emplace_back(ComponentType::CREATURE, creatureLevel.second.back());
  309. }
  310. }
  311. }
  312. return result;
  313. }
  314. void CGDwelling::updateGuards(IGameEventCallback & gameEvents) const
  315. {
  316. //TODO: store custom guard config and use it
  317. //TODO: store boolean flag for guards
  318. bool guarded = false;
  319. //default condition - creatures are of level 5 or higher
  320. for (auto creatureEntry : creatures)
  321. {
  322. if (LIBRARY->creatures()->getById(creatureEntry.second.at(0))->getLevel() >= 5 && ID != Obj::REFUGEE_CAMP)
  323. {
  324. guarded = true;
  325. break;
  326. }
  327. }
  328. if (guarded)
  329. {
  330. for (auto creatureEntry : creatures)
  331. {
  332. const CCreature * crea = creatureEntry.second.at(0).toCreature();
  333. SlotID slot = getSlotFor(crea->getId());
  334. if (hasStackAtSlot(slot)) //stack already exists, overwrite it
  335. {
  336. ChangeStackCount csc;
  337. csc.army = this->id;
  338. csc.slot = slot;
  339. csc.count = crea->getGrowth() * 3;
  340. csc.mode = ChangeValueMode::ABSOLUTE;
  341. gameEvents.sendAndApply(csc);
  342. }
  343. else //slot is empty, create whole new stack
  344. {
  345. InsertNewStack ns;
  346. ns.army = this->id;
  347. ns.slot = slot;
  348. ns.type = crea->getId();
  349. ns.count = crea->getGrowth() * 3;
  350. gameEvents.sendAndApply(ns);
  351. }
  352. }
  353. }
  354. }
  355. void CGDwelling::heroAcceptsCreatures(IGameEventCallback & gameEvents, const CGHeroInstance *h) const
  356. {
  357. CreatureID crid = creatures[0].second[0];
  358. auto *crs = crid.toCreature();
  359. TQuantity count = creatures[0].first;
  360. if(crs->getLevel() == 1 && ID != Obj::REFUGEE_CAMP) //first level - creatures are for free
  361. {
  362. if(count) //there are available creatures
  363. {
  364. if (cb->getSettings().getBoolean(EGameSettings::DWELLINGS_MERGE_ON_RECRUIT))
  365. {
  366. SlotID testSlot = h->getSlotFor(crid);
  367. if(!testSlot.validSlot()) //no available slot - try merging army of visiting hero
  368. {
  369. std::pair<SlotID, SlotID> toMerge;
  370. if (h->mergeableStacks(toMerge))
  371. {
  372. gameEvents.moveStack(StackLocation(h->id, toMerge.first), StackLocation(h->id, toMerge.second), -1); //merge toMerge.first into toMerge.second
  373. assert(!h->hasStackAtSlot(toMerge.first)); //we have now a new free slot
  374. }
  375. }
  376. }
  377. SlotID slot = h->getSlotFor(crid);
  378. if(!slot.validSlot()) //no available slot
  379. {
  380. InfoWindow iw;
  381. iw.type = EInfoWindowMode::AUTO;
  382. iw.player = h->tempOwner;
  383. iw.text.appendLocalString(EMetaText::GENERAL_TXT, 425);//The %s would join your hero, but there aren't enough provisions to support them.
  384. iw.text.replaceNamePlural(crid);
  385. gameEvents.showInfoDialog(&iw);
  386. }
  387. else //give creatures
  388. {
  389. SetAvailableCreatures sac;
  390. sac.tid = id;
  391. sac.creatures = creatures;
  392. sac.creatures[0].first = 0;
  393. InfoWindow iw;
  394. iw.type = EInfoWindowMode::AUTO;
  395. iw.player = h->tempOwner;
  396. iw.text.appendLocalString(EMetaText::GENERAL_TXT, 423); //%d %s join your army.
  397. iw.text.replaceNumber(count);
  398. iw.text.replaceNamePlural(crid);
  399. gameEvents.showInfoDialog(&iw);
  400. gameEvents.sendAndApply(sac);
  401. gameEvents.addToSlot(StackLocation(h->id, slot), crs, count);
  402. }
  403. }
  404. else //there no creatures
  405. {
  406. InfoWindow iw;
  407. iw.type = EInfoWindowMode::AUTO;
  408. iw.text.appendLocalString(EMetaText::GENERAL_TXT, 422); //There are no %s here to recruit.
  409. iw.text.replaceNamePlural(crid);
  410. iw.player = h->tempOwner;
  411. gameEvents.sendAndApply(iw);
  412. }
  413. }
  414. else
  415. {
  416. if(ID == Obj::WAR_MACHINE_FACTORY) //pick available War Machines
  417. {
  418. //there is 1 war machine available to recruit if hero doesn't have one
  419. SetAvailableCreatures sac;
  420. sac.tid = id;
  421. sac.creatures = creatures;
  422. for (auto & entry : sac.creatures)
  423. {
  424. CreatureID creature = entry.second.at(0);
  425. ArtifactID warMachine = creature.toCreature()->warMachine;
  426. if (h->hasArt(warMachine, true, false))
  427. entry.first = 0;
  428. else
  429. entry.first = 1;
  430. }
  431. gameEvents.sendAndApply(sac);
  432. }
  433. auto windowMode = (ID == Obj::CREATURE_GENERATOR1 || ID == Obj::REFUGEE_CAMP) ? EOpenWindowMode::RECRUITMENT_FIRST : EOpenWindowMode::RECRUITMENT_ALL;
  434. gameEvents.showObjectWindow(this, windowMode, h, true);
  435. }
  436. }
  437. void CGDwelling::battleFinished(IGameEventCallback & gameEvents, const CGHeroInstance *hero, const BattleResult &result) const
  438. {
  439. if (result.winner == BattleSide::ATTACKER)
  440. {
  441. onHeroVisit(gameEvents, hero);
  442. }
  443. }
  444. void CGDwelling::blockingDialogAnswered(IGameEventCallback & gameEvents, const CGHeroInstance *hero, int32_t answer) const
  445. {
  446. auto relations = cb->getPlayerRelations(getOwner(), hero->getOwner());
  447. if(stacksCount() > 0 && relations == PlayerRelations::ENEMIES) //guards present
  448. {
  449. if(answer)
  450. gameEvents.startBattle(hero, this);
  451. }
  452. else if(answer)
  453. {
  454. heroAcceptsCreatures(gameEvents, hero);
  455. }
  456. }
  457. void CGDwelling::serializeJsonOptions(JsonSerializeFormat & handler)
  458. {
  459. switch (ID.toEnum())
  460. {
  461. case Obj::WAR_MACHINE_FACTORY:
  462. case Obj::REFUGEE_CAMP:
  463. //do nothing
  464. break;
  465. case Obj::RANDOM_DWELLING:
  466. case Obj::RANDOM_DWELLING_LVL:
  467. case Obj::RANDOM_DWELLING_FACTION:
  468. if (!handler.saving)
  469. randomizationInfo = CGDwellingRandomizationInfo();
  470. randomizationInfo->serializeJson(handler);
  471. [[fallthrough]];
  472. default:
  473. serializeJsonOwner(handler);
  474. break;
  475. }
  476. }
  477. const IOwnableObject * CGDwelling::asOwnable() const
  478. {
  479. switch (ID.toEnum())
  480. {
  481. case Obj::WAR_MACHINE_FACTORY:
  482. case Obj::REFUGEE_CAMP:
  483. return nullptr; // can't be owned
  484. default:
  485. return this;
  486. }
  487. }
  488. ResourceSet CGDwelling::dailyIncome() const
  489. {
  490. return {};
  491. }
  492. std::vector<CreatureID> CGDwelling::providedCreatures() const
  493. {
  494. if (ID == Obj::WAR_MACHINE_FACTORY || ID == Obj::REFUGEE_CAMP)
  495. return {};
  496. std::vector<CreatureID> result;
  497. for (const auto & level : creatures)
  498. result.insert(result.end(), level.second.begin(), level.second.end());
  499. return result;
  500. }
  501. VCMI_LIB_NAMESPACE_END