forked from Dniel97/artemis
idac: bugfixes
This commit is contained in:
parent
88b3cfc750
commit
a1a43130bf
@ -539,7 +539,9 @@ class IDACSeason2(IDACBase):
|
||||
|
||||
async def _generate_special_data(self, user_id: int) -> Dict:
|
||||
# 4 = special mode
|
||||
specials = await self.data.item.get_best_challenges_by_vs_type(user_id, story_type=4)
|
||||
specials = await self.data.item.get_best_challenges_by_vs_type(
|
||||
user_id, story_type=4
|
||||
)
|
||||
|
||||
special_data = []
|
||||
for s in specials:
|
||||
@ -589,31 +591,41 @@ class IDACSeason2(IDACBase):
|
||||
user_id, self.version, updated_stock_data
|
||||
)
|
||||
|
||||
def _update_vs_info(self, user_id: int, battle_mode: int, data: Dict) -> Dict:
|
||||
vs_info = self.data.item.get_vs_info_by_mode(user_id, battle_mode)
|
||||
|
||||
async def _update_vs_info(self, user_id: int, battle_mode: int, data: Dict) -> Dict:
|
||||
vs_info = await self.data.item.get_vs_info_by_mode(user_id, battle_mode)
|
||||
|
||||
if vs_info is not None:
|
||||
vs_info = vs_info._asdict()
|
||||
del vs_info["id"]
|
||||
del vs_info["user"]
|
||||
|
||||
vs_info["invalid"] = vs_info["invalid"] + data.get("result")
|
||||
vs_info["str_now"] = vs_info["str_now"] + data.get("win_flg") if data.get("win_flg") == 1 else 0
|
||||
vs_info["str"] = vs_info["str"] if vs_info["str"] > vs_info["str_now"] else vs_info["str_now"]
|
||||
vs_info["str_now"] = (
|
||||
vs_info["str_now"] + data.get("win_flg")
|
||||
if data.get("win_flg") == 1
|
||||
else 0
|
||||
)
|
||||
vs_info["str"] = (
|
||||
vs_info["str"]
|
||||
if vs_info["str"] > vs_info["str_now"]
|
||||
else vs_info["str_now"]
|
||||
)
|
||||
vs_info["lose_now"] += 1 if data.get("win_flg") == 0 else 0
|
||||
vs_info["vs_history"] = data.get("vs_history")
|
||||
vs_info["break_count"] += data.get("break_count")
|
||||
vs_info["break_penalty_flag"] = data.get("break_penalty_flag")
|
||||
|
||||
self.data.item.put_vs_info(user_id, battle_mode, vs_info)
|
||||
|
||||
|
||||
await self.data.item.put_vs_info(user_id, battle_mode, vs_info)
|
||||
|
||||
vs_info["vs_cnt"] = 0
|
||||
vs_info["vs_win"] = 0
|
||||
vs_info["vsinfo_course_data"] = []
|
||||
|
||||
vs_courses_info = self.data.item.get_vs_course_info_by_mode(user_id, battle_mode)
|
||||
|
||||
vs_courses_info = await self.data.item.get_vs_course_infos_by_mode(
|
||||
user_id, battle_mode
|
||||
)
|
||||
course_not_exists = True
|
||||
|
||||
|
||||
if vs_courses_info is not None:
|
||||
for course in vs_courses_info:
|
||||
course = course._asdict()
|
||||
@ -625,13 +637,15 @@ class IDACSeason2(IDACBase):
|
||||
course["vs_win"] += data.get("win_flg")
|
||||
vs_info["vs_cnt"] += course["vs_cnt"]
|
||||
vs_info["vs_win"] += course["vs_win"]
|
||||
self.data.item.put_vs_course_info(user_id, battle_mode, course)
|
||||
await self.data.item.put_vs_course_info(
|
||||
user_id, battle_mode, course
|
||||
)
|
||||
course_not_exists = False
|
||||
else:
|
||||
vs_info["vs_cnt"] += course["vs_cnt"]
|
||||
vs_info["vs_win"] += course["vs_win"]
|
||||
vs_info["vsinfo_course_data"].append(course)
|
||||
|
||||
vs_info["vsinfo_course_data"].append(course)
|
||||
|
||||
if course_not_exists:
|
||||
course = {}
|
||||
course["course_id"] = data.get("course_id")
|
||||
@ -640,7 +654,7 @@ class IDACSeason2(IDACBase):
|
||||
vs_info["vs_cnt"] += course["vs_cnt"]
|
||||
vs_info["vs_win"] += course["vs_win"]
|
||||
vs_info["vsinfo_course_data"].append(course)
|
||||
self.data.item.put_vs_course_info(user_id, battle_mode, course)
|
||||
await self.data.item.put_vs_course_info(user_id, battle_mode, course)
|
||||
else:
|
||||
vs_info = {
|
||||
"battle_mode": battle_mode,
|
||||
@ -661,20 +675,20 @@ class IDACSeason2(IDACBase):
|
||||
# }
|
||||
# ],
|
||||
}
|
||||
self.data.item.put_vs_info(user_id, battle_mode, vs_info)
|
||||
|
||||
await self.data.item.put_vs_info(user_id, battle_mode, vs_info)
|
||||
|
||||
course_info = {
|
||||
"course_id": data.get("course_id"),
|
||||
"vs_cnt": 1,
|
||||
"vs_win": data.get("win_flg")
|
||||
"vs_win": data.get("win_flg"),
|
||||
}
|
||||
self.data.item.put_vs_course_info(user_id, battle_mode, course_info)
|
||||
|
||||
await self.data.item.put_vs_course_info(user_id, battle_mode, course_info)
|
||||
|
||||
vs_info["vs_cnt"] = 1
|
||||
vs_info["vs_win"] = data.get("win_flg")
|
||||
vs_info["vsinfo_course_data"] = []
|
||||
vs_info["vsinfo_course_data"].append(course_info)
|
||||
|
||||
|
||||
vs_info["course_select_priority"] = data.get("course_select_priority")
|
||||
return vs_info
|
||||
|
||||
@ -802,11 +816,13 @@ class IDACSeason2(IDACBase):
|
||||
|
||||
# get the users vs info data
|
||||
vs_info_data = []
|
||||
vs_info = self.data.item.get_vs_infos(user_id)
|
||||
vs_info = await self.data.item.get_vs_infos(user_id)
|
||||
if vs_info is not None:
|
||||
for vs in vs_info:
|
||||
vs = vs._asdict()
|
||||
vs_courses_infos = self.data.item.get_vs_course_infos_by_mode(user_id, vs["battle_mode"])
|
||||
vs_courses_infos = await self.data.item.get_vs_course_infos_by_mode(
|
||||
user_id, vs["battle_mode"]
|
||||
)
|
||||
total_vs_win = 0
|
||||
total_vs_cnt = 0
|
||||
courses_info = []
|
||||
@ -816,12 +832,11 @@ class IDACSeason2(IDACBase):
|
||||
del tmp["id"]
|
||||
del tmp["user"]
|
||||
del tmp["battle_mode"]
|
||||
|
||||
|
||||
total_vs_win += tmp["vs_win"]
|
||||
total_vs_cnt += tmp["vs_cnt"]
|
||||
|
||||
|
||||
courses_info.append(tmp)
|
||||
|
||||
|
||||
vs_info_data.append(
|
||||
{
|
||||
@ -840,7 +855,6 @@ class IDACSeason2(IDACBase):
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
# get the user's car
|
||||
cars = await self.data.item.get_cars(self.version, user_id, only_pickup=True)
|
||||
fulltune_count = 0
|
||||
@ -903,7 +917,9 @@ class IDACSeason2(IDACBase):
|
||||
|
||||
# get the user's timetrial event data
|
||||
timetrial_event_data = {}
|
||||
timetrial = await self.data.item.get_timetrial_event(user_id, self.timetrial_event_id)
|
||||
timetrial = await self.data.item.get_timetrial_event(
|
||||
user_id, self.timetrial_event_id
|
||||
)
|
||||
if timetrial is not None:
|
||||
timetrial_event_data = {
|
||||
"timetrial_event_id": timetrial["timetrial_event_id"],
|
||||
@ -990,14 +1006,18 @@ class IDACSeason2(IDACBase):
|
||||
"special_mode_hint_data": {"story_type": 0, "hint_display_flag": 0},
|
||||
}
|
||||
|
||||
async def handle_timetrial_getbestrecordpreta_request(self, data: Dict, headers: Dict):
|
||||
async def handle_timetrial_getbestrecordpreta_request(
|
||||
self, data: Dict, headers: Dict
|
||||
):
|
||||
user_id = headers["session"]
|
||||
|
||||
for car_id in data["car_ids"]:
|
||||
pass
|
||||
|
||||
course_mybest_data = []
|
||||
courses = await self.data.item.get_time_trial_user_best_courses(self.version, user_id)
|
||||
courses = await self.data.item.get_time_trial_user_best_courses(
|
||||
self.version, user_id
|
||||
)
|
||||
for course in courses:
|
||||
course_mybest_data.append(
|
||||
{
|
||||
@ -1065,7 +1085,9 @@ class IDACSeason2(IDACBase):
|
||||
"course_pickup_car_best_data": course_pickup_car_best_data,
|
||||
}
|
||||
|
||||
async def handle_timetrial_getbestrecordprerace_request(self, data: Dict, headers: Dict):
|
||||
async def handle_timetrial_getbestrecordprerace_request(
|
||||
self, data: Dict, headers: Dict
|
||||
):
|
||||
user_id = headers["session"]
|
||||
|
||||
course_id = data["course_id"]
|
||||
@ -1275,7 +1297,9 @@ class IDACSeason2(IDACBase):
|
||||
|
||||
return {"status_code": "0"}
|
||||
|
||||
async def handle_factory_updatecustomizeresult_request(self, data: Dict, headers: Dict):
|
||||
async def handle_factory_updatecustomizeresult_request(
|
||||
self, data: Dict, headers: Dict
|
||||
):
|
||||
user_id = headers["session"]
|
||||
|
||||
parts_data: List = data.pop("parts_list")
|
||||
@ -1413,7 +1437,9 @@ class IDACSeason2(IDACBase):
|
||||
|
||||
return {"status_code": "0"}
|
||||
|
||||
async def handle_factory_updatecustomizeavatar_request(self, data: Dict, headers: Dict):
|
||||
async def handle_factory_updatecustomizeavatar_request(
|
||||
self, data: Dict, headers: Dict
|
||||
):
|
||||
user_id = headers["session"]
|
||||
|
||||
avatar_data: Dict = data.pop("avatar_obj")
|
||||
@ -1427,7 +1453,9 @@ class IDACSeason2(IDACBase):
|
||||
|
||||
return {"status_code": "0"}
|
||||
|
||||
async def handle_factory_updatecustomizeuser_request(self, data: Dict, headers: Dict):
|
||||
async def handle_factory_updatecustomizeuser_request(
|
||||
self, data: Dict, headers: Dict
|
||||
):
|
||||
user_id = headers["session"]
|
||||
|
||||
stock_data: Dict = data.pop("stock_obj")
|
||||
@ -1449,7 +1477,9 @@ class IDACSeason2(IDACBase):
|
||||
|
||||
return {"status_code": "0"}
|
||||
|
||||
async def handle_user_updatetimetrialresult_request(self, data: Dict, headers: Dict):
|
||||
async def handle_user_updatetimetrialresult_request(
|
||||
self, data: Dict, headers: Dict
|
||||
):
|
||||
user_id = headers["session"]
|
||||
|
||||
stock_data: Dict = data.pop("stock_obj")
|
||||
@ -1710,7 +1740,9 @@ class IDACSeason2(IDACBase):
|
||||
"maker_use_count": [],
|
||||
}
|
||||
|
||||
async def handle_user_updatespecialmoderesult_request(self, data: Dict, headers: Dict):
|
||||
async def handle_user_updatespecialmoderesult_request(
|
||||
self, data: Dict, headers: Dict
|
||||
):
|
||||
user_id = headers["session"]
|
||||
|
||||
stock_data: Dict = data.pop("stock_obj")
|
||||
@ -1781,7 +1813,9 @@ class IDACSeason2(IDACBase):
|
||||
"maker_use_count": [],
|
||||
}
|
||||
|
||||
async def handle_user_updatechallengemoderesult_request(self, data: Dict, headers: Dict):
|
||||
async def handle_user_updatechallengemoderesult_request(
|
||||
self, data: Dict, headers: Dict
|
||||
):
|
||||
user_id = headers["session"]
|
||||
|
||||
stock_data: Dict = data.pop("stock_obj")
|
||||
@ -1859,7 +1893,9 @@ class IDACSeason2(IDACBase):
|
||||
"maker_use_count": [],
|
||||
}
|
||||
|
||||
async def _generate_time_trial_data(self, season_id: int, user_id: int) -> List[Dict]:
|
||||
async def _generate_time_trial_data(
|
||||
self, season_id: int, user_id: int
|
||||
) -> List[Dict]:
|
||||
# get the season time trial data from database
|
||||
timetrial_data = []
|
||||
|
||||
@ -1906,7 +1942,9 @@ class IDACSeason2(IDACBase):
|
||||
season_id = data.get("season_id")
|
||||
|
||||
# so to get the season 1 data just subtract 1 from the season id
|
||||
past_timetrial_data = await self._generate_time_trial_data(season_id - 1, user_id)
|
||||
past_timetrial_data = await self._generate_time_trial_data(
|
||||
season_id - 1, user_id
|
||||
)
|
||||
|
||||
# TODO: get the current season timetrial data somehow, because after requesting
|
||||
# GetPastSeasonTAData the game will NOT request GetTAData?!
|
||||
@ -1922,13 +1960,104 @@ class IDACSeason2(IDACBase):
|
||||
|
||||
# so to get the season 1 data just subtract 1 from the season id
|
||||
past_timetrial_data = self._generate_time_trial_data(season_id - 1, user_id)
|
||||
|
||||
|
||||
return {
|
||||
"status_code": "0",
|
||||
"season_id": season_id,
|
||||
"past_season_round_event_data": [{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "DAC稼働記念 1stラウンド","round_id": 0},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 2ndラウンド","round_id": 1},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 3rdラウンド","round_id": 2},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 4thラウンド","round_id": 3},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 5thラウンド","round_id": 4},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 6thラウンド","round_id": 5},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 7thラウンド","round_id": 6},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 8thラウンド","round_id": 7},{"count": 0,"win": 0,"rank": 0,"area_rank": 0,"point": 0,"total_round_point": 0,"round_name": "シーズン1 9thラウンド","round_id": 8}]
|
||||
"past_season_round_event_data": [
|
||||
{
|
||||
"count": 0,
|
||||
"win": 0,
|
||||
"rank": 0,
|
||||
"area_rank": 0,
|
||||
"point": 0,
|
||||
"total_round_point": 0,
|
||||
"round_name": "DAC稼働記念 1stラウンド",
|
||||
"round_id": 0,
|
||||
},
|
||||
{
|
||||
"count": 0,
|
||||
"win": 0,
|
||||
"rank": 0,
|
||||
"area_rank": 0,
|
||||
"point": 0,
|
||||
"total_round_point": 0,
|
||||
"round_name": "シーズン1 2ndラウンド",
|
||||
"round_id": 1,
|
||||
},
|
||||
{
|
||||
"count": 0,
|
||||
"win": 0,
|
||||
"rank": 0,
|
||||
"area_rank": 0,
|
||||
"point": 0,
|
||||
"total_round_point": 0,
|
||||
"round_name": "シーズン1 3rdラウンド",
|
||||
"round_id": 2,
|
||||
},
|
||||
{
|
||||
"count": 0,
|
||||
"win": 0,
|
||||
"rank": 0,
|
||||
"area_rank": 0,
|
||||
"point": 0,
|
||||
"total_round_point": 0,
|
||||
"round_name": "シーズン1 4thラウンド",
|
||||
"round_id": 3,
|
||||
},
|
||||
{
|
||||
"count": 0,
|
||||
"win": 0,
|
||||
"rank": 0,
|
||||
"area_rank": 0,
|
||||
"point": 0,
|
||||
"total_round_point": 0,
|
||||
"round_name": "シーズン1 5thラウンド",
|
||||
"round_id": 4,
|
||||
},
|
||||
{
|
||||
"count": 0,
|
||||
"win": 0,
|
||||
"rank": 0,
|
||||
"area_rank": 0,
|
||||
"point": 0,
|
||||
"total_round_point": 0,
|
||||
"round_name": "シーズン1 6thラウンド",
|
||||
"round_id": 5,
|
||||
},
|
||||
{
|
||||
"count": 0,
|
||||
"win": 0,
|
||||
"rank": 0,
|
||||
"area_rank": 0,
|
||||
"point": 0,
|
||||
"total_round_point": 0,
|
||||
"round_name": "シーズン1 7thラウンド",
|
||||
"round_id": 6,
|
||||
},
|
||||
{
|
||||
"count": 0,
|
||||
"win": 0,
|
||||
"rank": 0,
|
||||
"area_rank": 0,
|
||||
"point": 0,
|
||||
"total_round_point": 0,
|
||||
"round_name": "シーズン1 8thラウンド",
|
||||
"round_id": 7,
|
||||
},
|
||||
{
|
||||
"count": 0,
|
||||
"win": 0,
|
||||
"rank": 0,
|
||||
"area_rank": 0,
|
||||
"point": 0,
|
||||
"total_round_point": 0,
|
||||
"round_name": "シーズン1 9thラウンド",
|
||||
"round_id": 8,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
async def handle_user_gettadata_request(self, data: Dict, headers: Dict):
|
||||
user_id = headers["session"]
|
||||
|
||||
@ -1999,7 +2128,9 @@ class IDACSeason2(IDACBase):
|
||||
await self.data.item.put_ticket(user_id, ticket)
|
||||
|
||||
# save rank dist data in database
|
||||
await self.data.profile.put_profile_rank(user_id, self.version, reward_dist_data)
|
||||
await self.data.profile.put_profile_rank(
|
||||
user_id, self.version, reward_dist_data
|
||||
)
|
||||
|
||||
# update profile data and config in database
|
||||
await self.data.profile.put_profile(user_id, self.version, data)
|
||||
@ -2030,7 +2161,9 @@ class IDACSeason2(IDACBase):
|
||||
else:
|
||||
profile = await self.data.profile.get_profile(user_id, self.version)
|
||||
|
||||
rank = await self.data.profile.get_profile_rank(profile["user"], self.version)
|
||||
rank = await self.data.profile.get_profile_rank(
|
||||
profile["user"], self.version
|
||||
)
|
||||
|
||||
avatars = [
|
||||
{
|
||||
@ -2101,7 +2234,9 @@ class IDACSeason2(IDACBase):
|
||||
car = await self.data.item.get_random_car(self.version)
|
||||
else:
|
||||
avatar = await self.data.profile.get_profile_avatar(profile["user"])
|
||||
car = await self.data.item.get_random_user_car(profile["user"], self.version)
|
||||
car = await self.data.item.get_random_user_car(
|
||||
profile["user"], self.version
|
||||
)
|
||||
|
||||
parts_list = []
|
||||
for part in car["parts_list"]:
|
||||
@ -2223,7 +2358,9 @@ class IDACSeason2(IDACBase):
|
||||
while len(user_list) < count_auto_match:
|
||||
user_list.append(-1)
|
||||
|
||||
auto_match = await self._generate_theory_rival_data(user_list, course_id, user_id)
|
||||
auto_match = await self._generate_theory_rival_data(
|
||||
user_list, course_id, user_id
|
||||
)
|
||||
|
||||
# get profiles with the same powerhouse_lv for power match
|
||||
theory_courses = await self.data.item.get_theory_course_by_powerhouse_lv(
|
||||
@ -2235,7 +2372,9 @@ class IDACSeason2(IDACBase):
|
||||
while len(user_list) < count_power_match:
|
||||
user_list.append(-1)
|
||||
|
||||
power_match = await self._generate_theory_rival_data(user_list, course_id, user_id)
|
||||
power_match = await self._generate_theory_rival_data(
|
||||
user_list, course_id, user_id
|
||||
)
|
||||
|
||||
return {
|
||||
"status_code": "0",
|
||||
@ -2519,7 +2658,9 @@ class IDACSeason2(IDACBase):
|
||||
"maker_use_count": [],
|
||||
}
|
||||
|
||||
async def handle_user_updatestorebattleresult_request(self, data: Dict, headers: Dict):
|
||||
async def handle_user_updatestorebattleresult_request(
|
||||
self, data: Dict, headers: Dict
|
||||
):
|
||||
user_id = headers["session"]
|
||||
|
||||
stock_data: Dict = data.pop("stock_obj")
|
||||
@ -2581,7 +2722,9 @@ class IDACSeason2(IDACBase):
|
||||
)
|
||||
|
||||
# save vs_info in database
|
||||
vs_info = self._update_vs_info(user_id, IDACConstants.BATTLE_MODE_OFFLINE, data)
|
||||
vs_info = await self._update_vs_info(
|
||||
user_id, IDACConstants.BATTLE_MODE_OFFLINE, data
|
||||
)
|
||||
|
||||
return {
|
||||
"status_code": "0",
|
||||
|
Loading…
Reference in New Issue
Block a user