Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. from player import *
  2. from level import *
  3. from introduction import *
  4. import pickle
  5.  
  6. class Game:
  7. def __init__(self, levels, player):
  8. self.levels = levels
  9. self.player = player
  10. self.current_lvl = 0
  11.  
  12.  
  13. def run(self):
  14.  
  15. introduction()
  16. input("Aby przejść do gry, kliknij ENTER.")
  17.  
  18. while self.player.is_alive():
  19. print("Aktualnie znajdujesz się w: ", self.player.level.rooms[self.player.y][self.player.x])
  20. print("\n[gram] Pokaż zadanie do wykonania")
  21. print("-------------------")
  22. print("[góra] Idź w górę")
  23. print("[dół] Idź w dół")
  24. print("[lewo] Idź w lewo")
  25. print("[prawo] Idź w prawo")
  26. print("-------------------")
  27. print("[mapa] Otwórz mapę")
  28. print("[koniec] Zakonćz grę")
  29. print("[poziom 2] - dostępne po ukończeniu wszystkich gier na tym poziomie\n\nPozostało ")
  30.  
  31. command = input().lower()
  32.  
  33.  
  34. if command == "góra":
  35. self.player.move(command)
  36. elif command == "dół":
  37. self.player.move(command)
  38. elif command == "lewo":
  39. self.player.move(command)
  40. elif command == "prawo":
  41. self.player.move(command)
  42. elif command == "koniec":
  43. self.player.stats = {"health":0}
  44. elif command == "mapa":
  45. self.player.level.print_map() #map(0,0)
  46. elif command == 'level':
  47. # for room in self.player.level.rooms:
  48. if self.player.level.is_cleared():
  49. self.current_lvl += 1
  50. self.player.level = self.levels[self.current_lvl]
  51. self.player.x = 0
  52. self.player.y = 2
  53. else:
  54. print('nie ukonczyles wszystkich questow na tym poziomie')
  55. elif command == "gram":
  56. if self.player.level.rooms[self.player.y][self.player.x].quest is not None:
  57. self.player.level.rooms[self.player.y][self.player.x].quest.run()
  58. else:
  59. print("W tym pokoju nie ma gry.")
  60. elif command == "walka":
  61. enemy = self.player.level.rooms[self.player.y][self.player.x].enemy
  62. if enemy is not None:
  63. while self.player.is_alive() and enemy.is_alive():
  64. self.player.attack(enemy, input('Wybierz rodzaj ataku (siła lub magia): '))
  65. enemy.attack(self.player)
  66. else:
  67. print("W tym pokoju nie ma walki")
  68. elif command == "save":
  69. print("Zapisano grę")
  70.  
  71. else:
  72. print("Zła komenda.")
  73.  
  74.  
  75. print("GAME OVER.")
  76.  
  77.  
  78. def main():
  79. print("""Cześć!\n\nWitaj w grze "nazwa gry"!""")
  80. name = input("Aby kontynuować, wpisz imię swojego bohatera: ")
  81. levels = level_gen(2)
  82. player = Player(name, 0, 2, {"health":100, "strength": 100, "mp": 0, "magic_skills": 50}, levels[0])
  83. game = Game(levels, player)
  84. game.run()
  85.  
  86. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement