From ef842f99c6a426c83636402c58ff58a1a959193b Mon Sep 17 00:00:00 2001 From: WildEgo Date: Fri, 19 Sep 2025 14:42:14 +0100 Subject: [PATCH] add: ShopEx. --- app/Models/Game/Player/ShopEx.php | 56 ++++++++++++++++ app/Models/Game/Player/ShopExItem.php | 56 ++++++++++++++++ database/data/shopex.json | 12 ++++ database/data/shopex_item.json | 52 +++++++++++++++ ..._03_30_000062_create_skill_proto_table.php | 4 +- .../2025_09_19_102032_create_shopex_table.php | 34 ++++++++++ ..._09_19_102037_create_shopex_item_table.php | 65 +++++++++++++++++++ 7 files changed, 278 insertions(+), 1 deletion(-) create mode 100644 app/Models/Game/Player/ShopEx.php create mode 100644 app/Models/Game/Player/ShopExItem.php create mode 100644 database/data/shopex.json create mode 100644 database/data/shopex_item.json create mode 100644 database/migrations/2025_09_19_102032_create_shopex_table.php create mode 100644 database/migrations/2025_09_19_102037_create_shopex_item_table.php diff --git a/app/Models/Game/Player/ShopEx.php b/app/Models/Game/Player/ShopEx.php new file mode 100644 index 0000000..1e29950 --- /dev/null +++ b/app/Models/Game/Player/ShopEx.php @@ -0,0 +1,56 @@ + + */ + protected $fillable = [ + + ]; + + /** + * The attributes that should be hidden for serialization. + * + * @var array + */ + protected $hidden = [ + + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + + ]; +} diff --git a/app/Models/Game/Player/ShopExItem.php b/app/Models/Game/Player/ShopExItem.php new file mode 100644 index 0000000..c58c598 --- /dev/null +++ b/app/Models/Game/Player/ShopExItem.php @@ -0,0 +1,56 @@ + + */ + protected $fillable = [ + + ]; + + /** + * The attributes that should be hidden for serialization. + * + * @var array + */ + protected $hidden = [ + + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + + ]; +} diff --git a/database/data/shopex.json b/database/data/shopex.json new file mode 100644 index 0000000..80cdc22 --- /dev/null +++ b/database/data/shopex.json @@ -0,0 +1,12 @@ +[ + { + "vnum": 61, + "name": "Armor", + "npc_vnum": 20082 + }, + { + "vnum": 62, + "name": "Armor", + "npc_vnum": 20082 + } +] diff --git a/database/data/shopex_item.json b/database/data/shopex_item.json new file mode 100644 index 0000000..72a793c --- /dev/null +++ b/database/data/shopex_item.json @@ -0,0 +1,52 @@ +[ + { + "shop_vnum": 61, + "item_vnum": 12019, + "count": 1, + "price": 250, + "price_vnum": 0, + "price_type": "GOLD", + "attrtype1": 1, + "attrvalue1": 2000 + }, + { + "shop_vnum": 61, + "item_vnum": 12029, + "count": 1, + "price": 25000, + "price_vnum": 0, + "price_type": "GOLD", + "attrtype1": 0, + "attrvalue1": 0 + }, + { + "shop_vnum": 62, + "item_vnum": 299, + "count": 1, + "price": 5000, + "price_vnum": 0, + "price_type": "GOLD", + "attrtype1": 0, + "attrvalue1": 0 + }, + { + "shop_vnum": 62, + "item_vnum": 279, + "count": 1, + "price": 1, + "price_vnum": 299, + "price_type": "ITEM", + "attrtype1": 0, + "attrvalue1": 0 + }, + { + "shop_vnum": 62, + "item_vnum": 189, + "count": 1, + "price": 5000, + "price_vnum": 0, + "price_type": "EXP", + "attrtype1": 0, + "attrvalue1": 0 + } +] diff --git a/database/migrations/2024_03_30_000062_create_skill_proto_table.php b/database/migrations/2024_03_30_000062_create_skill_proto_table.php index 0f3ac97..893fea1 100644 --- a/database/migrations/2024_03_30_000062_create_skill_proto_table.php +++ b/database/migrations/2024_03_30_000062_create_skill_proto_table.php @@ -1,5 +1,6 @@ unsignedInteger('vnum')->primary()->autoIncrement(); + $table->string('name', 32)->default('NoName'); + $table->smallInteger('npc_vnum')->index(); // This should reference mob_proto + }); + + // Populate the table data + $data = File::json(database_path('data/shopex.json')); + + ShopEx::upsert($data, ['vnum']); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('shopex'); + } +}; diff --git a/database/migrations/2025_09_19_102037_create_shopex_item_table.php b/database/migrations/2025_09_19_102037_create_shopex_item_table.php new file mode 100644 index 0000000..e971ebb --- /dev/null +++ b/database/migrations/2025_09_19_102037_create_shopex_item_table.php @@ -0,0 +1,65 @@ +unsignedInteger('shop_vnum'); + $table->unsignedInteger('item_vnum'); + + $table->unsignedTinyInteger('count')->default(1); + $table->unsignedInteger('price')->default(0); + $table->unsignedInteger('price_vnum')->default(0); + $table->enum('price_type', ['GOLD', 'SECONDCOIN', 'ITEM', 'EXP'])->default('GOLD'); + + $table->unsignedInteger('socket0')->default(0); + $table->unsignedInteger('socket1')->default(0); + $table->unsignedInteger('socket2')->default(0); + $table->unsignedInteger('socket3')->default(0); + $table->unsignedInteger('socket4')->default(0); + + $table->tinyInteger('attrtype0')->default(0); + $table->smallInteger('attrvalue0')->default(0); + $table->tinyInteger('attrtype1')->default(0); + $table->smallInteger('attrvalue1')->default(0); + $table->tinyInteger('attrtype2')->default(0); + $table->smallInteger('attrvalue2')->default(0); + $table->tinyInteger('attrtype3')->default(0); + $table->smallInteger('attrvalue3')->default(0); + $table->tinyInteger('attrtype4')->default(0); + $table->smallInteger('attrvalue4')->default(0); + $table->tinyInteger('attrtype5')->default(0); + $table->smallInteger('attrvalue5')->default(0); + $table->tinyInteger('attrtype6')->default(0); + $table->smallInteger('attrvalue6')->default(0); + + $table->unique( + ['shop_vnum', 'item_vnum', 'count', 'price', 'price_vnum', 'price_type'], + 'vnum_unique' + ); + $table->foreign('shop_vnum')->references('vnum')->on('shopex')->cascadeOnDelete(); + }); + + // Populate the table data + $data = File::json(database_path('data/shopex_item.json')); + + ShopExItem::upsert($data, ['shop_vnum', 'item_vnum']); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('shopex_item'); + } +};