Beispiel #1
0
def alter_upkeep(cursor, the_team, upkeep_cost, the_world=None):
	"""Alters the team upkeep as needed"""
	if the_world == None:
		affinity_for_war = evolution_q.get_one_evolution(cursor, "Affinity for war")
	else:
		affinity_for_war = the_world.evolutions()[the_world.evolutions_lookup()['Affinity for war']]
	
	# Affinity for war evo
	team_evolutions = the_team.get_evolutions(cursor)
	
	multiplier = 1
	if affinity_for_war.id in team_evolutions:
		level = team_evolutions[affinity_for_war.id]
		if level > 0:
			multiplier = (1-(level*0.05))
		else:
			multiplier = (1+(level*0.1))
	
	return upkeep_cost * multiplier
Beispiel #2
0
def main(cursor):
	page_data['Redirect'] = ''
	
	evolution		= int(common.get_val("evolution", 0))
	level			= int(common.get_val("evolution_level", 0))
	team_id			= int(common.get_val("team", 0))
	
	current_level = evolution_q.get_one_evolution_level(cursor, evolution, team_id)
	
	# Do we need to save it?
	if level == current_level: return ""
	
	# Cost?
	the_evo = evolution_q.get_one_evolution(cursor, evolution)
	
	diff = level - current_level
	
	# Are we refunding?
	if diff < 0 and current_level > 0:
		if current_level > 0:
			cost = diff * the_evo.cost_per_level/2
	else:
		cost = diff * the_evo.cost_per_level
	
	# if current_level > level and level >= 0:
	# 	cost = ((level - current_level) * the_evo.cost_per_level)/2
	# elif current_level > level and level < 0:
	# 	pos_refund = (current_level * the_evo.cost_per_level)/2
	# 	neg_refund = (-level) * the_evo.cost_per_level
	# 	
	# 	cost = -(pos_refund + neg_refund)
	# else:
	# 	cost = (level - current_level) * the_evo.cost_per_level
	
	# print("")
	# print(cost)
	# exit()
	
	database.query(cursor, team_f.set_evolution(team=team_id, evolution=evolution, level=level, evo_cost=cost))
	
	page_data['Redirect'] = 'edit_team&team={0:d}'.format(team_id)
	return ""