added routes for new views

added displayTotalWorth view display
added form response for displaying total worth
modified Moons Controller
modified Moon Calc class
This commit is contained in:
2018-11-07 16:47:26 -06:00
parent a201986ef7
commit 62af0bcd5d
5 changed files with 339 additions and 2 deletions

View File

@@ -74,7 +74,6 @@ class MoonsController extends Controller
'region' => 'required', 'region' => 'required',
'system' => 'required', 'system' => 'required',
'structure' => 'required', 'structure' => 'required',
]); ]);
// Add new moon // Add new moon
@@ -127,4 +126,36 @@ class MoonsController extends Controller
return redirect('/moons/display')->with('success', 'Moon Updated'); return redirect('/moons/display')->with('success', 'Moon Updated');
} }
public function displayTotalWorthForm() {
return view('moons.formTotalWorth');
}
public function displayTotalWorth(Request $request) {
$firstOre = $request->firstOre;
$firstQuantity = $request->firstQuantity;
$secondOre = $request->secondOre;
$secondQuantity = $request->secondQuantity;
$thirdOre = $request->thirdOre;
$thirdQuantity = $request->thirdQuantity;
$fourthOre = $request->fourthOre;
$fourthQuantity = $request->fourthQuantity;
//Setup calls to the MoonCalc class
$moonCalc = new MoonCalc();
//Update the prices for the moon
$moonCalc->FetchNewPrices();
$totalGoo = $moonCalc->SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuantity,
$secondOre, $secondQuantity,
$thirdOre, $thirdQuantity,
$fourthOre, $fourthQuantity);
$totalWorth = $moonCalc->SpatialMoonsTotalWorth($firstOre, $firstQuantity,
$secondOre, $secondQuantity,
$thirdOre, $thirdQuantity,
$fourthOre, $fourthQuantity);
return view('moons.displayTotalWorth')->with(['totalWorth' => $totalWorth, 'totalGoo' => $totalGoo]);
}
} }

View File

@@ -19,6 +19,128 @@ use App\Models\ItemComposition;
class MoonCalc { class MoonCalc {
public function SpatialMoonsTotalWorth($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
//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
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
//Get the configuration for pricing calculations
$config = DB::table('Config')->get();
if($firstQuan >= 1.00) {
$firstPerc = $this->ConvertToPercentage($firstQuan);
} else {
$firstPerc = $firstQuan;
}
if($secondQuan >= 1.00) {
$secondPerc = $this->ConvertToPercentage($secondQuan);
} else {
$secondPerc = $secondQuan;
}
if($thirdQuan >= 1.00) {
$thirdPerc = $this->ConvertToPercentage($thirdQuan);
} else {
$thirdPerc = $thirdQuan;
}
if($fourthQuan >= 1.00) {
$fourthPerc = $this->ConvertToPercentage($fourthQuan);
} else {
$fourthPerc = $fourthQuan;
}
if($firstOre != "None") {
$firstTotal = $this->CalcPrice($firstOre, $firstPerc);
} 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;
}
//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 SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
//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
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
//Get the configuration for pricing calculations
$config = DB::table('Config')->get();
if($firstQuan >= 1.00) {
$firstPerc = $this->ConvertToPercentage($firstQuan);
} else {
$firstPerc = $firstQuan;
}
if($secondQuan >= 1.00) {
$secondPerc = $this->ConvertToPercentage($secondQuan);
} else {
$secondPerc = $secondQuan;
}
if($thirdQuan >= 1.00) {
$thirdPerc = $this->ConvertToPercentage($thirdQuan);
} else {
$thirdPerc = $thirdQuan;
}
if($fourthQuan >= 1.00) {
$fourthPerc = $this->ConvertToPercentage($fourthQuan);
} else {
$fourthPerc = $fourthQuan;
}
if($firstOre != "None") {
if($this->IsRMoon($firstOre)) {
$firstTotal = $this->CalcPrice($firstOre, $firstPerc);
} else {
$firstTotal = 0.00;
}
} else {
$firstTotal = 0.00;
}
if($secondOre != "None") {
if($this->IsRMoon($secondOre)) {
$secondTotal = $this->CalcPrice($secondOre, $secondPerc);
} else {
$secondTotal = 0.00;
}
} else {
$secondTotal = 0.00;
}
if($thirdOre != "None") {
if($this->IsRMoon($thirdOre)) {
$thirdTotal = $this->CalcPrice($thirdOre, $thirdPerc);
} else {
$thirdTotal = 0.00;
}
} else {
$thirdTotal = 0.00;
}
if($fourthOre != "None") {
if($this->IsRMoon($fourthOre)) {
$fourthTotal = $this->CalcPrice($fourthOre, $fourthPerc);
} else {
$fourthTotal = 0.00;
}
} else {
$fourthTotal = 0.00;
}
//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 SpatialMoonsOnlyGoo($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) { public function SpatialMoonsOnlyGoo($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
//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

View File

@@ -0,0 +1,10 @@
@extends('layouts.b4')
@section('content')
<div class="container">
<h2>Total Worth of the Moon / Month</h2>
<div class="jumbotron">
Total Moon Goo + Ore Worth: <?php echo $totalWorth; ?> <br>
Total Moon Goo Worth: <?php echo $totalGoo; ?> <br>
</div>
</div>
@endsection

View File

@@ -0,0 +1,173 @@
@extends('layouts.b4')
@section('content')
<div class="container">
<h2>Total Worth Calculator</h2><br>
<h3>Enter the moon composition</h3><br>
{!! Form::open(['action' => 'MoonsController@displayTotalWorth', 'method' => 'POST']) !!}
<div class="form-group col-md-6">
{{ Form::label('firstOre', 'First Ore') }}
{{ Form::select('firstOre', [
'None' => 'None',
'Bitumens' => 'Bitumens',
'Brilliant Gneiss' => 'Brilliant Gneiss',
'Carnotite' => 'Carnotite',
'Chromite' => 'Chromite',
'Cinnabar' => 'Cinnabar',
'Cobaltite' => 'Cobaltite',
'Coesite' => 'Coesite',
'Cubic Bistot' => 'Cubic Bistot',
'Dazzling Spodumain' => 'Dazzling Spodumain',
'Euxenite' => 'Euxenite',
'Flawless Arkonor' => 'Flawless Arkonor',
'Glossy Scordite' => 'Glossy Scordite',
'Immaculate Jaspet' => 'Immaculate Jaspet',
'Jet Ochre' => 'Jet Ochre',
'Loparite' => 'Loparite',
'Lustrous Hedbergite' => 'Lustrous Hedbergite',
'Monazite' => 'Monazite',
'Opulent Pyroxeres' => 'Opulent Pyroxeres',
'Otavite' => 'Otavite',
'Pellucid Crokite' => 'Pellucid Crokite',
'Platinoid Omber' => 'Platinoid Omber',
'Pollucite' => 'Pollucite',
'Resplendant Kernite' => 'Resplendant Kernite',
'Scheelite' => 'Scheelite',
'Scintillating Hemorphite' => 'Scintillating Hemorphite',
'Sparkling Plagioclase' => 'Sparkling Plagioclase',
'Sperrylite' => 'Sperrylite',
'Stable Veldspar' => 'Stable Veldspar',
'Sylvite' => 'Sylvite',
'Titanite' => 'Titanite',
'Vanadinite' => 'Vanadinite',
'Xenotime' => 'Xenotime',
'Ytterbite' => 'Ytterbite',
'Zeolites' => 'Zeolites',
'Zircon' => 'Zircon',
], 'None') }}
{{ Form::text('firstQuantity', '', ['class' => 'form-control']) }}
{{ Form::label('secondOre', 'Second Ore') }}
{{ Form::select('secondOre', [
'None' => 'None',
'Bitumens' => 'Bitumens',
'Brilliant Gneiss' => 'Brilliant Gneiss',
'Carnotite' => 'Carnotite',
'Chromite' => 'Chromite',
'Cinnabar' => 'Cinnabar',
'Cobaltite' => 'Cobaltite',
'Coesite' => 'Coesite',
'Cubic Bistot' => 'Cubic Bistot',
'Dazzling Spodumain' => 'Dazzling Spodumain',
'Euxenite' => 'Euxenite',
'Flawless Arkonor' => 'Flawless Arkonor',
'Glossy Scordite' => 'Glossy Scordite',
'Immaculate Jaspet' => 'Immaculate Jaspet',
'Jet Ochre' => 'Jet Ochre',
'Loparite' => 'Loparite',
'Lustrous Hedbergite' => 'Lustrous Hedbergite',
'Monazite' => 'Monazite',
'Opulent Pyroxeres' => 'Opulent Pyroxeres',
'Otavite' => 'Otavite',
'Pellucid Crokite' => 'Pellucid Crokite',
'Platinoid Omber' => 'Platinoid Omber',
'Pollucite' => 'Pollucite',
'Resplendant Kernite' => 'Resplendant Kernite',
'Scheelite' => 'Scheelite',
'Scintillating Hemorphite' => 'Scintillating Hemorphite',
'Sparkling Plagioclase' => 'Sparkling Plagioclase',
'Sperrylite' => 'Sperrylite',
'Stable Veldspar' => 'Stable Veldspar',
'Sylvite' => 'Sylvite',
'Titanite' => 'Titanite',
'Vanadinite' => 'Vanadinite',
'Xenotime' => 'Xenotime',
'Ytterbite' => 'Ytterbite',
'Zeolites' => 'Zeolites',
'Zircon' => 'Zircon',
], 'None') }}
{{ Form::text('secondQuantity', '', ['class' => 'form-control']) }}
{{ Form::label('thirdOre', 'Third Ore') }}
{{ Form::select('thirdOre', [
'None' => 'None',
'Bitumens' => 'Bitumens',
'Brilliant Gneiss' => 'Brilliant Gneiss',
'Carnotite' => 'Carnotite',
'Chromite' => 'Chromite',
'Cinnabar' => 'Cinnabar',
'Cobaltite' => 'Cobaltite',
'Coesite' => 'Coesite',
'Cubic Bistot' => 'Cubic Bistot',
'Dazzling Spodumain' => 'Dazzling Spodumain',
'Euxenite' => 'Euxenite',
'Flawless Arkonor' => 'Flawless Arkonor',
'Glossy Scordite' => 'Glossy Scordite',
'Immaculate Jaspet' => 'Immaculate Jaspet',
'Jet Ochre' => 'Jet Ochre',
'Loparite' => 'Loparite',
'Lustrous Hedbergite' => 'Lustrous Hedbergite',
'Monazite' => 'Monazite',
'Opulent Pyroxeres' => 'Opulent Pyroxeres',
'Otavite' => 'Otavite',
'Pellucid Crokite' => 'Pellucid Crokite',
'Platinoid Omber' => 'Platinoid Omber',
'Pollucite' => 'Pollucite',
'Resplendant Kernite' => 'Resplendant Kernite',
'Scheelite' => 'Scheelite',
'Scintillating Hemorphite' => 'Scintillating Hemorphite',
'Sparkling Plagioclase' => 'Sparkling Plagioclase',
'Sperrylite' => 'Sperrylite',
'Stable Veldspar' => 'Stable Veldspar',
'Sylvite' => 'Sylvite',
'Titanite' => 'Titanite',
'Vanadinite' => 'Vanadinite',
'Xenotime' => 'Xenotime',
'Ytterbite' => 'Ytterbite',
'Zeolites' => 'Zeolites',
'Zircon' => 'Zircon',
], 'None') }}
{{ Form::text('thirdQuantity', '', ['class' => 'form-control']) }}
{{ Form::label('fourthOre', 'Fourth Ore') }}
{{ Form::select('fourthOre', [
'None' => 'None',
'Bitumens' => 'Bitumens',
'Brilliant Gneiss' => 'Brilliant Gneiss',
'Carnotite' => 'Carnotite',
'Chromite' => 'Chromite',
'Cinnabar' => 'Cinnabar',
'Cobaltite' => 'Cobaltite',
'Coesite' => 'Coesite',
'Cubic Bistot' => 'Cubic Bistot',
'Dazzling Spodumain' => 'Dazzling Spodumain',
'Euxenite' => 'Euxenite',
'Flawless Arkonor' => 'Flawless Arkonor',
'Glossy Scordite' => 'Glossy Scordite',
'Immaculate Jaspet' => 'Immaculate Jaspet',
'Jet Ochre' => 'Jet Ochre',
'Loparite' => 'Loparite',
'Lustrous Hedbergite' => 'Lustrous Hedbergite',
'Monazite' => 'Monazite',
'Opulent Pyroxeres' => 'Opulent Pyroxeres',
'Otavite' => 'Otavite',
'Pellucid Crokite' => 'Pellucid Crokite',
'Platinoid Omber' => 'Platinoid Omber',
'Pollucite' => 'Pollucite',
'Resplendant Kernite' => 'Resplendant Kernite',
'Scheelite' => 'Scheelite',
'Scintillating Hemorphite' => 'Scintillating Hemorphite',
'Sparkling Plagioclase' => 'Sparkling Plagioclase',
'Sperrylite' => 'Sperrylite',
'Stable Veldspar' => 'Stable Veldspar',
'Sylvite' => 'Sylvite',
'Titanite' => 'Titanite',
'Vanadinite' => 'Vanadinite',
'Xenotime' => 'Xenotime',
'Ytterbite' => 'Ytterbite',
'Zeolites' => 'Zeolites',
'Zircon' => 'Zircon',
], 'None') }}
{{ Form::text('fourthQuantity', '', ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
@endsection

View File

@@ -27,10 +27,11 @@ Route::get('/dashboard', 'DashboardController@index');
Route::get('/moons/display', 'MoonsController@displayMoons'); Route::get('/moons/display', 'MoonsController@displayMoons');
Route::get('/moons/addmoon', 'MoonsController@addMoon'); Route::get('/moons/addmoon', 'MoonsController@addMoon');
Route::get('/moons/updatemoon', 'MoonsController@updateMoon'); Route::get('/moons/updatemoon', 'MoonsController@updateMoon');
Route::get('/moons/display/worth', 'MoonsController@displayTotalWorthForm');
//Moon Controller POST requests //Moon Controller POST requests
Route::post('storeMoon', 'MoonsController@storeMoon'); Route::post('storeMoon', 'MoonsController@storeMoon');
Route::post('storeUpdateMoon', 'MoonsController@storeUpdateMoon'); Route::post('storeUpdateMoon', 'MoonsController@storeUpdateMoon');
Route::post('displayTotalWorth', 'MoonsController@displayTotalWorth');
//Wiki Controller display pages //Wiki Controller display pages
Route::get('/wiki/register', 'WikiController@displayRegister'); Route::get('/wiki/register', 'WikiController@displayRegister');