Permalink
Browse files

change to way we do scoring - now a win/loss ratio once we reach a vo…

…te threshold. show 30 top scores
  • Loading branch information...
1 parent 1fe980f commit 3f30fd4a1f514b6583ef7e999e3bef9dd9ad77dd @iamcal iamcal committed Jul 21, 2011
Showing with 24 additions and 11 deletions.
  1. +7 −0 include/lib_smarty.php
  2. +10 −4 index.php
  3. +4 −4 templates/page_avatar.txt
  4. +1 −1 templates/page_top.txt
  5. +1 −1 templates/page_you.txt
  6. +1 −1 top.php
View
@@ -57,4 +57,11 @@ function smarty_timings(){
$GLOBALS['smarty']->register_function('timings', 'smarty_timings');
#######################################################################################
+
+ function ratio_percent($r){
+
+ return round($r * 100);
+ }
+
+ #######################################################################################
?>
View
@@ -66,14 +66,20 @@ function hash_ids($a, $b){
list($losses1) = db_list(db_fetch("SELECT COUNT(*) FROM glitchmash_votes WHERE lose_id=$win"));
list($losses2) = db_list(db_fetch("SELECT COUNT(*) FROM glitchmash_votes WHERE lose_id=$lose"));
+ $vote_limit = 50;
+
db_update('glitchmash_avatars', array(
- 'votes' => $wins1+$losses1,
- 'wins' => $wins1,
+ 'votes' => $wins1+$losses1,
+ 'wins' => $wins1,
+ 'enough_votes' => (($wins1+$losses1) > $vote_limit) ? 1 : 0,
+ 'ratio' => $wins1 / ($wins1+$losses1),
), "id=$win");
db_update('glitchmash_avatars', array(
- 'votes' => $wins2+$losses2,
- 'wins' => $wins2,
+ 'votes' => $wins2+$losses2,
+ 'wins' => $wins2,
+ 'enough_votes' => (($wins2+$losses2) > $vote_limit) ? 1 : 0,
+ 'ratio' => $wins2 / ($wins2+$losses2),
), "id=$lose");
@@ -34,15 +34,15 @@
</div>
{if $avatar.is_active}
- <p><b>This outfit is still being voted for.</b></p>
+ <p><b>This outfit is still being voted for</b></p>
{else}
- <p><b>This outfit is no longer being voted for.</b></p>
+ <p><b>This outfit is no longer being voted for</b></p>
{/if}
<p>Added {'Y-m-d H:i:s'|date:$avatar.date_added}</p>
- <p>This outfit has won {$avatar.wins} votes out of {$avatar.votes}.</p>
+ <p>This outfit has won {$avatar.wins} votes out of {$avatar.votes} ({$avatar.ratio|ratio_percent}%)</p>
- <p>Check out <a href="http://beta.glitch.com/profiles/{$avatar.player.tsid|escape}/">their profile</a> on Glitch.</p>
+ <p>Check out <a href="http://beta.glitch.com/profiles/{$avatar.player.tsid|escape}/">their profile</a> on Glitch</p>
<br clear="all" />
</div>
View
@@ -37,7 +37,7 @@
Added {'Y-m-d H:i:s'|date:$row.date_added}<br />
<br />
- This outfit has won {$row.wins} out of {$row.votes} votes.
+ This outfit has won {$row.wins} out of {$row.votes} votes ({$row.ratio|ratio_percent}%)
<br clear="both" />
</div>
View
@@ -44,7 +44,7 @@
{/if}
Added {'Y-m-d H:i:s'|date:$row.date_added}<br />
<br />
- This outfit has won {$row.wins} out of {$row.votes} votes.
+ This outfit has won {$row.wins} out of {$row.votes} votes ({$row.ratio|ratio_percent}%)
<br clear="both" />
</div>
View
@@ -13,7 +13,7 @@
$num = 1;
- $ret = db_fetch("SELECT * FROM glitchmash_avatars ORDER BY wins DESC LIMIT 10");
+ $ret = db_fetch("SELECT * FROM glitchmash_avatars WHERE enough_votes=1 ORDER BY ratio DESC LIMIT 30");
foreach ($ret['rows'] as $row){
$tsid_enc = AddSlashes($row['player_tsid']);

0 comments on commit 3f30fd4

Please sign in to comment.