PlayerHand.cpp 1.2 KB

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