diff --git a/curseServer/server.php b/curseServer/server.php index 23a390a90..d7a251644 100644 --- a/curseServer/server.php +++ b/curseServer/server.php @@ -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 ); + } + } + } + + @@ -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;"; } @@ -684,6 +738,9 @@ 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'; "; @@ -691,7 +748,9 @@ function cs_curse() { } cs_queryDatabase( $query ); - + + cs_scaleCurseScore( $email ); + echo "OK"; } diff --git a/curseServer/settings.php b/curseServer/settings.php index 369bf7856..bd65c6fe9 100644 --- a/curseServer/settings.php +++ b/curseServer/settings.php @@ -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 diff --git a/documentation/changeLog.txt b/documentation/changeLog.txt index 1409a3876..46bfb6b24 100644 --- a/documentation/changeLog.txt +++ b/documentation/changeLog.txt @@ -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.