diff --git a/db.py b/db.py index 957ef5e3..211df08d 100644 --- a/db.py +++ b/db.py @@ -21,7 +21,6 @@ Session = sessionmaker(bind=engine) # Create a new default session session = Session() - class Royal(Base): __tablename__ = "royals" @@ -82,6 +81,9 @@ class Steam(Base): else: return self.steam_id + def avatar_url(self): + return f"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/{self.avatar_hex[0:2]}/{self.avatar_hex}.jpg" + @staticmethod def get_or_create(royal_id, steam_id): s = session.query(Steam).get(steam_id) @@ -505,6 +507,9 @@ class Overwatch(Base): rank=j["comprank"]) return o + def icon_url(self): + return f"https://d1u1mce87gyfbn.cloudfront.net/game/unlocks/{self.icon}.png" + def update(self): r = requests.get(f"https://owapi.net/api/v3/u/{self.battletag}-{self.discriminator}/stats", headers={ "User-Agent": "Royal-Bot/4.0", @@ -558,4 +563,5 @@ class Diario(Base): # If run as script, create all the tables in the db if __name__ == "__main__": - Base.metadata.create_all(bind=engine) \ No newline at end of file + Base.metadata.create_all(bind=engine) + session.close() \ No newline at end of file diff --git a/newuser.py b/newuser.py index 287e2482..6c0d1589 100644 --- a/newuser.py +++ b/newuser.py @@ -1,45 +1,43 @@ import db -session = db.Session() - -while True: - user = db.Royal.get_or_create(input("Nome account: ")) - session.add(user) - session.commit() - try: - steam = db.Steam.get_or_create(user.id, input("Steam ID 1: ")) - except KeyboardInterrupt: - pass - else: - session.add(steam) - try: - dota = db.Dota.get_or_create(steam.steam_id) - except KeyboardInterrupt: - pass - else: - session.add(dota) - try: - rl = db.RocketLeague.get_or_create(steam.steam_id) - except KeyboardInterrupt: - pass - else: - session.add(rl) - try: - osu = db.Osu.get_or_create(user.id, input("Osu! username: ")) - except KeyboardInterrupt: - pass - else: - session.add(osu) - try: - overwatch = db.Overwatch.get_or_create(user.id, input("Battle.net battletag: ")) - except KeyboardInterrupt: - pass - else: - session.add(overwatch) - try: - lol = db.LeagueOfLegends.get_or_create(user.id, input("League summoner name: ")) - except KeyboardInterrupt: - pass - else: - session.add(lol) - session.commit() \ No newline at end of file +user = db.Royal.get_or_create(input("Nome account: ")) +db.session.add(user) +db.session.commit() +try: + steam = db.Steam.get_or_create(user.id, input("Steam ID 1: ")) +except KeyboardInterrupt: + pass +else: + db.session.add(steam) +try: + dota = db.Dota.get_or_create(steam.steam_id) +except KeyboardInterrupt: + pass +else: + db.session.add(dota) +try: + rl = db.RocketLeague.get_or_create(steam.steam_id) +except KeyboardInterrupt: + pass +else: + db.session.add(rl) +try: + osu = db.Osu.get_or_create(user.id, input("Osu! username: ")) +except KeyboardInterrupt: + pass +else: + db.session.add(osu) +try: + overwatch = db.Overwatch.get_or_create(user.id, input("Battle.net battletag: ")) +except KeyboardInterrupt: + pass +else: + db.session.add(overwatch) +try: + lol = db.LeagueOfLegends.get_or_create(user.id, input("League summoner name: ")) +except KeyboardInterrupt: + pass +else: + db.session.add(lol) +db.session.commit() +db.session.close() \ No newline at end of file diff --git a/static/lol-rank-icons/bronze_i.png b/static/lol-rank-icons/bronze_i.png new file mode 100644 index 00000000..81fc402a Binary files /dev/null and b/static/lol-rank-icons/bronze_i.png differ diff --git a/static/lol-rank-icons/bronze_ii.png b/static/lol-rank-icons/bronze_ii.png new file mode 100644 index 00000000..067956f5 Binary files /dev/null and b/static/lol-rank-icons/bronze_ii.png differ diff --git a/static/lol-rank-icons/bronze_iii.png b/static/lol-rank-icons/bronze_iii.png new file mode 100644 index 00000000..73b2d88f Binary files /dev/null and b/static/lol-rank-icons/bronze_iii.png differ diff --git a/static/lol-rank-icons/bronze_iv.png b/static/lol-rank-icons/bronze_iv.png new file mode 100644 index 00000000..fdbc0d32 Binary files /dev/null and b/static/lol-rank-icons/bronze_iv.png differ diff --git a/static/lol-rank-icons/bronze_v.png b/static/lol-rank-icons/bronze_v.png new file mode 100644 index 00000000..5f89799d Binary files /dev/null and b/static/lol-rank-icons/bronze_v.png differ diff --git a/static/lol-rank-icons/challenger.png b/static/lol-rank-icons/challenger.png new file mode 100644 index 00000000..eb97dd60 Binary files /dev/null and b/static/lol-rank-icons/challenger.png differ diff --git a/static/lol-rank-icons/diamond_i.png b/static/lol-rank-icons/diamond_i.png new file mode 100644 index 00000000..e112531d Binary files /dev/null and b/static/lol-rank-icons/diamond_i.png differ diff --git a/static/lol-rank-icons/diamond_ii.png b/static/lol-rank-icons/diamond_ii.png new file mode 100644 index 00000000..7e9ba9bd Binary files /dev/null and b/static/lol-rank-icons/diamond_ii.png differ diff --git a/static/lol-rank-icons/diamond_iii.png b/static/lol-rank-icons/diamond_iii.png new file mode 100644 index 00000000..218471fd Binary files /dev/null and b/static/lol-rank-icons/diamond_iii.png differ diff --git a/static/lol-rank-icons/diamond_iv.png b/static/lol-rank-icons/diamond_iv.png new file mode 100644 index 00000000..f5a7fbf7 Binary files /dev/null and b/static/lol-rank-icons/diamond_iv.png differ diff --git a/static/lol-rank-icons/diamond_v.png b/static/lol-rank-icons/diamond_v.png new file mode 100644 index 00000000..7420d41f Binary files /dev/null and b/static/lol-rank-icons/diamond_v.png differ diff --git a/static/lol-rank-icons/gold_i.png b/static/lol-rank-icons/gold_i.png new file mode 100644 index 00000000..284778a1 Binary files /dev/null and b/static/lol-rank-icons/gold_i.png differ diff --git a/static/lol-rank-icons/gold_ii.png b/static/lol-rank-icons/gold_ii.png new file mode 100644 index 00000000..329984ed Binary files /dev/null and b/static/lol-rank-icons/gold_ii.png differ diff --git a/static/lol-rank-icons/gold_iii.png b/static/lol-rank-icons/gold_iii.png new file mode 100644 index 00000000..e2f1f950 Binary files /dev/null and b/static/lol-rank-icons/gold_iii.png differ diff --git a/static/lol-rank-icons/gold_iv.png b/static/lol-rank-icons/gold_iv.png new file mode 100644 index 00000000..9059d215 Binary files /dev/null and b/static/lol-rank-icons/gold_iv.png differ diff --git a/static/lol-rank-icons/gold_v.png b/static/lol-rank-icons/gold_v.png new file mode 100644 index 00000000..09e614ed Binary files /dev/null and b/static/lol-rank-icons/gold_v.png differ diff --git a/static/lol-rank-icons/master.png b/static/lol-rank-icons/master.png new file mode 100644 index 00000000..09338d23 Binary files /dev/null and b/static/lol-rank-icons/master.png differ diff --git a/static/lol-rank-icons/platinum_i.png b/static/lol-rank-icons/platinum_i.png new file mode 100644 index 00000000..d85e1cb0 Binary files /dev/null and b/static/lol-rank-icons/platinum_i.png differ diff --git a/static/lol-rank-icons/platinum_ii.png b/static/lol-rank-icons/platinum_ii.png new file mode 100644 index 00000000..9d02c348 Binary files /dev/null and b/static/lol-rank-icons/platinum_ii.png differ diff --git a/static/lol-rank-icons/platinum_iii.png b/static/lol-rank-icons/platinum_iii.png new file mode 100644 index 00000000..bc90279f Binary files /dev/null and b/static/lol-rank-icons/platinum_iii.png differ diff --git a/static/lol-rank-icons/platinum_iv.png b/static/lol-rank-icons/platinum_iv.png new file mode 100644 index 00000000..3a64a145 Binary files /dev/null and b/static/lol-rank-icons/platinum_iv.png differ diff --git a/static/lol-rank-icons/platinum_v.png b/static/lol-rank-icons/platinum_v.png new file mode 100644 index 00000000..8b89b473 Binary files /dev/null and b/static/lol-rank-icons/platinum_v.png differ diff --git a/static/lol-rank-icons/provisional.png b/static/lol-rank-icons/provisional.png new file mode 100644 index 00000000..5fdcf3cc Binary files /dev/null and b/static/lol-rank-icons/provisional.png differ diff --git a/static/lol-rank-icons/silver_i.png b/static/lol-rank-icons/silver_i.png new file mode 100644 index 00000000..4af3291b Binary files /dev/null and b/static/lol-rank-icons/silver_i.png differ diff --git a/static/lol-rank-icons/silver_ii.png b/static/lol-rank-icons/silver_ii.png new file mode 100644 index 00000000..9f7a552e Binary files /dev/null and b/static/lol-rank-icons/silver_ii.png differ diff --git a/static/lol-rank-icons/silver_iii.png b/static/lol-rank-icons/silver_iii.png new file mode 100644 index 00000000..879da7c4 Binary files /dev/null and b/static/lol-rank-icons/silver_iii.png differ diff --git a/static/lol-rank-icons/silver_iv.png b/static/lol-rank-icons/silver_iv.png new file mode 100644 index 00000000..4b55f25d Binary files /dev/null and b/static/lol-rank-icons/silver_iv.png differ diff --git a/static/lol-rank-icons/silver_v.png b/static/lol-rank-icons/silver_v.png new file mode 100644 index 00000000..8db56b02 Binary files /dev/null and b/static/lol-rank-icons/silver_v.png differ diff --git a/static/royal.css b/static/royal.css new file mode 100644 index 00000000..f1db1ed2 --- /dev/null +++ b/static/royal.css @@ -0,0 +1,55 @@ +body { + background-color: #ff7f00; + color: black; +} + +table { + background-color: #fff2cd !important; + border-radius: 5px; +} + +.table td, .table th { + border: none !important; +} + +table.rl { + background: linear-gradient(to bottom,rgba(35,91,139,.5),rgba(16,54,84,.5)),linear-gradient(to right,rgba(35,91,139,.7),rgba(16,54,84,.7)) !important; + border-radius: 6px !important; + border: none !important; + padding: 12px !important; + color: white !important; +} + +.rl-rank-hidden { + display: none; +} + +.rl-rank-text { + display: inline-block; + vertical-align: middle; +} + +.rl-rank-division { + font-size: 9px; +} + +.thirtytwo { + width: 32px; + height: 32px; +} + +.round { + border-radius: 16px; +} + +.slightly-round { + border-radius: 2px; +} + +.rl-rank-number { + line-height: 14px; +} + +.rl-unranked { + color: grey; +} \ No newline at end of file diff --git a/static/sorttable.js b/static/sorttable.js new file mode 100644 index 00000000..719d2adb --- /dev/null +++ b/static/sorttable.js @@ -0,0 +1,495 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backwards compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i
Royal | +Steam | +Wins | +Solo MMR | +Party MMR | +
---|---|---|---|---|
{{ record.steam.royal.username }} | +{{ record.steam.persona_name }} | +{{ record.wins }} | +{{ record.solo_mmr if record.solo_mmr is not none}} | +{{ record.party_mmr if record.party_mmr is not none}} | +
Royal | +Steam | +Singolo 1v1 | +Doppio 2v2 | +Standard 3v3 | +Solo Standard SoloQ | +
---|---|---|---|---|---|
{{ record.steam.royal.username }} | +{{ record.steam.persona_name }} | +
+ {% if record.single_rank is not none %}
+
+
+
+ {% elif record.single_mmr is not none %}
+
+ {{ record.single_mmr }}
+ Div {{ record.single_div + 1 }}
+
+
+ {% endif %}
+ {{ record.single_mmr }}
+ Inattivo
+ |
+
+ {% if record.doubles_rank is not none %}
+
+
+
+ {% elif record.doubles_mmr is not none %}
+
+ {{ record.doubles_mmr }}
+ Div {{ record.doubles_div + 1 }}
+
+
+ {% endif %}
+ {{ record.doubles_mmr }}
+ Inattivo
+ |
+
+ {% if record.standard_rank is not none %}
+
+
+
+ {% elif record.standard_mmr is not none %}
+
+ {{ record.standard_mmr }}
+ Div {{ record.standard_div + 1 }}
+
+
+ {% endif %}
+ {{ record.standard_mmr }}
+ Inattivo
+ |
+
+ {% if record.solo_std_rank is not none %}
+
+
+
+ {% elif record.solo_std_mmr is not none %}
+
+ {{ record.solo_std_mmr }}
+ Div {{ record.solo_std_div + 1 }}
+
+
+ {% endif %}
+ {{ record.solo_std_mmr }}
+ Inattivo
+ |
+
Royal | +Battletag | +Livello | +Rank | +
---|---|---|---|
{{ record.royal.username }} | +{{ record }} | +{{ record.level }} | ++ {% if record.rank is not none %} + + {{ record.rank }} + {% endif %} + | +
Royal | +Username | +osu! | +osu!taiko | +osu!catch | +osu!mania | +
---|---|---|---|---|---|
{{ record.royal.username }} | +{{ record.osu_name }} | +{{ record.std_pp|round(0, "floor")|int if record.std_pp is not none and record.std_pp >= 1 }} | +{{ record.taiko_pp|round(0, "floor")|int if record.taiko_pp is not none and record.taiko_pp >= 1 }} | +{{ record.catch_pp|round(0, "floor")|int if record.catch_pp is not none and record.catch_pp >= 1 }} | +{{ record.mania_pp|round(0, "floor")|int if record.mania_pp is not none and record.mania_pp >= 1 }} | +
Royal | +Summoner | +Livello | +Solo SR | +Flex SR | +Flex TT | +|||
---|---|---|---|---|---|---|---|---|
{{ record.royal.username }} | +{{ record.summoner_name }} | +{{ record.level }} | + {% if record.solo_division is not none %} +{{ record.solo_division.name|capitalize }} {{ record.solo_rank.name }} | + {% else %} ++ {% endif %} + {% if record.flex_division is not none %} + | {{ record.flex_division.name|capitalize }} {{ record.flex_rank.name }} | + {% else %} ++ {% endif %} + {% if record.twtr_division is not none %} + | {{ record.twtr_division.name|capitalize }} {{ record.twtr_rank.name }} | + {% else %} ++ {% endif %} + |