def getAnimals(root): farm_location = get_location(root,'Farm') animals = {} for item in farm_location.find('buildings').iter('Building'): buildingtype = item.get(ns+'type') name = item.find('buildingType').text if buildingtype in animal_habitable_buildings: for animal in item.find('indoors').find('animals').iter('item'): animal = animal.find('value').find('FarmAnimal') an = animal.find('name').text aa = int(animal.find('age').text) at = animal.find('type').text ah = int(animal.find('happiness').text) ahx = int(animal.find('homeLocation').find('X').text) ahy = int(animal.find('homeLocation').find('Y').text) animaltuple = (an,aa,ah,ahx,ahy,name) try: animals[at].append(animaltuple) except KeyError: animals[at] = [animaltuple] horse = getNPCs(root,['Farm'],['Horse']) if horse != []: animals['horse']=horse[0].find('name').text return animals
def getFarmInfo(saveFile): ns = "{http://www.w3.org/2001/XMLSchema-instance}" farm = {} root = saveFile.getRoot() # Farm Objects s = [] farm_location = get_location(root, 'Farm') farm_age = int(root.find('player').find('stats').find('DaysPlayed').text) day_of_season = int(root.find('player').find('dayOfMonthForSaveGame').text) is_last_week_of_season = day_of_season > 21 for item in farm_location.find('objects').iter("item"): f = False obj = item.find('value').find('Object') name = obj.find('name').text x = int(item.find('key').find('Vector2').find('X').text) y = int(item.find('key').find('Vector2').find('Y').text) i = int(obj.find('parentSheetIndex').text) try: t = obj.find('type').text except: continue a = False other = obj.find('name').text if name == 'Chest': colours = obj.find('playerChoiceColor') try: red = int(colours.find('R').text) green = int(colours.find('G').text) blue = int(colours.find('B').text) tint = (red, green, blue) other = [other, tint] except Exception as e: print('Error getting chest colours. Possibly old save file') if obj.find('flipped').text == 'true': f = True if 'Fence' in name or name == 'Gate': t = int(obj.find('whichType').text) a = False if name == 'Gate': a = True name = 'Fence' else: name = 'Object' s.append(sprite(name, x, y, 0, 0, i, t, a, f, other)) d = {k[0]: [a for a in s if a[0] == k[0]] for k in s} try: farm['Fences'] = checkSurrounding(d['Fence']) except Exception as e: pass farm['objects'] = [a for a in s if a.name != 'Fence'] # Terrain Features tf = [] crops = [] for item in farm_location.find('terrainFeatures').iter('item'): s = None loc = None f = False name = item.find('value').find('TerrainFeature').get(ns + 'type') if name == 'Tree': t = int( item.find('value').find('TerrainFeature').find( 'treeType').text) s = int( item.find('value').find('TerrainFeature').find( 'growthStage').text) if item.find('value').find('TerrainFeature').find( 'flipped').text == 'true': f = True if name == 'Flooring': t = int( item.find('value').find('TerrainFeature').find( 'whichFloor').text) # simple fix to correct missing whichView node in some save files s = item.find('value').find('TerrainFeature').find('whichView') if s is None: s = 0 else: s = int(s.text) if name == "HoeDirt": crop = item.find('value').find('TerrainFeature').find('crop') if crop is not None: crop_x = int(item.find('key').find('Vector2').find('X').text) crop_y = int(item.find('key').find('Vector2').find('Y').text) crop_phase = int(crop.find('currentPhase').text) crop_location = int(crop.find('rowInSpriteSheet').text) if crop_location in [26, 27, 28, 29, 31]: r = int(crop.find('tintColor').find('R').text) g = int(crop.find('tintColor').find('G').text) b = int(crop.find('tintColor').find('B').text) days = int(crop.find('dayOfCurrentPhase').text) o = ((r, g, b), days) else: o = None crop_flip = False if crop.find('flip').text == 'true': crop_flip = True crop_dead = False if crop.find('dead').text == 'true': crop_dead = True crops.append( sprite('HoeDirtCrop', crop_x, crop_y, 1, 1, crop_dead, crop_location, crop_phase, crop_flip, o)) if name == "FruitTree": t = int( item.find('value').find('TerrainFeature').find( 'treeType').text) s = int( item.find('value').find('TerrainFeature').find( 'growthStage').text) if item.find('value').find('TerrainFeature').find( 'flipped').text == 'true': f = True if name == "Grass": t = int( item.find('value').find('TerrainFeature').find( 'grassType').text) s = int( item.find('value').find('TerrainFeature').find( 'numberOfWeeds').text) loc = int( item.find('value').find('TerrainFeature').find( 'grassSourceOffset').text) if name == "Bush": name = "Tea_Bush" node = item.find('value').find('TerrainFeature') f = node.find('flipped').text.lower() == 'true' t = int(node.find('size').text) # Calculate growth stage date_planted = int(node.find('datePlanted').text) age = farm_age - date_planted if age < 10: s = 0 elif age < 20: s = 1 else: s = 2 if s == 2 and is_last_week_of_season: s = 3 x = int(item.find('key').find('Vector2').find('X').text) y = int(item.find('key').find('Vector2').find('Y').text) tf.append(sprite(name, x, y, 1, 1, loc, t, s, f, None)) d = {k[0]: [a for a in tf if a[0] == k[0]] for k in tf} excludes = ['Flooring', 'HoeDirt', 'Crop'] farm['terrainFeatures'] = [a for a in tf if a.name not in excludes] farm['Crops'] = crops try: farm['Flooring'] = checkSurrounding(d['Flooring']) except Exception as e: pass try: farm['HoeDirt'] = (checkSurrounding(d['HoeDirt'])) except: pass # Large Terrain Features large_terrain_features = [] for ltf in farm_location.find('largeTerrainFeatures'): name = ltf.get(ns + 'type') flipped = ltf.find('flipped').text == 'true' size = int(ltf.find('size').text) x = int(ltf.find('tilePosition').find('X').text) y = int(ltf.find('tilePosition').find('Y').text) tile_sheet_offset = int(ltf.find('tileSheetOffset').text) large_terrain_features.append( sprite(name, x, y, 1, 1, tile_sheet_offset, None, size, flipped, None)) farm['largeTerrainFeatures'] = large_terrain_features # Resource Clumps s = [] for item in farm_location.find('resourceClumps').iter('ResourceClump'): name = item.get(ns + 'type') if name is None: name = 'ResourceClump' t = int(item.find('parentSheetIndex').text) x = int(item.find('tile').find('X').text) y = int(item.find('tile').find('Y').text) w = int(item.find('width').text) h = int(item.find('height').text) s.append(sprite(name, x, y, w, h, None, t, None, None, None)) farm['resourceClumps'] = s s = [] for item in farm_location.find('buildings').iter('Building'): name = 'Building' x = int(item.find('tileX').text) y = int(item.find('tileY').text) w = int(item.find('tilesWide').text) h = int(item.find('tilesHigh').text) t = item.find('buildingType').text o = None if 'cabin' in t.lower(): try: o = min( int( item.find('indoors').find('farmhand').find( 'houseUpgradeLevel').text), 2) except AttributeError: o = 0 if t.lower() == 'fish pond': netting_style = int(item.find('nettingStyle').find('int').text) # Handle water tint, default (25, 155, 178) water_color_element = item.find('overrideWaterColor').find('Color') red = int(water_color_element.find('R').text) green = int(water_color_element.find('G').text) blue = int(water_color_element.find('B').text) if red == 255 and green == 255 and blue == 255: tint = (25, 155, 178) else: tint = (red, green, blue) has_output = item.find('output') is not None o = { 'netting_style': netting_style, 'water_color': tint, 'has_output': has_output } s.append(sprite(name, x, y, w, h, None, t, None, None, o)) farm['buildings'] = s house = sprite('House', 58, 14, 10, 6, int(root.find('player').find('houseUpgradeLevel').text), None, None, None, None) hasGreenhouse = False try: community_center = get_location(root, 'CommunityCenter') cats = community_center.find('areasComplete').findall('boolean') if cats[0].text == 'true': hasGreenhouse = True except AttributeError: pass # Check for letter to confirm player has unlocked greenhouse, thanks /u/BumbleBHE for letter in root.find('player').find('mailReceived').iter('string'): if letter.text == "ccPantry": hasGreenhouse = True try: mapType = int(root.find('whichFarm').text) except Exception as e: mapType = 0 greenhouse_x = 36 if mapType == 5 else 25 greenhouse_y = 31 if mapType == 5 else 12 if hasGreenhouse: greenHouse = sprite('Greenhouse', greenhouse_x, greenhouse_y, 0, 6, 1, None, None, None, None) else: greenHouse = sprite('Greenhouse', greenhouse_x, greenhouse_y, 0, 6, 0, None, None, None, None) farm['misc'] = [house, greenHouse] spouse = get_partner(root.find('player')) spouse = spouse.lower() if spouse else None return {'type': map_types[mapType], 'data': farm, 'spouse': spouse}
def getFarmInfo(saveFile): ns = "{http://www.w3.org/2001/XMLSchema-instance}" farm = {} root = saveFile.getRoot() # Farm Objects s = [] farm_location = get_location(root, 'Farm') for item in farm_location.find('objects').iter("item"): f = False obj = item.find('value').find('Object') name = obj.find('name').text x = int(item.find('key').find('Vector2').find('X').text) y = int(item.find('key').find('Vector2').find('Y').text) i = int(obj.find('parentSheetIndex').text) try: t = obj.find('type').text except: continue a = False other = obj.find('name').text if name == 'Chest': colours = obj.find('playerChoiceColor') try: red = int(colours.find('R').text) green = int(colours.find('G').text) blue = int(colours.find('B').text) tint = (red, green, blue) other = [other, tint] except Exception as e: print('Error getting chest colours. Possibly old save file') if obj.find('flipped').text == 'true': f = True if 'Fence' in name or name == 'Gate': t = int(obj.find('whichType').text) a = False if name == 'Gate': a = True name = 'Fence' else: name = 'Object' s.append(sprite(name, x, y, 0, 0, i, t, a, f, other)) d = {k[0]: [a for a in s if a[0] == k[0]] for k in s} try: farm['Fences'] = checkSurrounding(d['Fence']) except Exception as e: pass farm['objects'] = [a for a in s if a.name != 'Fence'] # Terrain Features tf = [] crops = [] for item in farm_location.find('terrainFeatures').iter('item'): s = None loc = None f = False name = item.find('value').find('TerrainFeature').get(ns + 'type') if name == 'Tree': t = int(item.find('value').find('TerrainFeature').find('treeType').text) s = int(item.find('value').find('TerrainFeature').find('growthStage').text) if item.find('value').find('TerrainFeature').find('flipped').text == 'true': f = True if name == 'Flooring': t = int(item.find('value').find('TerrainFeature').find('whichFloor').text) # simple fix to correct missing whichView node in some save files s = item.find('value').find('TerrainFeature').find('whichView') if s is None: s = 0 else: s = int(s.text) if name == "HoeDirt": crop = item.find('value').find('TerrainFeature').find('crop') if crop is not None: crop_x = int(item.find('key').find('Vector2').find('X').text) crop_y = int(item.find('key').find('Vector2').find('Y').text) crop_phase = int(crop.find('currentPhase').text) crop_location = int(crop.find('rowInSpriteSheet').text) if crop_location in [26, 27, 28, 29, 31]: r = int(crop.find('tintColor').find('R').text) g = int(crop.find('tintColor').find('G').text) b = int(crop.find('tintColor').find('B').text) days = int(crop.find('dayOfCurrentPhase').text) o = ((r, g, b), days) else: o = None crop_flip = False if crop.find('flip').text == 'true': crop_flip = True crop_dead = False if crop.find('dead').text == 'true': crop_dead = True crops.append(sprite('HoeDirtCrop', crop_x, crop_y, 1, 1, crop_dead, crop_location, crop_phase, crop_flip, o)) if name == "FruitTree": t = int(item.find('value').find('TerrainFeature').find('treeType').text) s = int(item.find('value').find('TerrainFeature').find('growthStage').text) if item.find('value').find('TerrainFeature').find('flipped').text == 'true': f = True if name == "Grass": t = int(item.find('value').find('TerrainFeature').find('grassType').text) s = int(item.find('value').find('TerrainFeature').find('numberOfWeeds').text) loc = int(item.find('value').find('TerrainFeature').find('grassSourceOffset').text) x = int(item.find('key').find('Vector2').find('X').text) y = int(item.find('key').find('Vector2').find('Y').text) tf.append(sprite(name, x, y, 1, 1, loc, t, s, f, None)) d = {k[0]: [a for a in tf if a[0] == k[0]] for k in tf} excludes = ['Flooring', 'HoeDirt', 'Crop'] farm['terrainFeatures'] = [a for a in tf if a.name not in excludes] farm['Crops'] = crops try: farm['Flooring'] = checkSurrounding(d['Flooring']) except Exception as e: pass try: farm['HoeDirt'] = (checkSurrounding(d['HoeDirt'])) except: pass # Large Terrain Features large_terrain_features = [] for ltf in farm_location.find('largeTerrainFeatures'): name = ltf.get(ns + 'type') flipped = ltf.find('flipped').text == 'true' size = int(ltf.find('size').text) x = int(ltf.find('tilePosition').find('X').text) y = int(ltf.find('tilePosition').find('Y').text) tile_sheet_offset = int(ltf.find('tileSheetOffset').text) large_terrain_features.append( sprite(name, x, y, 1, 1, tile_sheet_offset, None, size, flipped, None) ) farm['largeTerrainFeatures'] = large_terrain_features # Resource Clumps s = [] for item in farm_location.find('resourceClumps').iter('ResourceClump'): name = item.get(ns + 'type') if name is None: name = 'ResourceClump' t = int(item.find('parentSheetIndex').text) x = int(item.find('tile').find('X').text) y = int(item.find('tile').find('Y').text) w = int(item.find('width').text) h = int(item.find('height').text) s.append(sprite(name, x, y, w, h, None, t, None, None, None)) farm['resourceClumps'] = s s = [] for item in farm_location.find('buildings').iter('Building'): name = 'Building' x = int(item.find('tileX').text) y = int(item.find('tileY').text) w = int(item.find('tilesWide').text) h = int(item.find('tilesHigh').text) t = item.find('buildingType').text o = None if 'cabin' in t.lower(): try: o = min(int(item.find('indoors').find('farmhand').find('houseUpgradeLevel').text), 2) except AttributeError: o = 0 s.append(sprite(name, x, y, w, h, None, t, None, None, o)) farm['buildings'] = s house = sprite('House', 58, 14, 10, 6, int(root.find('player').find('houseUpgradeLevel').text), None, None, None, None) hasGreenhouse = False try: community_center = get_location(root, 'CommunityCenter') cats = community_center.find('areasComplete').findall('boolean') if cats[0].text == 'true': hasGreenhouse = True except AttributeError: pass # Check for letter to confirm player has unlocked greenhouse, thanks /u/BumbleBHE for letter in root.find('player').find('mailReceived').iter('string'): if letter.text == "ccPantry": hasGreenhouse = True if hasGreenhouse: greenHouse = sprite('Greenhouse', 25, 12, 0, 6, 1, None, None, None, None) else: greenHouse = sprite('Greenhouse', 25, 12, 0, 6, 0, None, None, None, None) farm['misc'] = [house, greenHouse] try: mapType = int(root.find('whichFarm').text) except Exception as e: mapType = 0 spouse = get_partner(root.find('player')) spouse = spouse.lower() if spouse else None return {'type': map_types[mapType], 'data': farm, 'spouse': spouse}
def getFarmInfo(saveFile): ns = "{http://www.w3.org/2001/XMLSchema-instance}" farm = {} root = saveFile.getRoot() # Farm Objects s = [] farm_location = get_location(root, 'Farm') for item in farm_location.find('objects').iter("item"): f = False obj = item.find('value').find('Object') name = obj.find('name').text x = int(item.find('key').find('Vector2').find('X').text) y = int(item.find('key').find('Vector2').find('Y').text) i = int(obj.find('parentSheetIndex').text) try: t = obj.find('type').text except: continue a = False other = obj.find('name').text if name == 'Chest': colours = obj.find('playerChoiceColor') try: red = int(colours.find('R').text) green = int(colours.find('G').text) blue = int(colours.find('B').text) tint = (red, green, blue) other = [other, tint] except Exception as e: print('Error getting chest colours. Possibly old save file') if obj.find('flipped').text == 'true': f = True if 'Fence' in name or name == 'Gate': t = int(obj.find('whichType').text) a = False if name == 'Gate': a = True name = 'Fence' else: name = 'Object' s.append(sprite(name, x, y, 0, 0, i, t, a, f, other)) d = {k[0]: [a for a in s if a[0] == k[0]] for k in s} try: farm['Fences'] = checkSurrounding(d['Fence']) except Exception as e: pass farm['objects'] = [a for a in s if a.name != 'Fence'] # Terrain Features tf = [] crops = [] for item in farm_location.find('terrainFeatures').iter('item'): s = None loc = None f = False name = item.find('value').find('TerrainFeature').get(ns + 'type') if name == 'Tree': t = int( item.find('value').find('TerrainFeature').find( 'treeType').text) s = int( item.find('value').find('TerrainFeature').find( 'growthStage').text) if item.find('value').find('TerrainFeature').find( 'flipped').text == 'true': f = True if name == 'Flooring': t = int( item.find('value').find('TerrainFeature').find( 'whichFloor').text) # simple fix to correct missing whichView node in some save files s = item.find('value').find('TerrainFeature').find('whichView') if s is None: s = 0 else: s = int(s.text) if name == "HoeDirt": crop = item.find('value').find('TerrainFeature').find('crop') if crop is not None: crop_x = int(item.find('key').find('Vector2').find('X').text) crop_y = int(item.find('key').find('Vector2').find('Y').text) crop_phase = int(crop.find('currentPhase').text) crop_location = int(crop.find('rowInSpriteSheet').text) if crop_location in [26, 27, 28, 29, 31]: r = int(crop.find('tintColor').find('R').text) g = int(crop.find('tintColor').find('G').text) b = int(crop.find('tintColor').find('B').text) days = int(crop.find('dayOfCurrentPhase').text) o = ((r, g, b), days) else: o = None crop_flip = False if crop.find('flip').text == 'true': crop_flip = True crop_dead = False if crop.find('dead').text == 'true': crop_dead = True crops.append( sprite('HoeDirtCrop', crop_x, crop_y, 1, 1, crop_dead, crop_location, crop_phase, crop_flip, o)) if name == "FruitTree": t = int( item.find('value').find('TerrainFeature').find( 'treeType').text) s = int( item.find('value').find('TerrainFeature').find( 'growthStage').text) if item.find('value').find('TerrainFeature').find( 'flipped').text == 'true': f = True if name == "Grass": t = int( item.find('value').find('TerrainFeature').find( 'grassType').text) s = int( item.find('value').find('TerrainFeature').find( 'numberOfWeeds').text) loc = int( item.find('value').find('TerrainFeature').find( 'grassSourceOffset').text) x = int(item.find('key').find('Vector2').find('X').text) y = int(item.find('key').find('Vector2').find('Y').text) tf.append(sprite(name, x, y, 1, 1, loc, t, s, f, None)) d = {k[0]: [a for a in tf if a[0] == k[0]] for k in tf} excludes = ['Flooring', 'HoeDirt', 'Crop'] farm['terrainFeatures'] = [a for a in tf if a.name not in excludes] farm['Crops'] = crops try: farm['Flooring'] = checkSurrounding(d['Flooring']) except Exception as e: pass try: farm['HoeDirt'] = (checkSurrounding(d['HoeDirt'])) except: pass # Resource Clumps s = [] for item in farm_location.find('resourceClumps').iter('ResourceClump'): name = item.get(ns + 'type') if name is None: name = 'ResourceClump' t = int(item.find('parentSheetIndex').text) x = int(item.find('tile').find('X').text) y = int(item.find('tile').find('Y').text) w = int(item.find('width').text) h = int(item.find('height').text) s.append(sprite(name, x, y, w, h, None, t, None, None, None)) farm['resourceClumps'] = s s = [] for item in farm_location.find('buildings').iter('Building'): name = 'Building' x = int(item.find('tileX').text) y = int(item.find('tileY').text) w = int(item.find('tilesWide').text) h = int(item.find('tilesHigh').text) t = item.find('buildingType').text s.append(sprite(name, x, y, w, h, None, t, None, None, None)) farm['buildings'] = s house = sprite('House', 58, 14, 10, 6, int(root.find('player').find('houseUpgradeLevel').text), None, None, None, None) hasGreenhouse = False try: community_center = get_location(root, 'CommunityCenter') cats = community_center.find('areasComplete').findall('boolean') if cats[0].text == 'true': hasGreenhouse = True except AttributeError: pass # Check for letter to confirm player has unlocked greenhouse, thanks /u/BumbleBHE for letter in root.find('player').find('mailReceived').iter('string'): if letter.text == "ccPantry": hasGreenhouse = True if hasGreenhouse: greenHouse = sprite('Greenhouse', 25, 12, 0, 6, 1, None, None, None, None) else: greenHouse = sprite('Greenhouse', 25, 12, 0, 6, 0, None, None, None, None) farm['misc'] = [house, greenHouse] try: mapType = int(root.find('whichFarm').text) except Exception as e: mapType = 0 return {'type': map_types[mapType], 'data': farm}
def get_animals(self): if not hasattr(self, '_animals'): self._animals = get_animals(get_location(self.root, 'Farm'), self._get_npcs) return self._animals
def get_animals(self): if not hasattr(self, "_animals"): self._animals = get_animals(get_location(self.root, "Farm"), self._get_npcs) return self._animals
def getFarmInfo(saveFile): ns = "{http://www.w3.org/2001/XMLSchema-instance}" farm = {} root = saveFile.getRoot() # Farm Objects s = [] farm_location = get_location(root, "Farm") farm_age = int(root.find("player").find("stats").find("DaysPlayed").text) day_of_season = int(root.find("player").find("dayOfMonthForSaveGame").text) is_last_week_of_season = day_of_season > 21 for item in farm_location.find("objects").iter("item"): f = False obj = item.find("value").find("Object") name = obj.find("name").text x = int(item.find("key").find("Vector2").find("X").text) y = int(item.find("key").find("Vector2").find("Y").text) i = int(obj.find("parentSheetIndex").text) try: t = obj.find("type").text except: continue a = False other = obj.find("name").text if name == "Chest": colours = obj.find("playerChoiceColor") try: red = int(colours.find("R").text) green = int(colours.find("G").text) blue = int(colours.find("B").text) tint = (red, green, blue) other = [other, tint] except Exception as e: print("Error getting chest colours. Possibly old save file") if obj.find("flipped").text == "true": f = True if "Fence" in name or name == "Gate": t = int(obj.find("whichType").text) a = False if name == "Gate": a = True name = "Fence" else: name = "Object" s.append(sprite(name, x, y, 0, 0, i, t, a, f, other)) d = {k[0]: [a for a in s if a[0] == k[0]] for k in s} try: farm["Fences"] = checkSurrounding(d["Fence"]) except Exception as e: pass farm["objects"] = [a for a in s if a.name != "Fence"] # Terrain Features tf = [] crops = [] for item in farm_location.find("terrainFeatures").iter("item"): s = None loc = None f = False name = item.find("value").find("TerrainFeature").get(ns + "type") if name == "Tree": t = int( item.find("value").find("TerrainFeature").find( "treeType").text) s = int( item.find("value").find("TerrainFeature").find( "growthStage").text) if item.find("value").find("TerrainFeature").find( "flipped").text == "true": f = True if name == "Flooring": t = int( item.find("value").find("TerrainFeature").find( "whichFloor").text) # simple fix to correct missing whichView node in some save files s = item.find("value").find("TerrainFeature").find("whichView") if s is None: s = 0 else: s = int(s.text) if name == "HoeDirt": crop = item.find("value").find("TerrainFeature").find("crop") if crop is not None: crop_x = int(item.find("key").find("Vector2").find("X").text) crop_y = int(item.find("key").find("Vector2").find("Y").text) crop_phase = int(crop.find("currentPhase").text) crop_location = int(crop.find("rowInSpriteSheet").text) if crop_location in [26, 27, 28, 29, 31]: r = int(crop.find("tintColor").find("R").text) g = int(crop.find("tintColor").find("G").text) b = int(crop.find("tintColor").find("B").text) days = int(crop.find("dayOfCurrentPhase").text) o = ((r, g, b), days) else: o = None crop_flip = False if crop.find("flip").text == "true": crop_flip = True crop_dead = False if crop.find("dead").text == "true": crop_dead = True crops.append( sprite( "HoeDirtCrop", crop_x, crop_y, 1, 1, crop_dead, crop_location, crop_phase, crop_flip, o, )) if name == "FruitTree": t = int( item.find("value").find("TerrainFeature").find( "treeType").text) s = int( item.find("value").find("TerrainFeature").find( "growthStage").text) if item.find("value").find("TerrainFeature").find( "flipped").text == "true": f = True if name == "Grass": t = int( item.find("value").find("TerrainFeature").find( "grassType").text) s = int( item.find("value").find("TerrainFeature").find( "numberOfWeeds").text) loc = int( item.find("value").find("TerrainFeature").find( "grassSourceOffset").text) if name == "Bush": name = "Tea_Bush" node = item.find("value").find("TerrainFeature") f = node.find("flipped").text.lower() == "true" t = int(node.find("size").text) # Calculate growth stage date_planted = int(node.find("datePlanted").text) age = farm_age - date_planted if age < 10: s = 0 elif age < 20: s = 1 else: s = 2 if s == 2 and is_last_week_of_season: s = 3 x = int(item.find("key").find("Vector2").find("X").text) y = int(item.find("key").find("Vector2").find("Y").text) tf.append(sprite(name, x, y, 1, 1, loc, t, s, f, None)) d = {k[0]: [a for a in tf if a[0] == k[0]] for k in tf} excludes = ["Flooring", "HoeDirt", "Crop"] farm["terrainFeatures"] = [a for a in tf if a.name not in excludes] farm["Crops"] = crops try: farm["Flooring"] = checkSurrounding(d["Flooring"]) except Exception as e: pass try: farm["HoeDirt"] = checkSurrounding(d["HoeDirt"]) except: pass # Large Terrain Features large_terrain_features = [] for ltf in farm_location.find("largeTerrainFeatures"): name = ltf.get(ns + "type") flipped = ltf.find("flipped").text == "true" size = int(ltf.find("size").text) x = int(ltf.find("tilePosition").find("X").text) y = int(ltf.find("tilePosition").find("Y").text) tile_sheet_offset = int(ltf.find("tileSheetOffset").text) large_terrain_features.append( sprite(name, x, y, 1, 1, tile_sheet_offset, None, size, flipped, None)) farm["largeTerrainFeatures"] = large_terrain_features # Resource Clumps s = [] for item in farm_location.find("resourceClumps").iter("ResourceClump"): name = item.get(ns + "type") if name is None: name = "ResourceClump" t = int(item.find("parentSheetIndex").text) x = int(item.find("tile").find("X").text) y = int(item.find("tile").find("Y").text) w = int(item.find("width").text) h = int(item.find("height").text) s.append(sprite(name, x, y, w, h, None, t, None, None, None)) farm["resourceClumps"] = s s = [] for item in farm_location.find("buildings").iter("Building"): name = "Building" x = int(item.find("tileX").text) y = int(item.find("tileY").text) w = int(item.find("tilesWide").text) h = int(item.find("tilesHigh").text) t = item.find("buildingType").text o = None if "cabin" in t.lower(): try: o = min( int( item.find("indoors").find("farmhand").find( "houseUpgradeLevel").text), 2, ) except AttributeError: o = 0 if t.lower() == "fish pond": netting_style = int(item.find("nettingStyle").find("int").text) # Handle water tint, default (25, 155, 178) water_color_element = item.find("overrideWaterColor").find("Color") red = int(water_color_element.find("R").text) green = int(water_color_element.find("G").text) blue = int(water_color_element.find("B").text) if red == 255 and green == 255 and blue == 255: tint = (25, 155, 178) else: tint = (red, green, blue) has_output = item.find("output") is not None o = { "netting_style": netting_style, "water_color": tint, "has_output": has_output, } s.append(sprite(name, x, y, w, h, None, t, None, None, o)) farm["buildings"] = s house = sprite( "House", 58, 14, 10, 6, int(root.find("player").find("houseUpgradeLevel").text), None, None, None, None, ) hasGreenhouse = False try: community_center = get_location(root, "CommunityCenter") cats = community_center.find("areasComplete").findall("boolean") if cats[0].text == "true": hasGreenhouse = True except AttributeError: pass # Check for letter to confirm player has unlocked greenhouse, thanks /u/BumbleBHE for letter in root.find("player").find("mailReceived").iter("string"): if letter.text == "ccPantry": hasGreenhouse = True try: mapType = int(root.find("whichFarm").text) except Exception as e: mapType = 0 if mapType == 5: # Four Corners greenhouse_x = 36 greenhouse_y = 31 elif mapType == 6: # Island greenhouse_x = 14 greenhouse_y = 16 else: greenhouse_x = 25 greenhouse_y = 12 if hasGreenhouse: greenHouse = sprite("Greenhouse", greenhouse_x, greenhouse_y, 0, 6, 1, None, None, None, None) else: greenHouse = sprite("Greenhouse", greenhouse_x, greenhouse_y, 0, 6, 0, None, None, None, None) farm["misc"] = [house, greenHouse] spouse = get_partner(root.find("player")) spouse = spouse.lower() if spouse else None return {"type": map_types[mapType], "data": farm, "spouse": spouse}