def fight(self, combat_item=None):
     if self.is_friend:
         print_sleep(self.name + ' is a friend. Why would you even try to fight?', 2)
         return True
     else:
         print_sleep(self.name + ' is ready to fight.', 2)
         print_sleep('Fighting ... ', 3)
         if combat_item == self.weakness:
             print_sleep('You won!? I was not expecting that...', 3)
             return True
         else:
             print_sleep('Are you even trying? You lost! Happy now?', 1)
             return False
 def befriend(self, gift):
     if self.is_friend:
         print_sleep('You`re already friends. Not sure why. But you are.', 3)
     else:
         if not self.gift:
             print_sleep("You cannot be friends with " + self.name +
                         ". You do remember you destroyed this lovely human being's life, right?", 5)
         elif self.gift == gift:
             print_sleep('Congrats! You made a friend. We all know you need more of those.', 3)
         else:
             print_sleep('That was definitely not the right gift.', 4)
 def hug(self):
     if self.is_friend:
         print_sleep("You got a hug from " + self.name + ". Now that's an achievement right there!", 4)
     else:
         print_sleep('Smart! Very smart! Trying to hug an enemy. You could be stabbed!', 4)
 def friendly(self):
     if self.is_friend:
         print_sleep('Well that`s a bit surprising ... You`re actually friends.', 2)
     else:
         print_sleep('Enemy. Of course. Not many people like you.', 2)
 def talk(self):
     if self.conversation is not None:
         print_sleep("[" + self.name + " says]: " + self.conversation, 2)
     else:
         print_sleep(self.name + " doesn't want to talk to you", 2)
 def describe(self):
     print_sleep(self.name + ' is here! ' + self.description, 2)
Exemple #7
0
 def move(self, direction):
     if direction in self.linked_rooms:
         return self.linked_rooms[direction]
     else:
         print_sleep('You cannot go that way', 2)
         return self
Exemple #8
0
 def get_details(self):
     print_sleep(self.name)
     print_sleep('----------------')
     self.describe()
     for direction, room in self.linked_rooms.items():
         print_sleep('The ' + room.get_name().lower() + ' is ' + direction)
Exemple #9
0
 def describe(self):
     print_sleep(self.description)
Exemple #10
0
def run():
    alive = True
    current_room = get_initial_room()
    print_sleep('Would you like to skip the instructions? (yes/no)')
    command = input('> ')
    if command == 'no':
        instructions()

    while alive:
        print_sleep('\n')
        current_room.get_details()
        inhabitant = current_room.get_character()
        if inhabitant:
            inhabitant.describe()
        command = input('> ')
        if command in {
                'help', 'Help! O mighty voice in my head!',
                'I`m useless and I need help.'
        }:
            instructions(beginning=False)
        if command in {'north', 'south', 'east', 'west'}:
            current_room = current_room.move(command)
        elif command == 'friend?':
            if inhabitant:
                inhabitant.friendly()
            else:
                print_sleep(
                    'You`re asking if an empty room is a friend or an enemy?',
                    1)
                print_sleep('Right ...', 2)
                print_sleep('An enemy. Definitely an enemy.', 2)
        elif command == 'talk':
            if inhabitant:
                inhabitant.talk()
            else:
                print_sleep(
                    'Yeah, I bet you will get a reply from an empty room.', 3)
        # TODO: display some weapon options
        elif command == 'fight':
            if inhabitant:
                print_sleep('What will you fight with?')
                weapon = input('> ')
                if not inhabitant.fight(weapon):
                    alive = False
            else:
                print_sleep(
                    "There is no one here to fight with. Did you even read the room's description?",
                    4)
        # TODO: display some gift options
        elif command == 'befriend':
            if inhabitant:
                print_sleep('What do you bring as a gift?')
                gift = input('> ')
                inhabitant.befriend(gift)
            else:
                print_sleep(
                    'I am about to point out the obvious here, but here it goes: you are alone in this room!',
                    5)
        elif command == 'hug':
            if inhabitant:
                inhabitant.hug()
            else:
                print_sleep(
                    'Yeah, sometimes I like to try and get hugs from my favourite wall too.',
                    4)
        else:
            print_sleep(
                'Are you feeling alright? What are you trying to type?', 2)