Reformatted output, added a readme

This commit is contained in:
Anna Rose Wiggins 2012-06-07 14:53:44 -04:00
parent 256c722345
commit 223f32d56d
2 changed files with 96 additions and 14 deletions

View file

@ -90,30 +90,54 @@ def get_types_eq(strengths, value):
return ret
def print_entry(src_list):
try:
print '{:10}'.format(src_list.pop(0)),
except IndexError:
print ' '*10,
def main():
type_list = parse_args().types
# These arrays tell us our best values against each type
# on attack and on defense
atk_strengths = calculate_attack_values(type_list)
def_strengths = calculate_defense_values(type_list)
print '\n{space}Attack\n{space}======\n'.format(space=' '*16)
print 'Strong Normal Weak Immune'
print '------ ------ ---- ------'
atk_list = get_types_gt(atk_strengths, 1.0)
print 'These types are super-effective against {} types\n{}\n'.format(len(atk_list), '\n'.join(atk_list))
strengths = calculate_attack_values(type_list)
strong_list = get_types_gt(strengths, 1.0)
normal_list = get_types_eq(strengths, 1.0)
weak_list = list(set(get_types_lt(strengths, 1.0)) - set(get_types_eq(strengths, 0.0)))
immune_list = get_types_eq(strengths, 0.0)
atk_list = get_types_lt(atk_strengths, 1.0)
print 'They cannot be effective against {} types\n{}\n'.format(len(atk_list), '\n'.join(atk_list))
while strong_list or normal_list or weak_list or immune_list:
print_entry(strong_list)
print_entry(normal_list)
print_entry(weak_list)
print_entry(immune_list)
print
def_list = get_types_eq(def_strengths, 0.0)
print 'They are immune to {} types\n{}\n'.format(len(def_list), '\n'.join(def_list))
def_list = list(set(get_types_lt(def_strengths, 1.0)) - set(get_types_eq(def_strengths, 0.0)))
print 'They can defend well against {} types\n{}\n'.format(len(def_list), '\n'.join(def_list))
strengths = calculate_defense_values(type_list)
def_list = get_types_gt(def_strengths, 1.0)
print 'They have no good defense against {} types\n{}\n'.format(len(def_list), '\n'.join(def_list))
strong_list = list(set(get_types_lt(strengths, 1.0)) - set(get_types_eq(strengths, 0.0)))
normal_list = get_types_eq(strengths, 1.0)
weak_list = get_types_gt(strengths, 1.0)
immune_list = get_types_eq(strengths, 0.0)
print '\n\n{space}Defend\n{space}======\n'.format(space=' '*16)
print 'Strong Normal Weak Immune'
print '------ ------ ---- ------'
while strong_list or normal_list or weak_list or immune_list:
print_entry(strong_list)
print_entry(normal_list)
print_entry(weak_list)
print_entry(immune_list)
print
print
def parse_args():