diff --git a/dist/app/Models/User/PlayerData.php b/dist/app/Models/User/PlayerData.php index 2afa6b9..b26f0cf 100644 --- a/dist/app/Models/User/PlayerData.php +++ b/dist/app/Models/User/PlayerData.php @@ -12,6 +12,7 @@ use App\Models\Game\Challenge; use App\Models\Game\CharacterData; use App\Models\Game\QuitterState; +use Illuminate\Database\Eloquent\Casts\Attribute; use App\Models\Game\TimedChallenge; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -54,6 +55,8 @@ class PlayerData extends Model 'has_played_dg_1' => 'boolean', ]; + const CURRENCY_CAP = 50000; + protected static function booted(): void { static::created(function (PlayerData $playerData) { @@ -197,4 +200,22 @@ public static function getRemainingFactionExperience(int $level): int return 4; return 5; } + + public function currencyA(): Attribute { + return Attribute::make( + set: fn (int $value) => min($value, static::CURRENCY_CAP), + ); + } + + public function currencyB(): Attribute { + return Attribute::make( + set: fn (int $value) => min($value, static::CURRENCY_CAP), + ); + } + + public function currencyC(): Attribute { + return Attribute::make( + set: fn (int $value) => min($value, static::CURRENCY_CAP), + ); + } } diff --git a/dist/database/migrations/2024_12_19_185927_currency_cap.php b/dist/database/migrations/2024_12_19_185927_currency_cap.php new file mode 100644 index 0000000..cb089fb --- /dev/null +++ b/dist/database/migrations/2024_12_19_185927_currency_cap.php @@ -0,0 +1,30 @@ +update([ + 'currency_a' => self::USER_MIGRATION_CURRENCY, + 'currency_b' => self::USER_MIGRATION_CURRENCY, + 'currency_c' => self::USER_MIGRATION_CURRENCY, + ]); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // + } +};