PlayerHand.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #include "PlayerHand.h"
  2. #include "Block.h"
  3. #include "Entity.h"
  4. PlayerHandItemType::PlayerHandItemType()
  5. : ItemType(ItemTypeEnum::PLAYER_HAND,
  6. "PlayerHand",
  7. new PlayerHandLevelUpRule(),
  8. 0,
  9. ModelInfo("", "", 0))
  10. {}
  11. void PlayerHandItemType::loadSuperItemSkill(
  12. ItemSkill* zSkill, Framework::StreamReader* zReader) const
  13. {
  14. // TODO: load skill data
  15. }
  16. void PlayerHandItemType::saveSuperItemSkill(
  17. const ItemSkill* zSkill, Framework::StreamWriter* zWriter) const
  18. {
  19. // TODO: store skill data
  20. }
  21. Item* PlayerHandItemType::createItem() const
  22. {
  23. return 0; // there is no player hand item
  24. }
  25. ItemSkill* PlayerHandItemType::createDefaultItemSkill() const
  26. {
  27. return new PlayerHandSkill();
  28. }
  29. PlayerHandLevelUpRule::PlayerHandLevelUpRule()
  30. : ItemSkillLevelUpRule()
  31. {}
  32. void PlayerHandLevelUpRule::applyOn(ItemSkill* zSkill)
  33. {
  34. // TODO: level up the skill
  35. }
  36. PlayerHandSkill::PlayerHandSkill()
  37. : ItemSkill(ItemTypeEnum::PLAYER_HAND)
  38. {}
  39. bool PlayerHandSkill::use(Entity* zActor, Item* zUsedItem, Block* zTarget)
  40. {
  41. if (zActor->getStamina() > 0.001f)
  42. {
  43. if (zTarget && zTarget->getHardness() <= 1)
  44. {
  45. zActor->setStamina(zActor->getStamina() - 0.001f);
  46. zTarget->setHP(zTarget->getHP() - 1 / (zTarget->getHardness() + 1));
  47. }
  48. else
  49. {
  50. zActor->setStamina(zActor->getStamina() - 0.001f);
  51. zActor->setHP(zActor->getCurrentHP() - 0.01f);
  52. }
  53. }
  54. return false; // item was not changed
  55. }
  56. bool PlayerHandSkill::use(Entity* zActor, Item* zUsedItem, Entity* zTarget)
  57. {
  58. // TODO: make damage on the entity
  59. return false; // item was not changed
  60. }