Item.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #include "Item.h"
  2. #include <Text.h>
  3. Item::Item(const ItemType* zType, const char* name)
  4. : ReferenceCounter(),
  5. zType(zType),
  6. zBlockType(0),
  7. hp(1),
  8. maxHp(1),
  9. durability(1),
  10. maxDurability(1),
  11. eatable(0),
  12. placeable(0),
  13. equippable(0),
  14. solid(1),
  15. usable(0),
  16. maxStackSize(50),
  17. name(name)
  18. {}
  19. void Item::setHp(float hp)
  20. {
  21. this->hp = hp;
  22. }
  23. void Item::tick()
  24. {}
  25. const ItemType* Item::zItemType() const
  26. {
  27. return zType;
  28. }
  29. const BlockType* Item::zPlacedBlockType() const
  30. {
  31. return zBlockType;
  32. }
  33. float Item::getHp() const
  34. {
  35. return hp;
  36. }
  37. float Item::getDurability() const
  38. {
  39. return durability;
  40. }
  41. bool Item::isUsable() const
  42. {
  43. return usable;
  44. }
  45. bool Item::isEatable() const
  46. {
  47. return eatable;
  48. }
  49. bool Item::isPlaceable() const
  50. {
  51. return placeable;
  52. }
  53. bool Item::isEquippable() const
  54. {
  55. return equippable;
  56. }
  57. bool Item::isSolid() const
  58. {
  59. return solid;
  60. }
  61. float Item::getMaxDurability() const
  62. {
  63. return maxDurability;
  64. }
  65. int Item::getMaxStackSize() const
  66. {
  67. return maxStackSize;
  68. }
  69. float Item::getMaxHp() const
  70. {
  71. return maxHp;
  72. }
  73. bool Item::canBeStackedWith(const Item* zItem) const
  74. {
  75. return zType == zItem->zType &&
  76. durability == maxDurability &&
  77. zItem->durability == zItem->maxDurability &&
  78. maxHp == zItem->maxHp &&
  79. eatable == zItem->eatable &&
  80. placeable == zItem->placeable &&
  81. equippable == zItem->eatable &&
  82. solid == zItem->solid &&
  83. usable == zItem->usable &&
  84. maxStackSize == zItem->maxStackSize &&
  85. name.istGleich(zItem->name);
  86. }
  87. void Item::onPlaced()
  88. {
  89. hp = 0;
  90. }
  91. Framework::Text Item::getTooltipUIML() const
  92. {
  93. return Framework::Text("<tip><text width=\"auto\" height=\"auto\">") + name + "</text></tip>";
  94. }
  95. void Item::applyInventoryEffects(Entity* zTarget)
  96. {}
  97. void Item::removeInventoryEffects(Entity* zTarget)
  98. {}
  99. void Item::applyEquippedEffects(Entity* zTarget)
  100. {}
  101. void Item::removeEquippedEffects(Entity* zTarget)
  102. {}
  103. void Item::applyFoodEffects(Entity* zTarget)
  104. {}