PlayerHand.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "PlayerHand.h"
  2. #include "Block.h"
  3. PlayerHandItemType::PlayerHandItemType()
  4. : ItemType(ItemTypeEnum::PLAYER_HAND,
  5. "PlayerHand",
  6. new PlayerHandLevelUpRule(),
  7. 0,
  8. ModelInfo("", "", 0))
  9. {}
  10. void PlayerHandItemType::loadSuperItemSkill(ItemSkill* zSkill, Framework::StreamReader* zReader) const
  11. {
  12. // TODO: load skill data
  13. }
  14. void PlayerHandItemType::saveSuperItemSkill(const ItemSkill* zSkill, Framework::StreamWriter* zWriter) const
  15. {
  16. // TODO: store skill data
  17. }
  18. Item* PlayerHandItemType::createItem() const
  19. {
  20. return 0; // there is no player hand item
  21. }
  22. ItemSkill* PlayerHandItemType::createDefaultItemSkill() const
  23. {
  24. return new PlayerHandSkill();
  25. }
  26. PlayerHandLevelUpRule::PlayerHandLevelUpRule()
  27. : ItemSkillLevelUpRule()
  28. {}
  29. void PlayerHandLevelUpRule::applyOn(ItemSkill* zSkill)
  30. {
  31. // TODO: level up the skill
  32. }
  33. PlayerHandSkill::PlayerHandSkill() : ItemSkill(ItemTypeEnum::PLAYER_HAND) {}
  34. void PlayerHandSkill::use(Entity* zActor, Item* zUsedItem, Block* zTarget)
  35. {
  36. if (zTarget && zTarget->getHardness() <= 1)
  37. {
  38. zTarget->setHP(zTarget->getHP() - 1 / (zTarget->getHardness() + 1));
  39. }
  40. }
  41. void PlayerHandSkill::use(Entity* zActor, Item* zUsedItem, Entity* zTarget)
  42. {
  43. // TODO: make damage on the entity
  44. }