Exemple #1
0
def players(cursor):
	output = {}
	
	player_dict = player_q.get_active_players(cursor, turn_count=7)
	for p, the_player in player_dict.items():
		output[p] =  {
			"player_id":	p,
			"name":			the_player.name,
			"ir":			the_player.ir,
			"team":			the_player.team,
			"last_order":	the_player.last_posted,
		}
	
	return json.dumps(output)
Exemple #2
0
def teams(cursor):
	output = {}
	
	team_dict = team_q.get_all_teams(cursor)
	player_dict = player_q.get_active_players(cursor, turn_count=5)
	
	seconds = {}
	for p, the_player in player_dict.items():
		if p != team_dict[the_player.team].leader_id:
			if the_player.team not in seconds:
				seconds[the_player.team] = []
			seconds[the_player.team].append(p)
	
	deities = []
	evolutions = []
	
	for t, the_team in team_dict.items():
		if the_team.dead: continue
		if the_team.not_in_queue: continue
		if the_team.hidden: continue
		if the_team.not_a_team: continue
		
		output[t] =  {
			"team_id":		t,
			"name":			the_team.name,
			"leader":		the_team.leader_id,
			"seconds":		seconds.get(t, []),
			"culture":		the_team.culture_topic,
			"ir":			the_team.ir,
			"join_turn":	the_team.join_turn,
			
			"deities":		list(the_team.get_deities(cursor).keys()),
			"evolutions":	the_team.get_evolutions(cursor),
		}
	
	return json.dumps(output)
Exemple #3
0
def main(cursor):
	player_id	= int(common.get_val('player', 0))
	killer		= int(common.get_val('killer', 0))
	victim		= int(common.get_val('victim', 0))
	battle_id	= int(common.get_val('battle', 0))
	ajax		= bool(common.get_val('ajax', False))
	
	battle_dict = battle_q.get_all_battles(cursor)
	player_dict = player_q.get_all_players(cursor)
	active_dict = player_q.get_active_players(cursor)
	
	battle_dict[0] = battle.Battle({"name":"None"})
	
	if killer > 0:
		kill_list = player_q.get_kills(cursor, killer=killer)
	elif victim > 0:
		kill_list = player_q.get_kills(cursor, victim=victim)
	elif battle_id > 0:
		kill_list = player_q.get_kills(cursor, battle=battle_id)
	else:
		kill_list = player_q.get_kills(cursor)
	
	output = []
	
	output.append("""
	<table border="0" cellspacing="0" cellpadding="5" style="width: 100%;">
		<tr class="row2">
			<th>Killer</th>
			<th>Victim</th>
			<th>Battle</th>
			<th>Turn</th>
			<th>&nbsp;</th>
		</tr>""")
	
	count = -1
	for kill in kill_list:
		count += 1
		
		output.append("""
		<tr class="row%(row)d">
			<td><a href="web.py?mode=edit_player&amp;player=%(k_id)s">%(killer)s</a></td>
			<td><a href="web.py?mode=edit_player&amp;player=%(v_id)s">%(victim)s</a></td>
			<td>%(battle)s <em>(%(c_id)s)</em></td>
			<td>%(turn)s</td>
			
			<td style="padding: 0px;"><a class="block_link" href="exec.py?mode=remove_kill&amp;victim=%(v_id)s&amp;killer=%(k_id)s&amp;turn=%(turn)s&amp;battle=%(c_id)s%(p_id)s">Remove</a></td>
		</tr>
		""" % {	'row': (count % 2),
				
				'v_id':			kill['victim'],
				'k_id':			kill['killer'],
				'c_id':			kill['battle'],
				'p_id':			("&amp;player=%d" % player_id if player_id > 0 else ""),
				
				'killer':		player_dict[kill['killer']].name,
				'victim':		player_dict[kill['victim']].name,
				"battle":		battle_dict[kill['battle']].name,
				
				'turn':			kill['turn'],
			})
	
	# Add new power
	names = {}
	for p, the_p in active_dict.items():
		names[p] = the_p.name
	
	if not ajax:
		onload = common.onload("$('#killer').focus();")
	else:
		onload = ""
	
	count += 1
	output.append("""
	<tr class="row%(row)d">
		<form action="exec.py" id="add_kill_form" method="post" accept-charset="utf-8">
		<td style="padding: 1px;">%(killer)s</td>
		<td style="padding: 1px;">%(victim)s</td>
		<td style="padding: 0px;">%(battle)s</td>
		<td style="padding: 0px;">%(turn)s</td>
		
		<td style="padding: 1px;">
			<input type="hidden" name="mode" value="add_kill" />
			%(player_id)s
			<input type="submit" value="Add" />
		</td>
		</form>
		%(onload)s
	</tr>
	""" % {	'row': (count % 2),
			'killer':	common.option_box(
				name='killer',
				elements=names,
				element_order=active_dict.keys(),
				selected = killer if killer > 0 else "",
			),
			'victim':	common.option_box(
				name='victim',
				elements=names,
				element_order=active_dict.keys(),
				selected = victim if victim > 0 else "",
			),
			"turn":		'<input type="text" name="turn" id="turn" value="%d" />' % common.current_turn(),
			"battle":	'<input type="text" name="battle" id="battle" value="%d" />' % battle_id,
			"onload":	onload,
			"player_id": ('<input type="hidden" name="player" value="%d" />' % player_id if player_id > 0 else ""),
			})
	
	output.append("</table>")
	return "".join(output)
Exemple #4
0
def main(cursor):
	power_id	= int(common.get_val('power', 0))
	
	if power_id < 1:
		return "No power selected"
	
	the_power = power_q.get_one_power(cursor, power_id)
	
	output = ["<div style='padding: 5px;'>"]
	
	# Used for the player select menu
	player_dict = player_q.get_all_players(cursor)
	recent_dict = player_q.get_active_players(cursor)
	
	names = {}
	for p in recent_dict.keys():
		names[p] = player_dict[p].name
	
	if the_power.player not in names:
		# recent_dict[the_power.id] = the_power.player
		names[the_power.player] = player_dict[the_power.player].name
	
	
	output.append("""
	<form action="exec.py" method="post" accept-charset="utf-8">
		<input type="hidden" name="mode" id="mode" value="edit_power_commit" />
		<input type="hidden" name="id" id="id" value="%(power_id)s" />
	
		<table border="0" cellspacing="5" cellpadding="5">
			<tr>
				<td><label for="name">Name:</label></td>
				<td>%(name_text)s</td>
			
				<td width="5">&nbsp;</td>
			
				<td><label for="player">Player:</label></td>
				<td>%(player_select)s</td>
			</tr>
			<tr>
				<td><label for="type">Type:</label></td>
				<td>%(type)s</td>
			
				<td width="5">&nbsp;</td>
			
				<td>&nbsp;</td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td colspan="5"><label for="description">Description:</label><br />
				<textarea name="description" rows="4" cols="60">%(description)s</textarea></td>
			</tr>
		</table>
		<br />
		<input type="submit" value="Perform edit" />
	</form>
	<br /><br />""" % {
		"power_id":			power_id,
		"name":		the_power.name,
		"description":		the_power.description,
		"name_text":	common.text_box("name", the_power.name, size=20),
		"player_select":	common.option_box(
			name='player',
			elements=names,
			element_order=recent_dict.keys(),
			selected=the_power.player,
			custom_id="",
		),
		"type":	common.option_box(
			name='type',
			elements=power.power_types,
			selected=power.power_types[the_power.type],
		),
	})


	# End of padding
	output.append("</div>")

	return "".join(output)