Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevent greenhouse from rendering in main building loop #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 60 additions & 32 deletions sdv/farmInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def getFarmInfo(saveFile):

root = saveFile.getRoot()

# This is a crude flag to prevent two greenhouses from being registered in version 1.5
seen_greenhouse = False

# Farm Objects

s = []
Expand Down Expand Up @@ -286,6 +289,7 @@ def getFarmInfo(saveFile):
h = int(item.find("tilesHigh").text)
t = item.find("buildingType").text
o = None
index = 0
if "cabin" in t.lower():
try:
o = min(
Expand Down Expand Up @@ -320,7 +324,30 @@ def getFarmInfo(saveFile):
"has_output": has_output,
}

s.append(sprite(name, x, y, w, h, None, t, None, None, o))
if t.lower() == "greenhouse":
seen_greenhouse = True
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

hasGreenhouse |= farm_location.find("greenhouseUnlocked") == "true"

index = 1 if hasGreenhouse else 0
# Offset of greenhouse is 4 not 6
h -= 2


s.append(sprite(name, x, y, w, h, index, t, None, None, o))

farm["buildings"] = s

Expand All @@ -337,44 +364,45 @@ def getFarmInfo(saveFile):
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]

if not seen_greenhouse:
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 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

greenhouse = sprite(
"Greenhouse", greenhouse_x, greenhouse_y, 0, 6, 1 if hasGreenhouse else 0, None, None, None, None
)
farm["misc"] = [house, greenHouse]

farm['misc'].append(greenhouse)


spouse = get_partner(root.find("player"))
spouse = spouse.lower() if spouse else None
Expand Down
75 changes: 38 additions & 37 deletions sdv/imagegeneration/farm.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,43 +387,44 @@ def generateFarm(season, data, assets=None):
print(e)

if item.name == "Building":
try:
if item.type.lower() == "junimo hut":
offsety = (
assets["buildings"][item.type.lower()][season].height
- (item.h) * 16
)
farm_base.paste(
assets["buildings"][item.type.lower()][season],
(item.x * 16, item.y * 16 - offsety),
assets["buildings"][item.type.lower()][season],
)
elif item.type.lower() == "fish pond":
pond_image = render_fish_pond(item, assets)
pond_offset_y = 2 * 16
farm_base.paste(
pond_image,
(item.x * 16, item.y * 16 - pond_offset_y),
pond_image,
)
else:
offsety = (
assets["buildings"][item.type.lower()].height
- (item.h) * 16
)
asset = assets["buildings"][item.type.lower()]
if "cabin" in item.type.lower():
asset = cropImg(
asset,
item.orientation,
(item.w * 16, asset.height),
(item.w * 16, asset.height),
if item.type != "Greenhouse":
try:
if item.type.lower() == "junimo hut":
offsety = (
assets["buildings"][item.type.lower()][season].height
- (item.h) * 16
)
farm_base.paste(
asset, (item.x * 16, item.y * 16 - offsety), asset
)
except Exception as e:
print(e)
farm_base.paste(
assets["buildings"][item.type.lower()][season],
(item.x * 16, item.y * 16 - offsety),
assets["buildings"][item.type.lower()][season],
)
elif item.type.lower() == "fish pond":
pond_image = render_fish_pond(item, assets)
pond_offset_y = 2 * 16
farm_base.paste(
pond_image,
(item.x * 16, item.y * 16 - pond_offset_y),
pond_image,
)
else:
offsety = (
assets["buildings"][item.type.lower()].height
- (item.h) * 16
)
asset = assets["buildings"][item.type.lower()]
if "cabin" in item.type.lower():
asset = cropImg(
asset,
item.orientation,
(item.w * 16, asset.height),
(item.w * 16, asset.height),
)
farm_base.paste(
asset, (item.x * 16, item.y * 16 - offsety), asset
)
except Exception as e:
print(e)

if item.name == "spouse_area":
sprite = assets["spouseArea"][spouse][season]
Expand Down Expand Up @@ -466,7 +467,7 @@ def generateFarm(season, data, assets=None):
except Exception as e:
print(e)

if item.name == "Greenhouse":
if item.name == "Greenhouse" or item.type == "Greenhouse":
try:
greenhouse_img = cropImg(
assets["buildings"]["greenhouse"],
Expand Down