-
-
Save InvisibleSymbol/deca44757757b47deff0d5c9aa37b063 to your computer and use it in GitHub Desktop.
._.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function getUsernameAvailableAt() : Carbon | |
{ | |
$playCount = array_reduce(array_keys(Beatmap::MODES), function ($result, $mode) { | |
return $result + $this->statistics($mode, true)->value('playcount'); | |
}, 0); | |
if ($this->group_id !== 2) { | |
//reserved usernames | |
return Carbon::now()->addYears(10); //This will always be in the future, which is wanted | |
} | |
if ($this->user_type === 1) { | |
// restricted user | |
return $this->user_lastvisit | |
// This is a exponential decay function with the identity 1-e^{-$playCount}. | |
// The constant multiplier of 1580 causes the formula to flatten out at around 1580 days (~4.3 years). | |
// $playCount is then divided by the constant value 5900 causing it to flatten out at about 40,000 plays. | |
// Furthermore the formula has a 0.35 multiplier on $playCount, causing it to flatten out more slowly (closer to 80,000 plays). | |
// A linear bonus of 6x/5900 is added to reward long-term play. | |
->addDays(intval(1580 * (1 - pow(M_E, -0.35 * $playCount / 5900)) + (3 * 8 * $playCount / (4 * 5900)))); | |
} | |
return $this->user_lastvisit | |
->addDays(static::INACTIVE_DAYS) // base inactivity period for all accounts | |
// Same formula as above, but with the 0.35 multiplier removed and a linear bonus of 8x/5900 instead. | |
->addDays(intval(1580 * (1 - pow(M_E, -$playCount / 5900)) + (8 * $playCount / 5900))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment