Merge branch 'master' of https://github.com/drkthunder02/w4rpservices
This commit is contained in:
@@ -114,31 +114,107 @@ class MoonsController extends Controller
|
||||
|
||||
public function displayTotalWorth(Request $request) {
|
||||
$firstOre = $request->firstOre;
|
||||
$firstQuantity = $request->firstQuantity;
|
||||
if($request->firstQuantity >= 1.00) {
|
||||
$firstQuantity = $request->firstQuantity / 100.00;
|
||||
} else {
|
||||
$firstQuantity = $request->firstQuantity;
|
||||
}
|
||||
|
||||
$secondOre = $request->secondOre;
|
||||
$secondQuantity = $request->secondQuantity;
|
||||
if($request->secondQuantity >= 1.00) {
|
||||
$secondQuantity = $request->secondQuantity / 100.00;
|
||||
} else {
|
||||
$secondQuantity = $request->secondQuantity;
|
||||
}
|
||||
|
||||
$thirdOre = $request->thirdOre;
|
||||
$thirdQuantity = $request->thirdQuantity;
|
||||
if($request->thirdQuantity >= 1.00) {
|
||||
$thirdQuantity = $request->thirdQuantity / 100.00;
|
||||
} else {
|
||||
$thirdQuantity = $request->thirdQuantity;
|
||||
}
|
||||
|
||||
$fourthOre = $request->fourthOre;
|
||||
$fourthQuantity = $request->fourthQuantity;
|
||||
if($request->fourthQuantity >= 1.00) {
|
||||
$fourthQuantity = $request->fourthQuantity / 100.00;
|
||||
} else {
|
||||
$fourthQuantity = $request->fourthQuantity;
|
||||
}
|
||||
|
||||
if($request->reprocessing >= 1.00) {
|
||||
$reprocessing = $request->reprocessing / 100.00;
|
||||
} else {
|
||||
$reprocessing = $request->reprocessing;
|
||||
}
|
||||
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
$composition = array();
|
||||
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
||||
|
||||
//Calculate the total moon goo value
|
||||
$totalGoo = $moonCalc->SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
||||
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
||||
//Format the number to send to the blade
|
||||
$totalGoo = number_format($totalGoo, 2, ".", ",");
|
||||
|
||||
//Calculate the total worth of the moon
|
||||
$totalWorth = $moonCalc->SpatialMoonsTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
||||
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
||||
//Format the number to send to the blade.
|
||||
$totalWorth = number_format($totalWorth, 2, ".", ",");
|
||||
|
||||
$firstComp = $moonCalc->GetOreComposition($firstOre);
|
||||
$secondComp = $moonCalc->GetOreComposition($secondOre);
|
||||
$thirdComp = $moonCalc->GetOreComposition($thirdOre);
|
||||
$fourthComp = $moonCalc->GetOreComposition($fourthOre);
|
||||
//Get the composition for the first ore if it is not None.
|
||||
//Add the first ore composition to the final composition
|
||||
if($firstOre != 'None') {
|
||||
$firstComp = $moonCalc->GetOreComposition($firstOre);
|
||||
$rUnits = $moonCalc->CalcReprocessingUnits($firstOre, $firstQuantity);
|
||||
|
||||
$composition['Tritanium'] = $firstComp['Tritanium'] + $secondComp['Tritanium'] + $thirdComp['Tritanium'] + $fourthComp['Tritanium'];
|
||||
foreach($firstComp as $key => $value) {
|
||||
$composition[$key] += floor(($firstComp[$key] * $rUnits) * $reprocessing);
|
||||
}
|
||||
}
|
||||
|
||||
//Get the composition for the second ore if it is not None.
|
||||
//Add the second ore composition to the final composition
|
||||
if($secondOre != 'None') {
|
||||
$secondComp = $moonCalc->GetOreComposition($secondOre);
|
||||
$rUnits = $moonCalc->CalcReprocessingUnits($secondOre, $secondQuantity);
|
||||
|
||||
foreach($secondComp as $key => $value) {
|
||||
$composition[$key] += floor(($secondComp[$key] * $rUnits) * $reprocessing);
|
||||
}
|
||||
}
|
||||
|
||||
//Get the composition for the third ore if it is not None
|
||||
//Add the third ore composition to the final composition
|
||||
if($thirdOre != 'None') {
|
||||
$thirdComp = $moonCalc->GetOreComposition($thirdOre);
|
||||
$rUnits = $moonCalc->CalcReprocessingUnits($thirdOre, $thirdQuantity);
|
||||
|
||||
foreach($thirdComp as $key => $value) {
|
||||
$composition[$key] += floor(($thirdComp[$key] * $rUnits) * $reprocessing);
|
||||
}
|
||||
}
|
||||
|
||||
//Get the composition for the fourth ore if it is not None
|
||||
//Add the fourth ore composition to the final composition
|
||||
if($fourthOre != 'None') {
|
||||
$fourthComp = $moonCalc->GetOreComposition($fourthOre);
|
||||
$rUnits = $moonCalc->CalcReprocessingUnits($fourthOre, $fourthQuantity);
|
||||
|
||||
foreach($fourthComp as $key => $value) {
|
||||
$composition[$key] += floor(($fourthComp[$key] * $rUnits) * $reprocessing);
|
||||
}
|
||||
}
|
||||
|
||||
//Remove any items which don't equal a number above 0 in the composition in order to remove them from the total.
|
||||
//The less we display on the table the better.
|
||||
foreach($composition as $key => $value) {
|
||||
if($composition[$key] === 0) {
|
||||
unset($composition[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return view('moons.user.displayTotalWorth')->with('totalWorth', $totalWorth)
|
||||
|
||||
@@ -527,6 +527,42 @@ 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($percentage / $m3Size);
|
||||
//Calculate the units from the m3 pulled from the moon
|
||||
$units = floor($actualm3 / $m3Size);
|
||||
|
||||
return $units;
|
||||
}
|
||||
|
||||
public function CalcReprocessingUnits($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($percentage / $m3Size);
|
||||
//Calculate the units from the m3 pulled from the moon
|
||||
$units = floor($actualm3 / $m3Size);
|
||||
//Calculate the number of times the ore is reprocessed from the actual units
|
||||
$rUnits = floor($units / 100.00);
|
||||
|
||||
return $rUnits;
|
||||
}
|
||||
|
||||
private function CalcPrice($ore, $percentage) {
|
||||
//Specify the total pull amount
|
||||
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
||||
|
||||
Reference in New Issue
Block a user