first commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\CharacterStatus;
|
||||
use App\Models\Character;
|
||||
use App\Models\Location;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Character>
|
||||
*/
|
||||
class CharacterFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$genders = ['male', 'female', 'other'];
|
||||
|
||||
return [
|
||||
'name' => $this->faker->unique()->firstName() . ' ' . $this->faker->lastName(),
|
||||
'gender' => $genders[array_rand($genders)],
|
||||
'level' => $this->faker->numberBetween(1, 10),
|
||||
'experience' => $this->faker->numberBetween(0, 5000),
|
||||
'money' => $this->faker->numberBetween(1000, 50000),
|
||||
'bank' => $this->faker->numberBetween(0, 100000),
|
||||
'energy' => $this->faker->numberBetween(50, 100),
|
||||
'max_energy' => 100,
|
||||
'health' => $this->faker->numberBetween(50, 100),
|
||||
'max_health' => 100,
|
||||
'strength' => $this->faker->numberBetween(5, 20),
|
||||
'defense' => $this->faker->numberBetween(5, 20),
|
||||
'speed' => $this->faker->numberBetween(5, 20),
|
||||
'dexterity' => $this->faker->numberBetween(5, 20),
|
||||
'location_id' => Location::factory(),
|
||||
'faction_id' => null,
|
||||
'in_hospital_until' => null,
|
||||
'in_jail_until' => null,
|
||||
'last_action_at' => now(),
|
||||
'status' => CharacterStatus::ACTIVE,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a character with specific stats.
|
||||
*/
|
||||
public function withStats(int $strength, int $defense, int $speed, int $dexterity): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'strength' => $strength,
|
||||
'defense' => $defense,
|
||||
'speed' => $speed,
|
||||
'dexterity' => $dexterity,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a character at a specific level.
|
||||
*/
|
||||
public function atLevel(int $level): static
|
||||
{
|
||||
$experience = 0;
|
||||
if ($level > 1) {
|
||||
$base = config('game.leveling.exp_per_level', 1000);
|
||||
$multiplier = config('game.leveling.exp_multiplier', 1.20);
|
||||
for ($i = 2; $i <= $level; $i++) {
|
||||
$experience += (int) ($base * pow($multiplier, $i - 2));
|
||||
}
|
||||
// Add some extra to be in the middle of the level
|
||||
$experience += (int) ($base * pow($multiplier, $level - 1) * 0.5);
|
||||
}
|
||||
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'level' => $level,
|
||||
'experience' => $experience,
|
||||
'max_health' => 100 + (($level - 1) * 5),
|
||||
'max_energy' => 100 + (($level - 1) * 5),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a character with full health and energy.
|
||||
*/
|
||||
public function fresh(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'health' => $attributes['max_health'] ?? 100,
|
||||
'energy' => $attributes['max_energy'] ?? 100,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a character in hospital.
|
||||
*/
|
||||
public function inHospital(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'health' => 1,
|
||||
'status' => CharacterStatus::IN_HOSPITAL,
|
||||
'in_hospital_until' => now()->addHours(1),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a dead character.
|
||||
*/
|
||||
public function dead(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'health' => 0,
|
||||
'status' => CharacterStatus::DEAD,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a character in jail.
|
||||
*/
|
||||
public function inJail(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => CharacterStatus::IN_JAIL,
|
||||
'in_jail_until' => now()->addHours(1),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Character;
|
||||
use App\Models\Inventory;
|
||||
use App\Models\Item;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Inventory>
|
||||
*/
|
||||
class InventoryFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'character_id' => Character::factory(),
|
||||
'item_id' => Item::factory(),
|
||||
'quantity' => $this->faker->numberBetween(1, 10),
|
||||
'equipped' => false,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an equipped item.
|
||||
*/
|
||||
public function equipped(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'equipped' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create with a specific quantity.
|
||||
*/
|
||||
public function withQuantity(int $quantity): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'quantity' => $quantity,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Location;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Location>
|
||||
*/
|
||||
class LocationFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->unique()->city() . ' ' . $this->faker->randomElement(['District', 'Area', 'Sector', 'Zone']),
|
||||
'slug' => $this->faker->unique()->slug(2),
|
||||
'description' => $this->faker->sentence(),
|
||||
'travel_cost' => $this->faker->numberBetween(100, 5000),
|
||||
'requires_level' => $this->faker->randomElement([null, 1, 3, 5, 10, 15]),
|
||||
'faction_control' => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a starting location.
|
||||
*/
|
||||
public function starting(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'name' => 'Downtown',
|
||||
'slug' => 'downtown',
|
||||
'description' => 'The bustling city center with plenty of opportunities.',
|
||||
'travel_cost' => 0,
|
||||
'requires_level' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedSmallInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->string('connection');
|
||||
$table->string('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
|
||||
$table->index(['connection', 'queue', 'failed_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('locations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 100);
|
||||
$table->string('slug', 100)->unique();
|
||||
$table->text('description')->nullable();
|
||||
$table->unsignedInteger('travel_cost')->default(0);
|
||||
$table->unsignedInteger('requires_level')->nullable()->default(null);
|
||||
$table->unsignedBigInteger('faction_control')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes
|
||||
$table->index('slug');
|
||||
$table->index('requires_level');
|
||||
$table->index('faction_control');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('locations');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\CharacterStatus;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('characters', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name', 50);
|
||||
$table->enum('gender', ['male', 'female', 'other']);
|
||||
$table->unsignedInteger('level')->default(1);
|
||||
$table->unsignedBigInteger('experience')->default(0);
|
||||
$table->unsignedBigInteger('money')->default(5000);
|
||||
$table->unsignedBigInteger('bank')->default(0);
|
||||
$table->unsignedInteger('energy')->default(100);
|
||||
$table->unsignedInteger('max_energy')->default(100);
|
||||
$table->unsignedInteger('health')->default(100);
|
||||
$table->unsignedInteger('max_health')->default(100);
|
||||
$table->unsignedInteger('strength')->default(5);
|
||||
$table->unsignedInteger('defense')->default(5);
|
||||
$table->unsignedInteger('speed')->default(5);
|
||||
$table->unsignedInteger('dexterity')->default(5);
|
||||
$table->foreignId('location_id')->constrained();
|
||||
$table->unsignedBigInteger('faction_id')->nullable();
|
||||
$table->timestamp('in_hospital_until')->nullable();
|
||||
$table->timestamp('in_jail_until')->nullable();
|
||||
$table->timestamp('last_action_at')->nullable();
|
||||
$table->enum('status', CharacterStatus::values())->default(CharacterStatus::ACTIVE->value);
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes
|
||||
$table->index('user_id');
|
||||
$table->index('name');
|
||||
$table->index('level');
|
||||
$table->index('location_id');
|
||||
$table->index('faction_id');
|
||||
$table->index('status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('characters');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\ItemType;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 100);
|
||||
$table->string('slug', 100)->unique();
|
||||
$table->text('description')->nullable();
|
||||
$table->enum('type', ItemType::values());
|
||||
$table->unsignedInteger('value')->default(0);
|
||||
$table->unsignedInteger('buy_price')->nullable()->default(null);
|
||||
$table->unsignedInteger('sell_price')->nullable()->default(null);
|
||||
$table->unsignedInteger('requires_level')->nullable()->default(null);
|
||||
$table->integer('attack_bonus')->default(0);
|
||||
$table->integer('defense_bonus')->default(0);
|
||||
$table->integer('health_bonus')->default(0);
|
||||
$table->integer('energy_bonus')->default(0);
|
||||
$table->boolean('is_tradeable')->default(true);
|
||||
$table->boolean('is_usable')->default(false);
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes
|
||||
$table->index('slug');
|
||||
$table->index('type');
|
||||
$table->index('requires_level');
|
||||
$table->index('buy_price');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('items');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\CrimeDifficulty;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('crimes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 100);
|
||||
$table->string('slug', 100)->unique();
|
||||
$table->text('description')->nullable();
|
||||
$table->enum('difficulty', CrimeDifficulty::values())->default(CrimeDifficulty::EASY->value);
|
||||
$table->float('success_rate')->default(0.70);
|
||||
$table->unsignedInteger('reward_min')->default(0);
|
||||
$table->unsignedInteger('reward_max')->default(0);
|
||||
$table->unsignedInteger('experience')->default(0);
|
||||
$table->unsignedInteger('energy_cost')->default(10);
|
||||
$table->unsignedInteger('cooldown')->default(120); // seconds
|
||||
$table->unsignedInteger('requires_level')->nullable()->default(null);
|
||||
$table->foreignId('location_id')->nullable()->constrained();
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes
|
||||
$table->index('slug');
|
||||
$table->index('difficulty');
|
||||
$table->index('requires_level');
|
||||
$table->index('location_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('crimes');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('crime_attempts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('character_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('crime_id')->constrained();
|
||||
$table->boolean('success')->default(false);
|
||||
$table->unsignedBigInteger('reward')->default(0);
|
||||
$table->unsignedBigInteger('experience_gained')->default(0);
|
||||
$table->timestamp('attempted_at')->useCurrent();
|
||||
|
||||
// Indexes
|
||||
$table->index('character_id');
|
||||
$table->index('crime_id');
|
||||
$table->index('success');
|
||||
$table->index('attempted_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('crime_attempts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('activity_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('character_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('action', 100);
|
||||
$table->text('description')->nullable();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->string('user_agent')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes
|
||||
$table->index('character_id');
|
||||
$table->index('action');
|
||||
$table->index('created_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('activity_logs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('type', 100);
|
||||
$table->json('data')->nullable();
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes
|
||||
$table->index('user_id');
|
||||
$table->index('type');
|
||||
$table->index('read_at');
|
||||
$table->index('created_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('notifications');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('inventories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('character_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('item_id')->constrained();
|
||||
$table->unsignedInteger('quantity')->default(1);
|
||||
$table->boolean('equipped')->default(false);
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes
|
||||
$table->index('character_id');
|
||||
$table->index('item_id');
|
||||
$table->index('equipped');
|
||||
|
||||
// Unique constraint: one inventory entry per character per item
|
||||
$table->unique(['character_id', 'item_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('inventories');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Crime;
|
||||
use App\Models\Location;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CrimeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$downtown = Location::where('slug', 'downtown')->first();
|
||||
$industrial = Location::where('slug', 'industrial-district')->first();
|
||||
$waterfront = Location::where('slug', 'waterfront')->first();
|
||||
|
||||
$crimes = [
|
||||
// Downtown Crimes
|
||||
[
|
||||
'name' => 'Pickpocket',
|
||||
'slug' => 'pickpocket',
|
||||
'description' => 'Steal money from an unsuspecting pedestrian.',
|
||||
'difficulty' => 'easy',
|
||||
'success_rate' => 0.80,
|
||||
'reward_min' => 100,
|
||||
'reward_max' => 500,
|
||||
'experience' => 50,
|
||||
'energy_cost' => 10,
|
||||
'cooldown' => 60,
|
||||
'requires_level' => 1,
|
||||
'location_id' => $downtown?->id ?? null,
|
||||
],
|
||||
[
|
||||
'name' => 'Mugging',
|
||||
'slug' => 'mugging',
|
||||
'description' => 'Rob someone at knife-point.',
|
||||
'difficulty' => 'medium',
|
||||
'success_rate' => 0.70,
|
||||
'reward_min' => 500,
|
||||
'reward_max' => 1500,
|
||||
'experience' => 100,
|
||||
'energy_cost' => 15,
|
||||
'cooldown' => 120,
|
||||
'requires_level' => 3,
|
||||
'location_id' => $downtown?->id ?? null,
|
||||
],
|
||||
[
|
||||
'name' => 'Shoplifting',
|
||||
'slug' => 'shoplifting',
|
||||
'description' => 'Steal items from a store.',
|
||||
'difficulty' => 'medium',
|
||||
'success_rate' => 0.65,
|
||||
'reward_min' => 200,
|
||||
'reward_max' => 1000,
|
||||
'experience' => 75,
|
||||
'energy_cost' => 12,
|
||||
'cooldown' => 120,
|
||||
'requires_level' => 1,
|
||||
'location_id' => $downtown?->id ?? null,
|
||||
],
|
||||
|
||||
// Industrial District Crimes
|
||||
[
|
||||
'name' => 'Factory Theft',
|
||||
'slug' => 'factory-theft',
|
||||
'description' => 'Steal goods from a factory warehouse.',
|
||||
'difficulty' => 'medium',
|
||||
'success_rate' => 0.60,
|
||||
'reward_min' => 1000,
|
||||
'reward_max' => 3000,
|
||||
'experience' => 150,
|
||||
'energy_cost' => 20,
|
||||
'cooldown' => 180,
|
||||
'requires_level' => 5,
|
||||
'location_id' => $industrial?->id ?? null,
|
||||
],
|
||||
[
|
||||
'name' => 'Equipment Sabotage',
|
||||
'slug' => 'equipment-sabotage',
|
||||
'description' => 'Sabotage factory equipment for a fee.',
|
||||
'difficulty' => 'hard',
|
||||
'success_rate' => 0.50,
|
||||
'reward_min' => 2000,
|
||||
'reward_max' => 5000,
|
||||
'experience' => 200,
|
||||
'energy_cost' => 25,
|
||||
'cooldown' => 300,
|
||||
'requires_level' => 8,
|
||||
'location_id' => $industrial?->id ?? null,
|
||||
],
|
||||
|
||||
// Waterfront Crimes
|
||||
[
|
||||
'name' => 'Smuggling',
|
||||
'slug' => 'smuggling',
|
||||
'description' => 'Smuggle illegal goods past customs.',
|
||||
'difficulty' => 'hard',
|
||||
'success_rate' => 0.55,
|
||||
'reward_min' => 3000,
|
||||
'reward_max' => 8000,
|
||||
'experience' => 250,
|
||||
'energy_cost' => 30,
|
||||
'cooldown' => 300,
|
||||
'requires_level' => 10,
|
||||
'location_id' => $waterfront?->id ?? null,
|
||||
],
|
||||
[
|
||||
'name' => 'Piracy',
|
||||
'slug' => 'piracy',
|
||||
'description' => 'Hijack a shipment at sea.',
|
||||
'difficulty' => 'very_hard',
|
||||
'success_rate' => 0.40,
|
||||
'reward_min' => 5000,
|
||||
'reward_max' => 15000,
|
||||
'experience' => 400,
|
||||
'energy_cost' => 40,
|
||||
'cooldown' => 600,
|
||||
'requires_level' => 15,
|
||||
'location_id' => $waterfront?->id ?? null,
|
||||
],
|
||||
|
||||
// Generic Crimes (available everywhere)
|
||||
[
|
||||
'name' => 'Car Theft',
|
||||
'slug' => 'car-theft',
|
||||
'description' => 'Steal a car and sell it for parts.',
|
||||
'difficulty' => 'medium',
|
||||
'success_rate' => 0.75,
|
||||
'reward_min' => 2000,
|
||||
'reward_max' => 4000,
|
||||
'experience' => 120,
|
||||
'energy_cost' => 20,
|
||||
'cooldown' => 180,
|
||||
'requires_level' => 5,
|
||||
'location_id' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'Burglary',
|
||||
'slug' => 'burglary',
|
||||
'description' => 'Break into a house and steal valuables.',
|
||||
'difficulty' => 'hard',
|
||||
'success_rate' => 0.60,
|
||||
'reward_min' => 3000,
|
||||
'reward_max' => 6000,
|
||||
'experience' => 200,
|
||||
'energy_cost' => 25,
|
||||
'cooldown' => 300,
|
||||
'requires_level' => 7,
|
||||
'location_id' => null,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($crimes as $crime) {
|
||||
Crime::updateOrCreate(
|
||||
['slug' => $crime['slug']],
|
||||
$crime
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Seed locations first (required by other seeders)
|
||||
$this->call([
|
||||
LocationSeeder::class,
|
||||
]);
|
||||
|
||||
// Then seed items and crimes
|
||||
$this->call([
|
||||
ItemSeeder::class,
|
||||
CrimeSeeder::class,
|
||||
]);
|
||||
|
||||
// Create test user
|
||||
$user = User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
|
||||
// Optionally create a test character for the user
|
||||
// This can be done manually through the UI or via a separate seeder
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Item;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ItemSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$items = [
|
||||
// Weapons
|
||||
[
|
||||
'name' => 'Knife',
|
||||
'slug' => 'knife',
|
||||
'description' => 'A basic knife for self-defense.',
|
||||
'type' => 'weapon',
|
||||
'value' => 100,
|
||||
'buy_price' => 500,
|
||||
'sell_price' => 250,
|
||||
'requires_level' => 1,
|
||||
'attack_bonus' => 5,
|
||||
'defense_bonus' => 0,
|
||||
'health_bonus' => 0,
|
||||
'energy_bonus' => 0,
|
||||
'is_tradeable' => true,
|
||||
'is_usable' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'Baseball Bat',
|
||||
'slug' => 'baseball-bat',
|
||||
'description' => 'A sturdy bat that can deal serious damage.',
|
||||
'type' => 'weapon',
|
||||
'value' => 500,
|
||||
'buy_price' => 2500,
|
||||
'sell_price' => 1250,
|
||||
'requires_level' => 3,
|
||||
'attack_bonus' => 15,
|
||||
'defense_bonus' => 0,
|
||||
'health_bonus' => 0,
|
||||
'energy_bonus' => 0,
|
||||
'is_tradeable' => true,
|
||||
'is_usable' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'Pistol',
|
||||
'slug' => 'pistol',
|
||||
'description' => 'A handgun for more serious encounters.',
|
||||
'type' => 'weapon',
|
||||
'value' => 2000,
|
||||
'buy_price' => 10000,
|
||||
'sell_price' => 5000,
|
||||
'requires_level' => 10,
|
||||
'attack_bonus' => 30,
|
||||
'defense_bonus' => 0,
|
||||
'health_bonus' => 0,
|
||||
'energy_bonus' => 0,
|
||||
'is_tradeable' => true,
|
||||
'is_usable' => false,
|
||||
],
|
||||
|
||||
// Armor
|
||||
[
|
||||
'name' => 'Leather Jacket',
|
||||
'slug' => 'leather-jacket',
|
||||
'description' => 'Basic protection from attacks.',
|
||||
'type' => 'armor',
|
||||
'value' => 200,
|
||||
'buy_price' => 1000,
|
||||
'sell_price' => 500,
|
||||
'requires_level' => 1,
|
||||
'attack_bonus' => 0,
|
||||
'defense_bonus' => 5,
|
||||
'health_bonus' => 0,
|
||||
'energy_bonus' => 0,
|
||||
'is_tradeable' => true,
|
||||
'is_usable' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'Kevlar Vest',
|
||||
'slug' => 'kevlar-vest',
|
||||
'description' => 'Heavy body armor for serious protection.',
|
||||
'type' => 'armor',
|
||||
'value' => 1000,
|
||||
'buy_price' => 5000,
|
||||
'sell_price' => 2500,
|
||||
'requires_level' => 8,
|
||||
'attack_bonus' => 0,
|
||||
'defense_bonus' => 25,
|
||||
'health_bonus' => 0,
|
||||
'energy_bonus' => 0,
|
||||
'is_tradeable' => true,
|
||||
'is_usable' => false,
|
||||
],
|
||||
|
||||
// Consumables
|
||||
[
|
||||
'name' => 'First Aid Kit',
|
||||
'slug' => 'first-aid-kit',
|
||||
'description' => 'Restores 50 health when used.',
|
||||
'type' => 'consumable',
|
||||
'value' => 500,
|
||||
'buy_price' => 2500,
|
||||
'sell_price' => 1000,
|
||||
'requires_level' => 1,
|
||||
'attack_bonus' => 0,
|
||||
'defense_bonus' => 0,
|
||||
'health_bonus' => 50,
|
||||
'energy_bonus' => 0,
|
||||
'is_tradeable' => true,
|
||||
'is_usable' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Energy Drink',
|
||||
'slug' => 'energy-drink',
|
||||
'description' => 'Restores 30 energy when used.',
|
||||
'type' => 'consumable',
|
||||
'value' => 300,
|
||||
'buy_price' => 1500,
|
||||
'sell_price' => 750,
|
||||
'requires_level' => 1,
|
||||
'attack_bonus' => 0,
|
||||
'defense_bonus' => 0,
|
||||
'health_bonus' => 0,
|
||||
'energy_bonus' => 30,
|
||||
'is_tradeable' => true,
|
||||
'is_usable' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Mega Health Pack',
|
||||
'slug' => 'mega-health-pack',
|
||||
'description' => 'Restores all health when used.',
|
||||
'type' => 'consumable',
|
||||
'value' => 1500,
|
||||
'buy_price' => 7500,
|
||||
'sell_price' => 3000,
|
||||
'requires_level' => 15,
|
||||
'attack_bonus' => 0,
|
||||
'defense_bonus' => 0,
|
||||
'health_bonus' => 100,
|
||||
'energy_bonus' => 0,
|
||||
'is_tradeable' => true,
|
||||
'is_usable' => true,
|
||||
],
|
||||
|
||||
// Misc
|
||||
[
|
||||
'name' => 'Lockpick Set',
|
||||
'slug' => 'lockpick-set',
|
||||
'description' => 'Useful for picking locks.',
|
||||
'type' => 'misc',
|
||||
'value' => 200,
|
||||
'buy_price' => 1000,
|
||||
'sell_price' => 500,
|
||||
'requires_level' => 5,
|
||||
'attack_bonus' => 0,
|
||||
'defense_bonus' => 0,
|
||||
'health_bonus' => 0,
|
||||
'energy_bonus' => 0,
|
||||
'is_tradeable' => true,
|
||||
'is_usable' => false,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($items as $item) {
|
||||
Item::updateOrCreate(
|
||||
['slug' => $item['slug']],
|
||||
$item
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Location;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class LocationSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$locations = [
|
||||
[
|
||||
'name' => 'Downtown',
|
||||
'slug' => 'downtown',
|
||||
'description' => 'The bustling city center with plenty of opportunities for crime.',
|
||||
'travel_cost' => 0,
|
||||
'requires_level' => null,
|
||||
'faction_control' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'Industrial District',
|
||||
'slug' => 'industrial-district',
|
||||
'description' => 'Factories and warehouses provide cover for illegal activities.',
|
||||
'travel_cost' => 500,
|
||||
'requires_level' => 5,
|
||||
'faction_control' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'Waterfront',
|
||||
'slug' => 'waterfront',
|
||||
'description' => 'The docks are perfect for smuggling operations.',
|
||||
'travel_cost' => 1000,
|
||||
'requires_level' => 10,
|
||||
'faction_control' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'Uptown',
|
||||
'slug' => 'uptown',
|
||||
'description' => 'The wealthy district. High rewards but high risks.',
|
||||
'travel_cost' => 1500,
|
||||
'requires_level' => 15,
|
||||
'faction_control' => null,
|
||||
],
|
||||
[
|
||||
'name' => 'Suburbs',
|
||||
'slug' => 'suburbs',
|
||||
'description' => 'Quiet residential area. Less police presence but fewer opportunities.',
|
||||
'travel_cost' => 300,
|
||||
'requires_level' => 3,
|
||||
'faction_control' => null,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($locations as $location) {
|
||||
Location::updateOrCreate(
|
||||
['slug' => $location['slug']],
|
||||
$location
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user