示例#1
0
def find_other_name(context, known):		

	if known in first_names:
		known_str = 'first_name'
		unknown_str = 'last_name'
	else:
		known_str = 'last_name'
		unknown_str = 'first_name'
		
	if context is None:
		unknown_query = no_context_query.format(unknown_str, known_str, known)
	elif context[0] == 'room':
		unknown_query = context_room_query.format(unknown_str, known_str, known, context[1])
	elif context[0] == 'clue':
		unknown_query = context_clue_query.format(unknown_str, known_str, known, context[1])
	elif context[0] == 'murder':
		unknown_query = context_murder_query.format(unknown_str, known_str, known, context[1])
		
	unknown_names = sql.column_as_list(sql.run_query(unknown_query), 0)
	
	if len(unknown_names) == 1:
		unknown = unknown_names [0]
	elif context is None:
		unknown = None
	elif context[0] in ['clue', 'murder']:
		unknown = find_other_name(['room', player.location], known)
	elif context[0] == 'room':
		unknown = find_other_name (None, known)
	else:
		#this shouldn't ever occur
		DEBUG ("Context WTF?")
		unknown = None
	
	return unknown
示例#2
0
def blame(murderer, victim):

    DEBUG("Blame")
    message = ""

    id_m = sql.npc_id_from_name(murderer)
    id_v = sql.npc_id_from_name(victim)
    m_location = blamed_location(id_m)

    if m_location == player.location:

        query = "SELECT murderer FROM murder WHERE victim = {0};".format(id_v)
        right_murderer = sql.query_single(query)

        if right_murderer:
            if right_murderer == id_m:
                message = murder_solved(id_m)
            else:
                query = (
                    "select player_clue.detail "
                    "from player_clue "
                    "inner join npc_detail on player_clue.detail = npc_detail.detail "
                    "inner join mapped_npc on npc_detail.npc = mapped_npc.npc "
                    "and mapped_npc.mapped_id in ("
                    "select murderer "
                    "from murder where victim = {0}"
                    ");").format(id_v)

                details = sql.column_as_list(sql.run_query(query), 0)

                if len(details) < 3:
                    message = "They didn't kill that person!"
                else:
                    message = escaper(right_murderer)
        else:
            message = "They ain't even dead yet!"
    else:
        message = "You can't blame them, they're not here."
    return message
示例#3
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


	
	
	
	
	
	
示例#4
0
	elif len (sql.get_living_npcs()) == 1:
		DEBUG ("Game Over")
		playing = False
		end_state = 'one murderer left'
	
## END GAME LOOP	

points_for_survivor = 10
points_for_solved = 5
points_for_unsolved = 0
	
points = 0

if end_state == 'out of murderers':
	fprint ("You've gotten rid of all the killers. But at what price! {0} people died today.".format (sql.query_single("SELECT COUNT(*) FROM murder")))
	murders = sql.column_as_list(sql.run_query("SELECT state FROM murder INNER JOIN mapped_npc ON mapped_id = murderer;"), 0)

	for item in murders:
		if item == 'arrested':
			points += points_for_solved
		elif item == 'escaped':
			points += points_for_unsolved

	points += (len(npcs) - len(murders)) * points_for_survivor

	max_points = len(npcs) * points_for_survivor - int(len(npcs) / 10) * points_for_solved
	fprint("You got {0} points of {1}.".format(points, max_points))
	
elif end_state == 'one murderer left':
	last_murderer = sql.get_active_murderers()[0]
	formatted_name = format_npc(sql.npc_name_from_id(last_murderer))
示例#5
0
def escaped_npcs():
    query = "SELECT mapped_id FROM mapped_npc WHERE state = 'escaped';"
    return sql.column_as_list(sql.run_query(query), 0)
示例#6
0
def single_npc_details(target_id):
    query = ("SELECT detail.name from detail, npc_detail,mapped_npc "
             "WHERE detail.detail_id = npc_detail.detail "
             "AND npc_detail.npc = mapped_npc.npc "
             "AND mapped_npc.mapped_id = '") + str(target_id) + "';"
    return sql.column_as_list(sql.run_query(query), 0)
示例#7
0
def all_npcids_in_room(room_id):
    query = "SELECT mapped_npc.mapped_id FROM npc, mapped_npc WHERE npc.npc_id = mapped_npc.npc AND mapped_npc.location = '" + str(
        room_id) + "';"
    result = sql.column_as_list(sql.run_query(query), 0)
    return result
示例#8
0
			else:
				has_target1 = 0
			query += " AND has_target1 = {0}".format(has_target1)
				
			
			if target2:
				has_target2 = 1
			else:
				has_target2 = 0
			query += " AND has_target2 = {0}".format(has_target2)
			#---------------------------------------------------------------
			query += ";"
			
			# Get Action id
			action = sql.query_single(query)
			DEBUG((action, sql.column_as_list(sql.run_query("SELECT * FROM actions"), 0), query))
			# Do action, and spend action points
			if (action):
				super = int(action / 10)
				sub = action - super * 10
				
				# DEBUG("super: {0}, sub: {1}".format(super, sub))
				use_action_point = False
				if super == 1: # MOVE
					movement = move.move(target2)
					messages.append(movement[1])
					if movement [0]:
						messages.append(look.look(sql.room_name_from_id(player.location)))
						use_action_point = True
					
				elif super == 2: # LOOK