Exemplo n.º 1
0
def arena():
    """
    location
    arena where you fight until you die hahahaha
    """
    global monsters_defeated, arena_boss

    if not arena_boss:
	arena_boss = items_lists.random_monster('boss_monsters')
	if debug:
	    print '<arena boss = ' + str(arena_boss) + '>\n'

    raw_input("You enter a terrifyingly massive arena.\n")
    raw_input("Thousands of bloodthirsty fans are screaming your name.\n")
    raw_input("Suddenly, the doors behind you close with a slam.\n")
    raw_input("There's no escape.\n")

    boss_win = False
    arena_monsters_encountered = 0

    while player.get_health() > 0 and not boss_win:
	arena_monsters_encountered += 1
	if arena_monsters_encountered % 10:
	    fight()
	else: #every 10th monster, fight the boss
	    boss_fight = fight(arena_boss)
	    if boss_fight == 'win':
		boss_win = True

    if boss_win:
	raw_input("The dying monster's body crashes through the floor, revealing " + \
		  "a cavernous tunnel underneath the arena...\n")
	raw_input("The fans are getting restless, demanding another fight. You seize " + \
		  "your opportunity quickly and enter the enormous tunnel.\n")
	return 'main_tunnel'

    else:
	raw_input('You defeated ' +str(monsters_defeated) + ' monsters before dying a grisly death!\n')
	return 'death'
def arena():
    """
    location
    arena where you fight until you die hahahaha
    """
    global monsters_defeated, arena_boss

    if not arena_boss:
        arena_boss = items_lists.random_monster('boss_monsters')
        print '<arena boss = ' + str(arena_boss) + '>\n'

    raw_input("You enter a terrifyingly massive arena.\n")
    raw_input("Thousands of bloodthirsty fans are screaming your name.\n")
    raw_input("Suddenly, the doors behind you close with a slam.\n")
    raw_input("There's no escape.\n")

    boss_win = False
    arena_monsters_encountered = 0

    while player.get_health() > 0 and not boss_win:
        arena_monsters_encountered += 1
        if arena_monsters_encountered % 10:
            fight()
        else:
            boss_fight = fight(arena_boss)
            if boss_fight == 'win':
                boss_win = True

    if boss_win:
        raw_input("The dying monster's body crashes through the floor, revealing " + \
                  "a cavernous tunnel underneath the arena...\n")
        raw_input("The fans are getting restless, demanding another fight. You seize " + \
                  "your opportunity quickly and enter the enormous tunnel.\n")
        return 'main_tunnel'

    else:
        raw_input('You defeated ' + str(monsters_defeated) +
                  ' monsters before dying a grisly death!\n')
        return 'death'
Exemplo n.º 3
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(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
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