Adding SAO rewards saving for heroes

This commit is contained in:
Midorica 2023-05-30 14:29:50 -04:00
parent a2fe11d654
commit e466ddce55
4 changed files with 17305 additions and 3 deletions

View File

@ -3,7 +3,9 @@ import json, logging
from typing import Any, Dict
import random
import struct
import csv
from csv import *
from random import choice
import random as rand
from core.data import Data
from core import CoreConfig
@ -495,6 +497,25 @@ class SaoBase:
hero_data["skill_slot4_skill_id"],
hero_data["skill_slot5_skill_id"]
)
# Generate random hero(es) based off the response
for a in range(0,req_data.get_unanalyzed_log_tmp_reward_data_list_length):
with open('titles/sao/data/RewardTable.csv', 'r') as f:
keys_unanalyzed = next(f).strip().split(',')
data_unanalyzed = list(DictReader(f, fieldnames=keys_unanalyzed))
randomized_unanalyzed_id = choice(data_unanalyzed)
while int(randomized_unanalyzed_id['UnanalyzedLogGradeId']) != req_data.get_unanalyzed_log_tmp_reward_data_list[a].unanalyzed_log_grade_id:
randomized_unanalyzed_id = choice(data_unanalyzed)
heroList = self.game_data.static.get_hero_id(randomized_unanalyzed_id['CommonRewardId'])
if heroList:
self.game_data.item.put_hero_log(req_data.user_id, randomized_unanalyzed_id['CommonRewardId'], 1, 0, 101000016, 0, 30086, 1001, 1002, 0, 0)
# Item and Equipments saving will be done later here
# Send response
resp = SaoEpisodePlayEndResponse(int.from_bytes(bytes.fromhex(request[:4]), "big")+1)
return resp.make()
@ -511,4 +532,4 @@ class SaoBase:
def handle_c90a(self, request: Any) -> bytes: #should be tweaked for proper item unlock
#quest/episode_play_end_unanalyzed_log_fixed
resp = SaoEpisodePlayEndUnanalyzedLogFixedResponse(int.from_bytes(bytes.fromhex(request[:4]), "big")+1)
return resp.make()
return resp.make()

File diff suppressed because it is too large Load Diff

View File

@ -113,5 +113,4 @@ class SaoServlet(resource.Resource):
self.logger.info(f"Handler {req_url} - {sao_request[:4]} request")
self.logger.debug(f"Request: {request.content.getvalue().hex()}")
self.logger.debug(f"Response: {handler(sao_request).hex()}")
return handler(sao_request)

View File

@ -246,6 +246,14 @@ class SaoStaticData(BaseData):
return None
return [list[2] for list in result.fetchall()]
def get_hero_id(self, heroLogId: int) -> Optional[Dict]:
sql = hero.select(hero.c.heroLogId == heroLogId)
result = self.execute(sql)
if result is None:
return None
return result.fetchone()
def get_hero_ids(self, version: int, enabled: bool) -> Optional[List[Dict]]:
sql = hero.select(hero.c.version == version and hero.c.enabled == enabled).order_by(
hero.c.heroLogId.asc()