Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from player import *
- from level import *
- class Game:
- def __init__(self, levels, player):
- self.levels = levels
- self.player = player
- self.current_lvl = 0
- def run(self):
- while self.player.is_alive():
- print("You're in room", self.player.level.rooms[self.player.y][self.player.x])
- print("[n] Go north")
- print("[s] Go south")
- print("[e] Go east")
- print("[w] Go west")
- print("[map] Print map")
- print("[level] go to next level")
- command = input().lower()
- if command == 'n':
- self.player.move(command)
- elif command == 's':
- self.player.move(command)
- elif command == 'e':
- self.player.move(command)
- elif command == 'w':
- self.player.move(command)
- elif command == 'kill':
- self.player.stats = {"health": 0}
- elif command == 'map':
- self.player.level.print_map(0, 0)
- elif command == 'level':
- # for room in self.player.level.rooms:
- if self.player.level.is_cleared():
- self.current_lvl += 1
- self.player.level = self.levels[self.current_lvl]
- self.player.x = 0
- self.player.y = 2
- else:
- print('nie ukonczyles wszystkich questow na tym poziomie')
- elif command == 'quest':
- self.player.level.rooms[self.player.y][self.player.x].quest.run()
- elif command == 'fight':
- enemy = self.player.level.rooms[self.player.y][self.player.x].enemy
- if enemy is not None:
- while self.player.is_alive() and enemy.is_alive():
- attack_cmd = input('Select type of attack: magical or physical, or type heal to heal')
- if attack_cmd == 'heal':
- self.player.stats["health"] += 50
- else:
- self.player.attack(enemy, attack_cmd)
- enemy.attack(self.player)
- if not enemy.is_alive():
- print('you won')
- else:
- print('nie ma tu przeciwnika debilu')
- else:
- print("Unsupported command")
- print('umarles')
- def main():
- print("Welcome to belmondziak place, what's your name?")
- name = input()
- levels = level_generator(3)
- player = Player(name, 0, 2, {"health": 100, "strength": 15, "mana": 300, "magicpower": 500}, levels[0])
- game = Game(levels, player)
- game.run()
- if __name__ == "__main__":
- main()
- def movement_controller(x, y):
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement