예제 #1
0
def playeraction():
    action = input(character.Playercharacter.state + " > ")
    if action in directions:
        m.removeplayer()
        if action == "up":
            m.position.moveplayerup()
        elif action == "down":
            m.position.moveplayerdown()
        elif action == "left":
            m.position.moveplayerleft()
        elif action == "right":
            m.position.moveplayerright()
        m.redraw_character()
        m.display_map()
        character.display_stats()
    elif action == "open menu":
        character.Playercharacter.state = "looking at menu"
    elif action == "turn":
        direction = input("What direction?> ")
        m.turn_direction(direction)
        m.removeplayer()
        m.redraw_character()
        m.display_map()
        character.display_stats()
    elif action == "check":
        m.check_in_front()
    else:
        print("Please Try again")
예제 #2
0
 def test_displays_3x3_portion(self, mock_output):
     character.set_row(10)
     character.set_column(1)
     map.reset_map()
     display_map()
     expected_output = ' | ------\n\n' \
                       ' |  P    \n\n' \
                       ' \ ------\n\n'
     actual_output = mock_output.getvalue()
     self.assertEqual(expected_output, actual_output)
예제 #3
0
def end_battle():
    character.Playercharacter.state = ""
    map.position.map_name = bf.player["previous_map_name"]
    map.position.map_x_position = bf.player["previous_x"]
    map.position.map_y_position = bf.player["previous_y"]
    bf.clear_battlefield()
    map.reset_map()
    map.createmap(map.position.map_name)
    map.redraw_character()
    map.display_map()
    character.display_stats()
예제 #4
0
def monsters_turn():
    print("Monsters Turn")
    monster_name = bf.monster["name"]
    if bf.monster["damage_taken"] >= monsters.list_of_monster[
            monster_name].check_health():
        battle_won(monster_name)
    else:
        decide_monster_attack()
        check_player_death()
        map.display_map()
        character.display_stats()
예제 #5
0
def respawn_character():
    character.Playercharacter.state = ""
    map.position.map_name = character.Playercharacter.save_location
    map.position.map_x_position = character.Playercharacter.save_location[
        "x_position"]
    map.position.map_y_position = character.Playercharacter.save_location[
        "y_position"]
    bf.clear_battlefield()
    map.reset_map()
    map.createmap(map.position.map_name)
    map.redraw_character()
    map.display_map()
    character.display_stats()
예제 #6
0
def knock_back(number_of_spaces):
    facing = bf.monster["facing"]
    x_position = bf.monster["x_position"]
    y_position = bf.monster["y_position"]
    for i in range(number_of_spaces):
        try:
            remove_monster()
            if facing == "up":
                bf.monster["y_position"] = y_position + 1
            elif facing == "down":
                bf.monster["y_position"] = y_position - 1
            elif facing == "left":
                bf.monster["x_position"] = x_position + 1
            elif facing == "right":
                bf.monster["x_position"] = x_position - 1
            monster_combat_redraw()
            map.display_map()
        except IndexError:
            continue
예제 #7
0
def main():
    doctest.testmod()
    moved_list = ['north', 'east', 'south', 'west']
    # load or create a character and map
    character.get_user()
    map.get_user_map()

    # prints initial map, character, and message
    print(
        'You are in an abandoned village in your search for a hidden treasure.'
    )
    print('Type north, east, south, or west to move')
    print('Type help to see a list of other keywords you can use')
    map.display_map()
    character.print_character()
    player_input = user_input()

    # game loop continues until user inputs quit
    while player_input != 'quit':
        print_message(player_input)
        map.display_map()

        # If player moves checks for monster encounter
        if player_input in moved_list:
            # Checks for a monster encounter
            if not monster.check_monster_encounter():
                # If not encounter is found increase health
                if character.get_hitpoints() < 10:
                    character.set_hitpoints(character.get_hitpoints() + 1)

        # exits game loop if user dies
        if character.get_hitpoints() <= 0:
            print('You died :(')
            break

        # prints character and asks for next input
        character.print_character()
        player_input = user_input()

    # saves user and map in .json files if user did not die
    if character.get_hitpoints() > 0:
        character.save_user()
        map.save_map()
예제 #8
0
def create_battlefield():
    monstername = map.maplist[map.position.map_name].monsters[
        map.position.monster_encountered]["name"]
    map.reset_map()
    mapname = monsters.list_of_monster[monstername].map_name
    monster = bf.monster
    player = bf.player
    player["previous_map_name"] = map.position.map_name
    player["previous_x"] = map.position.map_x_position
    player["previous_y"] = map.position.map_y_position
    monster["name"] = monstername
    monster["x_position"] = map.maplist[mapname].width - 1
    monster["y_position"] = map.maplist[mapname].height - 1
    map.position.map_x_position = 0
    map.position.map_y_position = 0
    map.position.map_name = mapname
    map.createmap(mapname)
    bf.fighting = True
    map.display_map()
    character.display_stats()
예제 #9
0
import character
import combat
import map
import actions
import menus

pc = character.Playercharacter
play = True
character_created = False
need_map = True
# Run a check to see if player has a character

while play:
    if not character_created:
        pc.create_character()
        map.Playerposition.map_name = "Starting"
        print("Welcome to the world")
        character_created = True
    if need_map:
        map.createmap(map.Playerposition.map_name)
        map.display_map()
        need_map = False
    if pc.state == "looking at menu":
        menus.menuactions()
    elif pc.state == "":
        actions.playeraction()
    elif pc.state == "battle":
        combat.turns()
예제 #10
0
def display_projectiles():
    for items in bf.projectile:
        map.showmap[bf.projectile[items]["y_position"]][bf.projectile[items]
                                                        ["x_position"]] = items
    map.display_map()