Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. import fight_controller
  2. import pickle
  3. from level import Level
  4.  
  5. class Player:
  6. def __init__(self, name, x, y, stats, level):
  7. self.name = name
  8. self.x = x
  9. self.y = y
  10. self.stats = stats
  11. self.inv = []
  12. self.level = level
  13.  
  14. def __repr__(self):
  15. return self.name
  16.  
  17. def __str__(self):
  18. return self.name
  19.  
  20. def is_alive(self):
  21. return self.stats["health"] > 0
  22.  
  23. def move(self, direction):
  24. x_tmp = self.x
  25. y_tmp = self.y
  26. if direction == "góra":
  27. y_tmp -= 1
  28. if direction == "dół":
  29. y_tmp += 1
  30. if direction == "lewo":
  31. x_tmp -= 1
  32. if direction == "prawo":
  33. x_tmp += 1
  34. if self.level.can_move(x_tmp, y_tmp):
  35. self.x = x_tmp
  36. self.y = y_tmp
  37. else:
  38. print("Nie możesz ruszyć się w tą stronę!")
  39.  
  40. def attack(self, target, attacktype = 'physical'):
  41. fight_controller.fight_controller(self, target, attacktype)
  42.  
  43.  
  44.  
  45. class Item:
  46. def __init__(self, name):
  47. self.name = name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement