mirror of
https://github.com/Deathgarden-Rebirth/Deathgarden_Rebirth-Rewrite.git
synced 2026-09-08 19:25:10 -05:00
Added currency cap with Migration.
This commit is contained in:
21
dist/app/Models/User/PlayerData.php
vendored
21
dist/app/Models/User/PlayerData.php
vendored
@@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
30
dist/database/migrations/2024_12_19_185927_currency_cap.php
vendored
Normal file
30
dist/database/migrations/2024_12_19_185927_currency_cap.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
const USER_MIGRATION_CURRENCY = 10000;
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
\App\Models\User\PlayerData::query()->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
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user