1
0

feat: implement game logic

This commit is contained in:
2026-06-01 22:33:12 +08:00
parent 0619f8c429
commit 48b69b7775
11 changed files with 406 additions and 3 deletions
+16
View File
@@ -0,0 +1,16 @@
import logging
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from star_resonance_tracer.proto.enum_chit_chat_channel_type_pb2 import ChitChatChannelType
from inventory_wars.game import Game
from inventory_wars.models import Base
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()
+36
View File
@@ -0,0 +1,36 @@
from star_resonance_tracer.proto.enum_chit_chat_msg_type_pb2 import ChitChatMsgType
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 start_sniffing
from star_resonance_tracer.proto.serv_chit_chat_ntf_pb2 import ChitChatNtf as ChitChatNtfPb
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)
start_sniffing(sniffer)