PlayerHand.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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(
  11. ItemSkill* zSkill, Framework::StreamReader* zReader) const
  12. {
  13. // TODO: load skill data
  14. }
  15. void PlayerHandItemType::saveSuperItemSkill(
  16. const ItemSkill* zSkill, Framework::StreamWriter* zWriter) const
  17. {
  18. // TODO: store skill data
  19. }
  20. Item* PlayerHandItemType::createItem() const
  21. {
  22. return 0; // there is no player hand item
  23. }
  24. ItemSkill* PlayerHandItemType::createDefaultItemSkill() const
  25. {
  26. return new PlayerHandSkill();
  27. }
  28. PlayerHandLevelUpRule::PlayerHandLevelUpRule()
  29. : ItemSkillLevelUpRule()
  30. {}
  31. void PlayerHandLevelUpRule::applyOn(ItemSkill* zSkill)
  32. {
  33. // TODO: level up the skill
  34. }
  35. PlayerHandSkill::PlayerHandSkill()
  36. : ItemSkill(ItemTypeEnum::PLAYER_HAND)
  37. {}
  38. void PlayerHandSkill::use(Entity* zActor, Item* zUsedItem, Block* zTarget)
  39. {
  40. if (zTarget && zTarget->getHardness() <= 1)
  41. {
  42. zTarget->setHP(zTarget->getHP() - 1 / (zTarget->getHardness() + 1));
  43. }
  44. }
  45. void PlayerHandSkill::use(Entity* zActor, Item* zUsedItem, Entity* zTarget)
  46. {
  47. // TODO: make damage on the entity
  48. }