cleaned up some functions in the MoonCalc Library.
This commit is contained in:
@@ -186,8 +186,8 @@ class MoonMailerCommand extends Command
|
||||
//If today is greater than the rental end, then calculate the moon cost
|
||||
if($today->greaterThanOrEqualTo($end)) {
|
||||
//Get the updated price for the moon
|
||||
$price = $moonCalc->SpatialMoonsOnlyGooMailer($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
$price = $moonCalc->SpatialMoons($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
//Check the type and figure out which price to add in
|
||||
if($rental->Type == 'alliance') {
|
||||
|
||||
@@ -230,8 +230,8 @@ class MoonsAdminController extends Controller
|
||||
$color = 'table-danger';
|
||||
}
|
||||
|
||||
//Calculate hte price of the moon based on what is in the moon
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity, $moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
//Calculate the price of the moon based on what is in the moon
|
||||
$price = $moonCalc->SpatialMoons($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity, $moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
//Add the data to the html string to be passed to the view
|
||||
array_push($table, [
|
||||
@@ -409,8 +409,8 @@ class MoonsAdminController extends Controller
|
||||
])->first();
|
||||
|
||||
//Calculate the price of the rental and store it in the database
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
$price = $moonCalc->SpatialMoons($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
//Count how many rentals we find for later database processing
|
||||
$count = MoonRental::where([
|
||||
|
||||
@@ -254,8 +254,8 @@ class MoonsController extends Controller
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
}
|
||||
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
$price = $moonCalc->SpatialMoons($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
$worth = $moonCalc->SpatialMoonsTotalWorth($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
@@ -52,7 +52,7 @@ class MiningLedgerHelper {
|
||||
//Check if the character has the correct ESI Scope. If the character doesn't, then return false, but
|
||||
//also send a notice eve mail to the user. The HaveEsiScope sends a mail for us.
|
||||
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1')) {
|
||||
|
||||
Log::warning('Character: ' . $this->charId . ' did not have the appropriate esi scope for the mining ledger.');
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,10 @@ class MoonCalc {
|
||||
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||
|
||||
//Calculate the prices from the ores
|
||||
$this->CalculateTotalPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||
$this->CalculateTotalPrice($firstOre, $firstPerc, $firstTotal);
|
||||
$this->CalculateTotalPrice($secondOre, $secondPerc, $secondTotal);
|
||||
$this->CalculateTotalPrice($thirdOre, $thirdPerc, $thirdTotal);
|
||||
$this->CalculateTotalPrice($fourthOre, $fourthPerc, $fourthTotal);
|
||||
|
||||
//Calculate the total to price to be mined in one month
|
||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||
@@ -51,78 +54,6 @@ class MoonCalc {
|
||||
return $totalPriceMined;
|
||||
}
|
||||
|
||||
public function SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
||||
//Get the total moon pull in m3
|
||||
$totalPull = $this->CalculateTotalMoonPull();
|
||||
|
||||
//Get the configuration for pricing calculations
|
||||
$config = DB::table('Config')->get();
|
||||
|
||||
//Convert the quantities into numbers we want to utilize
|
||||
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||
|
||||
//Calculate the price of each ore
|
||||
$this->CalculateOnlyGooPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||
|
||||
//Calculate the total to price to be mined in one month
|
||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||
|
||||
//Return the rental price to the caller
|
||||
return $totalPriceMined;
|
||||
}
|
||||
|
||||
public function SpatialMoonsOnlyGooMailer($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
||||
//Get the total moon pull in m3
|
||||
$totalPull = $this->CalculateTotalMoonPull();
|
||||
|
||||
//Get the configuration for pricing calculations
|
||||
$config = DB::table('Config')->get();
|
||||
|
||||
//Convert the quantities into numbers we want to utilize
|
||||
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||
|
||||
//Calculate the price of each ore
|
||||
$this->CalculateOnlyGooPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||
|
||||
//Calculate the total to price to be mined in one month
|
||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||
|
||||
//Calculate the rental price. Refined rate is already included in the price from rental composition
|
||||
$rentalPrice['alliance'] = $totalPriceMined * ($config[0]->RentalTax / 100.00);
|
||||
$rentalPrice['outofalliance'] = $totalPriceMined * ($config[0]->AllyRentalTax / 100.00);
|
||||
|
||||
//Return the rental price to the caller
|
||||
return $rentalPrice;
|
||||
}
|
||||
|
||||
public function SpatialMoonsOnlyGoo($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
||||
//Get the total moon pull in m3
|
||||
$totalPull = $this->CalculateTotalMoonPull();
|
||||
|
||||
//Get the configuration for pricing calculations
|
||||
$config = DB::table('Config')->get();
|
||||
|
||||
//Convert the quantities into numbers we want to utilize
|
||||
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||
|
||||
//Calculate the price of each ore
|
||||
$this->CalculateOnlyGooPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||
|
||||
//Calculate the total to price to be mined in one month
|
||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||
|
||||
//Calculate the rental price. Refined rate is already included in the price from rental composition
|
||||
$rentalPrice['alliance'] = $totalPriceMined * ($config[0]->RentalTax / 100.00);
|
||||
$rentalPrice['outofalliance'] = $totalPriceMined * ($config[0]->AllyRentalTax / 100.00);
|
||||
|
||||
//Format the rental price to the appropriate number
|
||||
$rentalPrice['alliance'] = number_format($rentalPrice['alliance'], 0, ".", ",");
|
||||
$rentalPrice['outofalliance'] = number_format($rentalPrice['outofalliance'], 0, ".", ",");
|
||||
|
||||
//Return the rental price to the caller
|
||||
return $rentalPrice;
|
||||
}
|
||||
|
||||
public function SpatialMoons($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
||||
//Get the total moon pull in m3
|
||||
$totalPull = $this->CalculateTotalMoonPull();
|
||||
@@ -134,7 +65,10 @@ class MoonCalc {
|
||||
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||
|
||||
//Calculate the prices from the ores
|
||||
$this->CalculateTotalPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||
$this->CalculateTotalPrice($firstOre, $firstPerc, $firstTotal);
|
||||
$this->CalculateTotalPrice($secondOre, $secondPerc, $secondTotal);
|
||||
$this->CalculateTotalPrice($thirdOre, $thirdPerc, $thirdTotal);
|
||||
$this->CalculateTotalPrice($fourthOre, $fourthPerc, $fourthTotal);
|
||||
|
||||
//Calculate the total to price to be mined in one month
|
||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||
@@ -142,10 +76,6 @@ class MoonCalc {
|
||||
//Calculate the rental price. Refined rate is already included in the price from rental composition
|
||||
$rentalPrice['alliance'] = $totalPriceMined * ($config[0]->RentalTax / 100.00);
|
||||
$rentalPrice['outofalliance'] = $totalPriceMined * ($config[0]->AllyRentalTax / 100.00);
|
||||
|
||||
//Format the rental price to the appropriate number
|
||||
$rentalPrice['alliance'] = number_format($rentalPrice['alliance'], 0, ".", ",");
|
||||
$rentalPrice['outofalliance'] = number_format($rentalPrice['outofalliance'], 0, ".", ",");
|
||||
|
||||
//Return the rental price to the caller
|
||||
return $rentalPrice;
|
||||
@@ -382,7 +312,7 @@ class MoonCalc {
|
||||
|
||||
private function CalcPrice($ore, $percentage) {
|
||||
//Specify the total pull amount
|
||||
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
||||
$totalPull = $this->CalculateTotalMoonPull();
|
||||
|
||||
//Find the size of the asteroid from the database
|
||||
$m3Size = DB::table('ItemComposition')->where('Name', $ore)->value('m3Size');
|
||||
@@ -540,67 +470,15 @@ class MoonCalc {
|
||||
}
|
||||
}
|
||||
|
||||
private function CalculateTotalPrices($firstOre, $firstPerc, &$firstTotal, $secondOre, $secondPerc, &$secondTotal, $thirdOre, $thirdPerc, &$thirdTotal, $fourthOre, $fourthPerc, &$fourthTotal) {
|
||||
/**
|
||||
* Calculate the total price, then pass it by reference to the calling function
|
||||
*/
|
||||
private function CalclulateTotalPrice($ore, $perc, &$total) {
|
||||
//Calculate the prices from the ores
|
||||
if($firstOre != "None") {
|
||||
$firstTotal = $this->CalcPrice($firstOre, $firstPerc);
|
||||
if($ore != 'None') {
|
||||
$total = $this->CalcPrice($ore, $perc);
|
||||
} else {
|
||||
$firstTotal = 0.00;
|
||||
}
|
||||
if($secondOre != "None") {
|
||||
$secondTotal = $this->CalcPrice($secondOre, $secondPerc);
|
||||
} else {
|
||||
$secondTotal = 0.00;
|
||||
}
|
||||
if($thirdOre != "None") {
|
||||
$thirdTotal = $this->CalcPrice($thirdOre, $thirdPerc);
|
||||
} else {
|
||||
$thirdTotal = 0.00;
|
||||
}
|
||||
if($fourthOre != "None") {
|
||||
$fourthTotal = $this->CalcPrice($fourthOre, $fourthPerc);
|
||||
} else {
|
||||
$fourthTotal = 0.00;
|
||||
}
|
||||
}
|
||||
|
||||
private function CalculateOnlyGooPrices($firstOre, $firstPerc, &$firstTotal, $secondOre, $secondPerc, &$secondTotal, $thirdOre, $thirdPerc, &$thirdTotal, $fourthOre, $fourthPerc, &$fourthTotal) {
|
||||
//Calculate the price of each ore
|
||||
if($firstOre != "None") {
|
||||
if($this->IsRMoonGoo($firstOre)) {
|
||||
$firstTotal = $this->CalcPrice($firstOre, $firstPerc);
|
||||
} else {
|
||||
$firstTotal = 0.00;
|
||||
}
|
||||
} else {
|
||||
$firstTotal = 0.00;
|
||||
}
|
||||
if($secondOre != "None") {
|
||||
if($this->IsRMoonGoo($secondOre)) {
|
||||
$secondTotal = $this->CalcPrice($secondOre, $secondPerc);
|
||||
} else {
|
||||
$secondTotal = 0.00;
|
||||
}
|
||||
} else {
|
||||
$secondTotal = 0.00;
|
||||
}
|
||||
if($thirdOre != "None") {
|
||||
if($this->IsRMoonGoo($thirdOre)) {
|
||||
$thirdTotal = $this->CalcPrice($thirdOre, $thirdPerc);
|
||||
} else {
|
||||
$thirdTotal = 0.00;
|
||||
}
|
||||
} else {
|
||||
$thirdTotal = 0.00;
|
||||
}
|
||||
if($fourthOre != "None") {
|
||||
if($this->IsRMoonGoo($fourthOre)) {
|
||||
$fourthTotal = $this->CalcPrice($fourthOre, $fourthPerc);
|
||||
} else {
|
||||
$fourthTotal = 0.00;
|
||||
}
|
||||
} else {
|
||||
$fourthTotal = 0.00;
|
||||
$total = 0.00;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,15 +133,11 @@ class WikiHelper {
|
||||
* Add a new user group
|
||||
*/
|
||||
public function AddNewUserGroup($groupName, $description) {
|
||||
//Check if the user group already exists
|
||||
$count = DokuGroupNames::where(['gname' => $groupName])->count();
|
||||
|
||||
if($count == 0) {
|
||||
DokuGroupNames::insert([
|
||||
'gname' => $groupName,
|
||||
'description' => $description,
|
||||
]);
|
||||
}
|
||||
//Insert or ignore the group if it's already there.
|
||||
DokuGroupNames::insertOrIgnore([
|
||||
'gname' => $groupName,
|
||||
'description' => $description,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user