forked from Hay1tsme/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)
|
||||
|
||||
if vs_info is not None:
|
||||
vs_info["vs_cnt"] += 1
|
||||
vs_info["vs_win"] = vs_info["vs_win"] + data.get("win_flg")
|
||||
vs_info = vs_info._asdict()
|
||||
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"]
|
||||
@ -601,40 +600,71 @@ class IDACSeason2(IDACBase):
|
||||
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)
|
||||
|
||||
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
|
||||
for course in vs_info["vsinfo_course_data"]:
|
||||
if course["course_id"] == data.get("course_id"):
|
||||
course["vs_cnt"] += 1
|
||||
course["vs_win"] += data.get("win_flg")
|
||||
course_not_exists = False
|
||||
|
||||
if vs_courses_info is not None:
|
||||
for course in vs_courses_info:
|
||||
course = course._asdict()
|
||||
if course["course_id"] == data.get("course_id"):
|
||||
course["vs_cnt"] += 1
|
||||
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
|
||||
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:
|
||||
course = {}
|
||||
course["course_id"] = data.get("course_id")
|
||||
course["vs_cnt"] = 1
|
||||
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)
|
||||
self.data.item.put_vs_course_info(user_id, battle_mode, course)
|
||||
else:
|
||||
vs_info = {
|
||||
"battle_mode": battle_mode,
|
||||
"vs_cnt": 1,
|
||||
"vs_win": data.get("win_flg"),
|
||||
#"vs_cnt": 1,
|
||||
#"vs_win": data.get("win_flg"),
|
||||
"invalid": data.get("result"),
|
||||
"str": data.get("win_flg"),
|
||||
"str_now": data.get("win_flg"),
|
||||
"lose_now": 1 if data.get("win_flg") == 0 else 0,
|
||||
"break_count": data.get("break_count"),
|
||||
"break_penalty_flag": data.get("break_penalty_flag"),
|
||||
"vsinfo_course_data": [
|
||||
{
|
||||
"course_id": data.get("course_id"),
|
||||
"vs_cnt": 1,
|
||||
"vs_win": data.get("win_flg")
|
||||
}
|
||||
],
|
||||
#"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)
|
||||
|
||||
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")
|
||||
}
|
||||
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["vs_history"] = data.get("vs_history")
|
||||
vs_info["course_select_priority"] = data.get("course_select_priority")
|
||||
@ -765,21 +795,41 @@ class IDACSeason2(IDACBase):
|
||||
# get the users vs info data
|
||||
vs_info_data = []
|
||||
vs_info = self.data.item.get_vs_infos(user_id)
|
||||
for vs in vs_info:
|
||||
vs_info_data.append(
|
||||
{
|
||||
"battle_mode": vs_info["battle_mode"],
|
||||
"vs_cnt": vs_info["vs_cnt"],
|
||||
"vs_win": vs_info["vs_win"],
|
||||
"invalid": vs_info["invalid"],
|
||||
"str": vs_info["str"],
|
||||
"str_now": vs_info["str_now"],
|
||||
"lose_now": vs_info["lose_now"],
|
||||
"vs_history": 0,
|
||||
"course_select_priority": 0,
|
||||
"vsinfo_course_data": vs_info["vsinfo_course_data"],
|
||||
}
|
||||
)
|
||||
if vs_info is not None:
|
||||
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(
|
||||
{
|
||||
"battle_mode": vs["battle_mode"],
|
||||
"vs_cnt": total_vs_cnt,
|
||||
"vs_win": total_vs_win,
|
||||
"invalid": vs["invalid"],
|
||||
"str": vs["str"],
|
||||
"str_now": vs["str_now"],
|
||||
"lose_now": vs["lose_now"],
|
||||
"vs_history": 0,
|
||||
"course_select_priority": 0,
|
||||
"vsinfo_course_data": courses_info,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
# get the user's car
|
||||
cars = self.data.item.get_cars(self.version, user_id, only_pickup=True)
|
||||
|
Loading…
Reference in New Issue
Block a user