give a bonus reward for the first uploads of a user

This commit is contained in:
Spine
2025-10-02 04:59:56 +00:00
parent d8058f7b77
commit 2dee8ef9b8
9 changed files with 105 additions and 27 deletions

View File

@@ -5,6 +5,23 @@ declare(strict_types=1);
namespace Gazelle;
class BonusUploadReward extends Base {
public function boost(User $user): int {
if (
!BONUS_UPLOAD_BOOST_ACTIVE
||
$user->classLevel() > BONUS_UPLOAD_BOOST_MAX_LEVEL
) {
return 0;
}
$index = $user->ordinal()->value('bonus-upload-boost');
if (!isset(BONUS_UPLOAD_BOOST[$index])) {
return 0;
}
$boost = BONUS_UPLOAD_BOOST[$index];
$user->ordinal()->set('bonus-upload-boost', $index + 1);
return $boost;
}
public function reward(Torrent $torrent): int {
$categoryId = $torrent->group()->categoryId();
if ($torrent->isPerfectFlac()) {

View File

@@ -13,7 +13,7 @@ namespace Gazelle\User;
*/
class Ordinal extends \Gazelle\BaseUser {
final protected const CACHE_KEY = 'u_ord_%s';
final protected const CACHE_KEY = 'u_ord2_%s';
protected array $info;