Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.84 KB | None | 0 0
  1. from player import *
  2. from level import *
  3.  
  4.  
  5. class Game:
  6.     def __init__(self, levels, player):
  7.         self.levels = levels
  8.         self.player = player
  9.         self.current_lvl = 0
  10.     def run(self):
  11.  
  12.         while self.player.is_alive():
  13.             print("You're in room", self.player.level.rooms[self.player.y][self.player.x])
  14.             print("[n] Go north")
  15.             print("[s] Go south")
  16.             print("[e] Go east")
  17.             print("[w] Go west")
  18.             print("[map] Print map")
  19.             print("[level] go to next level")
  20.             command = input().lower()
  21.  
  22.             if command == 'n':
  23.                 self.player.move(command)
  24.             elif command == 's':
  25.                 self.player.move(command)
  26.             elif command == 'e':
  27.                 self.player.move(command)
  28.             elif command == 'w':
  29.                 self.player.move(command)
  30.             elif command == 'kill':
  31.                 self.player.stats = {"health": 0}
  32.             elif command == 'map':
  33.                 self.player.level.print_map(0, 0)
  34.             elif command == 'level':
  35.                 # for room in self.player.level.rooms:
  36.                 if self.player.level.is_cleared():
  37.                     self.current_lvl += 1
  38.                     self.player.level = self.levels[self.current_lvl]
  39.                     self.player.x = 0
  40.                     self.player.y = 2
  41.                 else:
  42.                     print('nie ukonczyles wszystkich questow na tym poziomie')
  43.  
  44.             elif command == 'quest':
  45.                 self.player.level.rooms[self.player.y][self.player.x].quest.run()
  46.             elif command == 'fight':
  47.                 enemy = self.player.level.rooms[self.player.y][self.player.x].enemy
  48.                 if enemy is not None:
  49.                     while self.player.is_alive() and enemy.is_alive():
  50.                         attack_cmd = input('Select type of attack: magical or physical, or type heal to heal')
  51.                         if attack_cmd == 'heal':
  52.                             self.player.stats["health"] += 50
  53.                         else:
  54.                             self.player.attack(enemy, attack_cmd)
  55.                             enemy.attack(self.player)
  56.                     if not enemy.is_alive():
  57.                         print('you won')
  58.                 else:
  59.                     print('nie ma tu przeciwnika debilu')
  60.             else:
  61.                 print("Unsupported command")
  62.         print('umarles')
  63.  
  64. def main():
  65.     print("Welcome to belmondziak place, what's your name?")
  66.     name = input()
  67.     levels = level_generator(3)
  68.     player = Player(name, 0, 2, {"health": 100, "strength": 15, "mana": 300, "magicpower": 500}, levels[0])
  69.     game = Game(levels, player)
  70.     game.run()
  71.  
  72.  
  73. if __name__ == "__main__":
  74.     main()
  75.  
  76.  
  77. def movement_controller(x, y):
  78.     pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement