Item.cpp 1.7 KB

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