Exemple #1
0
def printPath(path, direction):
    library.printStrWithDelay(
        "The {3} path is {0} units long and {1} obstacles, there is also {2}food.\n"
        .format(path['length'],
                "contains" if path['obstacle'] else "is free of",
                str(path['food']) + "lbs of " if path['food'] else "no ",
                direction))
Exemple #2
0
def gameLoop(player, monster):
    while player.checkStamina():

        if not player.resting:
            paths = getNewPaths()

            library.printStrWithDelay("Which path do you take ?.. [R/L" +
                                   ("/Power]" if player.power else "]"))
            u_input = raw_input()
            u_input = 'R' if not len(u_input) else u_input.capitalize()[0]

            if u_input == 'P':
                library.printStrWithDelay(player.power_up)
                player.power(paths['R'], player)

            else:
                player.move(u_input, paths[u_input])

        monster.update(player.dist)

        if monster.pos >= player.dist:
            if not player.combat(monster):
                return

            library.printStrWithDelay(library.getStrikedSentence())
            library.printStrWithDelay("You managed to make it flee but it will")
            library.printStrWithDelay(" come back, more adamant to feast on you.")
            monster.enrage(factor=15, reseted_speed=20, pos=player.dist-20)

        player.printStatus()
        player.rest()
        player.checkStamina()
Exemple #3
0
def gameLoop(player, monster):
    while player.checkStamina():

        if not player.resting:
            paths = getNewPaths()

            library.printStrWithDelay("Which path do you take ?.. [R/L" +
                                      ("/Power]" if player.power else "]"))
            u_input = raw_input()
            u_input = 'R' if not len(u_input) else u_input.capitalize()[0]

            if u_input == 'P':
                library.printStrWithDelay(player.power_up)
                player.power(paths['R'], player)

            else:
                player.move(u_input, paths[u_input])

        monster.update(player.dist)

        if monster.pos >= player.dist:
            if not player.combat(monster):
                return

            library.printStrWithDelay(library.getStrikedSentence())
            library.printStrWithDelay(
                "You managed to make it flee but it will")
            library.printStrWithDelay(
                " come back, more adamant to feast on you.")
            monster.enrage(factor=15, reseted_speed=20, pos=player.dist - 20)

        player.printStatus()
        player.rest()
        player.checkStamina()
Exemple #4
0
    def update(self, player_dist):
        # Print msg depending on the pos of the monster
        library.printStrWithDelay(
            library.getPosMonsterSentence(player_dist - self.pos))

        # Its coming
        self.pos += self.speed
        # increase speed according to player.distance
        self.speed += self.acceleration
Exemple #5
0
    def update(self, player_dist):
        # Print msg depending on the pos of the monster
        library.printStrWithDelay(library.getPosMonsterSentence(
                player_dist - self.pos))

        # Its coming
        self.pos += self.speed
        # increase speed according to player.distance
        self.speed += self.acceleration
Exemple #6
0
def initGame():
    options = {}

    for string in library.text['start']:
        if string[:5] == 'INPUT':
            options[string.split(' ')[1]] = raw_input().capitalize()
        else:
            delay = float(string.split('%')[0])
            library.printStrWithDelay(string.split('%')[1], delay)

    player = globals().get(options['spec'].capitalize(), Player)(**options)
    return player
Exemple #7
0
def initGame():
    options = {}

    for string in library.text['start']:
        if string[:5] == 'INPUT':
            options[string.split(' ')[1]] = raw_input().capitalize()
        else:
            delay = float(string.split('%')[0])
            library.printStrWithDelay(string.split('%')[1], delay)

    player = globals().get(options['spec'].capitalize(), Player)(**options)
    return player
Exemple #8
0
def getNewPaths():
    paths = {}

    library.printStrWithDelay(("The branches of the narrow trees slap your \
    face as you try to stay alive and two paths emerge before you.\n"))

    paths['R'] = genNewPath()
    paths['L'] = genNewPath(paths['R'])

    printPath(paths['R'], "right")
    printPath(paths['L'], "left")

    return paths
Exemple #9
0
def getNewPaths():
    paths = {}

    library.printStrWithDelay(("The branches of the narrow trees slap your \
    face as you try to stay alive and two paths emerge before you.\n"))

    paths['R'] = genNewPath()
    paths['L'] = genNewPath(paths['R'])

    printPath(paths['R'], "right")
    printPath(paths['L'], "left")

    return paths
Exemple #10
0
    def move(self, choice, path):
        library.printStrWithDelay("You went " +
                                  ("right.\n" if choice == 'R' else "left.\n"))

        # Update ressources
        self.dist += path['length']
        self.food += path['food']
        self.stamina -= path['length']

        # Cross obstacles
        if path['obstacle']:
            library.printStrWithDelay("Something blocks your way.\n" +
                                      library.getWalkedSentence())
            self.stamina -= self.action_cost
Exemple #11
0
    def move(self, choice, path):
        library.printStrWithDelay(
            "You went " + ("right.\n" if choice == 'R' else "left.\n"))

        # Update ressources
        self.dist += path['length']
        self.food += path['food']
        self.stamina -= path['length']

        # Cross obstacles
        if path['obstacle']:
            library.printStrWithDelay("Something blocks your way.\n"
                                      + library.getWalkedSentence())
            self.stamina -= self.action_cost
Exemple #12
0
    def checkStamina(self):
        if self.stamina <= 0:
            library.printStrWithDelay("You made it as far as {0}".format(self.dist))
            library.printStrWithDelay(" miles but you are exhausted and can't go")
            library.printStrWithDelay(" further.\nTonight, you will feed the beast.")
            return False

        return True
Exemple #13
0
    def checkStamina(self):
        if self.stamina <= 0:
            library.printStrWithDelay("You made it as far as {0}".format(
                self.dist))
            library.printStrWithDelay(
                " miles but you are exhausted and can't go")
            library.printStrWithDelay(
                " further.\nTonight, you will feed the beast.")
            return False

        return True
Exemple #14
0
    def rest(self):
        library.printStrWithDelay("The hollowed tree looks comfortable, ")
        library.printStrWithDelay("do you want to rest a bit ?..[Y/N] ")

        u_input = raw_input()
        self.resting = True if u_input[0] == "Y" else False

        if self.resting:
            self.stamina += 10 if self.food >= 10 else self.food
            self.food -= 10 if self.food >= 10 else self.food
            self.stamina += self.stamina * self.rest_rate
            library.printStrWithDelay(library.getRestedSentence())
Exemple #15
0
    def rest(self):
        library.printStrWithDelay("The hollowed tree looks comfortable, ")
        library.printStrWithDelay("do you want to rest a bit ?..[Y/N] ")

        u_input = raw_input()
        self.resting = True if u_input[0] == "Y" else False

        if self.resting:
            self.stamina += 10 if self.food >= 10 else self.food
            self.food -= 10 if self.food >= 10 else self.food
            self.stamina += self.stamina * self.rest_rate
            library.printStrWithDelay(library.getRestedSentence())
Exemple #16
0
    def combat(self, opponent):
        library.printStrWithDelay(
            "You can't run anymore, take your {0} and fight !\n".format(
                self.weapon))

        difficulty = 4
        res = random.randrange(0, difficulty)
        while not res:
            library.printStrWithDelay(library.getMissedSentence())
            self.stamina -= opponent.attack + self.action_cost
            library.printStrWithDelay(library.getHitSentence())
            if not self.checkStamina(): return False
            difficulty -= 1
            res = random.randrange(0, difficulty)

        return True
Exemple #17
0
    def combat(self, opponent):
        library.printStrWithDelay(
            "You can't run anymore, take your {0} and fight !\n".format(
                self.weapon))

        difficulty = 4
        res = random.randrange(0,difficulty)
        while not res:
            library.printStrWithDelay(library.getMissedSentence())
            self.stamina -= opponent.attack + self.action_cost
            library.printStrWithDelay(library.getHitSentence())
            if not self.checkStamina(): return False
            difficulty -= 1
            res = random.randrange(0,difficulty)

        return True
Exemple #18
0
 def printStatus(self):
     library.printStrWithDelay("Stamina {0}, food left {1}\n".format(
         self.stamina, self.food))
Exemple #19
0
def printPath(path, direction):
    library.printStrWithDelay(
        "The {3} path is {0} units long and {1} obstacles, there is also {2}food.\n".format(
            path['length'], "contains" if path['obstacle'] else "is free of",
            str(path['food']) + "lbs of " if path['food'] else "no ", direction))
Exemple #20
0
 def printStatus(self):
     library.printStrWithDelay("Stamina {0}, food left {1}\n".format(
             self.stamina, self.food))