Skip to content

Commit

Permalink
Curse server now keeps people in Donkey Town for a fixed amount of ti…
Browse files Browse the repository at this point in the history
…me based on the total number of curse points that they've earned in their lifetime as a player. First-time offenders are only kept there for 30 minutes. The worst repeat offenders will eventually be kept there for five hours every time.
  • Loading branch information
jasonrohrer committed Oct 31, 2018
1 parent 1eea035 commit 542cfc1
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
61 changes: 60 additions & 1 deletion curseServer/server.php
Expand Up @@ -616,6 +616,59 @@ function cs_getSequenceNumberForEmail( $inEmail ) {



function cs_scaleCurseScore( $inEmail ) {
global $tableNamePrefix;

$query = "SELECT curse_score, total_curse_score, extra_life_sec ".
"FROM $tableNamePrefix"."users ".
"WHERE email = '$inEmail';";

$result = cs_queryDatabase( $query );

$numRows = mysqli_num_rows( $result );

if( $numRows == 1 ) {
$curse_score = cs_mysqli_result( $result, 0, "curse_score" );
$total_curse_score =
cs_mysqli_result( $result, 0, "total_curse_score" );
$extra_life_sec = cs_mysqli_result( $result, 0, "extra_life_sec" );

global $curseThreshold, $lifetimeThresholds, $hoursToServe;

if( $curse_score >= $curseThreshold ) {

$hours = 0;

$index = 0;
foreach( $lifetimeThresholds as $thresh ) {
if( $total_curse_score >= $thresh ) {
$hours = $hoursToServe[ $index ];
}
$index++;
}

if( $hours > 0 && $hours < 1 ) {
$extra_life_sec += $hours * $secondsPerCurseScoreDecrement;

$hours = 1;
}
$hours = floor( $hours );

// score encodes hours to serve
// one hour puts them right at the threshold
$curse_score = $curseThreshold + $hours - 1;

$query = "UPDATE $tableNamePrefix"."users SET " .
"curse_score = $curse_score, " .
"extra_life_sec = $extra_life_sec " .
"WHERE email = '$inEmail'; ";

$result = cs_queryDatabase( $query );
}
}
}





Expand Down Expand Up @@ -676,6 +729,7 @@ function cs_curse() {
"total_curse_score = 1, ".
"extra_life_sec = 0 ".
"ON DUPLICATE KEY UPDATE sequence_number = sequence_number + 1, ".
"extra_life_sec = 0, ".
"curse_score = curse_score + 1, ".
"total_curse_score = total_curse_score + 1;";
}
Expand All @@ -684,14 +738,19 @@ function cs_curse() {
$query = "UPDATE $tableNamePrefix"."users SET " .
// our values might be stale, increment values in table
"sequence_number = sequence_number + 1, ".
// reset their accumulated lifetime counter when they
// get additional curse points.
"extra_life_sec = 0, ".
"curse_score = curse_score + 1, " .
"total_curse_score = total_curse_score + 1 " .
"WHERE email = '$email'; ";

}

cs_queryDatabase( $query );


cs_scaleCurseScore( $email );

echo "OK";
}

Expand Down
5 changes: 5 additions & 0 deletions curseServer/settings.php
Expand Up @@ -33,6 +33,11 @@
// isCursed returns 1 if player has this curse score or higher
$curseThreshold = 8;

// people serve longer and longer times as "isCursed" as their
// lifetime total curse score grows.
// hours must be fraction < 1 or a whole number >= 1
$lifetimeThresholds = array( 0, 15, 25, 55, 65, 75 );
$hoursToServe = array( 0.5, 1, 2, 3, 4, 5 );

// how long you have to live in a life before it "counts" toward
// time served to decrement your curse score
Expand Down
5 changes: 5 additions & 0 deletions documentation/changeLog.txt
Expand Up @@ -26,6 +26,11 @@ Server Fixes
--Fixed lineage ban calcuation for /die babies and killers/victims. Was
living extra time in other lines by accident.

--Curse server now keeps people in Donkey Town for a fixed amount of time based
on the total number of curse points that they've earned in their lifetime as
a player. First-time offenders are only kept there for 30 minutes. The
worst repeat offenders will eventually be kept there for five hours every
time.



Expand Down

0 comments on commit 542cfc1

Please sign in to comment.