Skip to content

Commit

Permalink
feat: Add Clothing creation script
Browse files Browse the repository at this point in the history
  • Loading branch information
octfx committed Apr 28, 2024
1 parent 241104f commit 8d1305f
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/Console/Commands/ScTools/CreateArmorVariantPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CreateArmorVariantPages extends AbstractToolsCommand
{{Navplate manufacturers|<MANUFACTURER CODE>}}
TEMPLATE;

private array $typeMapping = [
protected array $typeMapping = [
'Char_Armor_Arms' => 'Arms armor',
'Char_Armor_Torso' => 'Torso armor',
'Char_Armor_Legs' => 'Legs armor',
Expand Down Expand Up @@ -119,7 +119,7 @@ protected function prepareTemplate($armor): string
return $pageContent;
}

private function getSuffix(Armor $armor): ?string
protected function getSuffix($armor): ?string
{
return match (true) {
str_contains($armor->class_name, '_hd_sec') => ' Hurston Security',
Expand Down
93 changes: 93 additions & 0 deletions app/Console/Commands/ScTools/CreateClothingPages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

namespace App\Console\Commands\ScTools;

use App\Models\SC\Char\Clothing\Clothes;

class CreateClothingPages extends CreateArmorVariantPages
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sc-tools:create-clothing-pages {--base}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

protected string $template = <<<'TEMPLATE'
{{Item
|uuid = <UUID>
|image =
|name = <ITEM NAME>
|manufacturer = <MANUFACTURER CODE>
}}
The '''<ITEM NAME>''' is a <ARMOR CLASS> <ITEM TYPE> manufactured by [[{{subst:MFURN|<MANUFACTURER CODE>}}]].<VARIANTINFO><ref name="ig3221">{{Cite game|build=[[Star Citizen Alpha 3.22.1|Alpha 3.22.1]]|accessdate=<CURDATE>}}</ref>
== Description ==
{{Item description}}
== Acquisition ==
{{Item availability}}
== Model ==
=== Variants ===
{{Item variants}}
== References ==
<references />
{{Navplate manufacturers|<MANUFACTURER CODE>}}
TEMPLATE;

protected array $typeMapping = [
'Char_Clothing_Torso_1' => 'Jacket',
'Char_Clothing_Legs' => 'Pants',
'Char_Clothing_Torso_0' => 'Shirt',
'Char_Clothing_Feet' => 'Shoes',
'Char_Clothing_Hat' => 'Hat',
'Char_Clothing_Hands' => 'Gloves',
'Char_Clothing_Torso_2' => 'Belt',
'Char_Clothing_Backpack' => 'Backpack',
];

/**
* Execute the console command.
*/
public function handle()
{
$this->init();

$query = Clothes::query()
->where('name', '<>', '<= PLACEHOLDER =>')
->where('class_name', 'NOT LIKE', '%test%');

if ($this->option('base')) {
$this->baseQuery['createonly'] = true;
$query->whereNull('base_id');
} else {
$query->whereNotNull('base_id');

}
$this->withProgressBar($query->get(), function (Clothes $model) {
$this->createPage($model);
});
}

protected function prepareTemplate($armor): string
{
$template = parent::prepareTemplate($armor);

if (in_array($armor->type, ['Char_Clothing_Legs', 'Char_Clothing_Feet', 'Char_Clothing_Hands'], true)) {
$template = str_replace('is a', 'are', $template);
}

return $template;
}
}
2 changes: 2 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use App\Console\Commands\SC\Wiki\CreateWeaponWikiPages;
use App\Console\Commands\SC\Wiki\UploadItemImages;
use App\Console\Commands\ScTools\CreateArmorVariantPages;
use App\Console\Commands\ScTools\CreateClothingPages;
use App\Console\Commands\ScTools\CreateWeaponPersonalPages;
use App\Console\Commands\StarCitizen\Galactapedia\ImportArticleProperties;
use App\Console\Commands\StarCitizen\Galactapedia\ImportArticles;
Expand Down Expand Up @@ -134,6 +135,7 @@ class Kernel extends ConsoleKernel

CreateArmorVariantPages::class,
CreateWeaponPersonalPages::class,
CreateClothingPages::class,
];

private Schedule $schedule;
Expand Down

0 comments on commit 8d1305f

Please sign in to comment.