Пример #1
0
def main(cursor):
	raise Exception("Thought to no longer be used")
	
	team_id = int(common.get_val("team", -1))
	
	if team_id < 1:
		return "<div style='padding: 5px;'>%s</div>" %  common.select_team_form(cursor, 'results')
	
	the_team = team_q.get_one_team(cursor, team_id)
	the_world = world.World(cursor)
	
	output = ['<div style="padding: 5px;">']
	output.append('<span class="stitle">%s results</span>' % the_team.name)
	output.append('<textarea name="results" id="results" rows="13" style="width: 100%;">')
	output.append(team_f.create_results_tail(the_world, the_team))
	output.append('</textarea>Previous results:')
	
	# Now to get the results for the last few turns
	# results_dict = results.get_results_by_team()
	# our_results_dict = results_dict.get(team_id, {})
	# 
	# for t in range(common.current_turn(),common.current_turn()-5,-1):
	# 	if t in our_results_dict:
	# 		output.append("""
	# 		<hr />
	# 		Turn: %d<br />
	# 		%s
	# 		""" % (t, common.bbcode_to_html(our_results_dict[t].strip())))
	
	output.append('<hr /></div>')
	return "".join(output)
Пример #2
0
def main(cursor):
	output = []
	
	# Get city Id
	city_id = int(common.get_val('city', 1))
	if city_id < 1: return "No city selected"
	
	# Build city item
	the_city = city_q.get_one_city(cursor, city_id)
	the_team = team_q.get_one_team(cursor, the_city.team)
	tech_dict = tech_q.get_all_techs(cursor)
	
	output.append("""
	<div style="padding:5px;">
	<span class="stitle">{name}</span><br />
	<table border="0" cellspacing="0" cellpadding="5">
		<tr class="row2">
			<th>Resource</th>
			<th>Supply</th>
			<th>Demand</th>
		</tr>""".format(
			name = the_city.name,
		))
	
	terrain = mapper_q.get_terrain(cursor, the_city.x, the_city.y)
	team_techs = the_team.get_techs(cursor)[0]
	techs = {}
	for k, v in team_techs.items():
		techs[tech_dict[k].name] = v
	
	for i, r in enumerate(sad_rules.res_list):
		supply = round(sad_rules.supply[r](city=the_city, terrain=terrain, techs=techs), 2)
		demand = round(sad_rules.demand[r](city=the_city, terrain=terrain, techs=techs), 2)
		
		output.append("""
		<tr class="row{i}">
			<td>{res}</td>
			
			<td>{supply}</td>
			<td>{demand}</td>
		</tr>""".format(
			i = i % 2,
			res = r,
			supply = supply,
			demand = demand,
		))
		
	page_data['Title'] = "City trade (%s)" % the_city.name
	output.append("</table></div>")
	return "".join(output)
Пример #3
0
def main(cursor):
	t1 = team_q.get_one_team(cursor, int(common.get_val('t1')))
	t2 = team_q.get_one_team(cursor, int(common.get_val('t2')))
	
	relations = team_q.get_relations(cursor)
	
	output = []
	
	output.append("""
	<div style="padding:5px;">
	<span class="stitle"><strong>{t1} relation to {t2}</strong></span><br />
	<br />
	
	{t1} is {t12_border} towards {t2}<br />
	{t2} is {t21_border} towards {t1}<br />
	<br />
	
	{t1} has a tax rate of {t12_tax}% towards {t2}<br />
	{t2} has a tax rate of {t21_tax}% towards {t1}<br />
	<br />
	
	</div>
	""".format(
		t1 = t1.name,
		t2 = t2.name,
		
		t12_border = team.border_states[relations.get(t1.id, {}).get(t2.id, {}).get('border', t1.default_borders)],
		t21_border = team.border_states[relations.get(t2.id, {}).get(t1.id, {}).get('border', t2.default_borders)],
		
		t12_tax = relations.get(t1.id, {}).get(t2.id, {}).get('taxes', t1.default_taxes),
		t21_tax = relations.get(t2.id, {}).get(t1.id, {}).get('taxes', t2.default_taxes),
	))
	
	output.append("</div>")
	
	return "".join(output)
Пример #4
0
def main(cursor):
    team_id = int(common.get_val("team", 0))
    turn = int(common.get_val("turn", -1))

    if team_id < 1:
        return "<div style='padding: 5px;'>%s</div>" % common.select_team_form(cursor, "view_orders")

    if turn < 1:
        turn = common.current_turn()

    the_world = world.World(cursor)
    player_dict = the_world.players()

    the_team = team_q.get_one_team(cursor, team_id)
    the_orders = the_team.get_orders(cursor, the_world, "international", turn)

    # output = ["<div style='padding: 5px; font-size: 14px; line-height: 17px;'>"]
    output = ["<div style='padding: 5px;'>"]
    player_updates = {}

    for o in the_orders:
        player_updates[o.player] = o.team

        if o.content == "Orders placeholder":
            continue

        output.append(
            '<br /><hr />Post: <a href="http://woarl.com/board/viewtopic.php?p=%s#p%s">%s</a><br />'
            % (o.post_id, o.post_id, o.post_id)
        )
        output.append(
            'Poster: <a href="http://woarl.com/board/memberlist.php?mode=viewprofile&u=%d">%s</a> - '
            % (o.player, player_dict[o.player].name)
        )
        output.append('<a href="web.py?mode=edit_player&amp;player=%d">Local edit</a><br />' % (o.player))

        output.append(common.bbcode_to_html(o.content.replace('<span class="stitle">', '<hr /><span class="stitle">')))

    output.append("</div>")

    # Update player activity
    if turn == common.current_turn():
        database.query(cursor, player_f.update_player_activity(player_updates))

        # print "<br />".join(output)
    page_data["Title"] = "%s International orders" % the_team.name
    return "".join(output)
Пример #5
0
Файл: ti.py Проект: Teifion/Rob3
def get_bbcode_core(cursor, team_id):
	the_team = team_q.get_one_team(cursor, team_id)
	md5_name = team_f.team_hash(the_team.name)
	
	# bbcode = "".join([headers, output, footers])
	bbcode = ti_f.bbcode_ti(the_team, md5_name)
	
	ti_output = common.bbcode_to_html(bbcode)
	
	# Clean it
	bbcode = bbcode.replace(' ', '\\ ').replace('\n', 'NEWLINE').replace('\t', '')
	bbcode = bbcode.replace("'", 'APOSTRAPH').replace('&', 'AMPASAND')
	bbcode = bbcode.replace("(", '\\(').replace(')', '\\)')
	
	# Send it
	getter_data = "p=%s&mode=postUpdate&post=%d&string=%s" % (common.data['getterPass'], the_team.team_info_first_post, bbcode)
	result = urllib.request.urlopen(common.data['getter_url'], getter_data).read().strip()
	
	return bbcode
Пример #6
0
def main(cursor):
	# Get team Id
	team_id = int(common.get_val('team', 0))
	
	# Build team
	the_team = team_q.get_one_team(cursor, team_id)
	
	if team_id < 1:
		return "<div style='padding: 5px;'>%s</div>" % common.select_team_form(cursor, 'list_units')
	
	unit_dict = unit_q.get_units_from_team(cursor, team=team_id)
	equipment_dict = equipment_q.get_all_equipment(cursor)
	the_team.get_units(cursor)
	
	output = []
	output.append("""
	<table border="0" cellspacing="0" cellpadding="5" style="width: 100%;">
		<tr class="row2">
			<th>Icon</th>
			<th>Amount</th>
			<th>Name</th>
			<th>Cost</th>
			<th colspan='4'>Categories</th>
			<th>Equipment</th>
			<th style="width:70px;">Edit</th>
			<!--
			<th colspan="2">Add</th>
			-->
		</tr>""")

	names = {}
	count = -1
	if len(unit_dict) > 0:
		# for team_id, team in team_dict.items():
		for unit_id, the_unit in unit_dict.items():
			if unit_id not in the_team.units: the_team.units[unit_id] = 0
			
			names[unit_id] = the_unit.name
			count += 1
			
			output.append("""
			<tr class="row%(row)d" id="%(unit_id)d">
				<td>%(icon)s</td>
				<td>%(count)s</td>
				<td>%(name)s</td>
			
				<td>%(cost)s</td>
				<td>%(weapon_cat)s</td>
				<td>%(armour_cat)s</td>
				<td>%(move_cat)s</td>
				<td>%(training_cat)s</td>
				<td>%(equipment)s</td>
			
				<td style="padding: 0px;"><a class="block_link" href="web.py?mode=edit_unit&amp;unit=%(unit_id)d">Edit unit</a></td>
				<!--
				<td style="padding: 1px;">
					<form action="exec.py" method="post" accept-charset="utf-8">
						<input type="text" name="amount" value="" size="8"/>
						<input type="hidden" name="mode" value="alter_unit_count" />
						<input type="hidden" name="team" value="%(team_id)s" />
						<input type="hidden" name="unit" value="%(unit_id)s" />
					</form>
				</td>
				<td style="padding: 0px;">
					<a class="block_link" href="#" onclick="$('#form_add_%(unit_id)s').submit();">Add unit</a>
				</td>
				-->
			</tr>
			""" % {	'row': (count % 2),
				
					"team_id":		team_id,
					'unit_id':		unit_id,
					'name':	common.doubleclick_text("units", "name", unit_id, the_unit.name, "font-weight:bold"),
					'icon':			"",
					'count':		common.number_format(the_team.units[unit_id]),
					
					'weapon_cat':	unit.weapon_categories[the_unit.weapon_cat],
					'armour_cat':	unit.armour_categories[the_unit.armour_cat],
					'move_cat':	unit.move_categories[the_unit.move_cat],
					'training_cat':	unit.training_categories[the_unit.training_cat],
				
					"cost":			unit_rules.print_unit_cost(the_unit, cursor=cursor, equipment_dict=equipment_dict),
					"equipment":	the_unit.equipment_string,
				
					})
	
	# Add unit type
	# armies_dict = army_q.get_armies_from_team(cursor, team=team_id, include_garrisons=1)
	count += 1
	
	# armies_names = {}
	# has_non_garrison = False
	# for k, v in armies_dict.items():
	# 	armies_names[k] = v.name
	# 	if v.garrison < 0: has_non_garrison = True
	# 
	# armies_order.reverse()
	# armies_order.append("disabled")
	# armies_order.append("XYZ_all_garrisons")
	# if has_non_garrison == True:
	# 	armies_order.append("XYZ_all_non_garrisons")
	# 	armies_order.append("XYZ_all_armies")
	# armies_order.reverse()
	# 
	# if has_non_garrison == True:
	# 	armies_names["XYZ_all_armies"]			= "All armies"
	# 	armies_names["XYZ_all_non_garrisons"]	= "All non garrisons"
	# armies_names["XYZ_all_garrisons"]		= "All garrisons"


	output.append("""
	<tr class="row%(row)d">
		<form action="exec.py" method="post" id="new_unit_form" accept-charset="utf-8">
		<input type="hidden" name="mode" value="create_new_unit" />
		<input type="hidden" name="team" value="%(team_id)s" />
		<td>&nbsp;</td>
		<td style="padding: 1px;">&nbsp;</td>
		<td style="padding: 1px;"><input type="text" name="name" id="name" value="" size="13"/></td>
		<td colspan='4'>&nbsp;</td>
		<td style="padding: 1px;">&nbsp;</td>
		<td style="padding: 2px;">
			<textarea name="equipment_string" id="equipment_string" rows="1" cols="30"></textarea>
		</td>
	
		<td style="padding: 0px;"><a class="block_link" onclick="$('#new_unit_form').submit();" href="#">Add</a></td>
		%(onload)s
		</form>
	</tr>
	""" % {	'row': (count % 2),

			"team_id":		team_id,
			'onload':		common.onload("$('#name').focus();"),
			})

	# Now for solo units
	unit_dict = unit_q.get_units_from_team(cursor, team=0)
	if len(unit_dict) > 0:
		# for team_id, team in team_dict.items():
		for unit_id, the_unit in unit_dict.items():
			if unit_id not in the_team.units: the_team.units[unit_id] = 0
			
			names[unit_id] = the_unit.name
			count += 1
		
			output.append("""
			<tr class="row%(row)d" id="%(unit_id)d">
				<td>%(icon)s</td>
				<td>%(count)s</td>
				<td>%(name)s</td>
			
				<td>%(cost)s</td>
				
				<td colspan='4'>&nbsp;</td>
				
				<td>%(equipment)s</td>
			
				<td style="padding: 0px;"><a class="block_link" href="web.py?mode=edit_unit&amp;unit=%(unit_id)d">Edit unit</a></td>
				<!--
				<td style="padding: 1px;">
					<form action="exec.py" method="post" accept-charset="utf-8">
						<input type="text" name="amount" value="" size="8"/>
						<input type="hidden" name="mode" value="alter_unit_count" />
						<input type="hidden" name="team" value="%(team_id)s" />
						<input type="hidden" name="unit" value="%(unit_id)s" />
					</form>
				</td>
				<td style="padding: 0px;">
					<a class="block_link" href="#" onclick="$('#form_add_%(unit_id)s').submit();">Add unit</a>
				</td>
				-->
			</tr>
			""" % {	'row': (count % 2),
				
					"team_id":		team_id,
					'unit_id':		unit_id,
					'name':	common.doubleclick_text("units", "name", unit_id, the_unit.name, "font-weight:bold"),
					'icon':			"",
					'count':		common.number_format(the_team.units[unit_id]),
				
					"cost":			unit_rules.print_unit_cost(the_unit, cursor=cursor, equipment_dict=equipment_dict),
					"equipment":	the_unit.equipment_string,
				
					})
	
	output.append("</table>")
	page_data['Title'] = "%s unit list" % the_team.name
	return "".join(output)
Пример #7
0
def main(cursor):
	# Get team Id
	team_id = int(common.get_val('team', 0))
	if team_id < 1: return "No team selected"
	
	# Build team item
	the_team = team_q.get_one_team(cursor, team_id)
	
	# Get some properties
	the_team.get_population(cursor)
	
	# Lists
	trait_dict = trait_q.get_all_traits(cursor)
	deity_dict = deity_q.get_all_deities(cursor)
	evolution_dict = evolution_q.get_all_evolutions(cursor)
	
	# Is the join turn set?
	if the_team.join_turn == 0:
		the_team.join_turn = common.current_turn()
	
	# First row of check_boxes
	output = ["<div style='padding: 5px;'>"]

	output.append("""
	<span class="stitle">%(name)s</span>
	&nbsp;&nbsp;&nbsp;
	Population: %(team_population)s

	<br /><br />
	<form action="exec.py" method="post" accept-charset="utf-8">
		<input type="hidden" name="mode" id="mode" value="edit_team_commit" />
		<input type="hidden" name="id" id="id" value="%(team_id)d" />
	
		<input type="hidden" name="requestTime" id="requestTime" value="' . $the_team->requestTime . '" />
	
		<label for="active">Active:</label>&nbsp;&nbsp;
		%(active_check_box)s
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

		<label for="ir">IR:</label>&nbsp;&nbsp;
		%(ir_check_box)s
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

		<label for="hidden">Hidden:</label>&nbsp;&nbsp;
		%(hidden_check_box)s
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	
		<label for="not_a_team">Not a team:</label>&nbsp;&nbsp;
		%(not_a_team_check_box)s
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

		<label for="dead">Dead:</label>&nbsp;&nbsp;
		%(dead_check_box)s
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

		<label for="not_in_queue">Not in queue:</label>&nbsp;&nbsp;
		%(not_in_queue_check_box)s
		<br />
		""" % {	'team_id':					team_id,
				'name':				the_team.name,
				'team_population':			common.number_format(the_team.population),
				'active_check_box':			common.check_box('active', the_team.active),
				'ir_check_box':				common.check_box('ir', the_team.ir),
				'hidden_check_box':			common.check_box('hidden', the_team.hidden),
				'not_a_team_check_box':		common.check_box('not_a_team', the_team.not_a_team),
				'dead_check_box':			common.check_box('dead', the_team.dead),
				'not_in_queue_check_box':	common.check_box('not_in_queue', the_team.not_in_queue),
				})

	# Row 1
	output.append("""
		<table border="0" cellspacing="5" cellpadding="5" style="width:100%%;">
			<tr>
				<td><label for="forum_url_id">Forum URL id:</label></td>
				<td>%(forum_text_box)s</td>
		
				<td width="5">&nbsp;</td>
		
				<td><label for="orders_topic">Orders topic:</label></td>
				<td>%(orders_text_box)s</td>
		
				<td width="5">&nbsp;</td>
		
				<td><label for="intorders_topic">Int Orders topic:</label></td>
				<td>%(intorders_text_box)s</td>
			</tr>""" % {'forum_text_box':		common.text_box('forum_url_id', the_team.forum_url_id, warn_on = lambda x:(True if x < 0 else False)),
						'orders_text_box':		common.text_box('orders_topic', the_team.orders_topic, warn_on = lambda x:(True if x < 0 else False)),
						'intorders_text_box':	common.text_box('intorders_topic', the_team.intorders_topic, warn_on = lambda x:(True if x < 0 else False)),
						})


	# Row 2
	output.append("""
			<tr>
				<td><label for="results_topic">Results topic:</label></td>
				<td>{results_topic}</td>
			
				<td width="5">&nbsp;</td>
			
				<td><label for="teaminfo_topic">Team info topic:</label></td>
				<td>{teaminfo_topic}</td>
			
				<td width="5">&nbsp;</td>
			
				<td><label for="team_info_first_post">Team info first post:</label></td>
				<td>{team_info_first_post}</td>
			</tr>""".format(
			results_topic			= common.text_box('results_topic', the_team.results_topic, warn_on = lambda x:(True if x < 0 else False)),
			teaminfo_topic			= common.text_box('teaminfo_topic', the_team.teaminfo_topic, warn_on = lambda x:(True if x < 0 else False)),
			team_info_first_post	= common.text_box('team_info_first_post', the_team.team_info_first_post, warn_on = lambda x:(True if x < 0 else False)),
			))

	# Row 3
	output.append("""
			<tr>
				<td><label for="request_topic">Request topic:</label></td>
				<td>%(request_topic)s</td>
			
				<td width="5">&nbsp;</td>
			
				<td><label for="leader_id">Leader:</label></td>
				<td>%(leader_id)s</td>
			
				<td width="5">&nbsp;</td>
		
				<td>Culture topic:</td>
				<td>%(culture_topic)s</td>
			</tr>""" % {'leader_id':		common.text_box('leader_id', the_team.leader_id, warn_on = lambda x:(True if x < 1 else False)),
						'request_topic':	common.text_box('request_topic', the_team.request_topic, warn_on = lambda x:(True if x < 1 else False)),
						'culture_topic':	common.text_box('culture_topic', the_team.culture_topic, warn_on = lambda x:(True if x < 1 else False)),
					})
	
	output.append("""
	<tr>
		<td><label for="default_borders">Default borders:</label></td>
		<td>%(default_borders)s</td>
		
		<td width="5">&nbsp;</td>
		
		<td><label for="default_taxes">Default taxes:</label></td>
		<td>%(default_taxes)s</td>
		
		<td width="5">&nbsp;</td>
		
		<td><label for="evo_points">Evo points:</label></td>
		<td>%(evo_points)s</td>
	</tr>
	<tr>
		<td colspan="8" style="padding:0px;border-bottom:3px #EEE double;"></td>
	</tr>
	""" % {
		"default_borders":		common.option_box("default_borders", elements=team.border_states, selected=team.border_states[the_team.default_borders]),
		"default_taxes":		common.text_box('default_taxes', the_team.default_taxes, warn_on = lambda x:(True if int(x) < 0 else False), size=4),
		"evo_points":			common.text_box('evo_points', the_team.evo_points, warn_on = lambda x:(True if int(x) < 0 else False)),
	})
	
	output.append("""
			<!--
			<tr>
				<td>Previous resources:</td>
				<td>%(previous_resources)s</td>
			</tr>
			-->
	""" % {
		"previous_resources":	the_team.previous_resources,
		})
	
	# End row
	output.append("""
			<tr>
				<td>Join turn:</td>
				<td>%(join_turn)s</td>

				<td width="5">&nbsp;</td>

				<td>Primary:</td>
				<td>%(primary_colour)s</td>
			
				<td width="5">&nbsp;</td>

				<td>Secondary:</td>
				<td>%(secondary_colour)s</td>
			</tr>
		</table>
		<br />
	
		<input type="submit" value="Perform edit" />
		<input style="float:right; margin-right:100px;" type="button" value="Purge team" onclick="setTimeout('document.location=\\'web.py?mode=purge_team&team=%(team_id)s\\'', 0);"/>
	<a class="block_link" href="web.py?mode=ti&amp;post_output=1&amp;team=%(team_id)s">Update my TI</a>

	<br />""" % {
		"team_id":				team_id,
		'join_turn':			common.text_box('join_turn', the_team.join_turn),
		'previous_resources':	common.text_box('previous_resources', the_team.previous_resources, size=56),
	
		"primary_colour":		common.text_box('primary_colour', the_team.primary_colour),
		"secondary_colour":		common.text_box('secondary_colour', the_team.secondary_colour),
		})
		
	#	Resources
	#------------------------
	the_team.get_resources(cursor)
	
	output.append("""
	<table style="float:left; margin-right: 25px;" border="0" cellspacing="0" cellpadding="5">
	<tr class="row2">
		<th>Resource</th>
		<th>Amount</th>
	</tr>
	""")
	
	counter = -1
	for res_id, the_res in resource_list.data_dict.items():
		if the_res.category == resource_list.category['Map terrain feature']:
			continue
		
		# If it's not set then we need to give it a default
		if not res_id in the_team.resources.value:
			the_team.resources.value[res_id] = 0
		
		counter += 1
		
		output.append("""
		<tr class="row%(row)d">
			<td><label for="res_%(res_name)s">%(res_name)s</label></td>
			<td style="padding:1px;">%(res_amount)s</td>
		</tr>""" % {'row':			(counter % 2),
					'res_name':		the_res.name,
					'res_amount':	resource_f.print_form_element(res_id, the_team.resources[res_id])
					})
	
	output.append("</table></form>")# Subsequent forms are for other stuff
	
	#	Deities
	#----------------------
	the_team.get_deities(cursor)
	
	output.append("""
	<table style="float:left; margin-right: 25px;" border="0" cellspacing="0" cellpadding="5">
	<tr class="row2">
		<th>Deity</th>
		<th>&nbsp;</th>
	</tr>
	""")
	
	counter = -1
	for deity_id, team_favour in the_team.deities.items():
		counter += 1
		
		output.append("""
		<tr class="row%(row)d">
			<td><label for="%(name)s">%(name)s</label></td>
			<td style="padding: 0px;">
				<a class="block_link" href="exec.py?mode=remove_deity&amp;deity=%(deity_id)d&amp;team=%(team_id)d">Remove</a>
			</td>
		</tr>""" % {'row':			(counter % 2),
					'name':	deity_dict[deity_id].name,
					'deity_id':		deity_id,
					'team_id':		team_id
					})
	
	output.append("""
		<tr class="row%(row)d">
		<form id="team_add_deity_form" action="exec.py?mode=add_deity" method="post" accept-charset="utf-8">
			<input type="hidden" name="mode" value="add_deity" />
			<input type="hidden" name="team" value="%(team_id)s" />
			<td style="padding:1px;">
				<select name="deity">
					%(deity_option_box)s
				</select>
			</td>
			<td style="padding: 2px;">
				<input type="submit" value="Add" />
				<!--<a href="#" onclick="$('#team_add_deity_form').submit(); return false;" class="block_link">Add</a>-->
			</td>
		</tr>
		</form>
	</table>
	""" % {	'row':				((counter+1) % 2),
			'team_id':			the_team.id,
			'deity_option_box': deity_f.deity_option_list(cursor, the_team.deities)})
	
	
	#	Evolutions
	#-------------------
	the_team.get_evolutions(cursor)
	
	output.append("""
	<table style="float:left; margin-right: 25px;" border="0" cellspacing="0" cellpadding="5">
	<tr class="row2">
		<th>Evolution</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
	</tr>
	""")
	
	counter = -1
	for evo_id, evo_level in the_team.evolutions.items():
		counter += 1
		
		output.append("""
		<tr class="row%(row)d">
			<form id="edit_evo_%(evolution_id)s" action="exec.py" method="post" accept-charset="utf-8">
			<input type="hidden" name="mode" value="set_evolution" />
			<input type="hidden" name="team" value="%(team_id)s" />
			<input type="hidden" name="evolution" value="%(evolution_id)s" />
			<td><label for="%(name)s">%(name)s</label></td>
			<td style="padding:1px;">
				%(text_box)s
			</td>
			</form>
			<td style="padding: 0px;">
				<a class="block_link" href="exec.py?mode=set_evolution&amp;evolution=%(evolution_id)d&amp;team=%(team_id)d">Remove</a>
			</td>
		</tr>""" % {'row':				(counter % 2),
					'name':				evolution_dict[evo_id].name,
					'evolution_level':	evo_level,
					'evolution_id':		evo_id,
					'team_id':			team_id,
					
					"text_box": common.text_box("evolution_level", evo_level, custom_id="", size=3,
						warn_on = lambda e: (True if evolution_dict[evo_id].min_level > e or e > evolution_dict[evo_id].max_level else False)),
					})
	
	output.append("""
		<tr class="row%(row)d">
		<form id="team_add_evolution_form" action="exec.py" method="post" accept-charset="utf-8">
			<input type="hidden" name="mode" value="set_evolution" />
			<input type="hidden" name="team" value="%(team_id)d" />
			<td style="padding:1px;">
				<select name="evolution">
					%(evolution_option_box)s
				</select>
			</td>
			<td style="padding:1px;">
				%(evolution_level)s
			</td>
			<td style="padding: 0px;">
				<a href="#" onclick="$('#team_add_evolution_form').submit();" class="block_link">Add</a>
			</td>
		</tr>
		</form>
	</table>
	""" % {	'row':				((counter+1) % 2),
			'team_id':			the_team.id,
			'evolution_level':	common.text_box('evolution_level', 0, 4),
			'evolution_option_box': evolution_f.evolution_option_list(cursor, the_team.evolutions)})
	
	
	#	Traits
	#----------------------
	the_team.get_traits(cursor)
	
	output.append("""
	<table style="float:left; margin-right: 25px;" border="0" cellspacing="0" cellpadding="5">
	<tr class="row2">
		<th>Trait</th>
		<th>&nbsp;</th>
	</tr>
	""")
	
	counter = -1
	for trait_id in the_team.traits:
		counter += 1
		
		output.append("""
		<tr class="row%(row)d">
			<td><label for="%(name)s">%(name)s</label></td>
			<td style="padding: 0px;">
				<a class="block_link" href="exec.py?mode=remove_trait&amp;trait=%(trait_id)d&amp;team=%(team_id)d">Remove</a>
			</td>
		</tr>""" % {'row':			(counter % 2),
					'name':			trait_dict[trait_id].name,
					'trait_id':		trait_id,
					'team_id':		team_id
					})
	
	output.append("""
		<tr class="row%(row)d">
		<form id="team_add_trait_form" action="exec.py?mode=add_trait" method="post" accept-charset="utf-8">
			<input type="hidden" name="mode" value="add_trait" />
			<input type="hidden" name="team" value="%(team_id)s" />
			<td style="padding:1px;">
				<select name="trait">
					%(trait_option_box)s
				</select>
			</td>
			<td style="padding: 2px;">
				<input type="submit" value="Add" />
				<!--<a href="#" onclick="$('#team_add_trait_form').submit(); return false;" class="block_link">Add</a>-->
			</td>
		</tr>
		</form>
	</table>
	""" % {	'row':				((counter+1) % 2),
			'team_id':			the_team.id,
			'trait_option_box': trait_f.trait_option_list(cursor, the_team.traits)})
	
	
	# Hashes
	output.append("""
	<table style="float:left; margin-right: 25px;" border="0" cellspacing="0" cellpadding="5">
	<tr class="row2">
		<th>Turn</th>
		<th>Hash</th>
	</tr>
	""")

	for i, t in enumerate(range(common.current_turn(), common.current_turn()-5, -1)):
		output.append("""
		<tr class="row{i}">
			<td>{t}</td>
			<td>{hash}</td>
		</tr>""".format(
			i = i % 2,
			t = t,
			hash = team_f.team_hash(the_team.name, turn=t),
	))
	
	output.append("</table>")
	
	
	

	
	output.append("</div>")
	page_data['Title'] = "Edit team (%s)" % the_team.name
	return "".join(output)
Пример #8
0
def msn_run_orders(cursor, team_id):
	the_team = team_q.get_one_team(cursor, team_id)
	
	# Get orders
	getter_data = "p=%s&mode=latest_rr&topic=%s" % (common.data['getterPass'], the_team.request_topic)
	orders_str = urllib.request.urlopen(common.data['getter_url'], getter_data).read().strip()
	# print(common.data['getter_url'], getter_data)
	# return orders_str.decode('utf-8')
	
# 	orders_str = b"""-POST_SEPERATOR-                                                                                                                                                                             
# -START OF POST-
# post id:48143
# poster id:2
# -START OF ORDER 48143-
# 
# [o]Construction[/o]
# Build 25k Fortifications at Ashkar
# Build Border forts at Candor
# 
# [o]Military[/o]
# 
# Select army: Expeditionary fleet
# Reinforce squad: the Divine Wind, 100
# 
# [o]Research[/o]
# Architecture
# Covert training
# Dazzle
# Fireball
# 
# -END OF ORDER 48143-
# -END OF POST-
# """
	
	orders_str = orders_str.decode('utf-8')
	orders_str = re.sub(r'-END OF ORDER [0-9]*-', '', orders_str)
	orders_str = orders_str.replace('-END OF POST-', '')
	
	# Prep world
	the_world = world.World(cursor)
	the_world.prep_for_orders()
	
	the_team = the_world.teams()[team_id]
	produced_resources, new_resources = team_rules.produce_resources(cursor, the_team, the_world, force_requery=True)
	the_team.resources = new_resources
	
	blocks = convert_orders(the_world, the_team, orders_str)
	output = []
	
	# Setup
	for b in blocks:
		b.setup(msn_order=True)
	
	# Execution
	for b in blocks:
		b.execute()
	
	for b in blocks:
		output.append("""
[o]{name}[/o]
{input}\n
[fullbox={background},{border}]{results}[/fullbox]
""".format(
			name=b.title_name,
			cost=str(b.cost),
			input="\n".join(b.input_response).strip(),
			results="\n".join(b.results).strip(),
			background=b.background_colour,
			border=b.border_colour,
		))
	
	# return "".join(output)
	post_request_result(the_team, "".join(output))
	return "Orders run (%s)" % the_team.name
Пример #9
0
def main(cursor):
	# Get team Id
	team_id = int(common.get_val('team', 0))
	text_location = common.get_val('location', "")
	
	# Build team
	the_team = team_q.get_one_team(cursor, team_id)
	cities_dict = city_q.get_cities_from_team(cursor, team=team_id, include_dead=0)
	
	if team_id < 1:
		return "<div style='padding: 5px;'>%s</div>" %  common.select_team_form(cursor, 'list_armies')
		exit()
	
	armies_dict = army_q.get_armies_from_team(cursor, team=team_id, include_garrisons=1)
	
	output = []
	output.append("""
	<table border="0" cellspacing="0" cellpadding="5" style="width: 100%;">
		<tr class="row2">
			<th>Army</th>
			<th>Location</th>
			<th>Base</th>
			<th>Size</th>
			<th>&nbsp;</th>
			<th>&nbsp;</th>
		</tr>""")
	
	names = {}
	
	if len(armies_dict) > 0:
		count = -1
		
		# for team_id, team in team_dict.items():
		for army_id, the_army in armies_dict.items():
			count += 1
			
			city_location = the_army.garrison
			
			if the_army.garrison > 0:
				location = "Garrison"
			
			else:
				location = "%s, %s" % (the_army.x, the_army.y)
			
			if the_army.base in cities_dict:
				base_name = cities_dict[the_army.base].name
			else:
				base_name = "N/A"
			
			output.append("""
			<tr class="row%(row)d" id="%(army_id)d">
				<td><strong>%(name)s</strong></td>
				<td>%(location)s</td>
				<td>%(base)s</td>
				<td>%(size)s</td>
				
				<td style="padding: 0px;">
					<a class="block_link" id="show_squads_%(army_id)d" href="#" onclick="$('#div_%(army_id)d').load('web.py', {'mode':'list_squads', 'ajax':'True', 'army':'%(army_id)d'}, function () {$('#tr_%(army_id)d').fadeIn(0); $('#show_squads_%(army_id)d').fadeOut(0); $('#hide_squads_%(army_id)d').fadeIn(0);}); return false;">Show squads</a>
				<a id="hide_squads_%(army_id)d" style="display:none;" class="block_link" href="#" onclick="$('#tr_%(army_id)d').fadeOut(0); $('#show_squads_%(army_id)d').fadeIn(0); $('#hide_squads_%(army_id)d').fadeOut(0); return false;">Hide squads</a></td>
				
				<td style="padding: 0px;"><a class="block_link" href="web.py?mode=edit_army&amp;army=%(army_id)d">Edit army</a></td>
			</tr>
			<tr style="display: none;" id="tr_%(army_id)d">
				<td colspan="5" style="padding: 0 10px 10px 10px;">
					<div id="div_%(army_id)d">
						&nbsp;
					</div>
				</td>
			</tr>
			""" % {	'row': (count % 2),
					
					"army_id":		army_id,
					"name":			common.doubleclick_text("armies", "name", army_id, the_army.name, "font-weight:bold", size=18),
					"base":			base_name,
					"location":		location,
					"size":			the_army.get_size(cursor),
					})
	
	# Add new army thingie
	names = {}
	for c, the_city in cities_dict.items():
		names[c] = the_city.name
	
	count += 1
	output.append("""
	<tr class="row%(row)d">
		<form action="exec.py" id="add_army_form" method="post" accept-charset="utf-8">
		<input type="hidden" name="mode" value="add_army" />
		<input type="hidden" name="team" value="%(team_id)s" />
		<td style="padding: 1px;"><input type="text" id="new_name" name="name" value="" /></td>
		<td>&nbsp;</td>
		<td style="padding: 1px;">
			%(city_location)s
			&nbsp;&nbsp;&nbsp;
			%(text_location)s
		</td>
		<td style="padding: 0px;"><a href="web.py?mode=view_map&amp;new_mode=list_armies&amp;team=%(team_id)s" class="block_link">Pick location</a></td>
		<td colspan="2" style="padding: 0px;"><a class="block_link" href="#" onclick="$('#add_army_form').submit(); return false;">Add</a></td>
		</form>
		%(onload)s
	</tr>
	""" % {	'row': (count % 2),
			
			"team_id":			team_id,
			'city_location':	common.option_box(
				name='city_location',
				elements=names,
				element_order=cities_dict.keys(),
				custom_id="",
			),
			
			"text_location":	common.text_box("text_location", text_location, custom_id=""),
			"onload":			common.onload("$('#new_name').focus();")
			})	
	
	output.append("</table>")
	
	return "".join(output)
Пример #10
0
def main(cursor):
	team_id		= int(common.get_val("team", 0))
	turn		= int(common.get_val("turn", -1))
	
	turn = 81
	team_id = 83# Clan
	team_id = 71# Shrikes
	# team_id = 72# Daninia
	
	# Defaults
	if team_id < 1:
		return "<div style='padding: 5px;'>%s</div>" % common.select_team_form(cursor, 'view_orders')
	
	if turn < 1:
		turn = common.current_turn()
	
	# Build some handles
	the_world = world.World(cursor)
	player_dict = the_world.players()
	
	the_team = team_q.get_one_team(cursor, team_id)
	the_orders = the_team.get_orders(cursor, the_world, "international", turn)
	
	output = ["<div style='padding: 5px;'>"]
	player_updates = {}
	
	# Make sure we have the orders in place
	for o in the_orders:
		intorder_f.create_default(cursor, o)
	
	# Bulk get
	intorders = intorder_q.get_orders_from_posts(cursor, [o.post_id for o in the_orders])
	intorder_q.mass_get_parents(cursor, intorders)
	
	for i, o in intorders.items():
		# if o.parent.content == "Orders placeholder": continue
		
		sections = o.split()
		
		for s in sections:
			output.append("""
			<div class="intorder">
				<a href="http://woarl.com/board/memberlist.php?mode=viewprofile&amp;u={player.id}">{player.name}</a>:
				<a href="http://woarl.com/board/viewtopic.php?p={the_order.post_id}#p{the_order.post_id}">{the_order.post_id}</a>
				<br />
				
				{content}
			</div>""".format(
				intorder = o,
				player = player_dict[o.parent.player],
				the_order = o.parent,
				s = s,
				
				content = common.bbcode_to_html(s.content),
			))
		
		
		# output.append('<br /><hr />Post: <a href="http://woarl.com/board/viewtopic.php?p=%s#p%s">%s</a><br />' % (o.parent.post_id, o.parent.post_id, o.parent.post_id))
		# output.append('Poster: <a href="http://woarl.com/board/memberlist.php?mode=viewprofile&u=%s">%s</a><br />' % (o.parent.player, player_dict[o.parent.player].name))
		# 
		# output.append(common.bbcode_to_html(o.parent.content.replace('{SMILIES_PATH}', 'http://woarl.com/board/images/smilies')))
		# 
		# output.append(str(the_order.parent.topic))
		# output.append("<br />")
	
	output.append("</div>")
	
	# TODO update player activity
	
	# print "<br />".join(output)
	page_data['Title'] = "%s International orders" % the_team.name
	return "".join(output)
Пример #11
0
def main(cursor):
	# Get team Id
	team_id = int(common.get_val('team', 0))
	
	if team_id < 1:
		return "<div style='padding: 5px;'>%s</div>" % common.select_team_form(cursor, 'list_spells')
	
	# Build team item
	the_team = team_q.get_one_team(cursor, team_id)
	spell_dict = spell_q.get_all_spells(cursor)
	
	output = []
	
	the_team.get_spells(cursor)
	
	output.append("""
	<table style="width: 100%;" border="0" cellspacing="0" cellpadding="5">
	<tr class="row2">
		<th>#</th>
		<th>&nbsp;</th>
	</tr>
	""")
	
	max_spell_level = 1
	skip_spell_list = {}
	table_dict = {}
	spell_points_spent = 0
	
	for spell_id, spell_level in the_team.spell_levels.items():
		if spell_level not in table_dict:
			table_dict[spell_level]			= []
			skip_spell_list[spell_level]	= []
		max_spell_level = max(max_spell_level, spell_level)
		
		# Total that they've spent
		the_spell = spell_dict[spell_id]
		spell_points_spent += spell_rules.cost_to_get_to_level(cursor, the_spell, spell_level, in_spell_points=True).get("Spell points", 0)
		spell_points_spent += the_team.spell_points[spell_id]
		
		skip_spell_list[spell_level].append(spell_id)
		
		
		table_dict[spell_level].append("""%(name)s <a class="red_link" href="exec.py?mode=set_spell&amp;spell=%(spell_id)s&amp;team=%(team_id)s&amp;level=%(level_down)s&amp;points=0">&nbsp;&lt;&nbsp;</a>
			
			%(points)s/%(points_to_next)s
			
			<a class="green_link" href="exec.py?mode=set_spell&amp;spell=%(spell_id)s&amp;team=%(team_id)s&amp;level=%(level_up)s&amp;points=0">&nbsp;&gt;&nbsp;</a>""" % {
		"name":			the_spell.name,
		"spell_id":		spell_id,
		"team_id":		team_id,
		"points":			the_team.spell_points[spell_id],
		"points_to_next":	spell_rules.cost_for_next_level(cursor, the_spell, spell_level, in_spell_points=True).get("Spell points"),
		"level_down":	spell_level-1,
		"level_up":		spell_level+1,
		})
	
	
	for i in range(0, max_spell_level+1):
		if i not in table_dict:
			table_dict[i] = []
			skip_spell_list[i] = []
		
		output.append("""
		<tr class="row%(row_count)s">
			<td width="15">%(i)s</td>
			<td style="padding: 5px 2px 0 2px;">%(spells)s
			
			<!--
				<form id="spell_form_%(i)s" style="float: right;" action="exec.py" method="post" accept-charset="utf-8">
			<input type="hidden" name="mode" value="set_spell" />
			<input type="hidden" name="team" value="%(team_id)s" />
			<input type="hidden" name="points" value="0" />
			<input type="hidden" name="level" value="%(i)s" />
			<a href="#" onclick="$('#spell_form_%(i)s').submit();" class="block_link" style="float: right;">Add</a>
			<select style="float: right;" name="spell">%(new_spell)s</select></form>
			-->
			</td>
		</tr>
		""" % {
			"i":			i,
			"team_id":		team_id,
			"row_count":	(i%2),
			"spells":		", ".join(table_dict[i]),
			"new_spell":	spell_f.spell_option_list(cursor, skip_spell_list[i]),
		})
	
	# Add spells
	output.append("""
	<tr class="row%(row_count)s">
		<td colspan="2">
			<form action="exec.py" method="post" accept-charset="utf-8">
				<input type="hidden" name="mode" value="set_spell" />
				<input type="hidden" name="team" value="%(team_id)s" />
				<select name="spell" id="new_spell">
					%(spell_list)s
				</select>
				&nbsp;&nbsp;
				L: <input type="text" name="level" id="new_level" value="" onblur="$('#points_to_next').load('web.py', {'ajax':'True','mode':'spell_points_for_next','spell':$('#new_spell').val(), 'level':$('#new_level').val()});" size="5"/>
				&nbsp;&nbsp;
				P: <input type="text" name="points" value="" size="5" />/<span id="points_to_next">0</span>
				<input type="submit" value="Add" />
			</form>
		</td>
	</tr>
	%(onload)s
	""" % {
		"team_id":		team_id,
		"row_count":	((i+1)%2),
		"spell_list":	spell_f.spell_option_list(cursor),
		"onload":		common.onload("$('#new_spell').focus();"),
	})
	
	output.append("</table>")
	
	output.append("<br />&nbsp;&nbsp;&nbsp;Total spell points spent: %d" % spell_points_spent)
	
	return "".join(output)