forked from Hay1tsme/artemis
Compare commits
17 Commits
ongeki_bug
...
master
Author | SHA1 | Date | |
---|---|---|---|
639afaf4f8 | |||
afb34ce463 | |||
c6efb4ad38 | |||
5543faa0cd | |||
fc947d36a5 | |||
5f586379ca | |||
fe4dfe369b | |||
02040300b8 | |||
780a96ec15 | |||
b8b93a8d51 | |||
a0e24c6742 | |||
90024ddbd9 | |||
be00ad8e96 | |||
e2129b45b7 | |||
670747cf48 | |||
83f09e180e | |||
a83b717821 |
@ -545,21 +545,38 @@ class Mai2DX(Mai2Base):
|
||||
return {"userId": data["userId"], "length": 0, "userRegionList": []}
|
||||
|
||||
def handle_get_user_music_api_request(self, data: Dict) -> Dict:
|
||||
songs = self.data.score.get_best_scores(data["userId"])
|
||||
user_id = data.get("userId", 0)
|
||||
next_index = data.get("nextIndex", 0)
|
||||
max_ct = data.get("maxCount", 50)
|
||||
upper_lim = next_index + max_ct
|
||||
music_detail_list = []
|
||||
next_index = 0
|
||||
|
||||
if songs is not None:
|
||||
for song in songs:
|
||||
tmp = song._asdict()
|
||||
tmp.pop("id")
|
||||
tmp.pop("user")
|
||||
music_detail_list.append(tmp)
|
||||
if user_id <= 0:
|
||||
self.logger.warn("handle_get_user_music_api_request: Could not find userid in data, or userId is 0")
|
||||
return {}
|
||||
|
||||
songs = self.data.score.get_best_scores(user_id)
|
||||
if songs is None:
|
||||
self.logger.debug("handle_get_user_music_api_request: get_best_scores returned None!")
|
||||
return {
|
||||
"userId": data["userId"],
|
||||
"nextIndex": 0,
|
||||
"userMusicList": [],
|
||||
}
|
||||
|
||||
if len(music_detail_list) == data["maxCount"]:
|
||||
next_index = data["maxCount"] + data["nextIndex"]
|
||||
break
|
||||
num_user_songs = len(songs)
|
||||
|
||||
for x in range(next_index, upper_lim):
|
||||
if num_user_songs <= x:
|
||||
break
|
||||
|
||||
tmp = songs[x]._asdict()
|
||||
tmp.pop("id")
|
||||
tmp.pop("user")
|
||||
music_detail_list.append(tmp)
|
||||
|
||||
next_index = 0 if len(music_detail_list) < max_ct or num_user_songs == upper_lim else upper_lim
|
||||
self.logger.info(f"Send songs {next_index}-{upper_lim} ({len(music_detail_list)}) out of {num_user_songs} for user {user_id} (next idx {next_index})")
|
||||
return {
|
||||
"userId": data["userId"],
|
||||
"nextIndex": next_index,
|
||||
|
@ -2,9 +2,11 @@ from titles.ongeki.index import OngekiServlet
|
||||
from titles.ongeki.const import OngekiConstants
|
||||
from titles.ongeki.database import OngekiData
|
||||
from titles.ongeki.read import OngekiReader
|
||||
from titles.ongeki.frontend import OngekiFrontend
|
||||
|
||||
index = OngekiServlet
|
||||
database = OngekiData
|
||||
reader = OngekiReader
|
||||
frontend = OngekiFrontend
|
||||
game_codes = [OngekiConstants.GAME_CODE]
|
||||
current_schema_version = 5
|
||||
|
@ -978,35 +978,41 @@ class OngekiBase:
|
||||
"""
|
||||
Added in Bright
|
||||
"""
|
||||
rival_list = self.data.profile.get_rivals(data["userId"])
|
||||
if rival_list is None or len(rival_list) < 1:
|
||||
|
||||
rival_list = []
|
||||
user_rivals = self.data.profile.get_rivals(data["userId"])
|
||||
for rival in user_rivals:
|
||||
tmp = {}
|
||||
tmp["rivalUserId"] = rival[0]
|
||||
rival_list.append(tmp)
|
||||
|
||||
if user_rivals is None or len(rival_list) < 1:
|
||||
return {
|
||||
"userId": data["userId"],
|
||||
"length": 0,
|
||||
"userRivalList": [],
|
||||
}
|
||||
|
||||
return {
|
||||
"userId": data["userId"],
|
||||
"length": len(rival_list),
|
||||
"userRivalList": rival_list._asdict(),
|
||||
"userRivalList": rival_list,
|
||||
}
|
||||
|
||||
def handle_get_user_rival_data_api_reqiest(self, data: Dict) -> Dict:
|
||||
def handle_get_user_rival_data_api_request(self, data: Dict) -> Dict:
|
||||
"""
|
||||
Added in Bright
|
||||
"""
|
||||
rivals = []
|
||||
|
||||
print(data)
|
||||
for rival in data["userRivalList"]:
|
||||
name = self.data.profile.get_profile_name(
|
||||
rival["rivalUserId"], self.version
|
||||
)
|
||||
if name is None:
|
||||
continue
|
||||
|
||||
rivals.append({"rivalUserId": rival["rival"], "rivalUserName": name})
|
||||
|
||||
print(name)
|
||||
rivals.append({"rivalUserId": rival["rivalUserId"], "rivalUserName": name})
|
||||
print(rivals)
|
||||
return {
|
||||
"userId": data["userId"],
|
||||
"length": len(rivals),
|
||||
@ -1027,7 +1033,7 @@ class OngekiBase:
|
||||
for song in music["userMusicList"]:
|
||||
song["userRivalMusicDetailList"] = song["userMusicDetailList"]
|
||||
song.pop("userMusicDetailList")
|
||||
|
||||
print(music["userMusicList"])
|
||||
return {
|
||||
"userId": data["userId"],
|
||||
"rivalUserId": rival_id,
|
||||
|
42
titles/ongeki/frontend.py
Normal file
42
titles/ongeki/frontend.py
Normal file
@ -0,0 +1,42 @@
|
||||
import yaml
|
||||
import jinja2
|
||||
from twisted.web.http import Request
|
||||
from os import path
|
||||
from twisted.web.server import Session
|
||||
|
||||
from core.frontend import FE_Base, IUserSession
|
||||
from core.config import CoreConfig
|
||||
|
||||
from titles.ongeki.config import OngekiConfig
|
||||
from titles.ongeki.const import OngekiConstants
|
||||
from titles.ongeki.database import OngekiData
|
||||
|
||||
|
||||
class OngekiFrontend(FE_Base):
|
||||
def __init__(
|
||||
self, cfg: CoreConfig, environment: jinja2.Environment, cfg_dir: str
|
||||
) -> None:
|
||||
super().__init__(cfg, environment)
|
||||
self.data = OngekiData(cfg)
|
||||
self.game_cfg = OngekiConfig()
|
||||
if path.exists(f"{cfg_dir}/{OngekiConstants.CONFIG_NAME}"):
|
||||
self.game_cfg.update(
|
||||
yaml.safe_load(open(f"{cfg_dir}/{OngekiConstants.CONFIG_NAME}"))
|
||||
)
|
||||
self.nav_name = "O.N.G.E.K.I."
|
||||
self.geki_version = OngekiConstants.VERSION_NAMES[-1]+"?"
|
||||
print(OngekiConstants.VERSION_NAMES[-1])
|
||||
def render_GET(self, request: Request) -> bytes:
|
||||
template = self.environment.get_template(
|
||||
"titles/ongeki/frontend/ongeki_index.jinja"
|
||||
)
|
||||
sesh: Session = request.getSession()
|
||||
usr_sesh = IUserSession(sesh)
|
||||
|
||||
return template.render(
|
||||
title=f"{self.core_config.server.name} | {self.nav_name}",
|
||||
game_list=self.environment.globals["game_list"],
|
||||
gachas=self.game_cfg.gachas.enabled_gachas,
|
||||
version= self.geki_version,
|
||||
sesh=vars(usr_sesh)
|
||||
).encode("utf-16")
|
8
titles/ongeki/frontend/ongeki_index.jinja
Normal file
8
titles/ongeki/frontend/ongeki_index.jinja
Normal file
@ -0,0 +1,8 @@
|
||||
{% extends "core/frontend/index.jinja" %}
|
||||
{% block content %}
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<h1>{{ title }}</h1>
|
||||
Version: {{version}}
|
||||
{% endblock content %}
|
Reference in New Issue
Block a user