1
0
mirror of synced 2024-12-22 17:55:52 +01:00
artemis/titles/idz/handlers/create_profile.py

74 lines
2.2 KiB
Python
Raw Normal View History

2023-04-23 10:38:28 +02:00
import json
import struct
from datetime import datetime
from .base import IDZHandlerBase
from core.config import CoreConfig
from ..config import IDZConfig
2023-04-23 10:38:28 +02:00
class IDZHandlerCreateProfile(IDZHandlerBase):
cmd_codes = [0x0066, 0x0066, 0x0064, 0x0064]
rsp_codes = [0x0067, 0x0065, 0x0065, 0x0065]
name = "create_profile"
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
super().__init__(core_cfg, game_cfg, version)
self.size = 0x0020
2023-04-23 10:38:28 +02:00
def handle(self, data: bytes) -> bytearray:
ret = super().handle(data)
aime_id = struct.unpack_from("<L", data, 0x04)[0]
name = data[0x1E:0x0034].decode("shift-jis").replace("\x00", "")
car = data[0x40:0xA0].hex()
chara = data[0xA8:0xBC].hex()
2023-04-23 10:38:28 +02:00
self.logger.info(f"Create profile for {name} (aime id {aime_id})")
auto_team = None
if not auto_team:
team = {"bg": 0, "id": 0, "shop": ""}
2023-04-23 10:38:28 +02:00
else:
tdata = json.loads(auto_team["data"])
team = {"bg": tdata["bg"], "id": tdata["fx"], "shop": ""}
profile_data = {
2023-04-23 10:38:28 +02:00
"profile": {
"xp": 0,
"lv": 1,
"fame": 0,
"dpoint": 0,
"milage": 0,
"playstamps": 0,
"last_login": int(datetime.now().timestamp()),
"car_str": car, # These should probably be chaged to dicts
"chara_str": chara, # But this works for now...
2023-04-23 10:38:28 +02:00
},
"options": {
"music": 0,
"pack": 13640,
"aura": 0,
"paper_cup": 0,
"gauges": 5,
"driving_style": 0,
2023-04-23 10:38:28 +02:00
},
"missions": {"team": [], "solo": []},
"story": {"x": 0, "y": 0, "rows": {}},
2023-04-23 10:38:28 +02:00
"unlocks": {
"auras": 1,
"cup": 0,
"gauges": 32,
"music": 0,
"last_mileage_reward": 0,
},
"team": team,
2023-04-23 10:38:28 +02:00
}
2023-04-23 10:38:28 +02:00
if self.version > 2:
struct.pack_into("<L", ret, 0x04, aime_id)
else:
struct.pack_into("<L", ret, 0x08, aime_id)
return ret