Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/corowne/lorekeeper into …
Browse files Browse the repository at this point in the history
…extension/claymores-and-companions

# Conflicts:
#	app/Console/Commands/AddSiteSettings.php
#	app/Helpers/Helpers.php
#	app/Http/Controllers/Admin/Characters/CharacterController.php
#	app/Http/Controllers/Admin/Data/LootTableController.php
#	app/Http/Controllers/Admin/SubmissionController.php
#	app/Http/Controllers/Characters/CharacterController.php
#	app/Http/Controllers/ShopController.php
#	app/Http/Controllers/Users/SubmissionController.php
#	app/Http/Controllers/Users/UserController.php
#	app/Http/Kernel.php
#	app/Services/CharacterManager.php
#	app/Services/DesignUpdateManager.php
#	app/Services/SubmissionManager.php
#	app/Services/UserService.php
#	composer.lock
#	package-lock.json
#	public/css/lorekeeper.css
#	resources/views/admin/reports/report.blade.php
#	resources/views/admin/users/_create_edit_rank.blade.php
#	resources/views/character/_image_info.blade.php
#	resources/views/home/create_submission.blade.php
#	resources/views/shops/_stock_modal.blade.php
#	resources/views/shops/shop.blade.php
#	resources/views/widgets/_loot_select.blade.php
#	resources/views/widgets/_loot_select_row.blade.php
#	resources/views/world/species_features.blade.php
#	routes/lorekeeper/admin.php
#	routes/lorekeeper/browse.php
#	yarn.lock
  • Loading branch information
ScuffedNewt committed Dec 18, 2024
2 parents 724c48c + 01c3f7a commit 945d37f
Show file tree
Hide file tree
Showing 344 changed files with 31,637 additions and 2,282 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Lint & Build Mix Assets

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
types:
- opened
- edited
- synchronize
- reopened

jobs:
lint:
uses: itinerare/github-actions/.github/workflows/lint.yml@main
with:
php-version: '8.1'
concurrency:
group: ci-${{ github.head_ref || github.ref_name }}

rebuild-mix-assets:
uses: itinerare/github-actions/.github/workflows/mix_build.yml@main
concurrency:
group: ci-${{ github.head_ref }}
24 changes: 0 additions & 24 deletions .github/workflows/Lint.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ yarn-error.log
*.env
/composer.phar
*.cache
/.vs
4 changes: 2 additions & 2 deletions app/Console/Commands/AddImageHashes.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function handle() {
(new FeatureService)->handleImage(
null,
public_path($image->imageDirectory),
$image->hash.$image->id.'-image.png',
$image->id.'-'.$image->hash.'-image.png',
$oldName
)
) {
Expand All @@ -87,7 +87,7 @@ public function handle() {
(new FeatureService)->handleImage(
null,
public_path($image->imageDirectory),
$image->hash.$image->id.'-icon.png',
$image->id.'-'.$image->hash.'-icon.png',
$oldName
)
) {
Expand Down
4 changes: 4 additions & 0 deletions app/Console/Commands/AddSiteSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ public function handle() {
$this->addSiteSetting('coupon_settings', 0, '0: Percentage is taken from total (e.g 20% from 2 items costing a total of 100 = 80), 1: Percentage is taken from item (e.g 20% from 2 items costing a total of 100 = 90)');

$this->addSiteSetting('limited_stock_coupon_settings', 0, '0: Does not allow coupons to be used on limited stock items, 1: Allows coupons to be used on limited stock items');

$this->addSiteSetting('can_transfer_currency_directly', 1, 'Whether or not users can directly transfer currency to other users without trading. 0: Users cannot directly transfer currency. 1: Direct currency transfers are allowed.');

$this->addSiteSetting('can_transfer_items_directly', 1, 'Whether or not users can directly transfer items to other users without trading. 0: Users cannot directly transfer items. 1: Direct item transfers are allowed.');

$this->line("\nSite settings up to date!");
}
Expand Down
159 changes: 159 additions & 0 deletions app/Console/Commands/ConvertCharacterSubtype.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<?php

namespace App\Console\Commands;

use App\Models\Character\CharacterDesignUpdate;
use App\Models\Character\CharacterImage;
use App\Models\Character\CharacterImageSubtype;
use Illuminate\Console\Command;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class ConvertCharacterSubtype extends Command {
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'convert-character-subtype';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Converts the subtype_id columns in the character_images table to a new row in character_image_subtype table.';

/**
* Create a new command instance.
*/
public function __construct() {
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle() {
if (Schema::hasColumn('character_images', 'subtype_id')) {
// Check for second subtype columns up front to save on some redundant checks
$secondSubtype = false;
$thirdSubtype = false;
if (Schema::hasColumn('character_images', 'subtype_id_2') && Schema::hasColumn('design_updates', 'subtype_id_2')) {
$secondSubtype = true;
if (Schema::hasColumn('character_images', 'subtype_id_3') && Schema::hasColumn('design_updates', 'subtype_id_3')) {
$thirdSubtype = true;
}
}

// DESIGN UPDATES
$updates = CharacterDesignUpdate::where(function ($query) use ($secondSubtype, $thirdSubtype) {
if ($thirdSubtype) {
$query->whereNotNull('subtype_id')->orWhereNotNull('subtype_id_2')->orWhereNotNull('subtype_id_3');
} elseif ($secondSubtype) {
$query->whereNotNull('subtype_id')->orWhereNotNull('subtype_id_2');
} else {
$query->whereNotNull('subtype_id');
}
})->get();

$this->info('Converting '.count($updates).' updates\' subtypes...');
$updateBar = $this->output->createProgressBar(count($updates));

foreach ($updates as $update) {
$updateSubtypes = [];
if ($update->subtype_id) {
$updateSubtypes[] = $update->subtype_id;
}
if ($secondSubtype && $update->subtype_id_2) {
$updateSubtypes[] = $update->subtype_id_2;
}
if ($thirdSubtype && $update->subtype_id_3) {
$updateSubtypes[] = $update->subtype_id_3;
}

$update->update([
'subtype_ids' => $updateSubtypes,
]);
$updateBar->advance();
}

$updateBar->finish();
$this->info("\n".'Dropping subtype ID column'.($secondSubtype ? 's' : '').' from the design updates table...');

Schema::table('design_updates', function (Blueprint $table) {
$table->dropColumn('subtype_id');
});
if ($secondSubtype) {
Schema::table('design_updates', function (Blueprint $table) {
$table->dropColumn('subtype_id_2');
});
}
if ($thirdSubtype) {
Schema::table('design_updates', function (Blueprint $table) {
$table->dropColumn('subtype_id_3');
});
}

// CHARACTER IMAGES
$characterImages = CharacterImage::where(function ($query) use ($secondSubtype, $thirdSubtype) {
if ($thirdSubtype) {
$query->whereNotNull('subtype_id')->orWhereNotNull('subtype_id_2')->orWhereNotNull('subtype_id_3');
} elseif ($secondSubtype) {
$query->whereNotNull('subtype_id')->orWhereNotNull('subtype_id_2');
} else {
$query->whereNotNull('subtype_id');
}
})->get();

$this->info('Converting '.count($characterImages).' character images\' subtypes...');
$imageBar = $this->output->createProgressBar(count($characterImages));
foreach ($characterImages as $characterImage) {
if ($characterImage->subtype_id) {
CharacterImageSubtype::create([
'character_image_id' => $characterImage->id,
'subtype_id' => $characterImage->subtype_id,
]);
}

if ($secondSubtype && $characterImage->subtype_id_2) {
CharacterImageSubtype::create([
'character_image_id' => $characterImage->id,
'subtype_id' => $characterImage->subtype_id_2,
]);
}

if ($thirdSubtype && $characterImage->subtype_id_3) {
CharacterImageSubtype::create([
'character_image_id' => $characterImage->id,
'subtype_id' => $characterImage->subtype_id_3,
]);
}
$imageBar->advance();
}

$imageBar->finish();
$this->info("\n".'Dropping subtype ID column'.($secondSubtype ? 's' : '').' from the character images table...');

Schema::table('character_images', function (Blueprint $table) {
$table->dropColumn('subtype_id');
});
if ($secondSubtype) {
Schema::table('character_images', function (Blueprint $table) {
$table->dropColumn('subtype_id_2');
});
}
if ($thirdSubtype) {
Schema::table('character_images', function (Blueprint $table) {
$table->dropColumn('subtype_id_3');
});
}

$this->info('Done!');
} else {
$this->info('This command will not execute, as it has already been run.');
}
}
}
94 changes: 94 additions & 0 deletions app/Console/Commands/ConvertItemRarities.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace App\Console\Commands;

use App\Models\Item\Item;
use App\Models\Rarity;
use Illuminate\Console\Command;

class ConvertItemRarities extends Command {
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'convert-item-rarities';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Converts previously arbitrary item rarities (numeric format) to utilise existing rarity model';

/**
* Execute the console command.
*/
public function handle() {
//
if (!config('lorekeeper.extensions.item_entry_expansion.extra_fields')) {
$this->info('Item Entry Expansion is not enabled. Exiting.');

return;
}
$rarityItems = Item::whereNotNull('data->rarity')->get();
// pluck the rarity values from the items
$rarityValues = $rarityItems->pluck('data.rarity')->unique();
foreach ($rarityValues as $rarityValue) {
$this->info("\nCreating rarity for value: ".$rarityValue.'...');
$nearestRarity = Rarity::where('sort', $rarityValue)->first();
if (!$nearestRarity) {
$nearestRarity = Rarity::where('sort', $rarityValue - 1)->first();
}

if ($nearestRarity) {
$this->info('Closest rarity (based on sort) found: '.$nearestRarity->name);
$this->info('If this rarity is not correct, please enter "n" and choose the correct rarity.');
$ask = $this->ask('Do you want to use this rarity for the value '.$rarityValue.'? (y/n)', 'y');
if ($ask === 'y') {
$rarityItems->where('data.rarity', $rarityValue)->each(function ($item) use ($nearestRarity) {
$item->data = array_merge($item->data, ['rarity_id' => $nearestRarity->id]);
$item->save();
});
$this->info('Items with rarity value '.$rarityValue.' have been updated to use rarity '.$nearestRarity->name);
} else {
$rarityName = $this->ask('Enter the name of the rarity you want to use for the value '.$rarityValue);
$rarity = Rarity::where('name', 'LIKE', '%'.$rarityName.'%')->first();
if ($rarity) {
$check = $this->ask('Do you want to use the rarity '.$rarity->name.' for the value '.$rarityValue.'? (y/n)', 'y');
if ($check === 'y') {
$rarityItems->where('data.rarity', $rarityValue)->each(function ($item) use ($rarity) {
$item->data = array_merge($item->data, ['rarity_id' => $rarity->id]);
$item->save();
});
$this->info('Items with rarity value '.$rarityValue.' have been updated to use rarity '.$rarity->name);
} else {
$this->info('No changes made for rarity value '.$rarityValue.'.');
}
} else {
$this->info('No matching rarity found for name '.$rarityName.'.');
}
}
} else {
$this->info('No matching rarity found for value '.$rarityValue.'.');
$rarityName = $this->ask('Enter the name of the rarity you want to use for the value '.$rarityValue.':');
$rarity = Rarity::whereRaw('LOWER(name) LIKE ?', ['%'.strtolower($rarityName).'%'])->first();
if ($rarity) {
$check = $this->ask('Do you want to use the rarity '.$rarity->name.' for the value '.$rarityValue.'? (y/n)', 'y');
if ($check === 'y') {
$rarityItems->where('data.rarity', $rarityValue)->each(function ($item) use ($rarity) {
$item->data = array_merge($item->data, ['rarity_id' => $rarity->id]);
$item->save();
});
$this->info('Items with rarity value '.$rarityValue.' have been updated to use rarity '.$rarity->name);
} else {
$this->info('No changes made for rarity value '.$rarityValue.'.');
}
} else {
$this->info('No matching rarity found for name '.$rarityName.'.');
$this->info('Feel free to re-run the command to try again.');
}
}
}
}
}
Loading

0 comments on commit 945d37f

Please sign in to comment.