diff --git a/scripts/example_game.py b/scripts/example_game.py index c82df3c..86d6f4a 100644 --- a/scripts/example_game.py +++ b/scripts/example_game.py @@ -1,5 +1,4 @@ import logging -from signal import pause from sqlalchemy import create_engine from sqlalchemy.orm import Session @@ -7,13 +6,20 @@ from star_resonance_tracer.proto.enum_chit_chat_channel_type_pb2 import ChitChat from inventory_wars.game import Game from inventory_wars.models import Base +from inventory_wars.scoring import FirstGuess, HighestAmount logging.basicConfig(level=logging.INFO) engine = create_engine("sqlite:///app.db") Base.metadata.create_all(engine) -game = Game(Session(engine), item_id=1040202, listening_channels=[ChitChatChannelType.ChannelTeam]) -game.start() +game = Game(Session(engine), listening_channels=[ChitChatChannelType.ChannelTeam]) +while True: + item_id = input("Enter item id to start: ") + if not item_id: + break -pause() + game.start(int(item_id), HighestAmount()) + + input("Enter to end game. ") + game.end() diff --git a/scripts/sniff_items.py b/scripts/sniff_items.py deleted file mode 100644 index 3a9b867..0000000 --- a/scripts/sniff_items.py +++ /dev/null @@ -1,40 +0,0 @@ -from signal import pause - -from star_resonance_tracer.proto.enum_chit_chat_msg_type_pb2 import ChitChatMsgType -from star_resonance_tracer.proto.serv_chit_chat_ntf_pb2 import ChitChatNtf as ChitChatNtfPb -from star_resonance_tracer.proto.stru_place_holder_item_pb2 import PlaceHolderItem -from star_resonance_tracer.sniffer import Sniffer - -from inventory_wars.const import ChitChatNtf, decode_placeholder, HypertextVariant -from inventory_wars.sniffer import get_sniffer - - -def on_chit_chat_msg(event: ChitChatNtfPb.NotifyNewestChitChatMsgs) -> None: - req = event.vRequest - - if req.chatMsg.msgInfo.msgType is not ChitChatMsgType.ChatMsgHypertext: - return - - hypertext = req.chatMsg.msgInfo.chatHypertext - if hypertext.configId != HypertextVariant.ITEM_SHARING.value: - return - - for placeholder in hypertext.hypertextContents: - placeholder_content = decode_placeholder(placeholder) - match placeholder_content: - case PlaceHolderItem() as item: - print(item) - - -sniffer = Sniffer() -sniffer.set_service_type( - ChitChatNtf.ServiceId.value, - ChitChatNtf.Method.NotifyNewestChitChatMsgs.value, - ChitChatNtfPb.NotifyNewestChitChatMsgs -) -sniffer.on_service(ChitChatNtfPb.NotifyNewestChitChatMsgs, on_chit_chat_msg) - -scapy = get_sniffer(sniffer) -scapy.start() - -pause()