Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
Wanich Keatkajonjumroen | 639afaf4f8 | |
Wanich Keatkajonjumroen | afb34ce463 | |
Wanich Keatkajonjumroen | c6efb4ad38 | |
Wanich Keatkajonjumroen | 5543faa0cd |
|
@ -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,
|
||||
|
|
|
@ -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")
|
|
@ -0,0 +1,8 @@
|
|||
{% extends "core/frontend/index.jinja" %}
|
||||
{% block content %}
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<h1>{{ title }}</h1>
|
||||
Version: {{version}}
|
||||
{% endblock content %}
|
Loading…
Reference in New Issue