From 7851bafb38895183a6255a5fba22eb0b400feddc Mon Sep 17 00:00:00 2001 From: jamesbrq Date: Thu, 13 Jun 2024 00:17:34 -0400 Subject: [PATCH] v1.1 Initial Upload --- worlds/gl/GauntletLegendsClient.py | 34 ++++++++++++++---------------- worlds/gl/__init__.py | 3 +-- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/worlds/gl/GauntletLegendsClient.py b/worlds/gl/GauntletLegendsClient.py index c0f033e0a933..d19f088f0b11 100644 --- a/worlds/gl/GauntletLegendsClient.py +++ b/worlds/gl/GauntletLegendsClient.py @@ -1,7 +1,7 @@ import asyncio import socket import traceback -from typing import List +from typing import List, Optional import Patch import Utils @@ -55,7 +55,7 @@ async def write(self, message: str): await asyncio.sleep(0) self.socket.sendto(message.encode(), (self.host, self.port)) - async def read(self, message) -> bytes | None: + async def read(self, message) -> Optional[bytes]: await asyncio.sleep(0) self.socket.sendto(message.encode(), (self.host, self.port)) @@ -268,7 +268,7 @@ async def obj_read(self, mode=0): await self.socket.read( message_format( READ, - f"0x{format(obj_address + (self.offset * 0x3C), 'x')} {(len(self.item_locations) + 10) * 0x3C})", + f"0x{format(obj_address + (self.offset * 0x3C), 'x')} {(len(self.item_locations) + 10) * 0x3C}", ), ), ) @@ -283,7 +283,7 @@ async def obj_read(self, mode=0): await self.socket.read( message_format( READ, - f"0x{format(obj_address + ((self.offset + len(self.item_locations) + self.extra_items + len([spawner for spawner in spawners[(self.current_level[1] << 4) + self.current_level[0]] if self.difficulty >= spawner])) * 0x3C), 'x')} {(len(self.chest_locations) + 10) * 0x3C})", + f"0x{format(obj_address + ((self.offset + len(self.item_locations) + self.extra_items + len([spawner for spawner in spawners[(self.current_level[1] << 4) + (self.current_level[0] if self.current_level[1] != 1 else castle_id.index(self.current_level[0]) + 1)] if self.difficulty >= spawner])) * 0x3C), 'x')} {(len(self.chest_locations) + 10) * 0x3C}", ), ), ) @@ -511,15 +511,13 @@ async def scale(self): level = [0x1, 0xF] players = await self.active_players() player_level = await self.player_level() - scale_value = ( - min(self.clear_counts.get(str(level), 0), 3) - if self.glslotdata["scale"] == 1 - else min(max(((player_level - difficulty_convert[level[1]]) // 5), 0), 3) - ) - if level[1] == 2 and self.clear_counts.get(str(level), 0) != 0: - scale_value -= min(player_level // 10, 3) + max_value: int = self.glslotdata["max"] + scale_value = min(max(((player_level - difficulty_convert[level[1]]) // 5), 0), 3) + if self.glslotdata["instant_max"] == 1: + scale_value = max_value + mountain_value = min(player_level // 10, 3) await self.socket.write( - message_format(WRITE, f"0x{format(PLAYER_COUNT, 'x')} 0x{format(min(players + scale_value, 4), 'x')}"), + message_format(WRITE, f"0x{format(PLAYER_COUNT, 'x')} 0x{format(min(players + scale_value, max_value) - mountain_value, 'x')}"), ) self.scaled = True @@ -541,15 +539,14 @@ async def scout_locations(self, ctx: "GauntletLegendsContext") -> None: self.current_level = level players = await self.active_players() if self.clear_counts.get(str(level), 0) != 0: - difficulty = players + (0 if level[1] != 2 else min(await self.player_level() // 10, 3)) + self.difficulty = players + (0 if level[1] != 2 else min(await self.player_level() // 10, 3)) else: - difficulty = players - self.difficulty = difficulty + self.difficulty = players _id = level[0] if level[1] == 1: _id = castle_id.index(level[0]) + 1 raw_locations = [ - location for location in level_locations.get((level[1] << 4) + _id, []) if difficulty >= location.difficulty + location for location in level_locations.get((level[1] << 4) + _id, []) if self.difficulty >= location.difficulty ] await ctx.send_msgs( [ @@ -590,8 +587,9 @@ async def scout_locations(self, ctx: "GauntletLegendsContext") -> None: or ("Barrel" in location.name and "Barrel of Gold" not in location.name) and location not in self.obelisk_locations ] + max_value: int = self.glslotdata['max'] logger.info( - f"Locations: {len(self.obelisk_locations + self.item_locations + self.chest_locations)} Difficulty: {self.difficulty}", + f"Locations: {len([location for location in self.obelisk_locations + self.item_locations + self.chest_locations if location.difficulty <= max_value and location.id not in self.locations_checked])} Difficulty: {max_value}", ) # Compare values of loaded objects to see if they have been collected @@ -811,7 +809,7 @@ async def gl_sync_task(ctx: GauntletLegendsContext): def launch(): - Utils.init_logging("GLClient", exception_logger="Client") + Utils.init_logging("GauntletLegendsClient", exception_logger="Client") async def main(): parser = get_base_parser() diff --git a/worlds/gl/__init__.py b/worlds/gl/__init__.py index 219746206f2b..3acbdf8b4771 100644 --- a/worlds/gl/__init__.py +++ b/worlds/gl/__init__.py @@ -142,12 +142,11 @@ def fill_slot_data(self) -> dict: ] return { "player": self.player, - "scale": 0, "shards": shard_values, "speed": self.options.permanent_speed.value, "keys": self.options.infinite_keys.value, "character": self.options.unlock_character.value, - "max_value": self.options.max_difficulty_value.value if self.options.max_difficulty_toggle else 4, + "max": self.options.max_difficulty_value.value if self.options.max_difficulty_toggle else 4, "instant_max": self.options.instant_max.value }