Skip to content

Instantly share code, notes, and snippets.

@Xyphis12
Last active January 4, 2016 13:39
Show Gist options
  • Save Xyphis12/8629694 to your computer and use it in GitHub Desktop.
Save Xyphis12/8629694 to your computer and use it in GitHub Desktop.
Pokemon Type Matchup Tool
# Pokemon Type Matchups Tool
types = {
'bug' : {
'attack': {
'doublex': ('psychic', 'grass', 'dark'),
'halfx': ('fighting', 'fire', 'flying', 'ghost', 'poison', 'steel', 'fairy'),
'zerox': ()
},
'defend': {
'halfx': ('fighting', 'grass', 'ground'),
'doublex': ('fire', 'flying', 'rock'),
'zerox': ()
},
},
'dark' : {
'attack': {
'doublex': ('ghost', 'psychic'),
'halfx': ('dark', 'fighting', 'fairy'),
'zerox': ()
},
'defend': {
'halfx': ('dark', 'ghost'),
'doublex': ('bug', 'fighting', 'fairy'),
'zerox': ('psychic',)
}
},
'dragon' : {
'attack': {
'doublex': ('dragon',),
'halfx': ('steel',),
'zerox': ('fairy',)
},
'defend': {
'halfx': ('electric', 'fire', 'grass', 'water'),
'doublex': ('dragon', 'ice', 'fairy'),
'zerox': ()
}
},
'electric' : {
'attack': {
'doublex': ('flying', 'water'),
'halfx': ('dragon', 'electric', 'grass'),
'zerox': ('ground',)
},
'defend': {
'halfx': ('electric', 'flying', 'steel'),
'doublex': ('ground',),
'zerox': ()
}
},
'fairy' : {
'attack': {
'doublex': ('dark', 'dragon', 'fighting'),
'halfx': ('fire', 'poison', 'steel'),
'zerox': ()
},
'defend': {
'halfx': ('bug', 'dark', 'fighting'),
'doublex': ('poison', 'steel'),
'zerox': ('dragon',)
}
},
'fighting' : {
'attack': {
'doublex': ('dark', 'ice', 'normal', 'rock', 'steel'),
'halfx': ('bug', 'fairy', 'flying', 'poison', 'psychic'),
'zerox': ('ghost',)
},
'defend': {
'halfx': ('bug', 'dark', 'rock'),
'doublex': ('fairy', 'flying', 'psychic'),
'zerox': ()
}
},
'fire' : {
'attack': {
'doublex': ('bug', 'grass', 'ice', 'steel'),
'halfx': ('dragon', 'fire', 'rock', 'water'),
'zerox': ()
},
'defend': {
'halfx': ('bug', 'fairy', 'fire', 'grass', 'ice', 'steel'),
'doublex': ('bug', 'fire', 'flying', 'ice', 'poison'),
'zerox': ()
}
},
'flying' : {
'attack': {
'doublex': ('bug', 'fighting', 'grass'),
'halfx': ('electric', 'rock', 'steel'),
'zerox': ()
},
'defend': {
'halfx': ('bug', 'fighting', 'grass'),
'doublex': ('electric', 'ice', 'rock'),
'zerox': ('ground',)
}
},
'ghost' : {
'attack': {
'doublex': ('ghost', 'psychic'),
'halfx': ('dark',),
'zerox': ('normal',)
},
'defend': {
'halfx': ('bug', 'poison'),
'doublex': ('ghost', 'dark'),
'zerox': ('normal','fighting')
}
},
'grass' : {
'attack': {
'doublex': ('ground', 'rock', 'water'),
'halfx': ('bug', 'dragon', 'fire', 'flying', 'grass', 'poison', 'steel'),
'zerox': ()
},
'defend': {
'halfx': ('electric', 'grass', 'ground', 'water'),
'doublex': ('bug', 'fire', 'flying', 'ice', 'poison'),
'zerox': ()
}
},
'ground' : {
'attack': {
'doublex': ('electric', 'fire', 'poison', 'rock', 'steel'),
'halfx': ('bug', 'grass'),
'zerox': ('flying',)
},
'defend': {
'halfx': ('poison', 'rock'),
'doublex': ('grass', 'ice', 'water'),
'zerox': ('electric',)
}
},
'ice' : {
'attack': {
'doublex': ('dragon', 'flying', 'grass', 'ground'),
'halfx': ('fire', 'ice', 'steel', 'water'),
'zerox': ()
},
'defend': {
'halfx': ('ice',),
'doublex': ('fighting', 'fire', 'rock', 'steel'),
'zerox': ()
}
},
'normal' : {
'attack': {
'doublex': (),
'halfx': ('rock', 'steel'),
'zerox': ('ghost',)
},
'defend': {
'halfx': (),
'doublex': ('fighting',),
'zerox': ('ghost',)
}
},
'poison' : {
'attack': {
'doublex': ('grass', 'fairy'),
'halfx': ('ghost', 'ground', 'poison', 'rock'),
'zerox': ('steel',)
},
'defend': {
'halfx': ('bug', 'fairy', 'fighting', 'grass', 'poison'),
'doublex': ('ground', 'psychic'),
'zerox': ()
}
},
'psychic' : {
'attack': {
'doublex': ('fighting', 'poison'),
'halfx': ('psychic', 'steel'),
'zerox': ('dark',)
},
'defend': {
'halfx': ('fighting', 'psychic'),
'doublex': ('bug', 'dark', 'ghost'),
'zerox': ()
}
},
'rock' : {
'attack': {
'doublex': ('bug', 'fire', 'flying', 'ice'),
'halfx': ('fighting', 'ground', 'steel'),
'zerox': ()
},
'defend': {
'halfx': ('fire', 'flying', 'normal', 'poison'),
'doublex': ('fighting', 'grass', 'ground', 'steel', 'water'),
'zerox': ()
}
},
'steel' : {
'attack': {
'doublex': ('fairy', 'ice', 'rock'),
'halfx': ('electric', 'fire', 'steel', 'water'),
'zerox': ()
},
'defend': {
'halfx': ('bug', 'dragon', 'fairy', 'flying', 'grass', 'ice', 'normal', 'psychic', 'rock', 'steel'),
'doublex': ('fighting', 'fire', 'ground'),
'zerox': ('poison' ,)
}
},
'water' : {
'attack': {
'doublex': ('fire', 'ground', 'rock'),
'halfx': ('dragon', 'grass', 'steel'),
'zerox': ()
},
'defend': {
'halfx': ('fire', 'ice', 'steel', 'water'),
'doublex': ('electric', 'grass'),
'zerox': ()
}
}
}
def strong_against(poke_type):
'''Takes a dictionary and returns a tuple of dictionaries that inflicts double damage'''
if type(poke_type) == dict:
t = poke_type['defend']['doublex']
return t, None
else:
return None, "Not a dict {0}".format(poke_type)
def resolve1(s):
'''should return the type of a string of a pokemon type
this one assumes it's in this file
i'm not familiar with python dynamism anymore'''
try:
return types[s], None
except:
return None, "No such type {0}".format(s)
def listtypes(types):
# Generates a dict of numbers matched with types, and returns it
poke = dict((i+1, v) for (i, v) in enumerate(types))
for i in poke:
print i, poke[i]
return poke
def RF():
print "Which pokemon would you like to see Resestant from type matchups of"
poke=listtypes(types)
choice = int(raw_input('(Chose one) '))
name = str(poke.get(choice))
print resolve1(strong_against(name)[0])[0]
def intro():
# TODO: Make this not awful
print 'Welcome to dtalley11\' type matchup tool'
print 'What would you like to find out?'
print 'type Strong to, Weak to, Immune to, Resestant from, Weak from, Immune from'
choice = raw_input('(Chose one) ')
if choice == 'Strong to': return 'ST'
elif choice == 'Weak to': return 'WT'
elif choice == 'Immune to': return 'IT'
elif choice == 'Resestant from': return 'RF'
elif choice == 'Weak from': return 'WF'
elif choice == 'Immune from': return 'IF'
else: intro()
print strong_against(resolve1('fighting')[0])[0]
init = intro()
if init=='RF': RF()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment