PlayerHand.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "PlayerHand.h"
  2. #include "Block.h"
  3. #include "Entity.h"
  4. PlayerHandItemType::PlayerHandItemType()
  5. : ItemType("PlayerHand", 0, 0)
  6. {}
  7. Item* PlayerHandItemType::createItem() const
  8. {
  9. return 0; // there is no player hand item
  10. }
  11. ItemSkill* PlayerHandItemType::createDefaultItemSkill() const
  12. {
  13. return new PlayerHandSkill();
  14. }
  15. void PlayerHandItemType::levelUpItemSkill(ItemSkill* zSkill) const {}
  16. PlayerHandSkill::PlayerHandSkill()
  17. : ItemSkill(0.f, 1.f, 1.f)
  18. {}
  19. bool PlayerHandSkill::use(Entity* zActor, Item* zUsedItem, Block* zTarget)
  20. {
  21. if (zActor->getStamina() > 0.001f)
  22. {
  23. if (zTarget && zTarget->getHardness() <= 1)
  24. {
  25. zActor->setStamina(zActor->getStamina() - 0.001f);
  26. zTarget->setHP(zTarget->getHP() - 1 / (zTarget->getHardness() + 1));
  27. }
  28. else
  29. {
  30. zActor->setStamina(zActor->getStamina() - 0.001f);
  31. zActor->setHP(zActor->getCurrentHP() - 0.01f);
  32. }
  33. }
  34. return false; // item was not changed
  35. }
  36. bool PlayerHandSkill::use(Entity* zActor, Item* zUsedItem, Entity* zTarget)
  37. {
  38. // TODO: make damage on the entity
  39. return false; // item was not changed
  40. }