Esempio n. 1
0
def npc_move_message (moving_npcs, action):
	if moving_npcs == []:
		return None
		
	move_message = ""
	
	if action == 'enter':
		action_str = 'entered'
		preposition = ' from'
	elif action == 'exit':
		action_str = 'left'
		preposition = 'to'
	
	current_room = sql.room_name_from_id(player.location)
	for item in moving_npcs:
		name = format_npc(sql.npc_name_from_id(item[0]))
		other_room = sql.room_name_from_id(item[1])
		move_message += "{0} has {1} the {2} {3} the {4}.\n".format(
														name,
														action_str,
														current_room,
														preposition,
														other_room
														)
	
	return move_message [:-1]
Esempio n. 2
0
def look_around():
    room_name = format_room(sql.room_name_from_id(player.location))
    message = "You are in {0}.\n".format(room_name)

    query = "SELECT description FROM room WHERE room.room_id ='" + str(
        player.location) + "';"
    description = sql.query_single(query)  #muokattu näkymään
    if description:
        message += description

    message += "\nYou can move to:\n"  #muokattu uudelle riville

    #---------------------------
    passages = sql.get_adjacent_rooms_and_directions(player.location)

    room_names = []
    directions = []
    longest_length = 0
    count = 0

    for item in passages:
        room_names.append(sql.room_name_from_id(item[0]))
        length = len(room_names[-1])
        if length > longest_length:
            longest_length = length
        directions.append(sql.to_long_direction(item[1]))
        count += 1

    for i in range(count):
        message += "@i\t{0:{1}}\t{2}\n".format(format_room(room_names[i]),
                                               longest_length + 2,
                                               directions[i])
    #-----------------------------

    live_npcs = sql.live_npcsid_in_room(player.location)
    dead_npcs = sql.dead_npcsid_in_room(player.location)
    total_npcs = len(live_npcs) + len(dead_npcs)
    if total_npcs > 0:
        message += "These people are here:\n"
        for item in live_npcs:
            formatted_name = format_npc(sql.npc_name_from_id(item))
            message += "@i\t{0}\n".format(formatted_name)
        if len(dead_npcs) > 0:
            message += "But these people seem to be dead!:\n"
            for item in dead_npcs:
                formatted_name = format_npc(sql.npc_name_from_id(item))
                message += "@i\t{0}\n".format(formatted_name)
                sql.add_player_clue(item, None)
    else:
        message += "There is no one in here."

    return message
Esempio n. 3
0
def move(target):
    message = ""
    success = False
    if target in sql.get_rooms():
        target_room_id = sql.get_room_id(target)
        adjacent_rooms = sql.get_adjacent_rooms(player.location)
        if target_room_id in adjacent_rooms:
            player.location = target_room_id
            message = 'Moved to the {0}'.format(format_room(target))
            success = True
        else:
            message = "You can't move there from this room!"

    elif target in sql.get_all_directions():
        available_directions = sql.get_available_directions(player.location)
        if target in available_directions:
            player.location = sql.get_room_in_direction(
                player.location, target)
            message = 'Moved to the {0}'.format(
                format_room(sql.room_name_from_id(player.location)))
            success = True
        else:
            message = "You try to go in that direction and hit your face against the wall, ouch!"

    else:
        message = "That is not somewhere you can go!"

    return (success, message)
Esempio n. 4
0
def ask_other(target1, target2):
	target = target1 or target2

	if target in sql.get_rooms():
		destination_id = sql.room_id_from_name(target)
	
		if destination_id == player.location:
			message = "You are already there!"
	
		else:
			path = sql.find_path(player.location, destination_id)	
			npcs = sql.live_npcsid_in_room(player.location)
			if len(npcs) > 0:
				name = format_npc(sql.npc_name_from_id(random.choice(npcs)))
				message = "{0} tells you the way:\n".format(name)
				for item in path:
					room_name = format_room(sql.room_name_from_id(item[0]))
					direction = sql.to_long_direction(item[1])
					message += "@i\t{0:20} {1}\n".format(room_name, direction)
			else:
				room_name = format_room(sql.room_name_from_id(path[0][0]))
				message = "There's no one here to help you, but you feel you should go first to the {0}.".format(room_name)
				
	elif target in sql.all_npcs():
		
		target_alive = target in sql.live_npcs()
		target_present = target in sql.npcs_in_room(player.location)
		player_has_clue = sql.npc_id_from_name(target) in sql.column_as_list(sql.run_query("SELECT DISTINCT victim FROM player_clue;"), 0)

		if target1:
			if target_alive and target_present:
				message = "Who do you want to ask about from {0}?".format(format_npc(target))
				
			elif not target_present and (target_alive or not player_has_clue):
				message = "{0} is not here. Go ask somebody else.".format(format_npc(target))
			
			elif not target_alive and target_present:
				message = "You see {0} dead on ground. They don't say anything.".format(format_npc(target))
			
			elif not target_alive and not target_present and player_has_clue:
				message = "{0} is not here. As well as not alive.".format(format_npc(target))
		
		else:	
			message = "Whom do you want to ask about {0}?".format(format_npc(target))
	
	elif target in sql.get_all_directions():
	
		target = sql.to_long_direction(target)
		if target1:
			if  target == 'up':
				if sql.room_name_from_id(player.location) in ['front yard', 'back yard']:
					target = 'sky'
				else:
					target = 'ceiling'
			elif target == 'down':
				target = 'floor'
			message = "{0} doesn't tell you anything.".format(target.title())
		else:
			message = "But... Why? Don't do that."
	
	elif target in sql.get_specials():
		if target == 'notes':
			message = "You keep notes of clues you have collected. Type 'memo' or 'notes' to view them."
	
	else:
		message == "This is secret development question. You shold not ever again ask it."
	
	return message


	
	
	
	
	
	
Esempio n. 5
0
			current_murderer_id = murderers[0]
		else:
			current_murderer_id = next_murderer_id
		
		# Find victim ---------------------------------------------------------
		possible_targets = sql.get_targets(current_murderer_id)
		
		if possible_targets:
			victim_id = random.choice(possible_targets)
			
			murderer_location = sql.get_npc_location (current_murderer_id)
			victim_location = sql.get_npc_location(victim_id)
			sql.move_npc(current_murderer_id, victim_location)
		
			if victim_location != murderer_location:
				DEBUG ("Murderer {0} moved from {1} to {2} to kill {3}!".format(sql.npc_name_from_id(current_murderer_id), sql.room_name_from_id(murderer_location), sql.room_name_from_id(victim_location), sql.npc_name_from_id(victim_id)))
			else:
				DEBUG ("Murderer {0} killed {1} in {2}!".format(sql.npc_name_from_id(current_murderer_id), sql.npc_name_from_id(victim_id), sql.room_name_from_id(victim_location)))

		else:
			DEBUG("No targets left for remaining killer {0}.".format(sql.npc_name_from_id(current_murderer_id)))
			
			
		# Npcs move -----------------------------------------------------------
		# From and to player's location
		npcs_enter = []
		npcs_exit = []
		
		for npc in sql.get_living_npcs():
			if npc in [current_murderer_id, victim_id]:
				do_move = False
Esempio n. 6
0
def look(target):

    live_npcsid_in_room = sql.live_npcsid_in_room(player.location)
    dead_npcsid_in_room = sql.dead_npcsid_in_room(player.location)
    arrested = arrested_npcs()
    escaped = escaped_npcs()

    message = ""
    if (target in sql.get_rooms()):

        room_id = sql.get_room_id(target)
        if (room_id == player.location):
            message = look_around()
            if message == None:
                message = "{0} is rather nice.".format(target)
        else:
            message = "You cannot see there from here."

    elif (target in sql.all_npcs()):

        target_id = sql.npc_id_from_name(target)
        if (target_id in live_npcsid_in_room):

            message = single_npc_description(target_id)

            details = single_npc_details(target_id)
            if len(details) > 0:
                message += "\nYou immediately notice these striking details about them:"
                for detail in details:
                    message += "\n@i\t{0}".format(detail)

        elif (target_id in dead_npcsid_in_room):
            message = "Here lies the dead body of " + format_npc(
                target) + ". How sad indeed..."

        elif (target_id in arrested):
            message = "They've already been arrested and taken away."

        elif (target_id in escaped):
            message = "Oh no looks like they've escaped."

        else:
            message = "They're not here."

    elif (target in sql.get_all_directions()):
        room_in_direction = sql.get_room_in_direction(player.location, target)
        if room_in_direction:
            room_name = format_room(sql.room_name_from_id(room_in_direction))
            message = "You see the {0} in {1}.".format(
                room_name, sql.long_direction(target))
        else:
            message = "There's some tastefully arranged interior art there. Very apprecietable!"

    elif target == 'notes':
        notes = sql.get_notes()
        message = "NOTES:\n"
        if len(notes) > 0:
            for entry in notes:
                if entry[3]:
                    message += "\nSOLVED" + expired_colour
                victim_name = format_npc(sql.npc_name_from_id(entry[0]))
                room_name = format_room(sql.room_name_from_id(entry[1]))
                message += "\n{0} was killed in the {1}.".format(
                    victim_name, room_name)
                if entry[2]:
                    message += " Clues about their killer:"
                    for item in entry[2]:
                        message += "\n@i\t{0}".format(
                            sql.detail_name_from_id(item))

                if entry[3]:
                    message += default_colour
                message += "\n"

            # Slice away last newline
            message = message[:-1]

        else:
            message += "@i\tno notes yet"

    elif (target == 'hell'):
        message = "Looks like you looked right into your future."

    else:
        message = "Why would you look at that?"

    return message