コード例 #1
0
def beer():
    """
    should only be called from in the tavern
    """
    global cheated

    if enter_four == config.confus(config.config4):
        player.grab(helpful.Item('SixPack', 10, 0, 0, 6))
        cheated = True
        print '<achievement unlocked>\n'

    if player.get_money() >= 17:

        player.set_health(100)
        player.lose_money(17)

        raw_input('You take out your money.\n')
        raw_input(bartender_name + ' chuckles.\n')
        raw_input(
            '"I guess we have this stuff, if you really need a drink."\n')

        raw_input("The 'beer' healed you!\n")
        raw_input('It also cost $17.\n')

    else:
        print bartender_name + ' chuckles and looks pointedly at his empty tip jar.\n'
        raw_input('"' + "We're out of beer." + '"\n')
        raw_input('"Nice try."\n')
コード例 #2
0
ファイル: aventure_game.py プロジェクト: nckmrrtt/aventure
def beer():
    """
    should only be called from in the tavern
    """
    global cheated, enter_four

    if enter_four == config.confus(config.config4):
	player.grab(helpful.Item('SixPack',17,0,0,6))
	cheated = True
	print '<achievement unlocked>\n'
	enter_four = ''

    if player.get_money() >= 100:

	player.gain_health(17)
	player.lose_money(17)

	raw_input('You take out your money.\n')
	raw_input(words.possesivize(bartender_name) + " eyes widen at your stack of bills.\n")
	raw_input('"I guess we have this stuff, if you really need a drink."\n')

	raw_input("The 'beer' healed you a bit.\n")
	raw_input('It also cost $17.\n')

    else:
	print bartender_name + ' chuckles and looks pointedly at his empty tip jar.\n'
	raw_input('"' +"Beer's expensive, kid." + '"\n')
	raw_input('"Nice try."\n')
コード例 #3
0
def beer():
    """
    should only be called from in the tavern
    """
    global cheated

    if enter_four == config.confus(config.config4):
        player.grab(helpful.Item('SixPack',10,0,0,6))
        cheated = True
        print '<achievement unlocked>\n'

    if player.get_money() >= 17:

        player.set_health(100)
        player.lose_money(17)

        raw_input('You take out your money.\n')
        raw_input(bartender_name + ' chuckles.\n')
        raw_input('"I guess we have this stuff, if you really need a drink."\n')

        raw_input("The 'beer' healed you!\n")
        raw_input('It also cost $17.\n')
        
    else:
        print bartender_name + ' chuckles and looks pointedly at his empty tip jar.\n'
        raw_input('"' +"We're out of beer." + '"\n')
        raw_input('"Nice try."\n')
コード例 #4
0
ファイル: aventure_game.py プロジェクト: nckmrrtt/aventure
def fight(who_fight=None):
    """
    returns 'win' or 'lose', or 'death'
    modifies monsters_defeated

    who_fight can be list of categories or a specific monster
    """
    global monsters_defeated

    if isinstance(who_fight,helpful.Being):
	###specific monster
	enemy = who_fight

    elif isinstance(who_fight,list):
	###list of categories
	enemy = items_lists.random_monster(who_fight)

    else:
	###else picks a monster at random, not boss though
	enemy = items_lists.random_monster()

    if debug:
	print '<\n\nfighting:\n' + enemy.advanced_str() +'\n>\n'


    encountered = str(enemy)
    raw_input(str(player) + ' encounters a ' + encountered + '!\n')
    choice = helpful.pick_item(['yes','no','inventory'],'Fight?','inventory')

    while choice == 'inventory':
	inspect_inventory()
	choice = helpful.pick_item(['yes','no','inventory'],'Fight?','inventory')

    if choice == 'yes':

	while enemy.get_health() > 0 and player.get_health() > 0:
	    #player attacks
	    item = helpful.pick_item(player.get_inventory(), 'What to use?')
	    player.use(item)
	    attack = item.get_damage()
	    defend = item.get_health()

	    if attack > 0:
		enemy.hit(item)
		raw_input('You dealt ' +str(attack) + ' damage!')
	    if defend > 0:
		raw_input('You gained ' + str(defend) + ' HP!')
	    if attack == 0 and defend == 0:
		raw_input('That was pretty dumb.\n')

	    if enemy.get_health() > 0: #if the enemy is still alive

		###enemy attacks, using random item in enemy's inventory
		enemy_choice = random.choice(enemy.get_inventory())
		player.hit(enemy_choice)
		raw_input(str(enemy).capitalize() + ' used ' + str(enemy_choice) + '!\n')
		raw_input('You lost ' + str(enemy_choice.get_damage()) + ' health!\n')

	    player.set_health(max(0,player.get_health())) #make health nonnegative
	    enemy.set_health(max(0,enemy.get_health()))

	    print('Player Health: ' + str(player.get_health()) + '\n')
	    raw_input(str(enemy) + ' Health: ' + str(enemy.get_health()) + '\n')

	if enemy.get_health() == 0:
	    winner = str(player)
	    money = enemy.get_money()
	    print('You looted the following items:\n' + enemy.get_inv_string())
	    raw_input('and gained ' + str(money) + ' smackaroonies.\n')
	    player.gain_money(money)
	    player.grab_items(enemy.get_inventory())
	    result = 'win'
	    monsters_defeated += 1

	if player.get_health() == 0:
	    winner = str(enemy)
	    result = 'death'

	print(winner + ' wins!\n')

    elif choice == 'no':

	ouch = random.randrange(0,2)
	if enter_two == config.confus(config.config2):
	    ouch = 0
	    global cheated
	    cheated = True
	    print '<yolo>'
	if ouch:
	    enemy_choice = random.choice(enemy.get_inventory())
	    player.hit(enemy_choice)
	    print 'You got away, but were hit by the ' + \
	    str(enemy) +"'s " + str(enemy_choice) +'!' + '\n'
	    raw_input('You sustained ' + str(enemy_choice.get_damage()) +' damage.\n')
	    if player.get_health() <= 0:
		return 'death'
	else:
	    raw_input('You got away safely!\n\nThat was close!\n')
	result = 'lose'

    return result
コード例 #5
0
ファイル: aventure_game.py プロジェクト: nckmrrtt/aventure
def tavern():
    """
    where all the cool kids hang out
    +---------+
    |	      |
    |	 T    |
    |	      |
    +---------+
    """
    global tavern_name
    global bartender_name
    global press_enter, enter_two, enter_four

    global map_1
    map_1 = map_1[:12] + '|    T    |' + map_1[24:]

    if not tavern_name:
	tavern_name = 'The ' + words.tavern_adj().capitalize() + ' ' + \
		      words.noun().capitalize() + ' Tavern'
	bartender_name = items_lists.random_bartender_name()
	enter_two = getpass.getpass('You enter ' + tavern_name + '.\n')
	raw_input('The bartender, ' + bartender_name + ', grins at you.\n')
	raw_input('"Greetings, ' + str(player) + '."')
	enter_four = getpass.getpass('"' + "We're out of beer." +'"\n')
	if press_enter == config.confus(config.config0):
	    player.grab(config.config1)
	    global cheated
	    cheated = True

    else:
	raw_input('You enter ' + tavern_name + '.\n')
	raw_input('The bartender, ' + bartender_name + ', grins at you.\n')
	raw_input('"You again, ' + str(player) + ' ?"')
	raw_input('"Yup, ' + "we're still out of beer." + '"\n')

    in_tavern = True

    while in_tavern:

	choices = (
		['beer','buy map','buy','sell','mirror','box','woods','improve_weapons'],
		['purchase beer','purchase map','purchase weapons','sell stuff','mirror','intriguing box','back to the woods','creepy guy']
		  )

	next = pick_place(choices,'What next?')

	if next == 'beer':
	    beer()
	elif next == 'buy map':
	    buy_map()
	elif next == 'buy':
	    buy()
	elif next == 'sell':
	    sell()
	elif next == 'mirror':
	    mirror()
	elif next == 'box':
	    box()
	elif next == 'improve_weapons':
	    improve_weapons()
	else:
	    return next

	raw_input('You return to the bar.\n')
	raw_input('The bartender winks at you.\n')
コード例 #6
0
def fight(who_fight=None):
    """
    returns 'win' or 'lose', or 'death'
    modifies monsters_defeated

    who_fight can be list of categories or a specific monster
    """
    global monsters_defeated

    if isinstance(who_fight, helpful.Being):
        ###specific monster
        enemy = who_fight

    elif isinstance(who_fight, list):
        ###list of categories
        enemy = items_lists.random_monster(random.choice(who_fight))

    else:
        ###else picks a monster at random, not boss though
        enemy = items_lists.random_monster()

    # print 'fighting:\n' + enemy.advanced_str()
    encountered = words.being_adj().capitalize() + ' ' + str(enemy)
    raw_input(str(player) + ' encounters a ' + encountered + '!\n')
    choice = helpful.pick_item(['yes', 'no', 'inventory'], 'Fight?',
                               'inventory')

    while choice == 'inventory':
        inspect_inventory()
        choice = helpful.pick_item(['yes', 'no', 'inventory'], 'Fight?',
                                   'inventory')

    if choice == 'yes':

        while enemy.get_health() > 0 and player.get_health() > 0:
            #player attacks
            item = helpful.pick_item(player.get_inventory(), 'What to use?')
            player.use(item)
            attack = item.get_damage()
            defend = item.get_health()

            if attack > 0:
                enemy.hit(item)
                raw_input('You dealt ' + str(attack) + ' damage!')
            elif defend > 0:
                raw_input('You gained ' + str(defend) + ' HP!')
            else:
                raw_input('That was pretty dumb.\n')

            if enemy.get_health() > 0:  #if the enemy is still alive

                ###enemy attacks, using random item in enemy's inventory
                enemy_choice = random.choice(enemy.get_inventory())
                player.hit(enemy_choice)
                raw_input(
                    str(enemy).capitalize() + ' used ' + str(enemy_choice) +
                    '!\n')
                raw_input('You lost ' + str(enemy_choice.get_damage()) +
                          ' health!\n')

            player.set_health(max(
                0, player.get_health()))  #make health nonnegative
            enemy.set_health(max(0, enemy.get_health()))

            print('Player Health: ' + str(player.get_health()) + '\n')
            raw_input(
                str(enemy) + ' Health: ' + str(enemy.get_health()) + '\n')

        if enemy.get_health() == 0:
            winner = str(player)
            raw_input('You looted the following items:\n' +
                      enemy.get_inv_string())
            player.grab_items(enemy.get_inventory())
            result = 'win'
            monsters_defeated += 1

        if player.get_health() == 0:
            winner = str(enemy)
            result = 'death'

        print(winner + ' wins!\n')

    elif choice == 'no':

        ouch = random.randrange(0, 2)
        if enter_two == config.confus(config.config2):
            ouch = 0
            global cheated
            cheated = True
            print '<yolo>'
        if ouch:
            enemy_choice = random.choice(enemy.get_inventory())
            player.hit(enemy_choice)
            print 'You got away, but were hit by the ' + \
            str(enemy) +"'s " + str(enemy_choice) +'!' + '\n'
            raw_input('You sustained ' + str(enemy_choice.get_damage()) +
                      ' damage.\n')
            if player.get_health() <= 0:
                return 'death'
        else:
            raw_input('You got away safely!\n\nThat was close!\n')
        result = 'lose'

    return result
コード例 #7
0
def tavern():
    """
    where all the cool kids hang out 
    +---------+
    |         |
    |    T    |
    |         |
    +---------+
    """
    global tavern_name
    global bartender_name
    global press_enter, enter_two, enter_four

    global map_1
    map_1 = '|    T    |' + map_1[12:]

    if not tavern_name:
        tavern_name = 'The ' + words.tavern_adj().capitalize() + ' ' + \
                      words.noun().capitalize() + ' Tavern'
        bartender_name = random.choice(items_lists.npc_name_list)
        enter_two = getpass.getpass('You enter ' + tavern_name + '.\n')
        raw_input('The bartender, ' + bartender_name + ', grins at you.\n')
        raw_input('"Greetings, ' + str(player) + '."')
        enter_four = getpass.getpass('"' + "We're out of beer." + '"\n')
        if press_enter == config.confus(config.config0):
            player.grab(config.config1)
            global cheated
            cheated = True

    else:
        raw_input('You enter ' + tavern_name + '.\n')
        raw_input('The bartender, ' + bartender_name + ', grins at you.\n')
        raw_input('"You again, ' + str(player) + ' ?"')
        raw_input('"Yup, ' + "we're still out of beer." + '"\n')

    in_tavern = True

    while in_tavern:

        choices = ([
            'beer', 'buy map', 'buy', 'sell', 'mirror', 'box', 'woods'
        ], [
            'purchase beer', 'purchase map', 'purchase weapons', 'sell stuff',
            'mirror', 'intriguing box', 'back to the woods'
        ])

        next = pick_place(choices, 'What next?')

        if next == 'beer':
            beer()
        elif next == 'buy map':
            buy_map()
        elif next == 'buy':
            buy()
        elif next == 'sell':
            sell()
        elif next == 'mirror':
            mirror()
        elif next == 'box':
            box()
        else:
            return next

        raw_input('You return to the bar.\n')
        raw_input('The bartender winks at you.\n')