CCreatureSet.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. #define VCMI_DLL
  2. #include "CCreatureSet.h"
  3. #include "CCreatureHandler.h"
  4. #include "VCMI_Lib.h"
  5. #include <assert.h>
  6. #include "CObjectHandler.h"
  7. #include "IGameCallback.h"
  8. #include "CGameState.h"
  9. #include "CGeneralTextHandler.h"
  10. #include <sstream>
  11. #include "CSpellHandler.h"
  12. #include <boost/lexical_cast.hpp>
  13. #include <boost/algorithm/string/replace.hpp>
  14. const CStackInstance &CCreatureSet::operator[](TSlot slot) const
  15. {
  16. TSlots::const_iterator i = stacks.find(slot);
  17. if (i != stacks.end())
  18. return *i->second;
  19. else
  20. throw std::string("That slot is empty!");
  21. }
  22. const CCreature* CCreatureSet::getCreature(TSlot slot) const
  23. {
  24. TSlots::const_iterator i = stacks.find(slot);
  25. if (i != stacks.end())
  26. return i->second->type;
  27. else
  28. return NULL;
  29. }
  30. bool CCreatureSet::setCreature(TSlot slot, TCreature type, TQuantity quantity) /*slots 0 to 6 */
  31. {
  32. if(slot > 6 || slot < 0)
  33. {
  34. tlog1 << "Cannot set slot " << slot << std::endl;
  35. return false;
  36. }
  37. if(!quantity)
  38. {
  39. tlog2 << "Using set creature to delete stack?\n";
  40. eraseStack(slot);
  41. return true;
  42. }
  43. if(hasStackAtSlot(slot)) //remove old creature
  44. eraseStack(slot);
  45. putStack(slot, new CStackInstance(type, quantity));
  46. return true;
  47. }
  48. TSlot CCreatureSet::getSlotFor(TCreature creature, ui32 slotsAmount/*=7*/) const /*returns -1 if no slot available */
  49. {
  50. return getSlotFor(VLC->creh->creatures[creature], slotsAmount);
  51. }
  52. TSlot CCreatureSet::getSlotFor(const CCreature *c, ui32 slotsAmount/*=ARMY_SIZE*/) const
  53. {
  54. assert(c->valid());
  55. for(TSlots::const_iterator i=stacks.begin(); i!=stacks.end(); ++i)
  56. {
  57. assert(i->second->type->valid());
  58. if(i->second->type == c)
  59. {
  60. return i->first; //if there is already such creature we return its slot id
  61. }
  62. }
  63. for(ui32 i=0; i<slotsAmount; i++)
  64. {
  65. if(stacks.find(i) == stacks.end())
  66. {
  67. return i; //return first free slot
  68. }
  69. }
  70. return -1; //no slot available
  71. }
  72. int CCreatureSet::getStackCount(TSlot slot) const
  73. {
  74. TSlots::const_iterator i = stacks.find(slot);
  75. if (i != stacks.end())
  76. return i->second->count;
  77. else
  78. return 0; //TODO? consider issuing a warning
  79. }
  80. bool CCreatureSet::mergableStacks(std::pair<TSlot, TSlot> &out, TSlot preferable /*= -1*/) const /*looks for two same stacks, returns slot positions */
  81. {
  82. //try to match creature to our preferred stack
  83. if(preferable >= 0 && vstd::contains(stacks, preferable))
  84. {
  85. const CCreature *cr = stacks.find(preferable)->second->type;
  86. for(TSlots::const_iterator j=stacks.begin(); j!=stacks.end(); ++j)
  87. {
  88. if(cr == j->second->type && j->first != preferable)
  89. {
  90. out.first = preferable;
  91. out.second = j->first;
  92. return true;
  93. }
  94. }
  95. }
  96. for(TSlots::const_iterator i=stacks.begin(); i!=stacks.end(); ++i)
  97. {
  98. for(TSlots::const_iterator j=stacks.begin(); j!=stacks.end(); ++j)
  99. {
  100. if(i->second->type == j->second->type && i->first != j->first)
  101. {
  102. out.first = i->first;
  103. out.second = j->first;
  104. return true;
  105. }
  106. }
  107. }
  108. return false;
  109. }
  110. void CCreatureSet::sweep()
  111. {
  112. for(TSlots::iterator i=stacks.begin(); i!=stacks.end(); ++i)
  113. {
  114. if(!i->second->count)
  115. {
  116. stacks.erase(i);
  117. sweep();
  118. break;
  119. }
  120. }
  121. }
  122. void CCreatureSet::addToSlot(TSlot slot, TCreature cre, TQuantity count, bool allowMerging/* = true*/)
  123. {
  124. const CCreature *c = VLC->creh->creatures[cre];
  125. if(!hasStackAtSlot(slot))
  126. {
  127. setCreature(slot, cre, count);
  128. }
  129. else if(getCreature(slot) == c && allowMerging) //that slot was empty or contained same type creature
  130. {
  131. setStackCount(slot, getStackCount(slot) + count);
  132. }
  133. else
  134. {
  135. tlog1 << "Failed adding to slot!\n";
  136. }
  137. }
  138. void CCreatureSet::addToSlot(TSlot slot, CStackInstance *stack, bool allowMerging/* = true*/)
  139. {
  140. assert(stack->valid(true));
  141. if(!hasStackAtSlot(slot))
  142. {
  143. putStack(slot, stack);
  144. }
  145. else if(allowMerging && stack->type == getCreature(slot))
  146. {
  147. joinStack(slot, stack);
  148. }
  149. else
  150. {
  151. tlog1 << "Cannot add to slot " << slot << " stack " << *stack << std::endl;
  152. }
  153. }
  154. bool CCreatureSet::validTypes(bool allowUnrandomized /*= false*/) const
  155. {
  156. for(TSlots::const_iterator i=stacks.begin(); i!=stacks.end(); ++i)
  157. {
  158. if(!i->second->valid(allowUnrandomized))
  159. return false;
  160. }
  161. return true;
  162. }
  163. bool CCreatureSet::slotEmpty(TSlot slot) const
  164. {
  165. return !hasStackAtSlot(slot);
  166. }
  167. bool CCreatureSet::needsLastStack() const
  168. {
  169. return false;
  170. }
  171. int CCreatureSet::getArmyStrength() const
  172. {
  173. int ret = 0;
  174. for(TSlots::const_iterator i = stacks.begin(); i != stacks.end(); i++)
  175. ret += i->second->type->AIValue * i->second->count;
  176. return ret;
  177. }
  178. ui64 CCreatureSet::getPower (TSlot slot) const
  179. {
  180. return getCreature(slot)->AIValue * getStackCount(slot);
  181. }
  182. std::string CCreatureSet::getRoughAmount (TSlot slot) const
  183. {
  184. return VLC->generaltexth->arraytxt[174 + 3*CCreature::getQuantityID(getStackCount(slot))];
  185. }
  186. int CCreatureSet::stacksCount() const
  187. {
  188. return stacks.size();
  189. }
  190. void CCreatureSet::setFormation(bool tight)
  191. {
  192. formation = tight;
  193. }
  194. void CCreatureSet::setStackCount(TSlot slot, TQuantity count)
  195. {
  196. assert(hasStackAtSlot(slot));
  197. assert(count > 0);
  198. if (STACK_EXP)
  199. stacks[slot]->experience *= ((stacks[slot]->count + count)/(float)stacks[slot]->count);
  200. stacks[slot]->count = count;
  201. armyChanged();
  202. }
  203. void CCreatureSet::giveStackExp(expType exp)
  204. {
  205. for(TSlots::const_iterator i = stacks.begin(); i != stacks.end(); i++)
  206. i->second->giveStackExp(exp);
  207. }
  208. void CCreatureSet::clear()
  209. {
  210. while(!stacks.empty())
  211. {
  212. eraseStack(stacks.begin()->first);
  213. }
  214. }
  215. const CStackInstance& CCreatureSet::getStack(TSlot slot) const
  216. {
  217. assert(hasStackAtSlot(slot));
  218. return *stacks.find(slot)->second;
  219. }
  220. void CCreatureSet::eraseStack(TSlot slot)
  221. {
  222. assert(hasStackAtSlot(slot));
  223. CStackInstance *toErase = detachStack(slot);
  224. delNull(toErase);
  225. }
  226. bool CCreatureSet::contains(const CStackInstance *stack) const
  227. {
  228. if(!stack)
  229. return false;
  230. for(TSlots::const_iterator i = stacks.begin(); i != stacks.end(); ++i)
  231. if(i->second == stack)
  232. return true;
  233. return false;
  234. }
  235. TSlot CCreatureSet::findStack(const CStackInstance *stack) const
  236. {
  237. if(!stack)
  238. return -1;
  239. for(TSlots::const_iterator i = stacks.begin(); i != stacks.end(); ++i)
  240. if(i->second == stack)
  241. return i->first;
  242. return -1;
  243. }
  244. CArmedInstance * CCreatureSet::castToArmyObj()
  245. {
  246. return dynamic_cast<CArmedInstance *>(this);
  247. }
  248. void CCreatureSet::putStack(TSlot slot, CStackInstance *stack)
  249. {
  250. assert(!hasStackAtSlot(slot));
  251. stacks[slot] = stack;
  252. stack->setArmyObj(castToArmyObj());
  253. armyChanged();
  254. }
  255. void CCreatureSet::joinStack(TSlot slot, CStackInstance * stack)
  256. {
  257. const CCreature *c = getCreature(slot);
  258. assert(c == stack->type);
  259. assert(c);
  260. //TODO move stuff
  261. changeStackCount(slot, stack->count);
  262. delNull(stack);
  263. }
  264. void CCreatureSet::changeStackCount(TSlot slot, TQuantity toAdd)
  265. {
  266. setStackCount(slot, getStackCount(slot) + toAdd);
  267. }
  268. CCreatureSet::CCreatureSet()
  269. {
  270. formation = false;
  271. }
  272. CCreatureSet::CCreatureSet(const CCreatureSet&)
  273. {
  274. assert(0);
  275. }
  276. CCreatureSet::~CCreatureSet()
  277. {
  278. clear();
  279. }
  280. void CCreatureSet::setToArmy(CSimpleArmy &src)
  281. {
  282. clear();
  283. while(src)
  284. {
  285. TSimpleSlots::iterator i = src.army.begin();
  286. assert(i->second.type);
  287. assert(i->second.count);
  288. putStack(i->first, new CStackInstance(i->second.type, i->second.count));
  289. src.army.erase(i);
  290. }
  291. }
  292. CStackInstance * CCreatureSet::detachStack(TSlot slot)
  293. {
  294. assert(hasStackAtSlot(slot));
  295. CStackInstance *ret = stacks[slot];
  296. //if(CArmedInstance *armedObj = castToArmyObj())
  297. {
  298. ret->setArmyObj(NULL); //detaches from current armyobj
  299. }
  300. assert(!ret->armyObj); //we failed detaching?
  301. stacks.erase(slot);
  302. armyChanged();
  303. return ret;
  304. }
  305. void CCreatureSet::setStackType(TSlot slot, const CCreature *type)
  306. {
  307. assert(hasStackAtSlot(slot));
  308. CStackInstance *s = stacks[slot];
  309. s->setType(type->idNumber);
  310. armyChanged();
  311. }
  312. bool CCreatureSet::canBeMergedWith(const CCreatureSet &cs, bool allowMergingStacks) const
  313. {
  314. if(!allowMergingStacks)
  315. {
  316. int freeSlots = stacksCount() - ARMY_SIZE;
  317. std::set<const CCreature*> cresToAdd;
  318. for(TSlots::const_iterator i = cs.stacks.begin(); i != cs.stacks.end(); i++)
  319. {
  320. TSlot dest = getSlotFor(i->second->type);
  321. if(dest < 0 || hasStackAtSlot(dest))
  322. cresToAdd.insert(i->second->type);
  323. }
  324. return cresToAdd.size() <= freeSlots;
  325. }
  326. else
  327. {
  328. std::set<const CCreature*> cres;
  329. //get types of creatures that need their own slot
  330. for(TSlots::const_iterator i = cs.stacks.begin(); i != cs.stacks.end(); i++)
  331. cres.insert(i->second->type);
  332. for(TSlots::const_iterator i = stacks.begin(); i != stacks.end(); i++)
  333. cres.insert(i->second->type);
  334. return cres.size() <= ARMY_SIZE;
  335. }
  336. }
  337. bool CCreatureSet::hasStackAtSlot(TSlot slot) const
  338. {
  339. return vstd::contains(stacks, slot);
  340. }
  341. CCreatureSet & CCreatureSet::operator=(const CCreatureSet&cs)
  342. {
  343. assert(0);
  344. return *this;
  345. }
  346. void CCreatureSet::armyChanged()
  347. {
  348. }
  349. CStackInstance::CStackInstance()
  350. : armyObj(_armyObj)
  351. {
  352. init();
  353. }
  354. CStackInstance::CStackInstance(TCreature id, TQuantity Count)
  355. : armyObj(_armyObj)
  356. {
  357. init();
  358. setType(id);
  359. count = Count;
  360. }
  361. CStackInstance::CStackInstance(const CCreature *cre, TQuantity Count)
  362. : armyObj(_armyObj)
  363. {
  364. init();
  365. setType(cre);
  366. count = Count;
  367. }
  368. void CStackInstance::init()
  369. {
  370. experience = 0;
  371. count = 0;
  372. type = NULL;
  373. idRand = -1;
  374. _armyObj = NULL;
  375. nodeType = STACK_INSTANCE;
  376. }
  377. int CStackInstance::getQuantityID() const
  378. {
  379. return CCreature::getQuantityID(count);
  380. }
  381. int CStackInstance::getExpRank() const
  382. {
  383. int tier = type->level;
  384. if (iswith(tier, 1, 7))
  385. {
  386. for (int i = VLC->creh->expRanks[tier].size()-2; i >-1; --i)//sic!
  387. { //exp values vary from 1st level to max exp at 11th level
  388. if (experience >= VLC->creh->expRanks[tier][i])
  389. return ++i; //faster, but confusing - 0 index mean 1st level of experience
  390. }
  391. return 0;
  392. }
  393. else //higher tier
  394. {
  395. for (int i = VLC->creh->expRanks[tier].size()-2; i >-1; --i)
  396. {
  397. if (experience >= VLC->creh->expRanks[0][i])
  398. return ++i;
  399. }
  400. return 0;
  401. }
  402. }
  403. void CStackInstance::giveStackExp(expType exp)
  404. {
  405. int level = type->level;
  406. if (!iswith(level, 1, 7))
  407. level = 0;
  408. CCreatureHandler * creh = VLC->creh;
  409. amin(exp, (expType)creh->expRanks[level].back()); //prevent exp overflow due to different types
  410. amin(exp, (exp * creh->maxExpPerBattle[level])/100);
  411. amin(experience += exp, creh->expRanks[level].back()); //can't get more exp than this limit
  412. }
  413. void CStackInstance::setType(int creID)
  414. {
  415. setType(VLC->creh->creatures[creID]);
  416. }
  417. void CStackInstance::setType(const CCreature *c)
  418. {
  419. if(type)
  420. {
  421. detachFrom(const_cast<CCreature*>(type));
  422. if (type->isMyUpgrade(c) && STACK_EXP)
  423. experience *= VLC->creh->expAfterUpgrade / 100.0f;
  424. }
  425. type = c;
  426. attachTo(const_cast<CCreature*>(type));
  427. }
  428. std::string CStackInstance::bonusToString(Bonus *bonus, bool description) const
  429. {
  430. std::map<TBonusType, std::pair<std::string, std::string> >::iterator it = VLC->creh->stackBonuses.find(bonus->type);
  431. if (it != VLC->creh->stackBonuses.end())
  432. {
  433. std::string text;
  434. if (description) //long ability description
  435. {
  436. text = it->second.second;
  437. switch (bonus->type)
  438. {
  439. //no additional modifiers needed
  440. case Bonus::FLYING:
  441. case Bonus::UNLIMITED_RETALIATIONS:
  442. case Bonus::SHOOTER:
  443. case Bonus::FREE_SHOOTING:
  444. case Bonus::NO_SHOTING_PENALTY:
  445. case Bonus::NO_MELEE_PENALTY:
  446. case Bonus::NO_DISTANCE_PENALTY:
  447. case Bonus::NO_OBSTACLES_PENALTY:
  448. case Bonus::JOUSTING: //TODO: percent bonus?
  449. case Bonus::RETURN_AFTER_STRIKE:
  450. case Bonus::BLOCKS_RETALIATION:
  451. case Bonus::TWO_HEX_ATTACK_BREATH:
  452. case Bonus::THREE_HEADED_ATTACK:
  453. case Bonus::ATTACKS_ALL_ADJACENT:
  454. case Bonus::FULL_HP_REGENERATION:
  455. case Bonus::LIFE_DRAIN: //TODO: chance, hp percentage?
  456. case Bonus::SELF_MORALE:
  457. case Bonus::SELF_LUCK:
  458. case Bonus::FEAR:
  459. case Bonus::FEARLESS:
  460. case Bonus::CHARGE_IMMUNITY:
  461. case Bonus::HEALER:
  462. case Bonus::CATAPULT:
  463. case Bonus::DRAGON_NATURE:
  464. case Bonus::NON_LIVING:
  465. case Bonus::UNDEAD:
  466. break;
  467. //One numeric value
  468. //case Bonus::STACKS_SPEED: //Do we need description for creature stats?
  469. //case Bonus::STACK_HEALTH:
  470. case Bonus::MAGIC_RESISTANCE:
  471. case Bonus::SPELL_DAMAGE_REDUCTION:
  472. case Bonus::LEVEL_SPELL_IMMUNITY:
  473. case Bonus::CHANGES_SPELL_COST_FOR_ALLY:
  474. case Bonus::CHANGES_SPELL_COST_FOR_ENEMY:
  475. case Bonus::MANA_CHANNELING:
  476. case Bonus::MANA_DRAIN:
  477. case Bonus::HP_REGENERATION:
  478. case Bonus::ADDITIONAL_RETALIATION:
  479. case Bonus::DOUBLE_DAMAGE_CHANCE:
  480. case Bonus::ENEMY_DEFENCE_REDUCTION:
  481. case Bonus::MAGIC_MIRROR:
  482. case Bonus::DARKNESS: //Darkness Dragons any1?
  483. boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(bonus->val));
  484. break;
  485. //Complex descriptions
  486. case Bonus::HATE:
  487. boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(bonus->val));
  488. boost::algorithm::replace_first(text, "%s", VLC->creh->creatures[bonus->subtype]->namePl);
  489. break;
  490. case Bonus::SPELL_IMMUNITY:
  491. boost::algorithm::replace_first(text, "%s", VLC->spellh->spells[bonus->subtype]->name);
  492. break;
  493. case Bonus::SPELL_AFTER_ATTACK:
  494. boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(bonus->additionalInfo % 100));
  495. boost::algorithm::replace_first(text, "%s", VLC->spellh->spells[bonus->subtype]->name);
  496. break;
  497. default:
  498. {}//TODO: allow custom bonus types... someday, somehow
  499. }
  500. }
  501. else //short name
  502. {
  503. text = it->second.first;
  504. switch (bonus->type)
  505. {
  506. case Bonus::HATE:
  507. boost::algorithm::replace_first(text, "%s", VLC->creh->creatures[bonus->subtype]->namePl);
  508. break;
  509. case Bonus::LEVEL_SPELL_IMMUNITY:
  510. boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(bonus->val));
  511. break;
  512. case Bonus::SPELL_IMMUNITY:
  513. case Bonus::SPELL_AFTER_ATTACK:
  514. boost::algorithm::replace_first(text, "%s", VLC->spellh->spells[bonus->subtype]->name);
  515. break;
  516. }
  517. }
  518. return text;
  519. }
  520. else
  521. return "";
  522. }
  523. void CStackInstance::setArmyObj(const CArmedInstance *ArmyObj)
  524. {
  525. if(_armyObj)
  526. detachFrom(const_cast<CArmedInstance*>(_armyObj));
  527. _armyObj = ArmyObj;
  528. if(ArmyObj)
  529. {
  530. attachTo(const_cast<CArmedInstance*>(_armyObj));
  531. }
  532. }
  533. // void CStackInstance::getParents(TCNodes &out, const CBonusSystemNode *source /*= NULL*/) const
  534. // {
  535. // out.insert(type);
  536. //
  537. // if(source && source != this) //we should be root, if not - do not inherit anything
  538. // return;
  539. //
  540. // if(armyObj)
  541. // out.insert(armyObj);
  542. // else
  543. // out.insert(&IObjectInterface::cb->gameState()->globalEffects);
  544. // }
  545. std::string CStackInstance::getQuantityTXT(bool capitalized /*= true*/) const
  546. {
  547. return VLC->generaltexth->arraytxt[174 + getQuantityID()*3 + 2 - capitalized];
  548. }
  549. bool CStackInstance::valid(bool allowUnrandomized) const
  550. {
  551. bool isRand = (idRand != -1);
  552. if(!isRand)
  553. {
  554. return (type && type == VLC->creh->creatures[type->idNumber]);
  555. }
  556. else
  557. return allowUnrandomized;
  558. }
  559. CStackInstance::~CStackInstance()
  560. {
  561. }
  562. std::string CStackInstance::nodeName() const
  563. {
  564. std::ostringstream oss;
  565. oss << "Stack of " << count << " of ";
  566. if(type)
  567. oss << type->namePl;
  568. else if(idRand)
  569. oss << "[no type, idRand=" << idRand << "]";
  570. else
  571. oss << "[UNDEFINED TYPE]";
  572. return oss.str();
  573. }
  574. void CStackInstance::deserializationFix()
  575. {
  576. setType(type);
  577. setArmyObj(armyObj);
  578. }
  579. CStackBasicDescriptor::CStackBasicDescriptor()
  580. {
  581. type = NULL;
  582. count = -1;
  583. }
  584. CStackBasicDescriptor::CStackBasicDescriptor(TCreature id, TQuantity Count)
  585. : type (VLC->creh->creatures[id]), count(Count)
  586. {
  587. }
  588. CStackBasicDescriptor::CStackBasicDescriptor(const CCreature *c, TQuantity Count)
  589. : type(c), count(Count)
  590. {
  591. }
  592. DLL_EXPORT std::ostream & operator<<(std::ostream & str, const CStackInstance & sth)
  593. {
  594. if(!sth.valid(true))
  595. str << "an invalid stack!";
  596. str << "stack with " << sth.count << " of ";
  597. if(sth.type)
  598. str << sth.type->namePl;
  599. else
  600. str << sth.idRand;
  601. return str;
  602. }
  603. void CSimpleArmy::clear()
  604. {
  605. army.clear();
  606. }
  607. CSimpleArmy::operator bool() const
  608. {
  609. return army.size();
  610. }
  611. bool CSimpleArmy::setCreature(TSlot slot, TCreature cre, TQuantity count)
  612. {
  613. assert(!vstd::contains(army, slot));
  614. army[slot] = CStackBasicDescriptor(cre, count);
  615. return true;
  616. }