1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

complete trionfi

This commit is contained in:
Steffo 2020-09-26 03:02:04 +02:00
parent 1e41892f1d
commit a1f44ff1af
4 changed files with 74 additions and 7 deletions

View file

@ -0,0 +1,64 @@
import datetime
import royalnet.backpack.tables as rbt
import royalnet.constellation.api as rca
from .trionfistatus import TrionfiStatus
class ApiUserTrionfiStar(rca.ApiStar):
path = "/api/user/trionfi/v2"
parameters = {
"get": {
"uid": "(Choose one) The id of the user to get information about.",
"alias": "(Choose one) The alias of the user to get information about.",
}
}
auth = {
"get": True
}
tags = ["user"]
async def get_user(self, data: rca.ApiData):
uid = data.int("uid", optional=True)
alias = data.str("alias", optional=True)
if uid:
user = await rbt.User.find(self.alchemy, data.session, uid)
elif alias:
user = await rbt.User.find(self.alchemy, data.session, alias)
else:
raise rca.MissingParameterError("Neither uid or alias were specified.")
if user is None:
raise rca.NotFoundError("No such user.")
return user
@rca.magic
async def get(self, data: rca.ApiData) -> dict:
"""Get Royalpack information about a user."""
author = await data.user()
if len(author.steam) >= 1:
steam = author.steam[0]
if steam.trionfistatus is None:
TrionfiStatusT = self.alchemy.get(TrionfiStatus)
ts = TrionfiStatusT(steam=steam)
data.session.add(ts)
await data.session_commit()
if not steam.trionfistatus.zero:
steam.trionfistatus.zero = datetime.datetime.now()
await data.session_commit()
user = await self.get_user(data)
result = {
**user.json(),
"bio": user.bio.json() if user.bio is not None else None,
"fiorygi": user.fiorygi.fiorygi if user.fiorygi is not None else None,
"steam": [steam.json() for steam in user.steam],
"leagueoflegends": [leagueoflegends.json() for leagueoflegends in user.leagueoflegends],
"osu": [osu.json() for osu in user.osu],
"trivia": user.trivia_score.json() if user.trivia_score is not None else None,
}
return result

View file

@ -9,7 +9,7 @@ trionfilist: List[TrionfoInfo] = [
roman="0", roman="0",
name="Il Folle", name="Il Folle",
puzzle="UN VIAGGIO TI ATTENDE", puzzle="UN VIAGGIO TI ATTENDE",
objective="Partecipa ai Trionfi Reali.", objective="Trova la pagina dei Trionfi Reali.",
check=NullCheck(), check=NullCheck(),
), ),
TrionfoInfo( TrionfoInfo(
@ -18,7 +18,7 @@ trionfilist: List[TrionfoInfo] = [
roman="I", roman="I",
name="Il Mago", name="Il Mago",
puzzle="L'ULTIMO GIORNO", puzzle="L'ULTIMO GIORNO",
objective="Trova una /spell che possa fare almeno 250 danni.", objective="Scopri una magia che possa fare più di 250 danni.",
check=NullCheck(), check=NullCheck(),
), ),
TrionfoInfo( TrionfoInfo(
@ -55,7 +55,7 @@ trionfilist: List[TrionfoInfo] = [
name="Il Papa", name="Il Papa",
puzzle="ALLA DECIMASESTA ORA", puzzle="ALLA DECIMASESTA ORA",
objective="Completa la prima zona di [url=https://store.steampowered.com/app/247080]Crypt of the Necrodancer[" objective="Completa la prima zona di [url=https://store.steampowered.com/app/247080]Crypt of the Necrodancer["
"/url] (con qualsiasi personaggio).", "/url] con qualsiasi personaggio.",
check=CheckAchievementSteamGame(247080, "ACH_ZONE1_COMPLETE") check=CheckAchievementSteamGame(247080, "ACH_ZONE1_COMPLETE")
), ),
TrionfoInfo( TrionfoInfo(
@ -64,7 +64,7 @@ trionfilist: List[TrionfoInfo] = [
roman="VI", roman="VI",
name="Gli Amanti", name="Gli Amanti",
puzzle="ANCORA TRENTA MINUTI", puzzle="ANCORA TRENTA MINUTI",
objective="Finisci l'Atto 3 di [url=https://store.steampowered.com/app/698780]Doki Doki Literature Club[" objective="Gioca almeno mezz'ora a [url=https://store.steampowered.com/app/698780]Doki Doki Literature Club["
"/url].", "/url].",
check=CheckPlayedSteamGame(698780), check=CheckPlayedSteamGame(698780),
), ),
@ -74,7 +74,7 @@ trionfilist: List[TrionfoInfo] = [
roman="VII", roman="VII",
name="Il Carro", name="Il Carro",
puzzle="SOPRA UN CARRO", puzzle="SOPRA UN CARRO",
objective="Gioca 5 incontri a [url=https://store.steampowered.com/app/326460/ShellShock_Live]ShellShock Live[" objective="Gioca 5 incontri di [url=https://store.steampowered.com/app/326460/ShellShock_Live]ShellShock Live["
"/url].", "/url].",
check=CheckAchievementSteamGame(326460, "play5") check=CheckAchievementSteamGame(326460, "play5")
), ),
@ -209,7 +209,7 @@ trionfilist: List[TrionfoInfo] = [
roman="XXI", roman="XXI",
name="Il Mondo", name="Il Mondo",
puzzle="""44°35'45.0"N 11°02'58.9"E""", puzzle="""44°35'45.0"N 11°02'58.9"E""",
objective="???", objective="Attraverso i Trionfi, il segreto ti sarà lentamente rivelato...",
check=NullCheck(), check=NullCheck(),
), ),
] ]

View file

@ -15,6 +15,7 @@ from .api_user_avatar import ApiUserAvatarStar
from .api_auth_login_osu import ApiAuthLoginOsuStar from .api_auth_login_osu import ApiAuthLoginOsuStar
from .api_diario_range import ApiDiarioRangeStar from .api_diario_range import ApiDiarioRangeStar
from .api_diario_latest import ApiDiarioLatestStar from .api_diario_latest import ApiDiarioLatestStar
from ..halloween2020.api_user_trionfi import ApiUserTrionfiStar
# Enter the PageStars of your Pack here! # Enter the PageStars of your Pack here!
available_page_stars = [ available_page_stars = [
@ -34,6 +35,7 @@ available_page_stars = [
ApiAuthLoginOsuStar, ApiAuthLoginOsuStar,
ApiDiarioRangeStar, ApiDiarioRangeStar,
ApiDiarioLatestStar, ApiDiarioLatestStar,
ApiUserTrionfiStar,
] ]
# Don't change this, it should automatically generate __all__ # Don't change this, it should automatically generate __all__

View file

@ -77,7 +77,8 @@ class Steam:
"dota": self.dota.json() if self.dota is not None else None, "dota": self.dota.json() if self.dota is not None else None,
"brawlhalla": self.brawlhalla.json() if self.brawlhalla is not None else None, "brawlhalla": self.brawlhalla.json() if self.brawlhalla is not None else None,
"trionfistatus": self.trionfistatus.json() if self.trionfistatus is not None else None, "trionfistatus": self.trionfistatus.json() if (self.trionfistatus is not None and self.trionfistatus.zero
is not None) else None,
} }
def __repr__(self): def __repr__(self):