-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/corowne/lorekeeper into …
…feature/trades
- Loading branch information
Showing
122 changed files
with
4,753 additions
and
529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Limit\Limit; | ||
use DB; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class ConvertShopLimits extends Command { | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'convert-shop-limits'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Converts existing shop limits to the new system.'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() { | ||
if (!Schema::hasTable('shop_limits')) { | ||
$this->info('No shop limits to convert.'); | ||
|
||
return; | ||
} | ||
|
||
$shopLimits = DB::table('shop_limits')->get(); | ||
$bar = $this->output->createProgressBar(count($shopLimits)); | ||
$bar->start(); | ||
foreach ($shopLimits as $shopLimit) { | ||
Limit::create([ | ||
'object_model' => 'App\Models\Shop\Shop', | ||
'object_id' => $shopLimit->shop_id, | ||
'limit_type' => 'item', | ||
'limit_id' => $shopLimit->item_id, | ||
'quantity' => 1, | ||
]); | ||
|
||
$bar->advance(); | ||
} | ||
$bar->finish(); | ||
|
||
// drop the is_restricted column from the shops table | ||
Schema::table('shops', function ($table) { | ||
$table->dropColumn('is_restricted'); | ||
}); | ||
|
||
Schema::dropIfExists('shop_limits'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Loot\Loot; | ||
use Illuminate\Console\Command; | ||
|
||
class FixEqualsCriteriaLoots extends Command { | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'fix-equals-criteria-loots'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Fix equals criteria loots to double equals for use in where clause'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() { | ||
// | ||
$loots = Loot::whereNotNull('data')->get(); | ||
|
||
foreach ($loots as $loot) { | ||
$data = $loot->data; | ||
|
||
if (isset($data['criteria']) && $data['criteria'] == '=') { | ||
$data['criteria'] = '=='; | ||
|
||
Loot::where([ | ||
['loot_table_id', '=', $loot->loot_table_id], | ||
['rewardable_type', '=', $loot->rewardable_type], | ||
['rewardable_id', '=', $loot->rewardable_id], | ||
])->update(['data' => $data]); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Shop\ShopStock; | ||
use Carbon\Carbon; | ||
use Illuminate\Console\Command; | ||
|
||
class RestockShops extends Command { | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'restock-shops'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Restocks shops.'; | ||
|
||
/** | ||
* Create a new command instance. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() { | ||
$stocks = ShopStock::where('is_limited_stock', 1)->where('restock', 1)->get(); | ||
foreach ($stocks as $stock) { | ||
if ($stock->restock_interval == 2) { | ||
// check if it's start of week | ||
$now = Carbon::now(); | ||
$day = $now->dayOfWeek; | ||
if ($day != 1) { | ||
continue; | ||
} | ||
} elseif ($stock->restock_interval == 3) { | ||
// check if it's start of month | ||
$now = Carbon::now(); | ||
$day = $now->day; | ||
if ($day != 1) { | ||
continue; | ||
} | ||
} | ||
|
||
// if the stock is random, restock from the stock type | ||
if ($stock->isRandom) { | ||
$type = $stock->stock_type; | ||
$model = getAssetModelString(strtolower($type)); | ||
if (method_exists($model, 'visible')) { | ||
$itemId = $stock->categoryId ? | ||
$model::visible()->where(strtolower($type).'_category_id', $stock->categoryId)->inRandomOrder()->first()->id : | ||
$model::visible()->inRandomOrder()->first()->id; | ||
} elseif (method_exists($model, 'released')) { | ||
$itemId = $stock->categoryId ? | ||
$model::released()->where(strtolower($type).'_category_id', $stock->categoryId)->inRandomOrder()->first()->id : | ||
$model::released()->inRandomOrder()->first()->id; | ||
} else { | ||
$itemId = $stock->categoryId ? | ||
$model::where(strtolower($type).'_category_id', $stock->categoryId)->inRandomOrder()->first()->id : | ||
$model::inRandomOrder()->first()->id; | ||
} | ||
|
||
$stock->item_id = $itemId; | ||
$stock->save(); | ||
} | ||
|
||
$stock->quantity = $stock->range ? mt_rand(1, $stock->restock_quantity) : $stock->restock_quantity; | ||
$stock->save(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Shop\Shop; | ||
use App\Models\Shop\ShopStock; | ||
use Illuminate\Console\Command; | ||
|
||
class UpdateTimedStock extends Command { | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'update-timed-stock'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Hides timed stock or shops when expired, or sets it active if ready.'; | ||
|
||
/** | ||
* Create a new command instance. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() { | ||
$hidestock = ShopStock::where('is_timed_stock', 1)->where('is_visible', 1)->get()->filter(function ($stock) { | ||
return !$stock->isActive; | ||
}); | ||
$showstock = ShopStock::where('is_timed_stock', 1)->where('is_visible', 0)->get()->filter(function ($stock) { | ||
return $stock->isActive; | ||
}); | ||
|
||
// set stock that should be active to active | ||
foreach ($showstock as $showstock) { | ||
$showstock->is_visible = 1; | ||
$showstock->save(); | ||
} | ||
// hide stock that should be hidden now | ||
foreach ($hidestock as $hidestock) { | ||
$hidestock->is_visible = 0; | ||
$hidestock->save(); | ||
} | ||
|
||
// also activate or deactivate the shops | ||
$hideshop = Shop::where('is_timed_shop', 1)->where('is_active', 1)->get()->filter(function ($shop) { | ||
return !$shop->isActive; | ||
}); | ||
$showshop = Shop::where('is_timed_shop', 1)->where('is_active', 0)->get()->filter(function ($shop) { | ||
return $shop->isActive; | ||
}); | ||
|
||
// set shop that should be active to active | ||
foreach ($showshop as $showshop) { | ||
$showshop->is_active = 1; | ||
$showshop->save(); | ||
} | ||
// hide shop that should be hidden now | ||
foreach ($hideshop as $hideshop) { | ||
$hideshop->is_active = 0; | ||
$hideshop->save(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.