mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Replace localtriforcehunt with teamtriforcehunt
This commit is contained in:
@@ -93,6 +93,7 @@ class Context(Node):
|
||||
self.hint_cost = hint_cost
|
||||
self.location_check_points = location_check_points
|
||||
self.hints_used = collections.defaultdict(int)
|
||||
self.treasure_count = collections.defaultdict(int)
|
||||
self.hints: typing.Dict[typing.Tuple[int, int], typing.Set[Utils.Hint]] = collections.defaultdict(set)
|
||||
self.forfeit_mode: str = forfeit_mode
|
||||
self.remaining_mode: str = remaining_mode
|
||||
@@ -228,6 +229,7 @@ class Context(Node):
|
||||
d = {
|
||||
"rom_names": list(self.rom_names.items()),
|
||||
"received_items": tuple((k, v) for k, v in self.received_items.items()),
|
||||
"treasure_count": tuple((k, v) for k, v in self.treasure_count.items()),
|
||||
"hints_used": tuple((key, value) for key, value in self.hints_used.items()),
|
||||
"hints": tuple(
|
||||
(key, list(hint.re_check(self, key[0]) for hint in value)) for key, value in self.hints.items()),
|
||||
@@ -256,6 +258,8 @@ class Context(Node):
|
||||
return
|
||||
|
||||
received_items = {tuple(k): [ReceivedItem(*i) for i in v] for k, v in savedata["received_items"]}
|
||||
print(savedata["treasure_count"])
|
||||
self.treasure_count = {tuple(k): v for k, v in savedata["treasure_count"]}
|
||||
|
||||
self.received_items = received_items
|
||||
self.hints_used.update({tuple(key): value for key, value in savedata["hints_used"]})
|
||||
@@ -505,7 +509,6 @@ def register_location_checks(ctx: Context, team: int, slot: int, locations):
|
||||
if recvd_item.location == location and recvd_item.player == slot:
|
||||
found = True
|
||||
break
|
||||
|
||||
if not found:
|
||||
new_item = ReceivedItem(target_item, location, slot)
|
||||
recvd_items.append(new_item)
|
||||
@@ -521,6 +524,15 @@ def register_location_checks(ctx: Context, team: int, slot: int, locations):
|
||||
if client.team == team and client.wants_item_notification:
|
||||
asyncio.create_task(
|
||||
ctx.send_msgs(client, [['ItemFound', (target_item, location, slot)]]))
|
||||
try:
|
||||
print('TRY', target_item, get_item_name_from_id(target_item))
|
||||
if 'Triforce Piece' in get_item_name_from_id(target_item):
|
||||
print('PIECE', team, slot, ctx.treasure_count.get(team), 'No Pieces')
|
||||
ctx.treasure_count[team] = ctx.treasure_count.get(team, 0) + 1
|
||||
print('NOW', ctx.treasure_count[(team, slot)])
|
||||
ctx.broadcast_team(team, [['TreasureCount', (ctx.treasure_count[team],)]])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
ctx.location_checks[team, slot] |= known_locations
|
||||
send_new_items(ctx)
|
||||
|
||||
@@ -1046,6 +1058,11 @@ async def process_client_cmd(ctx: Context, client: Client, cmd, args):
|
||||
if items:
|
||||
reply.append(['ReceivedItems', (0, tuplize_received_items(items))])
|
||||
client.send_index = len(items)
|
||||
try:
|
||||
if ctx.treasure_count.get(client.team):
|
||||
ctx.broadcast_team(team, [['TreasureCount', (ctx.treasure_count[client.team],)]])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
await ctx.send_msgs(client, reply)
|
||||
await on_client_joined(ctx, client)
|
||||
|
||||
@@ -1055,6 +1072,12 @@ async def process_client_cmd(ctx: Context, client: Client, cmd, args):
|
||||
if items:
|
||||
client.send_index = len(items)
|
||||
await ctx.send_msgs(client, [['ReceivedItems', (0, tuplize_received_items(items))]])
|
||||
try:
|
||||
print('TRY2')
|
||||
if ctx.treasure_count.get((team)):
|
||||
ctx.broadcast_team(team, [['TreasureCount', (ctx.treasure_count[team],)]])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
elif cmd == 'LocationChecks':
|
||||
if type(args) is not list:
|
||||
|
Reference in New Issue
Block a user