Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else:
gender = 'female'
if assets is None:
assets = loadAvatarAssets()
base = assets['base'][gender]
leg_colour = (int(player['pantsColor'][0]), int(player['pantsColor'][1]), int(player['pantsColor'][2]))
legs = tintImage(assets['legs'][gender], leg_colour)
hair = cropImg(assets['hair'], int(player['hair']), defaultSize=(16, 32*3), objectSize=(16, 32), resize=True, displacement=(0, 0))
hair_color = tuple(map(int, player['hairstyleColor']))
hair = tintImage(hair, hair_color)
acc = cropImg(assets['accessories'], int(player['accessory']), defaultSize=(16, 16*2), objectSize=(16, 16), resize=True, displacement=(0, 1))
if int(player['accessory']) <= 5:
acc = tintImage(acc, hair_color)
shirt = cropImg(assets['shirts'], int(player['shirt']), defaultSize=(8, 8*4), objectSize=(8, 8), resize=True, displacement=(4, 14))
skin_x = int(player['skin']) % 24 * 1
skin_y = int(player['skin']) // 24 * 1
skin_color = assets['skin colors'].getpixel((skin_x, skin_y))
base = tintImage(base, skin_color)
arms = tintImage(assets['arms'][gender], skin_color)
body = base.load()
eyeColor = tuple(map(int, player['newEyeColor']))
white = (255, 255, 255)
if player['isMale'] == 'true':
body[6, 10] = eyeColor
farm = sorted(chain.from_iterable(farm.values()), key=lambda x: x.y)
floor_types = ['Flooring', 'HoeDirt']
floor = [i for i in farm if i.name in floor_types]
gates = []
farm_tile_height = farm_height // 16
other_things = {y: [i for i in farm if (i not in floor and i.y == y)] for y in range(farm_tile_height)}
for i in range(farm_tile_height):
strip_back = assets['overlays'][type][season]['Buildings'][i]
farm_base.paste(strip_back, (0, i * 16), strip_back)
print('\tRendering Sprites...')
for item in floor:
if item.name == 'Flooring':
floor_type = cropImg(assets['flooring'], item.type,
(64, 64), (64, 64))
floor_view = cropImg(floor_type, item.orientation)
farm_base.paste(floor_view, (item.x * 16, item.y * 16), floor_view)
if item.name == 'HoeDirt':
if season != 'winter':
hoe_sheet = assets['hoe dirt']['normal']
else:
hoe_sheet = assets['hoe dirt']['winter']
hoe_tile = cropImg(hoe_sheet, item.orientation)
farm_base.paste(hoe_tile, (item.x * 16, item.y * 16), hoe_tile)
for y, items in other_things.items():
for item in items:
if 'Crop' in item.name:
spouse_area.paste(plant_pot_full, (0, 16 * 2), plant_pot_full)
spouse_area.paste(plant_pot_empty, (16 * 1, 16 * 2), plant_pot_empty)
spouse_area.paste(plant_pot_full, (16 * 3, 16 * 2), plant_pot_full)
elif spouse_name == 'leah':
sculpture = cropImg(sprite_sheet, 25 * 122 + 22, objectSize=(16, 32))
spouse_area.paste(sculpture, (16, 16), sculpture)
elif spouse_name == 'sebastian':
bike = cropImg(sprite_sheet, 25 * 155 + 2, objectSize=(16 * 3, 16 * 2))
spouse_area.paste(bike, (16, 16), bike)
elif spouse_name == 'alex':
kettle_bell = cropImg(sprite_sheet, 25 * 122 + 24, objectSize=(16, 16))
spouse_area.paste(kettle_bell, (0, 16 * 2), kettle_bell)
elif spouse_name == 'emily':
crystal_blue = cropImg(sprite_sheet, 25 * 153 + 16, objectSize=(16, 16))
crystal_green = cropImg(sprite_sheet, 25 * 152 + 17, objectSize=(16, 16 * 2))
crystal_pink = cropImg(sprite_sheet, 25 * 157 + 17, objectSize=(16, 16))
spouse_area.paste(crystal_blue, (16 * 2, 16 * 2), crystal_blue)
spouse_area.paste(crystal_blue, (0, 16 * 3), crystal_blue)
spouse_area.paste(crystal_green, (0, 16 * 1), crystal_green)
spouse_area.paste(crystal_green, (16 * 3, 16 * 1), crystal_green)
spouse_area.paste(crystal_pink, (16, 16 * 2), crystal_pink)
spouse_area.paste(crystal_pink, (16 * 3, 16 * 3), crystal_pink)
elif spouse_name == 'haley':
palm = cropImg(sprite_sheet, 25 * 119 + 24, objectSize=(16, 16 * 3))
spouse_area.paste(palm, (0, 0), palm)
spouse_area.paste(palm, (16 * 3, 0), palm)
elif spouse_name == 'shane':
roof = cropImg(sprite_sheet, 25 * 148 + 22, objectSize=(16 * 3, 16 * 2))
return cropImg(img, growth, defaultSize, objectSize)
else:
bloomed = False
if T == 26 and days > 1:
bloomed = True
if T == 27 and days > 2:
bloomed = True
if T == 28 and days > 2:
bloomed = True
if T == 29 and days > 2:
bloomed = True
if T == 31 and days > 3:
bloomed = True
if bloomed:
plant_body = cropImg(img, 5, defaultSize, objectSize)
plant_head = cropImg(img, 6, defaultSize, objectSize)
plant_head = tintImage(plant_head, colour)
plant_body.paste(plant_head, (0, 0), plant_head)
else:
plant_body = cropImg(img, 4, defaultSize, objectSize)
return plant_body
plant_pot_empty = cropImg(sprite_sheet, 25 * 123 + 23, objectSize=(16, 16))
plant_pot_full = cropImg(sprite_sheet, 25 * 122 + 23, objectSize=(16, 16))
spouse_area.paste(plant_pot_full, (0, 16 * 2), plant_pot_full)
spouse_area.paste(plant_pot_empty, (16 * 1, 16 * 2), plant_pot_empty)
spouse_area.paste(plant_pot_full, (16 * 3, 16 * 2), plant_pot_full)
elif spouse_name == 'leah':
sculpture = cropImg(sprite_sheet, 25 * 122 + 22, objectSize=(16, 32))
spouse_area.paste(sculpture, (16, 16), sculpture)
elif spouse_name == 'sebastian':
bike = cropImg(sprite_sheet, 25 * 155 + 2, objectSize=(16 * 3, 16 * 2))
spouse_area.paste(bike, (16, 16), bike)
elif spouse_name == 'alex':
kettle_bell = cropImg(sprite_sheet, 25 * 122 + 24, objectSize=(16, 16))
spouse_area.paste(kettle_bell, (0, 16 * 2), kettle_bell)
elif spouse_name == 'emily':
crystal_blue = cropImg(sprite_sheet, 25 * 153 + 16, objectSize=(16, 16))
crystal_green = cropImg(sprite_sheet, 25 * 152 + 17, objectSize=(16, 16 * 2))
crystal_pink = cropImg(sprite_sheet, 25 * 157 + 17, objectSize=(16, 16))
spouse_area.paste(crystal_blue, (16 * 2, 16 * 2), crystal_blue)
spouse_area.paste(crystal_blue, (0, 16 * 3), crystal_blue)
spouse_area.paste(crystal_green, (0, 16 * 1), crystal_green)
spouse_area.paste(crystal_green, (16 * 3, 16 * 1), crystal_green)
spouse_area.paste(crystal_pink, (16, 16 * 2), crystal_pink)
spouse_area.paste(crystal_pink, (16 * 3, 16 * 3), crystal_pink)
elif spouse_name == 'haley':
palm = cropImg(sprite_sheet, 25 * 119 + 24, objectSize=(16, 16 * 3))
spouse_area.paste(palm, (0, 0), palm)
season_offset = 8 * 3
elif season == 'winter':
season_offset = 8 * 3 + 4
elif item.growth == 2:
if season == 'spring':
season_offset = 0
elif season == 'summer':
season_offset = 0
elif season == 'fall':
season_offset = 3
elif season == 'winter':
season_offset = 8 * 3
sprite_index = [8 * 14, 8 * 0, 8 * 8][item.growth] + season_offset
obj_img = cropImg(assets['bushes'], sprite_index, objectSize=sprite_size)
if item.flipped:
obj_img = obj_img.transpose(Image.FLIP_LEFT_RIGHT)
farm_base.paste(obj_img, (item.x * 16, item.y * 16 - (sprite_size[1]) + 16),
obj_img)
if item.name == 'ResourceClump':
obj_img = cropImg(assets['objects'], item.type, objectSize=(32, 32))
farm_base.paste(obj_img, (item.x * 16, item.y * 16), obj_img)
if item.name == 'Tree':
try:
if item.type == 1:
tree_img = assets['trees']['oak'][season]
elif item.type == 2:
crystal_pink = cropImg(sprite_sheet, 25 * 157 + 17, objectSize=(16, 16))
spouse_area.paste(crystal_blue, (16 * 2, 16 * 2), crystal_blue)
spouse_area.paste(crystal_blue, (0, 16 * 3), crystal_blue)
spouse_area.paste(crystal_green, (0, 16 * 1), crystal_green)
spouse_area.paste(crystal_green, (16 * 3, 16 * 1), crystal_green)
spouse_area.paste(crystal_pink, (16, 16 * 2), crystal_pink)
spouse_area.paste(crystal_pink, (16 * 3, 16 * 3), crystal_pink)
elif spouse_name == 'haley':
palm = cropImg(sprite_sheet, 25 * 119 + 24, objectSize=(16, 16 * 3))
spouse_area.paste(palm, (0, 0), palm)
spouse_area.paste(palm, (16 * 3, 0), palm)
elif spouse_name == 'shane':
roof = cropImg(sprite_sheet, 25 * 148 + 22, objectSize=(16 * 3, 16 * 2))
body = cropImg(sprite_sheet, 25 * 155 + 15, objectSize=(16 * 3, 16 * 2))
spouse_area.paste(roof, (16, 0), roof)
spouse_area.paste(body, (16, 16 * 2), body)
return spouse_area
else:
bloomed = False
if T == 26 and days > 1:
bloomed = True
if T == 27 and days > 2:
bloomed = True
if T == 28 and days > 2:
bloomed = True
if T == 29 and days > 2:
bloomed = True
if T == 31 and days > 3:
bloomed = True
if bloomed:
plant_body = cropImg(img, 5, defaultSize, objectSize)
plant_head = cropImg(img, 6, defaultSize, objectSize)
plant_head = tintImage(plant_head, colour)
plant_body.paste(plant_head, (0, 0), plant_head)
else:
plant_body = cropImg(img, 4, defaultSize, objectSize)
return plant_body
spouse_area.paste(plant_pot_full, (16 * 3, 16 * 2), plant_pot_full)
elif spouse_name == 'leah':
sculpture = cropImg(sprite_sheet, 25 * 122 + 22, objectSize=(16, 32))
spouse_area.paste(sculpture, (16, 16), sculpture)
elif spouse_name == 'sebastian':
bike = cropImg(sprite_sheet, 25 * 155 + 2, objectSize=(16 * 3, 16 * 2))
spouse_area.paste(bike, (16, 16), bike)
elif spouse_name == 'alex':
kettle_bell = cropImg(sprite_sheet, 25 * 122 + 24, objectSize=(16, 16))
spouse_area.paste(kettle_bell, (0, 16 * 2), kettle_bell)
elif spouse_name == 'emily':
crystal_blue = cropImg(sprite_sheet, 25 * 153 + 16, objectSize=(16, 16))
crystal_green = cropImg(sprite_sheet, 25 * 152 + 17, objectSize=(16, 16 * 2))
crystal_pink = cropImg(sprite_sheet, 25 * 157 + 17, objectSize=(16, 16))
spouse_area.paste(crystal_blue, (16 * 2, 16 * 2), crystal_blue)
spouse_area.paste(crystal_blue, (0, 16 * 3), crystal_blue)
spouse_area.paste(crystal_green, (0, 16 * 1), crystal_green)
spouse_area.paste(crystal_green, (16 * 3, 16 * 1), crystal_green)
spouse_area.paste(crystal_pink, (16, 16 * 2), crystal_pink)
spouse_area.paste(crystal_pink, (16 * 3, 16 * 3), crystal_pink)
elif spouse_name == 'haley':
palm = cropImg(sprite_sheet, 25 * 119 + 24, objectSize=(16, 16 * 3))
spouse_area.paste(palm, (0, 0), palm)
spouse_area.paste(palm, (16 * 3, 0), palm)
elif spouse_name == 'shane':
roof = cropImg(sprite_sheet, 25 * 148 + 22, objectSize=(16 * 3, 16 * 2))
body = cropImg(sprite_sheet, 25 * 155 + 15, objectSize=(16 * 3, 16 * 2))
try:
if item.type == 1:
tree_img = assets['trees']['oak'][season]
elif item.type == 2:
tree_img = assets['trees']['maple'][season]
elif item.type == 3:
tree_img = assets['trees']['pine'][season]
elif item.type == 7:
tree_img = assets['trees']['mushroom']
if item.growth == 0:
tree_crop = cropImg(tree_img, 26)
offsetx = 0
offsety = 0
elif item.growth == 1:
tree_crop = cropImg(tree_img, 24)
offsetx = 0
offsety = 0
elif item.growth == 2:
tree_crop = cropImg(tree_img, 25)
offsetx = 0
offsety = 0
elif item.growth == 3 or item.growth == 4:
tree_crop = cropImg(tree_img, 18, objectSize=(16, 32))
offsetx = 0
offsety = 16
else:
tree_crop = loadTree(tree_img)
offsety = 5 * 16
offsetx = 1 * 16
if item.flipped:
tree_crop = tree_crop.transpose(Image.FLIP_LEFT_RIGHT)