コード例 #1
0
def talk(thing):
    if thing == None:
        a.say("You talk a bit to yourself")
        return
    # check if the thing is in the inventory or in the current room
    # inventory and room.items are SET's. to merge them, I use pythons join command
    for i in inventory.union(current_room.items):
        if thing in i.aliases:
            exist = True
            break
    else:
        # else in a for loop means the whole loop was interrated trough, without any break
        a.say(
            "there is no {} to talk to, neither in your inventory nor in this room/location"
            .format(thing))
        return
    # the thing exist. thing is a string, i is the object
    a.say("you talk to {}...".format(thing))
    # check if object i (the item) has the .answers attribute
    if "answers" in i.__dict__.keys():
        a.say("and the {} says: '{}'".format(thing, random.choice(i.answers)))
    else:
        a.say(
            "but you get no reply. None at all. It seems that the {} is unable to talk"
            .format(thing))
コード例 #2
0
def main():
    game_config = _load_config()
    if game_config.get("extra_commands"):
        from . import extra_commands
    _start_game(None, game_config)
    adventurelib.say("")  # Necessary for space before first prompt.
    adventurelib.start()
コード例 #3
0
def drop(thing):
    obj = inventory.take(thing)
    if not obj:
        a.say('You do not have a %s.' % thing)
    else:
        a.say('You drop the %s.' % obj)
        current_room.items.add(obj)
コード例 #4
0
def test_say_room():
    """saw() will format input as strings."""
    r = Room('You are standing in a hallway.')

    buf = StringIO()
    with redirect_stdout(buf):
        say(r)
    assert buf.getvalue() == 'You are standing in a hallway.\n'
コード例 #5
0
def look():
    al.say(current_room)


    msg = 'Exists are '
    for exit in current_room.exits():
        msg += exit + ' '
    msg += '.'
    al.say(msg)
コード例 #6
0
def go(direction):
    global current_room
    room = current_room.exit(direction)
    if room:
        current_room = room
        al.say('You go {}.'.format(direction))
        look()
    else:
        al.say('You can\'t go {}.'.format(direction))
コード例 #7
0
def go(direction):
    global current_room
    room = current_room.exit(direction)
    if room:
        current_room = room
        a.say('You go %s.' % direction)
        look()
        if room == magic_forest:
            a.set_context('magic_aura')
        else:
            a.set_context('default')
コード例 #8
0
ファイル: say.py プロジェクト: xmunoz/cronenbroguelike
def insayne(text, add_newline=True, insanity=None):
    """Renders @text to screen, modified based on player's insanity stat.

    Interpolates arcane markings and violent exhortations if player's sanity
    is not pristine. Renders UI text less and less legible as sanity degrades.
    """
    if add_newline:
        adventurelib.say("")
    if insanity is None:
        insanity = G.player.insanity.value
    text = _hear_voices(text, insanity)
    adventurelib.say(text)
コード例 #9
0
def brush_teeth():
    obj = maybe(globalvars.save_data.player.find('toothpaste'))
    if obj.is_none:
        print('you have no toothpaste')
    else:
        say(""" 
            You squirt a bit too much toothpaste onto your
            brush and dozily jiggle it round your mouth.

            Your teeth feel clean and shiny now, as you
            run your tongue over them.
        """)
コード例 #10
0
ファイル: story.py プロジェクト: bdavs/adventurelib
def look():
    say(current_room)
    if current_room.items:
        for i in current_room.items:
            if i.amount > 0:
                say('There are {} {} here.'.format(i.amount, i))
            else:
                say('A %s is here.' % i)
    if current_room.gold > 0:
        say("There is {} gold on the ground.".format(current_room.gold))
    if current_room == shop_room:
        for i in current_room.store_items:
            say('The {} costs {}.'.format(i, i.cost))
コード例 #11
0
def main():
    game_config = _load_config()
    if game_config.get("extra_commands"):
        from . import extra_commands
    while True:
        try:
            _start_game(game_config)
            adventurelib.say("")  # Necessary for space before first prompt.
            adventurelib.start()
        except KeyboardInterrupt:
            adventurelib.say("☠ Farewell☠")
            return
        except tartarus.RaptureException:
            pass
コード例 #12
0
def answer(response):
    nb = story.inventory.find("Notebook")
    if nb and nb.letters_found:
        if len(nb.letters_found) == len(story.letter_bank):
            adv.say("You have found all the letters. ")
        # for letter in nb.letters_found:
        #    adv.say(letter)
    adv.say("You speak the words to the door and.... ")
    if response == "THANKS FOR PLAYING".lower():
        adv.say("The door swings open! You walk into the light with a satisfaction of completing your quest. Thank you for playing!")
    else:
        adv.say("nothing happens :-( Try again.")
コード例 #13
0
ファイル: story.py プロジェクト: bdavs/adventurelib
def use(item):
    current_item = inventory.find(item)
    if not current_item:
        say("you do not have that item")
    elif current_item is compass:
        exits = current_room.exits()
        for x in exits:
            say(x)
            next_room = current_room.exit(x)
            if next_room.visited == 0:
                next_room.visited = 3
#        say(current_room.exits())
    elif current_item is ball:
        for dir in current_room.exits():
            say(" You gaze into the crystal and picture yourself moving {}: ".
                format(dir))
            say(current_room.exit(dir))
    else:
        say("Oak's words echoed... There's a time and place for everything, but not now."
            )
コード例 #14
0
ファイル: story.py プロジェクト: bdavs/adventurelib
def go(direction):
    global current_room
    room = current_room.exit(direction)
    if room:
        current_room = room
        current_room.visited = 1
        say('You go %s.' % direction)
        look()
        if room == door_room:
            set_context('final_door')
        elif room == shop_room:
            set_context('shop')
        elif room == starting_room:
            set_context('starting_room')
        elif room == grue_room:
            set_context('grue_room')
        else:
            set_context('default')
    else:
        say("You can't currently go %s." % direction)
        look()
コード例 #15
0
def take(item):
    if item == "wizard":
        a.say("The wizard does not want to be picked up by you")
        return
    obj = current_room.items.take(item)
    if obj:
        a.say('You pick up the %s.' % obj)
        inventory.add(obj)
    else:
        a.say('There is no %s here.' % item)
コード例 #16
0
def give(item):
    if adv.TESTING:
        thisItem = story.master_item_list.find(item)
        if thisItem:
            story.inventory.add(thisItem)
            adv.say("Added {} to your bag".format(thisItem))
        else:
            adv.say("Sorry could not find that item")
    else:
        adv.say("Sorry, that feature is not currently enabled")
コード例 #17
0
def look():
    a.say(current_room)
    if current_room.items:
        for i in current_room.items:
            a.say('A %s is here.' % i)
コード例 #18
0
        current_room.items.add(obj)


@a.when('look')
def look():
    a.say(current_room)
    if current_room.items:
        for i in current_room.items:
            a.say('A %s is here.' % i)


@a.when('inventory')
def show_inventory():
    a.say('You have:')
    for thing in inventory:
        a.say(thing)


@a.when('cast', magic=None, context='magic_aura')
@a.when("cast MAGIC", context='magic_aura')
def cast(magic):
    if magic == None:
        a.say("Which magic you would like to spell?")
    elif magic == "fireball":
        a.say("you cast a flaming Fireball! Woooosh....")


look()
a.say("hallo Horst")
a.start()
コード例 #19
0
def sell(thing):
    adv.say("I ain't no fool or a charity, kid. Go find your own way to make some money like the rest of us.")
コード例 #20
0
def buy(thing):
    gold = story.inventory.gold
    item = story.shop_room.store_items.find(thing)
    if item:
        if item.cost <= gold:
            adv.say("You buy the {}. ".format(item))
            story.inventory.gold -= item.cost
            story.shop_room.store_items.take(thing)
            #adv.say("{}".format(story.letter_bank))
            if item in story.letter_bank:
                nb = story.inventory.find("notebook")
                if nb:
                    adv.say('You tape the %s in your notebook' % item)
                    nb.letters_found.add(item)
                else:
                    adv.say("You do not have a way to record it, so you just drop it on the ground")
                    story.current_room.items.add(item)
            else:
                story.inventory.add(item)
            adv.say("You now have {} gold. ".format(story.inventory.gold))
        else:
            adv.say("You can't afford the {}. you have {} gold and it costs {} gold. ".format(item,gold,item.cost))
    else:
        adv.say("Sorry I don't have a {} in my shop. ".format(thing))
コード例 #21
0

@a.when('look')
def look():
    a.say(current_room)
    if current_room.items:
        for i in current_room.items:
            a.say('A %s is here.' % i)


@a.when('inventory')
def show_inventory():
    a.say('You have:')
    for thing in inventory:
        a.say(thing)

@a.when('cast', magic=None, context='magic_aura')
@a.when("cast MAGIC", context='magic_aura')
def cast(magic):
    if magic == None:
        a.say("Which magic you would like to spell?")
    elif magic == "fireball":
        a.say("you cast a flaming Fireball! Woooosh....")




look()
a.say("hallo Raphaela")
a.start()
コード例 #22
0
def say_at_width(width, msg):
    buf = StringIO()
    with patch('adventurelib.get_terminal_size', return_value=(width, 24)):
        with redirect_stdout(buf):
            say(msg)
    return buf.getvalue()
コード例 #23
0
def cast(magic):
    if magic == None:
        a.say("Which magic you would like to spell?")
    elif magic == "fireball":
        a.say("you cast a flaming Fireball! Woooosh....")
コード例 #24
0
ファイル: story.py プロジェクト: bdavs/adventurelib
def show_inventory():
    single = True
    say('You have:')
    for thing in inventory:
        if thing.amount > 0:
            say("{} {}".format(thing.amount, thing))
            single = False
        else:
            #            if len(inventory) > 1
            say("{},".format(thing))
            #if single:
            #    say(thing)
            #else:
            #    say(thing)
            single = False
# if inventory.gold > 0:
#    if not single:
#        say(",")
    say("{} gold.".format(inventory.gold))
    #single = False

    nb = inventory.find("Notebook")
    if nb and nb.letters_found:
        say("You have found the following letters:")
        #       single = True
        for letter in nb.letters_found:
            #           if single:
            say("{}".format(letter))
コード例 #25
0
        current_room.items.add(obj)


@a.when('look')
def look():
    a.say(current_room)
    if current_room.items:
        for i in current_room.items:
            a.say('A %s is here.' % i)


@a.when('inventory')
def show_inventory():
    a.say('You have:')
    for thing in inventory:
        a.say(thing)


@a.when('cast', magic=None, context='magic_aura')
@a.when("cast MAGIC", context='magic_aura')
def cast(magic):
    if magic == None:
        a.say("Which magic you would like to spell?")
    elif magic == "fireball":
        a.say("you cast a flaming Fireball! Woooosh....")


look()
a.say("hallo Anastasija")
a.start()
コード例 #26
0
ファイル: story.py プロジェクト: bdavs/adventurelib
def take(item):
    obj = current_room.items.take(item)
    if obj:
        if obj in letter_bank:
            nb = inventory.find("notebook")
            if nb:
                say('You record the %s in your notebook and wipe away the letter to avoid confusion'
                    % obj)
                nb.letters_found.add(obj)
            else:
                say("You do not have a way to record it, so you just leave it there for now"
                    )
                current_room.items.add(obj)
        else:
            say('You pick up the %s.' % obj)
            inventory.add(obj)
    elif item == 'gold':
        if current_room.gold > 0:
            inventory.gold += current_room.gold
            say('You pick up the {} gold'.format(current_room.gold))
            current_room.gold = 0
        else:
            say("There is no gold on the ground here")
    elif current_room == shop_room:
        obj = current_room.store_items.find(item)
        if obj:
            say("You gunna pay for that {}, kid? It costs {} gold. ".format(
                obj, obj.cost))
        else:
            say('There is no {} on the ground.'.format(item))
    else:
        say('There is no {} on the ground.'.format(item))
コード例 #27
0
def show_inventory():
    a.say('You have:')
    for thing in inventory:
        a.say(thing)
コード例 #28
0
ファイル: story.py プロジェクト: bdavs/adventurelib
def cast(magic):
    if magic is None:
        say("Which magic you would like to spell?")
    else:
        say("You cast " + magic)