Reformatted output, added a readme
This commit is contained in:
parent
256c722345
commit
223f32d56d
52
poketypes.py
52
poketypes.py
|
@ -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():
|
||||
|
|
58
readme.md
Normal file
58
readme.md
Normal file
|
@ -0,0 +1,58 @@
|
|||
## Poketypes
|
||||
|
||||
Poketypes is a fairly simple tool for players of the Pokémon video game series.
|
||||
|
||||
It allows you to simply list a set of types that are present on your team, like so:
|
||||
|
||||
$ ./poketypes.py dragon grass ghost poison fire ice
|
||||
|
||||
|
||||
It will then treat these types as an aggregate, and let you know types your theoretical team is
|
||||
capable of being strong against both offensively and defensively. This is to help you spot potentially
|
||||
weaknesses when building a team.
|
||||
|
||||
For example, the above command will output:
|
||||
|
||||
```
|
||||
Attack
|
||||
======
|
||||
|
||||
Strong Normal Weak Immune
|
||||
------ ------ ---- ------
|
||||
water normal
|
||||
grass fire
|
||||
ice electric
|
||||
ground fighting
|
||||
flying poison
|
||||
psychic dark
|
||||
bug
|
||||
rock
|
||||
ghost
|
||||
dragon
|
||||
steel
|
||||
|
||||
|
||||
Defend
|
||||
======
|
||||
|
||||
Strong Normal Weak Immune
|
||||
------ ------ ---- ------
|
||||
steel flying normal
|
||||
electric psychic fighting
|
||||
fire rock
|
||||
ice ghost
|
||||
water dragon
|
||||
poison dark
|
||||
grass
|
||||
bug
|
||||
ground
|
||||
```
|
||||
|
||||
|
||||
You can also use it as a quick-reference for a single type's strengths and weaknesses by listing just that type.
|
||||
|
||||
|
||||
|
||||
### Todo
|
||||
|
||||
Currently the tool assumes you can switch to any of the listed types separately. At some point, I'll try to handle dual types in a sensible way.
|
Loading…
Reference in New Issue
Block a user