def get_result_extra_handicaps(game_info, red_score): net_red_handicap = get_net_handicap(game_info['team colours'], game_info['handicaps before this game']) additional_handicap = 1 if game_info['team colours'][0] == 'red': additional_handicap += 0.5 else: additional_handicap -= 0.5 additional_handicap += 0.1 * get_net_weight_advantage(game_info) net_red_handicap += additional_handicap winning_scores = get_winning_scores_raw(net_red_handicap) result = get_result(winning_scores, red_score) margin = abs(get_winning_margin(winning_scores, net_red_handicap, red_score)) if result == 'draw': result_string = "With this adjustment game would have been a perfect draw" elif result == 'red': result_string = "With this adjustment, red team would have won by {}".format(margin) elif result == 'blue': result_string = "With this adjustment, blue team would have won by {}".format(margin) elif result == 'red no change': result_string = "With this adjustment, red team would have won by {} so no handicap change".format(margin) else: result_string = "With this adjustment, blue team would have won by {} so no handicap change".format(margin) return paragraph( "Red team additional handicap with colour/positions/weight class adjustment of 1, 0.5, 0.1 is {}." .format(additional_handicap) ) + paragraph( result_string )
def print_page(title, page_content): print '''Content-Type: text/html <html> <head> <title>MK8: {}</title> </head> '''.format(title) for section_type, section_content in page_content: if section_type == 'table': print html_table(section_content) elif section_type == 'text': print paragraph(section_content) elif section_type == 'important text': print bold(paragraph(section_content)) else: raise Exception( "I don't know how to deal with this type of content: {}" .format(section_type) )
def get_result_extra_handicaps(game_info, red_score): net_red_handicap = get_net_handicap( game_info['team colours'], game_info['handicaps before this game']) additional_handicap = 1 if game_info['team colours'][0] == 'red': additional_handicap += 0.5 else: additional_handicap -= 0.5 additional_handicap += 0.1 * get_net_weight_advantage(game_info) net_red_handicap += additional_handicap winning_scores = get_winning_scores_raw(net_red_handicap) result = get_result(winning_scores, red_score) margin = abs( get_winning_margin(winning_scores, net_red_handicap, red_score)) if result == 'draw': result_string = "With this adjustment game would have been a perfect draw" elif result == 'red': result_string = "With this adjustment, red team would have won by {}".format( margin) elif result == 'blue': result_string = "With this adjustment, blue team would have won by {}".format( margin) elif result == 'red no change': result_string = "With this adjustment, red team would have won by {} so no handicap change".format( margin) else: result_string = "With this adjustment, blue team would have won by {} so no handicap change".format( margin) return paragraph( "Red team additional handicap with colour/positions/weight class adjustment of 1, 0.5, 0.1 is {}." .format(additional_handicap)) + paragraph(result_string)