gtfo has_key

This commit is contained in:
Loudrob 2015-07-20 19:02:13 -04:00
parent 1236e38d62
commit 43b138e338

View file

@ -33,7 +33,7 @@ WateringMult = 2
def getWateringCanPower(wateringCan, wateringCanSkill): def getWateringCanPower(wateringCan, wateringCanSkill):
numBoxes = 0 numBoxes = 0
for curWateringCan in range(wateringCan + 1): for curWateringCan in xrange(wateringCan + 1):
wateringCanAttrib = WateringCanAttributes[curWateringCan] wateringCanAttrib = WateringCanAttributes[curWateringCan]
curBoxes = wateringCanAttrib['numBoxes'] curBoxes = wateringCanAttrib['numBoxes']
skill = wateringCanAttrib['skillPts'] skill = wateringCanAttrib['skillPts']
@ -308,7 +308,7 @@ def getTreeTypeIndex(track, level):
NUM_GAGS = 7 * 7 NUM_GAGS = 7 * 7
for i in range(NUM_GAGS): for i in xrange(NUM_GAGS):
track, level = getTreeTrackAndLevel(i) track, level = getTreeTrackAndLevel(i)
if level <= 6: if level <= 6:
name = TTLocalizer.BattleGlobalAvPropStrings[track][level] + TTLocalizer.GardenGagTree name = TTLocalizer.BattleGlobalAvPropStrings[track][level] + TTLocalizer.GardenGagTree
@ -494,7 +494,7 @@ ShovelAttributes = {0: {'numBoxes': 2,
def getShovelPower(shovel, shovelSkill): def getShovelPower(shovel, shovelSkill):
numBoxes = 0 numBoxes = 0
for curShovel in range(shovel + 1): for curShovel in xrange(shovel + 1):
shovelAttrib = ShovelAttributes[curShovel] shovelAttrib = ShovelAttributes[curShovel]
curBoxes = shovelAttrib['numBoxes'] curBoxes = shovelAttrib['numBoxes']
skill = shovelAttrib['skillPts'] skill = shovelAttrib['skillPts']
@ -596,8 +596,8 @@ def getSpeciesVarietyGivenRecipe(recipeKey):
attrib = PlantAttributes[species] attrib = PlantAttributes[species]
if attrib['plantType'] == GAG_TREE_TYPE: if attrib['plantType'] == GAG_TREE_TYPE:
continue continue
if attrib.has_key('varieties'): if 'varieties' in attrib:
for variety in range(len(attrib['varieties'])): for variety in xrange(len(attrib['varieties'])):
if attrib['varieties'][variety][0] == recipeKey: if attrib['varieties'][variety][0] == recipeKey:
return (species, variety) return (species, variety)
@ -608,14 +608,14 @@ def getNumBeansRequired(species, variety):
retval = -1 retval = -1
if not PlantAttributes.get(species): if not PlantAttributes.get(species):
return retval return retval
if not PlantAttributes[species].has_key('varieties'): if 'varieties' not in PlantAttributes[species]:
return retval return retval
if variety >= len(PlantAttributes[species]['varieties']): if variety >= len(PlantAttributes[species]['varieties']):
return -1 return -1
recipeKey = PlantAttributes[species]['varieties'][variety][0] recipeKey = PlantAttributes[species]['varieties'][variety][0]
recipe = Recipes.get(recipeKey) recipe = Recipes.get(recipeKey)
if recipe: if recipe:
if recipe.has_key('beans'): if 'beans' in recipe:
retval = len(recipe['beans']) retval = len(recipe['beans'])
return retval return retval
@ -652,7 +652,7 @@ def validateRecipes(notify):
def validatePlantAttributes(notify): def validatePlantAttributes(notify):
uniqueRecipes = [] uniqueRecipes = []
flowerRecipeDistribution = [] flowerRecipeDistribution = []
for i in range(getNumberOfShovelBoxes() + 1): for i in xrange(getNumberOfShovelBoxes() + 1):
flowerRecipeDistribution.append([]) flowerRecipeDistribution.append([])
for key in PlantAttributes.keys(): for key in PlantAttributes.keys():
@ -674,7 +674,7 @@ def validatePlantAttributes(notify):
newInfo = (getFlowerVarietyName(key, list(varieties).index(variety)), Recipes[recipeNum]['beans'], TTLocalizer.FlowerColorStrings[variety[1]]) newInfo = (getFlowerVarietyName(key, list(varieties).index(variety)), Recipes[recipeNum]['beans'], TTLocalizer.FlowerColorStrings[variety[1]])
flowerRecipeDistribution[recipeLength].append(newInfo) flowerRecipeDistribution[recipeLength].append(newInfo)
for numBeans in range(len(flowerRecipeDistribution)): for numBeans in xrange(len(flowerRecipeDistribution)):
notify.debug('%d flowers with %d beans' % (len(flowerRecipeDistribution[numBeans]), numBeans)) notify.debug('%d flowers with %d beans' % (len(flowerRecipeDistribution[numBeans]), numBeans))
for flower in flowerRecipeDistribution[numBeans]: for flower in flowerRecipeDistribution[numBeans]:
notify.debug(' %s, beans = %s, color=%s' % (flower[0], flower[1], flower[2])) notify.debug(' %s, beans = %s, color=%s' % (flower[0], flower[1], flower[2]))