CArtHandler.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #define VCMI_DLL
  2. #include "../stdafx.h"
  3. #include "CArtHandler.h"
  4. #include "CLodHandler.h"
  5. #include <boost/assign/std/vector.hpp>
  6. #include <boost/assign/list_of.hpp>
  7. #include "../lib/VCMI_Lib.h"
  8. extern CLodHandler *bitmaph;
  9. using namespace boost::assign;
  10. CArtHandler::CArtHandler()
  11. {
  12. VLC->arth = this;
  13. }
  14. void CArtHandler::loadArtifacts()
  15. {
  16. std::vector<ui16> slots;
  17. slots += 17, 16, 15,14,13, 18, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0;
  18. std::map<char,EartClass> classes =
  19. map_list_of('S',SartClass)('T',TartClass)('N',NartClass)('J',JartClass)('R',RartClass);
  20. std::string buf = bitmaph->getTextFile("ARTRAITS.TXT"), dump, pom;
  21. int it=0;
  22. for(int i=0; i<2; ++i)
  23. {
  24. loadToIt(dump,buf,it,3);
  25. }
  26. for (int i=0; i<ARTIFACTS_QUANTITY; i++)
  27. {
  28. CArtifact nart;
  29. loadToIt(nart.name,buf,it,4);
  30. loadToIt(pom,buf,it,4);
  31. nart.price=atoi(pom.c_str());
  32. for(int j=0;j<slots.size();j++)
  33. {
  34. loadToIt(pom,buf,it,4);
  35. if(pom[0]=='x')
  36. nart.possibleSlots.push_back(slots[j]);
  37. }
  38. loadToIt(pom,buf,it,4);
  39. nart.aClass = classes[pom[0]];
  40. loadToIt(nart.description,buf,it,3);
  41. nart.id=i;
  42. artifacts.push_back(nart);
  43. }
  44. for(int i=0;i<144;i++) //do 144, bo nie chcemy bzdurek
  45. {
  46. switch (artifacts[i].aClass)
  47. {
  48. case TartClass:
  49. treasures.push_back(&(artifacts[i]));
  50. break;
  51. case NartClass:
  52. minors.push_back(&(artifacts[i]));
  53. break;
  54. case JartClass:
  55. majors.push_back(&(artifacts[i]));
  56. break;
  57. case RartClass:
  58. relics.push_back(&(artifacts[i]));
  59. break;
  60. }
  61. }
  62. }
  63. int CArtHandler::convertMachineID(int id, bool creToArt )
  64. {
  65. int dif = 142;
  66. if(creToArt)
  67. {
  68. switch (id)
  69. {
  70. case 147:
  71. dif--;
  72. break;
  73. case 148:
  74. dif++;
  75. break;
  76. }
  77. dif = -dif;
  78. }
  79. else
  80. {
  81. switch (id)
  82. {
  83. case 6:
  84. dif--;
  85. break;
  86. case 5:
  87. dif++;
  88. break;
  89. }
  90. }
  91. return id + dif;
  92. }