global leaderboard added

This commit is contained in:
Walter 2025-02-24 15:57:17 +01:00
parent 93a9ffb268
commit 169f0f9018
15 changed files with 30 additions and 17 deletions

View File

@ -113,6 +113,8 @@
#global-leaderboard-iframe { #global-leaderboard-iframe {
height: 629px; height: 629px;
width: 160px; width: 160px;
overflow: hidden; // overflow: hidden;
// overflow-y: scroll;
// overflow-x: hidden;
} }

View File

@ -7,13 +7,14 @@
text-align: left; text-align: left;
white-space: nowrap; white-space: nowrap;
margin: 0; margin: 0;
overflow: hidden;
} }
.rowa { .rowa {
background-color: #563EAB; background-color: #348feb;
} }
.rowb { .rowb {
background-color: #6B0047; background-color: #536DFE;
} }
.glb-position { .glb-position {
@ -30,6 +31,7 @@
width: 160px; width: 160px;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
border-bottom: 4px solid #3455eb;
} }
.glb-main-info { .glb-main-info {
@ -65,6 +67,15 @@
} }
.glb-rank-icon { .glb-rank-icon {
object-fit: contain;
}
.glb-beaten {
color: #62eb4d;
}
.glb-golds {
color: #fcba03;
} }
body { body {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 KiB

View File

@ -4,7 +4,7 @@
<link rel="stylesheet" type="text/css" media="screen" href="{% static 'bloonsa_game/css/append.css' %}"/> <link rel="stylesheet" type="text/css" media="screen" href="{% static 'bloonsa_game/css/append.css' %}"/>
<div id="glb-global"> <div id="glb-global">
{% for player in players %} {% for player in players %}
<div class="rowa glb-entry"> <div class="{% if forloop.counter|divisibleby:2 %}rowa{% else %}rowb{% endif %} glb-entry">
<div class="glb-avatar-box"> <div class="glb-avatar-box">
<img class="glb-avatar" src="{{ player.avatar.url }}" height=48px width=48px> <img class="glb-avatar" src="{{ player.avatar.url }}" height=48px width=48px>
</div> </div>
@ -18,13 +18,13 @@
<object data="{% static 'bloonsa_game/img/levelinfo/wins.svg' %}" <object data="{% static 'bloonsa_game/img/levelinfo/wins.svg' %}"
class="filter-orange glb-wins-img" class="filter-orange glb-wins-img"
type="image/svg+xml"></object> type="image/svg+xml"></object>
<span>{{ player.bloonsa_levels_beaten_count }}</span> <span class="glb-beaten">{{ player.bloonsa_levels_beaten_count }}</span>
</div> </div>
<div class="glb-gdarts-box"> <div class="glb-gdarts-box">
<object data="{% static 'bloonsa_game/img/levelinfo/dart.svg' %}" <object data="{% static 'bloonsa_game/img/levelinfo/dart.svg' %}"
class="filter-orange glb-darts-img" class="filter-orange glb-darts-img"
type="image/svg+xml"></object> type="image/svg+xml"></object>
<span>{{ player.bloonsa_dart_glitch_count }}</span> <span class="glb-golds">{{ player.bloonsa_dart_glitch_count }}</span>
</div> </div>
</div> </div>
<div class="glb-rank-box"> <div class="glb-rank-box">

View File

@ -4,6 +4,7 @@ from django.shortcuts import render
from django.views.generic import TemplateView from django.views.generic import TemplateView
from bloonsa_game.models import Level from bloonsa_game.models import Level
from settings.settings import DEBUG
from users.models import Player from users.models import Player
from users.util import bloonsa_util, actions from users.util import bloonsa_util, actions
@ -39,7 +40,8 @@ class GameView(TemplateView):
r = render(request, "bloonsa_game/game.html", r = render(request, "bloonsa_game/game.html",
context={"total_levels": total_levels,}) context={"total_levels": total_levels,})
r["x-frame-options"] = "sameorigin" if DEBUG:
r["x-frame-options"] = "sameorigin"
return r return r
@ -52,12 +54,12 @@ class LeaderboardGlobalView(TemplateView):
golds=Count(F("bloonsa_level_scores__dart_glitch_ever")) golds=Count(F("bloonsa_level_scores__dart_glitch_ever"))
).annotate( ).annotate(
volforce=F("clears") + F("golds") volforce=F("clears") + F("golds")
).order_by("-volforce")[:100] ).order_by("-volforce")[:10]
for player in players:
print(player.bloonsa_volforce_rating)
r = render(request, "bloonsa_game/modules/leaderboard_global.html", r = render(request, "bloonsa_game/modules/leaderboard_global.html",
context={ context={
"players": players "players": players
}) })
r["x-frame-options"] = "sameorigin" if DEBUG:
r["x-frame-options"] = "sameorigin"
return r return r

View File

@ -58,23 +58,21 @@ class Player(models.Model):
@property @property
def bloonsa_volforce_rating(self): def bloonsa_volforce_rating(self):
total_levels = 66396 # TODO dont hardcode this
total_levels = 66396
beaten_levels = self.bloonsa_levels_beaten_count beaten_levels = self.bloonsa_levels_beaten_count
gold_levels = self.bloonsa_dart_glitch_count gold_levels = self.bloonsa_dart_glitch_count
estimated_limit = total_levels + ((total_levels / 100) * 20) estimated_limit = total_levels + ((total_levels / 100) * 20)
estimated_max_rank = 80.00 estimated_max_rank = 40.00
player_score = beaten_levels + gold_levels player_score = beaten_levels + gold_levels
player_volforce = player_score * (estimated_max_rank / estimated_limit) player_volforce = player_score * (estimated_max_rank / estimated_limit)
import random
player_volforce = random.randint(100, 2700) / 100
return "{:.2f}".format(player_volforce) return "{:.2f}".format(player_volforce)
@property @property
def bloonsa_rank(self): def bloonsa_rank(self):
return math.floor(float(self.bloonsa_volforce_rating) / 100) + 1 return math.floor(float(self.bloonsa_volforce_rating) / 4) + 1
def __str__(self): def __str__(self):