Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3.2
- import re
- import urllib.request
- def getPokemans():
- url = 'http://bulbapedia.bulbagarden.net/w/index.php?title=List_of_Pok%C3%A9mon_by_type&action=edit'
- data = urllib.request.urlopen(url).read().decode('utf8')
- data = data[data.find('>', data.find('textarea')) + 1:data.find('</textarea>')]
- data = [i[:i.find('}')].split('|') for i in data.split('{{Abilityentry1|')][1:]
- names = [i[1] for i in data]
- types = [i[3:] for i in data]
- pokemans = dict(zip(names,types))
- print('Got pokemon types...')
- return pokemans
- def getMoves():
- url = 'http://bulbapedia.bulbagarden.net/w/index.php?title=List_of_moves&action=edit'
- data = urllib.request.urlopen(url).read().decode('utf8')
- data = data[data.find('>', data.find('textarea')) + 1:data.find('</textarea>')]
- names = [i[1:i.find('}')] for i in re.split('{{m', data)][1:]
- types = [i[1:i.find('}')] for i in re.split('{{typetable', data)][1:]
- moves = dict(zip(names, types))
- print('Got move list...')
- return moves
- def getModifiers():
- indexes = 'Normal', 'Fighting', 'Flying', 'Poison', 'Ground', 'Rock', 'Bug', 'Ghost', 'Steel', 'Fire', 'Water', 'Grass', 'Electric', 'Psychic', 'Ice', 'Dragon', 'Dark'
- copypasta = [line.split(' ') for line in
- '''1× 1× 1× 1× 1× ½× 1× 0× ½× 1× 1× 1× 1× 1× 1× 1× 1×
- 2× 1× ½× ½× 1× 2× ½× 0× 2× 1× 1× 1× 1× ½× 2× 1× 2×
- 1× 2× 1× 1× 1× ½× 2× 1× ½× 1× 1× 2× ½× 1× 1× 1× 1×
- 1× 1× 1× ½× ½× ½× 1× ½× 0× 1× 1× 2× 1× 1× 1× 1× 1×
- 1× 1× 0× 2× 1× 2× ½× 1× 2× 2× 1× ½× 2× 1× 1× 1× 1×
- 1× ½× 2× 1× ½× 1× 2× 1× ½× 2× 1× 1× 1× 1× 2× 1× 1×
- 1× ½× ½× ½× 1× 1× 1× ½× ½× ½× 1× 2× 1× 2× 1× 1× 2×
- 0× 1× 1× 1× 1× 1× 1× 2× ½× 1× 1× 1× 1× 2× 1× 1× ½×
- 1× 1× 1× 1× 1× 2× 1× 1× ½× ½× ½× 1× ½× 1× 2× 1× 1×
- 1× 1× 1× 1× 1× ½× 2× 1× 2× ½× ½× 2× 1× 1× 2× ½× 1×
- 1× 1× 1× 1× 2× 2× 1× 1× 1× 2× ½× ½× 1× 1× 1× ½× 1×
- 1× 1× ½× ½× 2× 2× ½× 1× ½× ½× 2× ½× 1× 1× 1× ½× 1×
- 1× 1× 2× 1× 0× 1× 1× 1× 1× 1× 2× ½× ½× 1× 1× ½× 1×
- 1× 2× 1× 2× 1× 1× 1× 1× ½× 1× 1× 1× 1× ½× 1× 1× 0×
- 1× 1× 2× 1× 2× 1× 1× 1× ½× ½× ½× 2× 1× 1× ½× 2× 1×
- 1× 1× 1× 1× 1× 1× 1× 1× ½× 1× 1× 1× 1× 1× 1× 2× 1×
- 1× ½× 1× 1× 1× 1× 1× 2× ½× 1× 1× 1× 1× 2× 1× 1× ½×'''.replace('×','').replace('½', '0.5').splitlines()]
- copypasta = [[float(i) for i in line if i!=''] for line in copypasta]
- modifiers = dict(zip(indexes, copypasta))
- for k in modifiers:
- modifiers[k] = dict(zip(indexes, modifiers[k]))
- return modifiers
- if __name__=='__main__':
- modifiers = getModifiers()
- moves = getMoves()
- pokemans = getPokemans()
- while True:
- x = input().split(' -> ')
- if x == '': break
- try:
- move = moves[x[0]]
- def_type = pokemans[x[1]]
- result = 1
- for t in def_type:
- result *= modifiers[move][t]
- if result == 0: print('It has no effect')
- elif result < 1: print('Not very effective...')
- elif result == 1: print('It hit!')
- elif result > 1: print("It's super effective!")
- except:
- print('Entry not found.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement