diff --git a/MultiServer.py b/MultiServer.py index 04b2bcfc..7faa12ff 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -710,7 +710,8 @@ def collect_hints(ctx: Context, team: int, slot: int, item: str) -> typing.List[ if receiving_player == slot and item_id == seeked_item_id: found = location_id in ctx.location_checks[team, finding_player] entrance = ctx.er_hint_data.get(finding_player, {}).get(location_id, "") - hints.append(NetUtils.Hint(receiving_player, finding_player, location_id, item_id, found, entrance, item_flags)) + hints.append(NetUtils.Hint(receiving_player, finding_player, location_id, item_id, found, entrance, + item_flags)) return hints diff --git a/NetUtils.py b/NetUtils.py index 820ee0ed..bf7463bf 100644 --- a/NetUtils.py +++ b/NetUtils.py @@ -17,6 +17,8 @@ class JSONMessagePart(typing.TypedDict, total=False): color: str # owning player for location/item player: int + # if type == item indicates item flags + flags: int class ClientStatus(enum.IntEnum): @@ -211,7 +213,7 @@ class JSONtoTextParser(metaclass=HandlerMeta): return self._handle_color(node) def _handle_item_name(self, node: JSONMessagePart): - flags = node.get("item_flags", 0) + flags = node.get("flags", 0) if flags == 0: node["color"] = 'cyan' elif flags & 1 << 0: # advancement @@ -266,7 +268,7 @@ def add_json_text(parts: list, text: typing.Any, **kwargs) -> None: def add_json_item(parts: list, item_id: int, player: int = 0, item_flags: int = 0, **kwargs) -> None: - parts.append({"text": str(item_id), "player": player, "item_flags": item_flags, "type": JSONTypes.item_id, **kwargs}) + parts.append({"text": str(item_id), "player": player, "flags": item_flags, "type": JSONTypes.item_id, **kwargs}) def add_json_location(parts: list, item_id: int, player: int = 0, **kwargs) -> None: @@ -287,7 +289,8 @@ class Hint(typing.NamedTuple): return self found = self.location in ctx.location_checks[team, self.finding_player] if found: - return Hint(self.receiving_player, self.finding_player, self.location, self.item, found, self.entrance, self.item_flags) + return Hint(self.receiving_player, self.finding_player, self.location, self.item, found, self.entrance, + self.item_flags) return self def __hash__(self): diff --git a/docs/network protocol.md b/docs/network protocol.md index 906097a8..18dff35e 100644 --- a/docs/network protocol.md +++ b/docs/network protocol.md @@ -342,10 +342,10 @@ In JSON this may look like: Flags are bit flags: | Flag | Meaning | | ----- | ----- | -| 0 | Indicates, indicates the item had no specail use in generation | -| 1 << 0 | If set, indicates the item can unlock advancement | -| 1 << 1 | If set, indicates the item is important but not necessarily unlocks advancement | -| 1 << 2 | If set, indicates the item is an trap | +| 0 | Nothing special about this item | +| 0b100 | If set, indicates the item can unlock logical advancement | +| 0b100 | If set, indicates the item is important but not in a way that unlocks advancement | +| 0b100 | If set, indicates the item is a trap | ### JSONMessagePart Message nodes sent along with [PrintJSON](#PrintJSON) packet to be reconstructed into a legible message. The nodes are intended to be read in the order they are listed in the packet. @@ -355,8 +355,8 @@ from typing import TypedDict, Optional class JSONMessagePart(TypedDict): type: Optional[str] text: Optional[str] - color: Optional[str] # only available if type is an color - item_flags: Optional[int] # only available if type is an item + color: Optional[str] # only available if type is a color + flags: Optional[int] # only available if type is an item_id or item_name player: Optional[int] # only available if type is either item or location ``` @@ -371,7 +371,7 @@ Possible values for `type` include: | item_id | Item ID, should be resolved to Item Name | | item_name | Item Name, not currently used over network, but supported by reference Clients. | | location_id | Location ID, should be resolved to Location Name | -| location_name |Location Name, not currently used over network, but supported by reference Clients. | +| location_name | Location Name, not currently used over network, but supported by reference Clients. | | entrance_name | Entrance Name. No ID mapping exists. | | color | Regular text that should be colored. Only `type` that will contain `color` data. | @@ -400,7 +400,7 @@ Color options: `text` is the content of the message part to be displayed. `player` marks owning player id for location/item, -`item_flags` contains the [NetworkItem](#NetworkItem) flags that belong to the item +`flags` contains the [NetworkItem](#NetworkItem) flags that belong to the item ### Client States An enumeration containing the possible client states that may be used to inform the server in [StatusUpdate](#StatusUpdate).