Skip to content

Commit

Permalink
v1.1 Initial Upload
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbrq committed Jun 13, 2024
1 parent bd47005 commit 7851baf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
34 changes: 16 additions & 18 deletions worlds/gl/GauntletLegendsClient.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import socket
import traceback
from typing import List
from typing import List, Optional

import Patch
import Utils
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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}",
),
),
)
Expand All @@ -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}",
),
),
)
Expand Down Expand Up @@ -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

Expand All @@ -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(
[
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions worlds/gl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 7851baf

Please sign in to comment.