Fixing level calculation saving & loading on SAO
This commit is contained in:
parent
2b4ac06389
commit
a2fe11d654
@ -3,6 +3,7 @@ import json, logging
|
||||
from typing import Any, Dict
|
||||
import random
|
||||
import struct
|
||||
import csv
|
||||
|
||||
from core.data import Data
|
||||
from core import CoreConfig
|
||||
@ -29,7 +30,6 @@ class SaoBase:
|
||||
|
||||
def handle_c122(self, request: Any) -> bytes:
|
||||
#common/get_maintenance_info
|
||||
|
||||
resp = SaoGetMaintResponse(int.from_bytes(bytes.fromhex(request[:4]), "big")+1)
|
||||
return resp.make()
|
||||
|
||||
@ -438,11 +438,29 @@ class SaoBase:
|
||||
exp = int(profile["rank_exp"]) + 100 #always 100 extra exp for some reason
|
||||
col = int(profile["own_col"]) + int(req_data.base_get_data[0].get_col)
|
||||
|
||||
# Calculate level based off experience and the CSV list
|
||||
with open(r'titles/sao/data/PlayerRank.csv') as csv_file:
|
||||
csv_reader = csv.reader(csv_file, delimiter=',')
|
||||
line_count = 0
|
||||
data = []
|
||||
rowf = False
|
||||
for row in csv_reader:
|
||||
if rowf==False:
|
||||
rowf=True
|
||||
else:
|
||||
data.append(row)
|
||||
|
||||
for i in range(0,len(data)):
|
||||
if exp>=int(data[i][1]) and exp<int(data[i+1][1]):
|
||||
player_level = int(data[i][0])
|
||||
break
|
||||
|
||||
# Update profile
|
||||
updated_profile = self.game_data.profile.put_profile(
|
||||
req_data.user_id,
|
||||
profile["user_type"],
|
||||
profile["nick_name"],
|
||||
profile["rank_num"],
|
||||
player_level,
|
||||
exp,
|
||||
col,
|
||||
profile["own_vp"],
|
||||
|
BIN
titles/sao/data/HeroLogLevel.csv
Normal file
BIN
titles/sao/data/HeroLogLevel.csv
Normal file
Binary file not shown.
|
BIN
titles/sao/data/PlayerRank.csv
Normal file
BIN
titles/sao/data/PlayerRank.csv
Normal file
Binary file not shown.
Can't render this file because it has a wrong number of fields in line 11.
|
@ -2,6 +2,7 @@ import struct
|
||||
from datetime import datetime
|
||||
from construct import *
|
||||
import sys
|
||||
import csv
|
||||
|
||||
class SaoBaseRequest:
|
||||
def __init__(self, data: bytes) -> None:
|
||||
@ -493,9 +494,29 @@ class SaoGetHeroLogUserDataListResponse(SaoBaseResponse):
|
||||
self.last_set_skill_slot5_skill_id = []
|
||||
|
||||
for i in range(len(hero_data)):
|
||||
|
||||
# Calculate level based off experience and the CSV list
|
||||
with open(r'titles/sao/data/HeroLogLevel.csv') as csv_file:
|
||||
csv_reader = csv.reader(csv_file, delimiter=',')
|
||||
line_count = 0
|
||||
data = []
|
||||
rowf = False
|
||||
for row in csv_reader:
|
||||
if rowf==False:
|
||||
rowf=True
|
||||
else:
|
||||
data.append(row)
|
||||
|
||||
exp = hero_data[i][4]
|
||||
|
||||
for e in range(0,len(data)):
|
||||
if exp>=int(data[e][1]) and exp<int(data[e+1][1]):
|
||||
hero_level = int(data[e][0])
|
||||
break
|
||||
|
||||
self.user_hero_log_id.append(hero_data[i][2])
|
||||
self.log_level.append(hero_data[i][3])
|
||||
self.max_log_level_extended_num.append(hero_data[i][3])
|
||||
self.log_level.append(hero_level)
|
||||
self.max_log_level_extended_num.append(hero_level)
|
||||
self.log_exp.append(hero_data[i][4])
|
||||
self.last_set_skill_slot1_skill_id.append(hero_data[i][7])
|
||||
self.last_set_skill_slot2_skill_id.append(hero_data[i][8])
|
||||
@ -510,8 +531,8 @@ class SaoGetHeroLogUserDataListResponse(SaoBaseResponse):
|
||||
self.user_hero_log_id = list(map(str,self.user_hero_log_id)) #str
|
||||
self.hero_log_id = list(map(int,self.user_hero_log_id)) #int
|
||||
self.log_level = list(map(int,self.log_level)) #short
|
||||
self.max_log_level_extended_num = list(map(int,self.log_level)) #short
|
||||
self.log_exp = list(map(int,self.log_level)) #int
|
||||
self.max_log_level_extended_num = list(map(int,self.max_log_level_extended_num)) #short
|
||||
self.log_exp = list(map(int,self.log_exp)) #int
|
||||
self.possible_awakening_flag = 0 #byte
|
||||
self.awakening_stage = 0 #short
|
||||
self.awakening_exp = 0 #int
|
||||
|
Loading…
Reference in New Issue
Block a user