Exemple #1
0
def hero_menu():
    while True:
        clear_screen()
        hero_selected = False
        choice = 0
        print_slow("-" * 25)
        print_slow(
            "Welcome to Dungeon run now it's time to choose your hero: ")
        print_slow("The available options are as follows :")
        print_slow("# 1 for Knight")
        print_slow("# 2 for Wizard")
        print_slow("# 3 for Rogue")
        print_slow("# 9 To Go Back")
        print_slow("-" * 25)

        hero_select = validate_int()

        if (hero_select == 1):
            hero_selected = True
            choice, hero_name, hero_instance = choose_hero("Knight")

        elif (hero_select == 2):
            hero_selected = True
            choice, hero_name, hero_instance = choose_hero("Wizard")

        elif (hero_select == 3):
            hero_selected = True
            choice, hero_name, hero_instance = choose_hero("Rouge")
        if choice == "9":
            continue
        if hero_select == 9:
            return False, "hero_name", "hero_instance"
        if hero_selected is True:
            return True, hero_name, hero_instance
Exemple #2
0
def start_game(hero, grid_select, spawn_coordinates, hero_name, oscars_hotfix):
    game_loop = True

    current_run = map(grid_size=grid_select)
    current_run.update_room(coordinate=spawn_coordinates, update="is_here")
    current_run.print_map()

    while game_loop is True:
        old_position = ask_player_to_move(current_run, hero_name)

        clear_screen()

        current_run.print_map()

        position = current_run.where_am_i(option="return")
        is_not_outside = check_if_outside(
            position, current_run
        )  # returns True for not outside and False for is outside

        if not is_not_outside:  # if not True/False, outside of map == False
            return "end"

        x, y = position

        current_room = current_run.grid[y][x]

        if oscars_hotfix == 0:  # om det är första rundan i spelet så kommer den att sätta första rummet som neutraliserat
            current_room.fight == False
            oscars_hotfix += 1

        if current_room.fight == False:
            # if the room is already "finished" or if it is "edge", if edge should be picked up a few lines above doe
            fight_outcome = "win"  # this is only so it will go down a few lines into the "elif  fight_outcome == "win":" section
        else:
            # if the room is "unfinished" or "untouched"
            current_fight = current_run.grid[y][x].fight_generator(
                hero
            )  # genererar en fight instans för dem x,y coordinates som anges
            fight_outcome = current_fight.run_fight(
            )  # kör den fighteninstansen och ska returnera outcome för fighten

        # försöka få mapen att uppdatera sig utifrån hur fight outcome blir
        if fight_outcome == "escaped":
            current_run.update_room(coordinate=old_position,
                                    update="unfinished")
        elif fight_outcome == "win":
            score = current_room.total_loot
            hero.score_list.append(score)
            print("Your points from this round: {}".format(score))
            update_score(hero_name, hero)
            current_room.total_loot = 0
            current_room.fight = False
        elif fight_outcome == "died":
            break

        current_run.print_map()

    return
Exemple #3
0
 def ai_won_game_or_done(self):
     clear_screen()
     self.arnold()
     print()
     print(self.theme_lyrics)
     print()
     stats = self.return_game_stats()
     for stat in stats:
         print(stat, " ", stats[stat])
     print()
     self.api_theme_song_open_in_browser()
     print()
     input("Press enter to continue...")
	def main_loop(self):

		while self.game_active:
			if self.round_count == 0: # sets a random spawn point
				spawn = self.ai.spawn_select(grid_select=self.map_size)
				spawn = self.map.get_room(coordinate=spawn)
				spawn.is_here()
				self.round_count += 1
				clear_screen() #clear
				self.pmap() #print
				time.sleep(2) #wait
			else: 
				# updates old room and sets new room to X
				current_coordinate = self.where_am_i() # hämta kordinater
				new_coordinate = self.new_move_coordinate() # ny random kordinat runtomkring
				self.update_old_room(coordinate=current_coordinate)
				self.ai.ai_rooms_add(current_coordinate) # statics
				self.mark_new_room(coordinate=new_coordinate)
				self.round_count += 1 #add round count
				room = self.get_room(new_coordinate)
				clear_screen() #clear
				self.pmap() #print map
				time.sleep(2) #wait

				# fight
				room.fight_generator(hero_instance=self.hero, is_ai=True)
				monster_list = room.fight.monsters_list
				room.fight.ai_choice_number = self.ai.ai_choice(self.ai.fight_or_run(monster_list))
				win_or_not = room.fight.run_fight()
				self.ai.ai_monsters_killed(room.fight.update_monster_killed_number)
				self.fight_win_or_not(win_or_not)
				self.ai.ai_treasure_collected(treasure_points=room.total_loot)
				room.total_loot = 0

				if self.hero.health == 0:
					self.ai.ai_won_game_or_done()
					self.game_active = False

			if self.round_count > self.round_max: # max limit, atm för loopen
				self.game_active = False # för att få stop på loopen
				self.ai.ai_won_game_or_done()

			if self.round_count == self.stop_value:
				self.game_active = False # för att få stop på loopen
				self.ai.ai_won_game_or_done()
Exemple #5
0
def ai_grid_select():
    clear_screen()
    print_slow("-" * 25)
    print_slow(
        "A true AI needs a map to explore, please choose a grid size suitable for SKYNET to destroy"
    )
    print_slow("The available options are as follows :")
    print_slow("# 4 for 4x4 grid")
    print_slow("# 5 for 5x5 grid")
    print_slow("# 8 for 8x8 grid")
    print_slow("-" * 25)
    try:
        grid_select = int(input('\n --> '))
    except ValueError:
        print_slow("Bad input")

    if grid_select != 4 and grid_select != 5 and grid_select != 8:
        print_slow("Wrong input please follow the instructions correctly")
    else:
        return grid_select
Exemple #6
0
def spawn_menu(grid_select):
    clear_screen()
    spawn_selected = False
    spawn_select = 0
    spawn_coordinates = []

    print_slow("-" * 25)
    print_slow("Pick a spawn point on the map: ")
    print_slow("# 1 for NorthWest")
    print_slow("# 2 for NorthEast")
    print_slow("# 3 for SouthWest")
    print_slow("# 4 for SouthEast")
    print_slow("-" * 25)

    try:
        spawn_select = int(input('\n --> '))
    except ValueError:
        print_slow("Wrong input")

    if spawn_select == 1:
        spawn_point = "NW"
        spawn_selected = True
        spawn_coordinates = [1, 1]
    elif spawn_select == 2:
        spawn_point = "NE"
        spawn_selected = True
        spawn_coordinates = calc_spawnpoint(grid_select, spawn_point)
    elif spawn_select == 3:
        spawn_point = "SW"
        spawn_selected = True
        spawn_coordinates = calc_spawnpoint(grid_select, spawn_point)
    elif spawn_select == 4:
        spawn_point = "SE"
        spawn_selected = True
        spawn_coordinates = calc_spawnpoint(grid_select, spawn_point)
    if spawn_selected:
        return spawn_coordinates
Exemple #7
0
            for value in dict_list:
                if dict_list[value]["Type"] == "Knight":
                    knight = Knight(value)
                    knight.score = dict_list[value]["Score"]
                    saved_character_list.append(knight)
                elif dict_list[value]["Type"] == "Rouge":
                    rouge = Rouge(value)
                    rouge.score = dict_list[value]["Score"]
                    saved_character_list.append(rouge)
                elif dict_list[value]["Type"] == "Wizard":
                    wizard = Wizard(value)
                    wizard.score = dict_list[value]["Score"]
                    saved_character_list.append(wizard)

        grid_size = 0
        clear_screen()
        print_slow("""


				██████╗ ██╗   ██╗███╗   ██╗ ██████╗ ███████╗ ██████╗ ███╗   ██╗    ██████╗ ██╗   ██╗███╗   ██╗
				██╔══██╗██║   ██║████╗  ██║██╔════╝ ██╔════╝██╔═══██╗████╗  ██║    ██╔══██╗██║   ██║████╗  ██║
				██║  ██║██║   ██║██╔██╗ ██║██║  ███╗█████╗  ██║   ██║██╔██╗ ██║    ██████╔╝██║   ██║██╔██╗ ██║
				██║  ██║██║   ██║██║╚██╗██║██║   ██║██╔══╝  ██║   ██║██║╚██╗██║    ██╔══██╗██║   ██║██║╚██╗██║
				██████╔╝╚██████╔╝██║ ╚████║╚██████╔╝███████╗╚██████╔╝██║ ╚████║    ██║  ██║╚██████╔╝██║ ╚████║
				╚═════╝  ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝  ╚═══╝    ╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═══╝
																								

		""")
        #print_slow(" \n Dungeon Run \n")
        print_slow("-" * 50 +
                   "Welcome to DUNGEON RUN choose an option to continue" +