Esempio n. 1
0
    def move(self, direction):
        nextArea = None
        if direction == "n": nextArea = self.current_area.north
        if direction == "e": nextArea = self.current_area.east
        if direction == "s": nextArea = self.current_area.south
        if direction == "w": nextArea = self.current_area.west

        direction_names = {
            "n": "North",
            "e": "East",
            "s": "South",
            "w": "West"
        }

        if nextArea != None:
            distance = 3
            header = "   Travelling " + direction_names[direction] + " to " + nextArea.name
            print()
            safe = None

            for i in range(0, distance):
                print(header + ("." * i), end="\r")
                sleep(0.4)
                if randint(0,20) == 1:
                    rand_encounter = Combat(self.player)
                    safe = rand_encounter.combat_loop()
                    break

            if safe == None:
                print(header + "...  You made it safely.", end ="\r")
                self.current_area = nextArea
                sleep(1)
            elif safe == True:
                print()
                print_loading_anim("You made it to " + nextArea.name + " safely.", 3)
                self.current_area = nextArea
            else:
                print_loading_anim("You stumble back to " + self.current_area.name + ", defeated", 3)


            return True
        else:
            return False
Esempio n. 2
0
from Combat import Enemy, Combat
from Player import Player, Weapon, Armour
from bestiary import bastard_sword, quarterstaff

player = Player("Hrothgar")
player.add_item(bastard_sword)
player.add_item(quarterstaff)
player.add_item(Armour("Leather Leggings", "", 1, "leggings"))
player.equip("sword")

rand_encounter = Combat(player)
rand_encounter.combat_loop()