Added another js callback for when a level is rated

This commit is contained in:
Walter 2025-02-17 13:01:43 +01:00
parent 2f7d028086
commit 3d0f4e4353
4 changed files with 20 additions and 3 deletions

View File

@ -1,5 +1,3 @@
import math
from django.core.validators import MinValueValidator, MaxValueValidator from django.core.validators import MinValueValidator, MaxValueValidator
from django.db import models from django.db import models
from django.db.models import Avg from django.db.models import Avg
@ -42,7 +40,7 @@ class Level(models.Model):
@property @property
def stars(self): def stars(self):
result = list(self.bloonsa_level_ratings.aggregate(Avg("rating")).values())[0] result = list(self.bloonsa_level_ratings.aggregate(Avg("rating")).values())[0]
return 0 if result is None else math.ceil(result) return 0 if result is None else round(result)
def __str__(self): def __str__(self):

View File

@ -8,6 +8,12 @@ function bloonsa_level_completed(level_id) {
bloonsa_update_data(level_id) bloonsa_update_data(level_id)
} }
function bloonsa_rated_level_success(level_id) {
console.log("call to bloonsa_rated_level_success");
bloonsa_update_data(level_id)
}
function bloonsa_update_data(level_id) { function bloonsa_update_data(level_id) {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
console.log("call to update_data"); console.log("call to update_data");

View File

@ -0,0 +1,13 @@
bug triggers:
- RESET button in-game: _parent._parent.popgame.Init();
- GO RANDOM button in-game: _parent._parent.popgame.GetRandomLevel(0);
- PLAY RANDOM button post-game: _parent._parent.popgame.GetRandomLevel(0);
- PLAY RANDOM button mainmenu: _parent.popgame.GetRandomLevel(0);
doesn't trigger:
- REPLAY LEVEL button post-game:
_parent.dest = "play";
_parent.gotoAndPlay("drawOff");
- PLAY button from level-id in mainmenu:
_parent._parent.popgame.curLevel = loadthis_txt.text;
_parent._parent.gotoAndPlay("play");