forked from Dniel97/artemis
implement new vs_info saving method
This commit is contained in:
parent
39031757f4
commit
a42993aca7
@ -592,8 +592,7 @@ class IDACSeason2(IDACBase):
|
|||||||
vs_info = self.data.item.get_vs_infos_by_mode(user_id, battle_mode)
|
vs_info = self.data.item.get_vs_infos_by_mode(user_id, battle_mode)
|
||||||
|
|
||||||
if vs_info is not None:
|
if vs_info is not None:
|
||||||
vs_info["vs_cnt"] += 1
|
vs_info = vs_info._asdict()
|
||||||
vs_info["vs_win"] = vs_info["vs_win"] + data.get("win_flg")
|
|
||||||
vs_info["invalid"] = vs_info["invalid"] + data.get("result")
|
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_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"] = vs_info["str"] if vs_info["str"] > vs_info["str_now"] else vs_info["str_now"]
|
||||||
@ -601,40 +600,71 @@ class IDACSeason2(IDACBase):
|
|||||||
vs_info["break_count"] += data.get("break_count")
|
vs_info["break_count"] += data.get("break_count")
|
||||||
vs_info["break_penalty_flag"] = data.get("break_penalty_flag")
|
vs_info["break_penalty_flag"] = data.get("break_penalty_flag")
|
||||||
|
|
||||||
|
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)
|
||||||
course_not_exists = True
|
course_not_exists = True
|
||||||
for course in vs_info["vsinfo_course_data"]:
|
|
||||||
|
if vs_courses_info is not None:
|
||||||
|
for course in vs_courses_info:
|
||||||
|
course = course._asdict()
|
||||||
if course["course_id"] == data.get("course_id"):
|
if course["course_id"] == data.get("course_id"):
|
||||||
course["vs_cnt"] += 1
|
course["vs_cnt"] += 1
|
||||||
course["vs_win"] += data.get("win_flg")
|
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)
|
||||||
course_not_exists = False
|
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)
|
||||||
|
|
||||||
if course_not_exists:
|
if course_not_exists:
|
||||||
course = {}
|
course = {}
|
||||||
course["course_id"] = data.get("course_id")
|
course["course_id"] = data.get("course_id")
|
||||||
course["vs_cnt"] = 1
|
course["vs_cnt"] = 1
|
||||||
course["vs_win"] = data.get("win_flg")
|
course["vs_win"] = data.get("win_flg")
|
||||||
|
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)
|
||||||
|
self.data.item.put_vs_course_info(user_id, battle_mode, course)
|
||||||
else:
|
else:
|
||||||
vs_info = {
|
vs_info = {
|
||||||
"battle_mode": battle_mode,
|
"battle_mode": battle_mode,
|
||||||
"vs_cnt": 1,
|
#"vs_cnt": 1,
|
||||||
"vs_win": data.get("win_flg"),
|
#"vs_win": data.get("win_flg"),
|
||||||
"invalid": data.get("result"),
|
"invalid": data.get("result"),
|
||||||
"str": data.get("win_flg"),
|
"str": data.get("win_flg"),
|
||||||
"str_now": data.get("win_flg"),
|
"str_now": data.get("win_flg"),
|
||||||
"lose_now": 1 if data.get("win_flg") == 0 else 0,
|
"lose_now": 1 if data.get("win_flg") == 0 else 0,
|
||||||
"break_count": data.get("break_count"),
|
"break_count": data.get("break_count"),
|
||||||
"break_penalty_flag": data.get("break_penalty_flag"),
|
"break_penalty_flag": data.get("break_penalty_flag"),
|
||||||
"vsinfo_course_data": [
|
#"vsinfo_course_data": [
|
||||||
{
|
# {
|
||||||
|
# "course_id": data.get("course_id"),
|
||||||
|
# "vs_cnt": 1,
|
||||||
|
# "vs_win": data.get("win_flg")
|
||||||
|
# }
|
||||||
|
#],
|
||||||
|
}
|
||||||
|
self.data.item.put_vs_info(user_id, battle_mode, vs_info)
|
||||||
|
|
||||||
|
course_info = {
|
||||||
"course_id": data.get("course_id"),
|
"course_id": data.get("course_id"),
|
||||||
"vs_cnt": 1,
|
"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)
|
||||||
}
|
|
||||||
|
|
||||||
self.data.item.put_vs_info(user_id, battle_mode, vs_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["vs_history"] = data.get("vs_history")
|
vs_info["vs_history"] = data.get("vs_history")
|
||||||
vs_info["course_select_priority"] = data.get("course_select_priority")
|
vs_info["course_select_priority"] = data.get("course_select_priority")
|
||||||
@ -765,22 +795,42 @@ class IDACSeason2(IDACBase):
|
|||||||
# get the users vs info data
|
# get the users vs info data
|
||||||
vs_info_data = []
|
vs_info_data = []
|
||||||
vs_info = self.data.item.get_vs_infos(user_id)
|
vs_info = self.data.item.get_vs_infos(user_id)
|
||||||
|
if vs_info is not None:
|
||||||
for vs in vs_info:
|
for vs in vs_info:
|
||||||
|
vs = vs._asdict()
|
||||||
|
vs_courses_info = self.data.item.get_vs_course_info_by_mode(user_id, vs["battle_mode"])
|
||||||
|
total_vs_win = 0
|
||||||
|
total_vs_cnt = 0
|
||||||
|
courses_info = []
|
||||||
|
if vs_courses_info is not None:
|
||||||
|
for course in vs_courses_info:
|
||||||
|
tmp = course._asdict()
|
||||||
|
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(
|
vs_info_data.append(
|
||||||
{
|
{
|
||||||
"battle_mode": vs_info["battle_mode"],
|
"battle_mode": vs["battle_mode"],
|
||||||
"vs_cnt": vs_info["vs_cnt"],
|
"vs_cnt": total_vs_cnt,
|
||||||
"vs_win": vs_info["vs_win"],
|
"vs_win": total_vs_win,
|
||||||
"invalid": vs_info["invalid"],
|
"invalid": vs["invalid"],
|
||||||
"str": vs_info["str"],
|
"str": vs["str"],
|
||||||
"str_now": vs_info["str_now"],
|
"str_now": vs["str_now"],
|
||||||
"lose_now": vs_info["lose_now"],
|
"lose_now": vs["lose_now"],
|
||||||
"vs_history": 0,
|
"vs_history": 0,
|
||||||
"course_select_priority": 0,
|
"course_select_priority": 0,
|
||||||
"vsinfo_course_data": vs_info["vsinfo_course_data"],
|
"vsinfo_course_data": courses_info,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# get the user's car
|
# get the user's car
|
||||||
cars = self.data.item.get_cars(self.version, user_id, only_pickup=True)
|
cars = self.data.item.get_cars(self.version, user_id, only_pickup=True)
|
||||||
fulltune_count = 0
|
fulltune_count = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user