Permalink
Browse files

Bug 30 - num. trinkets saved with your score, displayed on leaderboard

  • Loading branch information...
jonoxia committed Nov 13, 2011
1 parent 8f83151 commit 57641e962c14b57d42b15b87cb0f2d84aad71086
Showing with 12 additions and 9 deletions.
  1. +2 −0 complete-level.py
  2. +5 −2 listlevels.py
  3. +1 −0 webrunner-mobs.js
  4. +3 −2 webrunner-play.js
  5. +1 −5 webrunner-world.js
View
@@ -15,6 +15,7 @@
q = cgi.FieldStorage()
levelName = q.getfirst("levelName", "")
completionTime = q.getfirst("completionTime", "")
+trinkets = q.getfirst("trinkets", 0)
player = verify_id()
@@ -28,6 +29,7 @@
score = Score(level = level,
player = player,
completionTime = int(completionTime),
+ trinkets = int(trinkets),
achievedOn = datetime.datetime.now())
print "Saved score %d for %s on %s." % (int(completionTime), player.name, level.name)
else:
View
@@ -39,13 +39,16 @@ def printList(player):
scores = Score.selectBy(level = level)
best = ""
if (scores.count() > 0):
- best = "%s by %s" % (formatTime(scores[0].completionTime), scores[0].player.name)
+ best = "%s by %s with %d trinkets" % (formatTime(scores[0].completionTime),
+ scores[0].player.name,
+ scores[0].trinkets)
else:
best = "Nobody Yet!"
scores = Score.selectBy(player = player, level = level)
your_time = ""
if (scores.count() > 0):
- your_time = formatTime(scores[0].completionTime)
+ your_time = "%s with %d trinkets" % (formatTime(scores[0].completionTime),
+ scores[0].trinkets)
work_list += render_template_file( "list-level-row.html",
{"moddate": date,
"title": title,
View
@@ -248,6 +248,7 @@ Player.prototype = {
hitPoints: 2,
maxHitPoints: 2,
mercyInvincibility: 0,
+ numTrinkets: 0,
onMobTouch: function(mob, intercept) {
// So this is kind of weird.
View
@@ -150,13 +150,14 @@ function startGame() {
// check for #WINNING:
if (player.intersecting(TheWorld.goalArea)) {
$("#output").html("A WINRAR IS YOU!");
+ // stop bgm, play victory sound effects!
$("#bgm")[0].pause();
playSfx("victory-sfx");
- // TODO play victory sound effects!
$.ajax({type: "POST",
url: "complete-level.py",
data: {levelName: gup("level"),
- completionTime: Date.now() - startTime},
+ completionTime: Date.now() - startTime,
+ trinkets: player.numTrinkets},
success: function(data, textStatus, jqXHR) {
$("#debug").html(data);
},
View
@@ -673,11 +673,7 @@ PointlessTrinket.prototype = {
},
onCollect: function(player) {
playSfx("kaching-sfx");
- if (!player.numTrinkets) {
- player.numTrinkets = 1;
- } else {
- player.numTrinkets ++;
- }
+ player.numTrinkets ++;
$("#trinkets").html(player.numTrinkets);
}
};

0 comments on commit 57641e9

Please sign in to comment.