Skip to content

Commit

Permalink
Added support for deathlink, hard maya, and shop discount
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrossmann144 committed Jul 9, 2024
1 parent 857f34a commit 7553d5e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
29 changes: 25 additions & 4 deletions RustedMossClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ def _cmd_patch(self, directory: str = ""):
else:
self.output("Patching successful")

async def _cmd_deathlink(self):
"""Toggles deathlink on or off."""
if isinstance(self.ctx, RustedMossContext):
self.ctx.deathlink_status = not self.ctx.deathlink_status
await self.ctx.update_death_link(self.ctx.deathlink_status)
if self.ctx.deathlink_status:
self.output(f"Deathlink enabled.")
else:
self.output(f"Deathlink disabled.")

class RustedMossContext(CommonContext):
tags = {"AP"}
Expand All @@ -58,6 +67,7 @@ class RustedMossContext(CommonContext):
deathlink_status = False
titania_pieces_required = 0
hard_maya = False
shop_discount_percentage = 100

def __init__(self, server_address, password):
super().__init__(server_address, password)
Expand All @@ -67,6 +77,7 @@ def __init__(self, server_address, password):
self.deathlink_status = False
self.hard_maya = False
self.ending = 0
self.shop_discount_percentage = 100

async def server_auth(self, password_requested: bool = False):
if password_requested and not self.password:
Expand All @@ -79,7 +90,7 @@ def clear_rusted_moss_files(self):
self.finished_game = False
for root, dirs, files in os.walk(path):
for file in files:
if file in ["deathlinkFromClient", "deathlinkFromServer", "checkedLocations", "receivedItems", "newItems", "scoutLocations", "newLocations", "endingAchieved"]:
if file in ["deathlinkFromClient", "deathlinkFromServer", "checkedLocations", "receivedItems", "newItems", "scoutLocations", "newLocations", "endingAchieved", "options", "readOptions"]:
os.remove(os.path.join(root, file))

async def connect(self, address: typing.Optional[str] = None):
Expand Down Expand Up @@ -131,6 +142,15 @@ async def process_rusted_moss_cmd(ctx: RustedMossContext, cmd: str, args: dict):
await ctx.update_death_link(ctx.deathlink_status)
ctx.hard_maya = args["slot_data"]["hard_maya"]
ctx.ending = args["slot_data"]["ending"]
ctx.shop_discount_percentage = args["slot_data"]["shop_discount_percentage"]
with open(os.path.join(ctx.save_game_folder, "options"), "w") as f:
f.write("hard_maya\n")
f.write(str(ctx.hard_maya) + "\n")
f.write("shop_discount_percentage\n")
f.write(str(ctx.shop_discount_percentage) + "\n")
f.close()
with open(os.path.join(ctx.save_game_folder, "readOptions"), "w") as f:
f.close()
with open(os.path.join(ctx.save_game_folder, "checkedLocations"), "w") as f:
for location in args["checked_locations"]:
f.write(str(location) + "\n")
Expand Down Expand Up @@ -171,14 +191,15 @@ async def game_watcher(ctx: RustedMossContext):
while not ctx.exit_event.is_set():
if ctx.got_deathlink:
ctx.got_deathlink = False
with open(os.path.join(ctx.save_game_folder, "deathlinkFromServer"), "w") as f:
f.close()
if ctx.deathlink_status:
with open(os.path.join(ctx.save_game_folder, "deathlinkFromServer"), "w") as f:
f.close()

sending = []
for root, dirs, files in os.walk(ctx.save_game_folder):
for file in files:
if "deathlinkFromClient" in file:
if "DeathLink" in ctx.tags:
if ctx.deathlink_status:
await ctx.send_death()
os.remove(os.path.join(root, file))
if "scoutLocations" == file:
Expand Down
18 changes: 13 additions & 5 deletions worlds/rusted_moss/Options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import typing
from dataclasses import dataclass
from Options import Toggle, Choice, PerGameCommonOptions
from Options import Toggle, Choice, PerGameCommonOptions, Range

# class TitaniaPiecesRequired(Range):
# """How many pieces of Titania are required to complete the game."""
Expand All @@ -10,7 +10,7 @@
# range_end = 8

class Ending(Choice):
"""The ending of the game required to win."""
"""The ending of the game required to win"""
display_name = "Required Ending"
option_ending_a = 0
option_ending_b = 1
Expand All @@ -20,7 +20,7 @@ class Ending(Choice):
default = 0

class RouteRequired(Choice):
"""Main route of the game required to win."""
"""Main route of the game required to win"""
display_name = "Required Route"
option_neutral = 0
option_pacifist = 1
Expand All @@ -29,7 +29,7 @@ class RouteRequired(Choice):
default = 0

class HardMaya(Toggle):
"""Choose to enable the hard version of the Living Quarters Maya fight."""
"""Choose to enable the hard version of the Living Quarters Maya fight"""
display_name = "Hard Maya"

class Deathlink(Toggle):
Expand Down Expand Up @@ -61,6 +61,13 @@ class HardCombat(Toggle):
"""Locations which require more proficiency in combat to access will be considered in logic"""
display_name = "Hard Combat"

class ShopDiscountPercentage(Range):
"""Discount percentage to apply to shop prices to reduce money farming requirement"""
display_name = "Shop Item Cost Percentage"
default = 50
range_start = 1
range_end = 100

@dataclass
class RustedMossOptions(PerGameCommonOptions):
# titania_pieces_required: TitaniaPiecesRequired
Expand All @@ -72,4 +79,5 @@ class RustedMossOptions(PerGameCommonOptions):
precise_movement: PreciseMovement
precise_grapple: PreciseGrapple
bunny_hopping: BunnyHopping
hard_combat: HardCombat
hard_combat: HardCombat
shop_discount_percentage: ShopDiscountPercentage
1 change: 1 addition & 0 deletions worlds/rusted_moss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,6 @@ def fill_slot_data(self) -> Dict[str, Any]:
"precise_grapple": self.options.precise_grapple.value,
"bunny_hopping": self.options.bunny_hopping.value,
"hard_combat": self.options.hard_combat.value,
"shop_discount_percentage": self.options.shop_discount_percentage.value,
}

0 comments on commit 7553d5e

Please sign in to comment.