mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
2
This commit is contained in:
parent
95ac87e9ae
commit
1a20ad296a
4 changed files with 53 additions and 8 deletions
34
db.py
34
db.py
|
@ -257,9 +257,39 @@ class Dota(Base):
|
||||||
losses = Column(Integer, nullable=False)
|
losses = Column(Integer, nullable=False)
|
||||||
|
|
||||||
def get_rank_icon_url(self):
|
def get_rank_icon_url(self):
|
||||||
|
# Rank icon is determined by the first digit of the rank tier
|
||||||
|
return f"https://www.opendota.com/assets/images/dota2/rank_icons/rank_icon_{str(self.rank_tier)[0] if self.rank_tier is not None else '0'}.png"
|
||||||
|
|
||||||
|
def get_rank_stars_url(self):
|
||||||
|
# Rank stars are determined by the second digit of the rank tier
|
||||||
|
if self.rank_tier is None or str(self.rank_tier)[1] == "0":
|
||||||
|
return ""
|
||||||
|
return f"https://www.opendota.com/assets/images/dota2/rank_icons/rank_star_{str(self.rank_tier)[1]}.png"
|
||||||
|
|
||||||
|
def get_rank_name(self):
|
||||||
|
# This should probably be an enum, but who cares
|
||||||
if self.rank_tier is None or self.rank_tier < 10:
|
if self.rank_tier is None or self.rank_tier < 10:
|
||||||
return f"https://www.opendota.com/assets/images/dota2/rank_icons/rank_icon_0.png"
|
return "Unranked"
|
||||||
return f"https://www.opendota.com/assets/images/dota2/rank_icons/rank_icon_{self.rank_tier - 10 // 6}.png"
|
number = str(self.rank_tier)[0]
|
||||||
|
if number == "1":
|
||||||
|
return "Harald"
|
||||||
|
elif number == "2":
|
||||||
|
return "Guardian"
|
||||||
|
elif number == "3":
|
||||||
|
return "Crusader"
|
||||||
|
elif number == "4":
|
||||||
|
return "Archon"
|
||||||
|
elif number == "5":
|
||||||
|
return "Legend"
|
||||||
|
elif number == "6":
|
||||||
|
return "Ancient"
|
||||||
|
elif number == "7":
|
||||||
|
return "Divine"
|
||||||
|
|
||||||
|
def get_rank_number(self):
|
||||||
|
if self.rank_tier is None or self.rank_tier < 10:
|
||||||
|
return ""
|
||||||
|
return str(self.rank_tier)[1]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create(session: Session, steam_id: int):
|
def create(session: Session, steam_id: int):
|
||||||
|
|
|
@ -31,6 +31,11 @@ table.dota th {
|
||||||
border-bottom: 1px solid #666 !important;
|
border-bottom: 1px solid #666 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dota-rank-medal-stars {
|
||||||
|
position: relative;
|
||||||
|
left: -32px;
|
||||||
|
}
|
||||||
|
|
||||||
.rl-rank-hidden {
|
.rl-rank-hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Leaderboards - RYG</title>
|
<title>Leaderboards - RYG</title>
|
||||||
<script src="{{ url_for('static', filename='sorttable.js') }}"></script>
|
<script src="{{ url_for('static', filename='sorttable.js') }}"></script>
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
|
||||||
|
@ -32,7 +33,16 @@
|
||||||
<td>{{ record.steam.royal.username }}</td>
|
<td>{{ record.steam.royal.username }}</td>
|
||||||
<td><a href="http://steamcommunity.com/profiles/{{ record.steam.steam_id }}"><img src="{{ record.steam.avatar_url() }}"> {{ record.steam.persona_name }}</a></td>
|
<td><a href="http://steamcommunity.com/profiles/{{ record.steam.steam_id }}"><img src="{{ record.steam.avatar_url() }}"> {{ record.steam.persona_name }}</a></td>
|
||||||
<td>{{ record.wins }}</td>
|
<td>{{ record.wins }}</td>
|
||||||
<td><img sorttable_customkey={{ record.rank_tier }} class="thirtytwo" src="{{ record.get_rank_icon_url() }}"></td>
|
<td sorttable_customkey="{{ record.rank_tier }}">
|
||||||
|
<div class="dota-rank-medal">
|
||||||
|
<img class="thirtytwo dota-rank-medal-icon" src="{{ record.get_rank_icon_url() }}">{% if record.get_rank_stars_url() %}<img class="thirtytwo dota-rank-medal-stars" src="{{ record.get_rank_stars_url() }}">{% endif %}
|
||||||
|
{% if record.rank_tier is not none and record.rank_tier >= 10 %}
|
||||||
|
{{ record.get_rank_name() }} {{ record.get_rank_number() }}
|
||||||
|
{% else %}
|
||||||
|
<span class="rl-unranked">Unranked</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
10
webserver.py
10
webserver.py
|
@ -10,11 +10,11 @@ app.jinja_env.lstrip_blocks = True
|
||||||
@app.route("/leaderboards")
|
@app.route("/leaderboards")
|
||||||
def page_leaderboards():
|
def page_leaderboards():
|
||||||
session = Session()
|
session = Session()
|
||||||
dota_data = session.query(Dota).options(joinedload(Dota.steam).joinedload(Steam.royal)).join(Steam).join(Royal).all()
|
dota_data = session.query(Dota).options(joinedload(Dota.steam).joinedload(Steam.royal)).join(Steam).join(Royal).order_by(Dota.rank_tier).all()
|
||||||
rl_data = session.query(RocketLeague).options(joinedload(RocketLeague.steam).joinedload(Steam.royal)).join(Steam).join(Royal).all()
|
rl_data = session.query(RocketLeague).options(joinedload(RocketLeague.steam).joinedload(Steam.royal)).join(Steam).join(Royal).order_by(RocketLeague.doubles_mmr).all()
|
||||||
ow_data = session.query(Overwatch).options(joinedload(Overwatch.royal)).join(Royal).all()
|
ow_data = session.query(Overwatch).options(joinedload(Overwatch.royal)).join(Royal).order_by(Overwatch.rank).all()
|
||||||
osu_data = session.query(Osu).options(joinedload(Osu.royal)).join(Royal).all()
|
osu_data = session.query(Osu).options(joinedload(Osu.royal)).join(Royal).order_by(Osu.std_pp).all()
|
||||||
lol_data = session.query(LeagueOfLegends).options(joinedload(LeagueOfLegends.royal)).join(Royal).all()
|
lol_data = session.query(LeagueOfLegends).options(joinedload(LeagueOfLegends.royal)).join(Royal).order_by(LeagueOfLegends.summoner_name).all()
|
||||||
session.close()
|
session.close()
|
||||||
return render_template("leaderboards.html", dota_data=dota_data, rl_data=rl_data, ow_data=ow_data, osu_data=osu_data, lol_data=lol_data)
|
return render_template("leaderboards.html", dota_data=dota_data, rl_data=rl_data, ow_data=ow_data, osu_data=osu_data, lol_data=lol_data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue