laid out framework for updating moon rental price, and moved some functions around in the moon calculation library
This commit is contained in:
71
app/Jobs/Commands/Moons/UpdateMoonRentalPrice.php
Normal file
71
app/Jobs/Commands/Moons/UpdateMoonRentalPrice.php
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\Moons;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use DB;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use App\Library\Moons\MoonCalc;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||||
|
|
||||||
|
class UpdateMoonRentalPrice implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3200;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $retries = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//Set the connection for the job
|
||||||
|
$this->connection = 'redis';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare the helper for moon calculations
|
||||||
|
$moonHelper = new MoonCalc;
|
||||||
|
//Get all the moons from the rental database
|
||||||
|
$moons = AllianceRentalMoon::all();
|
||||||
|
//Get the configuration from the database for the pricing calculate of rental moons
|
||||||
|
$config = DB::table('Config')->get();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the worth of each moon along with the rental prices.
|
||||||
|
*/
|
||||||
|
foreach($moons as $rental) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -153,6 +153,28 @@ class MoonCalc {
|
|||||||
$this->UpdateItemPricing();
|
$this->UpdateItemPricing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function CalcOreUnits($ore, $percentage) {
|
||||||
|
//Specify the total pull amount
|
||||||
|
$totalPull = 5.55 * (3600.00 * 24.00 *30.00);
|
||||||
|
|
||||||
|
//Find the size of the asteroid from the database
|
||||||
|
$item = ItemComposition::where([
|
||||||
|
'Name' => $ore,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
//Get the m3 size from the item composition
|
||||||
|
$m3Size = $item->m3Size;
|
||||||
|
|
||||||
|
//Calculate the actual m3 from the total pull amount in m3 using the percentage of the ingredient
|
||||||
|
$actualm3 = floor($totalPull * $percentage);
|
||||||
|
|
||||||
|
//Calculate the units from the m3 pulled from the moon
|
||||||
|
$units = floor($actualm3 / $m3Size);
|
||||||
|
|
||||||
|
//Return the calculated data
|
||||||
|
return $units;
|
||||||
|
}
|
||||||
|
|
||||||
private function UpdateItemPricing() {
|
private function UpdateItemPricing() {
|
||||||
//Get the configuration from the config table
|
//Get the configuration from the config table
|
||||||
$config = DB::table('Config')->first();
|
$config = DB::table('Config')->first();
|
||||||
@@ -280,28 +302,6 @@ class MoonCalc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CalcOreUnits($ore, $percentage) {
|
|
||||||
//Specify the total pull amount
|
|
||||||
$totalPull = 5.55 * (3600.00 * 24.00 *30.00);
|
|
||||||
|
|
||||||
//Find the size of the asteroid from the database
|
|
||||||
$item = ItemComposition::where([
|
|
||||||
'Name' => $ore,
|
|
||||||
])->first();
|
|
||||||
|
|
||||||
//Get the m3 size from the item composition
|
|
||||||
$m3Size = $item->m3Size;
|
|
||||||
|
|
||||||
//Calculate the actual m3 from the total pull amount in m3 using the percentage of the ingredient
|
|
||||||
$actualm3 = floor($totalPull * $percentage);
|
|
||||||
|
|
||||||
//Calculate the units from the m3 pulled from the moon
|
|
||||||
$units = floor($actualm3 / $m3Size);
|
|
||||||
|
|
||||||
//Return the calculated data
|
|
||||||
return $units;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function CalculateTotalMoonPull() {
|
private function CalculateTotalMoonPull() {
|
||||||
//Always assume a 1 month pull which equates to 5.55m3 per second or 2,592,000 seconds
|
//Always assume a 1 month pull which equates to 5.55m3 per second or 2,592,000 seconds
|
||||||
//Total pull size is 14,385,600 m3
|
//Total pull size is 14,385,600 m3
|
||||||
|
|||||||
Reference in New Issue
Block a user