Change PLAYERSKINSDB to a GET_PLAYERDATA function
parent
cd9c201191
commit
3d04d83b08
|
@ -18,7 +18,7 @@ API_URL = "{scheme}://{host}/{endpoint}".format(
|
||||||
|
|
||||||
CHARACTERS = { c.smashggid : c.name for c in characters_ssbu.EVERYONE }
|
CHARACTERS = { c.smashggid : c.name for c in characters_ssbu.EVERYONE }
|
||||||
|
|
||||||
PLAYERSKINS = {}
|
GET_PLAYERDATA = lambda tag: {"tag": tag,}
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
@ -44,15 +44,20 @@ class Player():
|
||||||
self.seeding = int(seeding)
|
self.seeding = int(seeding)
|
||||||
self.twitterHandle = ( "" if twitterHandle is None else twitterHandle )
|
self.twitterHandle = ( "" if twitterHandle is None else twitterHandle )
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.playerdata = GET_PLAYERDATA(self.gamerTag)
|
||||||
|
except:
|
||||||
|
self.playerdata = {}
|
||||||
|
|
||||||
# Check if there's a redirect in the players DB
|
# Check if there's a redirect in the players DB
|
||||||
try:
|
try:
|
||||||
self.gamerTag = PLAYERSKINS[self.gamerTag.lower()]["redirect"]
|
self.gamerTag = self.playerdata["tag"]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Prefix is superseeded by sponsors infos in DB
|
# Prefix is superseeded by sponsors infos in DB
|
||||||
try:
|
try:
|
||||||
self.prefix = PLAYERSKINS[self.gamerTag.lower()]["sponsor"]
|
self.prefix = self.playerdata["sponsor"]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -71,7 +76,7 @@ class Player():
|
||||||
charname = character # Unknown char -> sgg id
|
charname = character # Unknown char -> sgg id
|
||||||
|
|
||||||
try:
|
try:
|
||||||
skin = PLAYERSKINS[self.gamerTag.lower()]["skins"][charname]
|
skin = self.playerdata["skins"][charname]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
skin = "00" # default skin
|
skin = "00" # default skin
|
||||||
|
|
||||||
|
@ -122,6 +127,21 @@ characters: {charslist}""" \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
def __str__(self):
|
||||||
|
# The char list looks like 'character1_skin1 (12.08), character2_skin2
|
||||||
|
# (3.02)' where the number between parenthesis is the number of time
|
||||||
|
# the character was played
|
||||||
|
charslist = ", ".join( [ "{}_{} ({:.2f})".format(c,s,n) for (c,s),n in
|
||||||
|
sorted( self.chars.items(), key = lambda cv: cv[1], reverse =
|
||||||
|
True,) ])
|
||||||
|
return "{plc}/ [{pfx}] {tag} -- {charslist}" \
|
||||||
|
.format(
|
||||||
|
tag = self.gamerTag,
|
||||||
|
pfx = self.prefix,
|
||||||
|
plc = self.placement,
|
||||||
|
charslist = charslist,
|
||||||
|
)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
class Tournament():
|
class Tournament():
|
||||||
|
@ -176,11 +196,27 @@ numEntrants: {nbe}""" \
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
def clean_name(self, name_seo_delimiter):
|
def clean_name(self, name_seo_delimiter):
|
||||||
|
|
||||||
if name_seo_delimiter is not None:
|
if name_seo_delimiter is not None and name_seo_delimiter != "":
|
||||||
self.name = self.name.split(name_seo_delimiter)[0].strip()
|
self.name = self.name.split(name_seo_delimiter)[0].strip()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
def __str__(self):
|
||||||
|
return "Tournament {name} ({date} at {loc}), {nbe} entrants" \
|
||||||
|
.format(
|
||||||
|
id = self.id,
|
||||||
|
name = self.name,
|
||||||
|
date = self.startAt,
|
||||||
|
loc = self.venueName,
|
||||||
|
addr = self.venueAddress,
|
||||||
|
city = self.city,
|
||||||
|
ctry = self.countryCode,
|
||||||
|
slug = self.slug,
|
||||||
|
nbe = self.numEntrants,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
def run_query(
|
def run_query(
|
||||||
|
|
Loading…
Reference in New Issue