Esempio n. 1
0
kitchen.link_room(dining_hall, "south")
dining_hall.link_room(kitchen, "north")
dining_hall.link_room(ballroom, "west")
ballroom.link_room(dining_hall, "east")

dave = game.Enemy("Dave", "A smelly zombie")
dave.set_conversation("What's up, dude! I'm hungry.")
dave.set_weakness("cheese")
dining_hall.set_character(dave)

tabitha = game.Enemy("Tabitha", "An enormous spider with countless eyes and furry legs.")
tabitha.set_conversation("Sssss....I'm so bored...")
tabitha.set_weakness("book")
ballroom.set_character(tabitha)

cheese = game.Item("cheese")
cheese.set_description("A large and smelly block of cheese")
ballroom.set_item(cheese)

book = game.Item("book")
book.set_description("A really good book entitled 'Knitting for dummies'")
dining_hall.set_item(book)

current_room = kitchen
backpack = []

dead = False

while dead == False:

    print("\n")
Esempio n. 2
0
secretary = game.Enemy(
    "Секретарка",
    "Пло суті жінка добра, але у всьому слідє букві закону. Правильно "
    "виконана процедура вирішує все.")

secretary.set_conversation(
    "Доброго дня, югаче. Ви принесли необхідні документи")
secretary.set_weakness("довідка")
halytska.set_character(secretary)

big_boss = game.Enemy("Розпорядник", "Людина, що вирішить долю університету.")
big_boss.set_conversation("Покажіть ваш проект")
big_boss.set_weakness("проект")
halytska.set_character(big_boss)

paper = game.Item("довідка")
paper.set_description(
    "Довідка про доходи. Одна зі складових пакету документів для отримання дозволу на землю."
)
stryiska.set_item(paper)

police = game.Item("поліцейський")
police.set_description("Може допомогти мені у боротьбі з посіпаками.")
franka.set_item(police)

stick = game.Item("ціпок")
stick.set_description(
    "Бабуся рада добрій справі яку я почав. Але стурбована моєю безпекою. Тому вона "
    "далє мені свій ціпок для захисту.")
saksahanskoho.set_item(stick)
Esempio n. 3
0
dining_room.set_description('Small room with big table.')
bathroom = game.Room('Bathroom')
bathroom.set_description('Toilet and shower. Thats all.')
kitchen.room_location(dining_room, 'south')
dining_room.room_location(kitchen, 'north')
dining_room.room_location(bathroom, 'west')
bathroom.room_location(dining_room, 'east')
zombie = game.Enemy('Ted', 'A stuped zombie')
zombie.set_conversation('Aaaaaaaarrrr!')
zombie.set_weakness('sword')
dining_room.set_character(zombie)
spider = game.Enemy('Spidy', 'A small spider but so terrible.')
spider.set_conversation('Now I living here. I must leave.')
spider.set_weakness('magazine')
bathroom.set_character(spider)
sword = game.Item('sword')
sword.set_description('A long acute sword.')
bathroom.set_item(sword)
magazine = game.Item('magazine')
magazine.set_description('A boring magazine.')
dining_room.set_item(magazine)
current_room = kitchen
bag = []
dead = False

if __name__ == '__main__':
    while dead == False:

        print('\n')
        current_room.get_details()
Esempio n. 4
0
def main_game():
    '''
    Main function that organises the flow of the game
    '''
    print_intro_screen()

    reception = game.Location('Reception')
    reception.set_description(
        'Sheptytsky Center reception on the first floor next to entrance.\
With monitors, termometer and guards')

    basement = game.Location('Basement')
    basement.set_description(
        'Sheptytsky Center Underground Basement with lots of tables,\
chairs, desks and sofas to study')

    it_space = game.Location('IT Space')
    it_space.set_description(
        'Basement in Academic Corps with tables and comfortable chairs')

    trapezna = game.Location('Trapezna')
    trapezna.set_description('Place to eat. Large room with tables')

    striysky_park_south = game.Location('Stryiskyi Park South Side Entrance')
    striysky_park_south.set_description(
        'Dark park. Nobody knows what a mistery and dangerous\
creatures hides inside')

    railway_station = game.Location('Children Railway Station')
    railway_station.set_description(
        'Forgoten and abandoned childrens railway station.\
Old building and trains')

    striysky_park_fountain = game.Location('Stryiskyi Park Fountain')
    striysky_park_fountain.set_description(
        'Fountain in Stryiskyi Park, with some\
infrastructure around')

    luno = game.Item('LUNO')
    luno.set_description('Mysterious and powerful object')
    luno.set_damage(150)

    guard = game.Character('Guard',
                           'Angry guard, you\'d better not mess up with him')
    guard_conv = read_conversation('guard.txt', False)
    guard.set_conversation(guard_conv)

    lotr1 = game.Enemy('Lotr 1',
                       'Aggressive tall and slim jerk, blocking you way')
    lotr1.set_properties(5, 7)
    lotr1_conv = read_conversation('lotr1.txt', False)
    lotr1.set_conversation(lotr1_conv)
    lotr1.not_passable()

    lotr2 = game.Enemy('Lotr 2', 'Angry fat but slow lotr, blocking you way')
    lotr2.set_properties(40, 3)
    lotr2_conv = read_conversation('lotr2.txt', False)
    lotr2.set_conversation(lotr2_conv)
    lotr2.not_passable()

    alcoholic = game.Enemy(
        'Alcoholic', 'Old mysterous homeless alcoholic with white beard')
    alcoholic.set_properties(10, 10)
    alcoholic_conv = read_conversation('alcoholic.txt', False)
    alcoholic.set_conversation(alcoholic_conv)
    alcoholic.set_drop(luno)

    abaddon = game.Enemy('Abaddon', 'Mighty creature, blocking you way to win')
    abaddon.set_properties(125, 75)
    abaddon_conv = read_conversation('abaddon.txt', False)
    abaddon.set_conversation(abaddon_conv)
    abaddon.not_passable()

    vendor = game.Character('Vendor', 'Polite vendor in Trapezna')
    vendor_conv = read_conversation('vendor.txt', False)
    vendor.set_conversation(vendor_conv)

    spider = game.Enemy('Spider', 'Tiny spider hidding in his corner')
    spider.set_properties(1, 3)
    spider_conv = read_conversation('spider.txt', True)
    spider.set_conversation(spider_conv)

    hero = game.Hero()

    basement.link_loc(reception)
    reception.link_loc(striysky_park_south)
    reception.link_loc(it_space)
    reception.link_loc(trapezna)
    it_space.link_loc(trapezna)
    it_space.link_loc(striysky_park_south)
    it_space.link_loc(reception)
    trapezna.link_loc(reception)
    trapezna.link_loc(it_space)
    trapezna.link_loc(striysky_park_south)
    striysky_park_south.link_loc(railway_station)
    striysky_park_south.link_loc(striysky_park_fountain)
    striysky_park_south.link_loc(trapezna)
    striysky_park_south.link_loc(it_space)
    striysky_park_south.link_loc(reception)
    railway_station.link_loc(striysky_park_fountain)
    railway_station.link_loc(striysky_park_south)

    trapezna.set_character(vendor)
    reception.set_character(guard)
    striysky_park_south.set_character(lotr1)
    striysky_park_south.set_character(lotr2)
    it_space.set_character(spider)
    railway_station.set_character(alcoholic)
    striysky_park_fountain.set_character(abaddon)

    pencil = game.Item('Pencil')
    pencil.set_description('Sharp gray pencil')
    pencil.set_damage(20)
    basement.set_item(pencil)

    current_location = basement
    previous_location = None
    backpack = {}

    while True:
        time.sleep(0.9)
        print('\n')
        print(term.bold(f'HP: {hero.hp}'))
        print(f'{term.bold("BKPCK: ")}', end='')
        print(', '.join(backpack.keys()))
        time.sleep(0.2)
        could_pass = True
        current_location.get_details()
        time.sleep(0.3)

        personages, personages_dict = current_location.get_characters(), {}
        fightable_personages_dict = {}
        for personage in personages:
            time.sleep(0.1)
            personage.describe()
            personages_dict[personage.name] = personage
            if isinstance(personage, game.Enemy):
                fightable_personages_dict[personage.name] = personage
                could_pass = could_pass and personage.passable

        if current_location.name == 'Stryiskyi Park Fountain':
            if could_pass:
                print('Yey, you won')
                return
            print(
                'This is the last stage. Defeat enemy, who block your pass here and you win'
            )

        items, items_dict = current_location.get_items(), {}
        for item in items:
            item.describe()
            items_dict[item.name] = item

        print()
        linked_locs = []
        print(f'{term.bold("[GO]:    ")}', end='')
        for loc in current_location.linked_locs:
            linked_locs.append(loc.name)
        print(', '.join(linked_locs))
        time.sleep(0.1)

        print(f'{term.bold("[TAKE]:  ")}', end='')
        print(', '.join(items_dict.keys()))
        time.sleep(0.1)

        print(f'{term.bold("[TALK]:  ")}', end='')
        print(', '.join(personages_dict.keys()))
        time.sleep(0.1)

        print(f'{term.bold("[FIGHT]: ")}', end='')
        print(', '.join(fightable_personages_dict.keys()))
        time.sleep(0.1)

        command = input('> ')

        if command.lower() == 'go':
            if not could_pass:
                print(
                    'It was a trap, you should defeat enemy who is blocking your way ahead'
                )
                print(
                    'But still, you can return to the previous location. Returning...'
                )
                current_location, previous_location = previous_location, current_location
            elif len(linked_locs) > 1:
                print('Where you want to go?')
                goto_loc = input('> ')
                if goto_loc in linked_locs:
                    previous_location = current_location
                    current_location = current_location.move(goto_loc)
                else:
                    print(f'There is no such location as {goto_loc}')
            else:
                previous_location = current_location
                current_location = current_location.move(linked_locs[0])

        elif command.lower() == 'talk':
            if personages_dict:
                if len(personages_dict) > 1:
                    print('Whom you want to talk to?')
                    talkto_personage = input('> ')
                    if talkto_personage in list(personages_dict.keys()):
                        personages_dict[talkto_personage].talk()
                    else:
                        print(f'Your can\'t talk to {talkto_personage}')
                else:
                    personages_dict[list(personages_dict.keys())[0]].talk()
            else:
                print('There is nobody to talk to')

        elif command.lower() == 'take':
            if items_dict:
                if len(items_dict) > 1:
                    print('What you wann take?')
                    for item in items_dict:
                        print(item)
                        time.sleep(0.1)
                    take_item = input('> ')
                    if take_item in list(items_dict.keys()):
                        backpack[take_item] = items_dict[take_item]
                        current_location.items.remove(items_dict[take_item])
                    else:
                        print(f'Your can\'t take to {take_item}')
                else:
                    backpack_item_key = list(items_dict.keys())[0]
                    backpack[backpack_item_key] = items_dict[backpack_item_key]
                    current_location.items.remove(
                        items_dict[backpack_item_key])
                    print(f'Put {backpack_item_key} in backpack')

            else:
                print('There is nothing to take')

        elif command.lower() == 'fight':
            if fightable_personages_dict:
                if len(fightable_personages_dict) > 1:
                    print('Whom you want to fight with?')
                    fightwith_personage = input('> ')
                    if fightwith_personage not in list(
                            fightable_personages_dict.keys()):
                        print(f'You can\'t fight with {fightwith_personage}')
                        continue
                else:
                    fightwith_personage = list(
                        fightable_personages_dict.keys())[0]

                adverser = fightable_personages_dict[fightwith_personage]
                print('What you wanna fight with?')
                for fightwith_item in backpack:
                    backpack[fightwith_item].describe()
                fightwith_item = input('> ')
                if fightwith_item in backpack:
                    fight_damage = adverser.fight(
                        backpack[fightwith_item].damage)
                    hero.hp -= fight_damage
                    if hero.hp > 0:
                        hero.victories += 1
                        print('Congrats, you won. Remaining health:', hero.hp)
                        try:
                            current_location.set_item(adverser.get_drop_item())
                        except AttributeError:
                            pass
                        current_location.characters.remove(adverser)
                    else:
                        print('Oups, you are dead.')
                        break
                else:
                    print(f'You have no {fightwith_item}')
            else:
                print('There is nobody to fight with')
        else:
            print('Hmm, seems like a wrong command')
zbuy.set_weakness("karate")

zhorzh.set_character(zbuy)

batiar = game.Walker(
    "Batiar",
    "Gravis, a drunkard, a popular late-19th-early-20th-century, brutal woman")
batiar.set_conversation("The last glass was enough.")
celentano.set_character(batiar)

laidak = game.Walker("Laidak", "Poor homeless man.")
laidak.set_conversation("Give me some money and I will start new busyness.")
fountain_near_Opera_theater.set_character(laidak)

# make items details
beer = game.Item("a glass of beer")
beer.set_description("Tool from batiar")
opera_theater.set_item(beer)

karate = game.Item("karate")
karate.set_description("Marshial art to protect yourself")
lvivski_kruasany.set_item(karate)

chocolate = game.Item("chocolate")
chocolate.set_description("Treatment for your friends")
arsen.set_item(chocolate)

money = game.Item("money")
money.set_description("Resource for new busyness")
fountain_near_Opera_theater.set_item(money)
chef.set_conversation(
    "You don't have enough money or discount?.. It's your problem, loser))")
chef.set_weakness("local card")
academic.set_character(chef)

teacher = game.Friend("Teacher")
teacher.set_conversation("Don't forget your books.")
space.set_character(teacher)

conscience = game.Friend("Your Conscience")
conscience.set_conversation(
    "I hope you'll not spend so much time playing video games")
collegium.set_character(conscience)

###############################################################
ticket = game.Item("reader's ticket")
ticket.set_description(
    "Without Reader's Ticket you will be in Black List of Library Legion")
academic.set_item(ticket)

local = game.Item("local card")
local.set_description(
    "You'll not be able to get Trapezna's Treasure without Local Card")
sheptytsky.set_item(local)

books = game.Item("books")
books.set_description("Reading books, you understand the wisdom of ancestors")
space.set_item(books)

###############################################################
current_building = church