mirror of
https://github.com/573dev/gfdm-server.git
synced 2026-03-21 17:54:19 -05:00
Save playstyle. Fix some bugs
This commit is contained in:
parent
a46b0210eb
commit
aed03a5fdb
|
|
@ -104,7 +104,7 @@ class Data(object):
|
|||
self.chara = int(root.find("chara").text)
|
||||
self.uid = root.find("uid").text
|
||||
self.cabid = int(root.find("cabid").text)
|
||||
self.is_succession = itob(int(root.find("is_succession")))
|
||||
self.is_succession = itob(int(root.find("is_succession").text))
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class Progress(object):
|
|||
def __init__(self, req: ServiceRequest) -> None:
|
||||
self.progress_value = int(req.xml[0].find("progress").text)
|
||||
|
||||
def progress(self) -> etree:
|
||||
def response(self) -> etree:
|
||||
return load_xml_template("dlstatus", "progress")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from v8_server import db
|
|||
from v8_server.eamuse.services.services import ServiceRequest
|
||||
from v8_server.eamuse.xml.utils import get_xml_attrib, load_xml_template
|
||||
from v8_server.model.song import HitChart
|
||||
from v8_server.model.user import User, UserData
|
||||
from v8_server.utils.convert import int_to_bool as itob
|
||||
|
||||
|
||||
|
|
@ -448,6 +449,27 @@ class Regist(object):
|
|||
db.session.add(hc)
|
||||
db.session.commit()
|
||||
|
||||
# Save player data
|
||||
playerinfo = self.player.playerinfo
|
||||
user = User.from_refid(playerinfo.refid)
|
||||
if user is not None:
|
||||
user_data = UserData.from_userid(user.userid)
|
||||
|
||||
if user_data is None:
|
||||
user_data = UserData(
|
||||
userid=user.userid,
|
||||
style=playerinfo.styles,
|
||||
style_2=playerinfo.styles_2,
|
||||
)
|
||||
db.session.add(user_data)
|
||||
else:
|
||||
user_data.style = playerinfo.styles
|
||||
user_data.style_2 = playerinfo.styles_2
|
||||
|
||||
db.session.commit()
|
||||
else:
|
||||
raise Exception("This user doesn't exist")
|
||||
|
||||
# Just send back a dummy object for now
|
||||
now_time = datetime.now().strftime(self.DT_FMT)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from lxml import etree
|
|||
from v8_server.eamuse.services.services import ServiceRequest
|
||||
from v8_server.eamuse.utils.crc import calculate_crc8
|
||||
from v8_server.eamuse.xml.utils import fill, get_xml_attrib, load_xml_template
|
||||
from v8_server.model.user import User, UserData
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -74,6 +75,17 @@ class Get(object):
|
|||
return f"Gametop.Get<player = {self.player}>"
|
||||
|
||||
def response(self) -> etree:
|
||||
# Grab user_data
|
||||
user = User.from_refid(self.player.refid)
|
||||
style = 2097152
|
||||
style_2 = 0
|
||||
if user is not None:
|
||||
user_data = UserData.from_userid(user.userid)
|
||||
|
||||
if user_data is not None:
|
||||
style = user_data.style
|
||||
style_2 = user_data.style_2
|
||||
|
||||
# Generate history rounds (blank for now)
|
||||
history_rounds = ""
|
||||
for _ in range(0, 10):
|
||||
|
|
@ -95,7 +107,8 @@ class Get(object):
|
|||
|
||||
args = {
|
||||
"secret_music": secret_music,
|
||||
"style": 2097152,
|
||||
"style": style,
|
||||
"style_2": style_2,
|
||||
"secret_chara": secret_chara,
|
||||
"tag": tag,
|
||||
"history_rounds": history_rounds,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<favorite_music_3 __type="s16" __count="20">-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1</favorite_music_3>
|
||||
<secret_music __type="u16" __count="32">{secret_music}</secret_music>
|
||||
<style __type="u32">{style}</style>
|
||||
<style_2 __type="u32">0</style_2>
|
||||
<style_2 __type="u32">{style_2}</style_2>
|
||||
<shutter_list __type="u32">0</shutter_list>
|
||||
<judge_logo_list __type="u32">0</judge_logo_list>
|
||||
<skin_list __type="u32">0</skin_list>
|
||||
|
|
|
|||
|
|
@ -59,12 +59,35 @@ class UserAccount(BaseModel):
|
|||
is_succession = Column(Boolean, nullable=False)
|
||||
user = relationship("User", back_populates="user_account")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
f'UserAccount<userid = {self.userid}, name = "{self.name}", '
|
||||
f"chara = {self.chara}, is_succession = {self.is_succession}>"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_userid(cls, userid: int) -> Optional[UserAccount]:
|
||||
q = db.session.query(UserAccount).filter(UserAccount.userid == userid)
|
||||
return q.one_or_none()
|
||||
|
||||
|
||||
class UserData(BaseModel):
|
||||
"""
|
||||
Table representing user data such as mods, etc
|
||||
"""
|
||||
|
||||
__tablename__ = "user_data"
|
||||
|
||||
userid = Column(Integer, ForeignKey("users.userid"), primary_key=True)
|
||||
style = Column(Integer, nullable=False)
|
||||
style_2 = Column(Integer, nullable=False)
|
||||
|
||||
@classmethod
|
||||
def from_userid(cls, userid: int) -> Optional[UserData]:
|
||||
q = db.session.query(UserData).filter(UserData.userid == userid)
|
||||
return q.one_or_none()
|
||||
|
||||
|
||||
class Card(BaseModel):
|
||||
"""
|
||||
Table representing a card associated with a user. Users may have zero or more cards
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user