Skip to content

Commit

Permalink
Add construction advisor
Browse files Browse the repository at this point in the history
  • Loading branch information
WaveHack committed Jan 23, 2017
1 parent e8c08c2 commit fca2af1
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,86 @@
@section('content')
@include('partials.dominion.advisor-selector')

todo
<div class="row">

<div class="col-sm-12 col-md-6">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title"><i class="fa fa-home"></i> Construction Advisor</h3>
</div>
<div class="box-body no-padding">
<table class="table">
<colgroup>
<col>
<col width="100">
<col width="100">
<col width="100">
</colgroup>
<thead>
<tr>
<th>Building Type</th>
<th class="text-center">Number</th>
<th class="text-center">% of land</th>
</tr>
</thead>
<tbody>
@foreach ($buildingHelper->getBuildingTypes() as $buildingType)
<tr>
<td>{{ ucfirst($buildingType) }}</td>
<td class="text-center">{{ number_format($selectedDominion->{'building_' . $buildingType}) }}</td>
<td class="text-center">{{ number_format((($selectedDominion->{'building_' . $buildingType} / $landCalculator->getTotalLand()) * 100), 2) }}%</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>

<div class="col-sm-12 col-md-6">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title"><i class="fa fa-clock-o"></i> Incoming building breakdown</h3>
</div>
<div class="box-body no-padding">
<table class="table">
<colgroup>
<col>
@for ($i = 0; $i < 13; $i++)
<col width="20">
@endfor
<col width="100">
</colgroup>
<thead>
<tr>
<th>Land Type</th>
@for ($i = 0; $i < 13; $i++)
<th class="text-center">{{ $i }}</th>
@endfor
<th class="text-center">Total</th>
</tr>
</thead>
<tbody>
@foreach ($buildingHelper->getBuildingTypes() as $buildingType)
<tr>
<td>{{ ucfirst($buildingType) }}</td>
@for ($i = 0; $i < 13; $i++)
<td class="text-center">
@if ($dominionQueueService->getConstructionQueue()[$buildingType][$i] === 0)
-
@else
{{ number_format($dominionQueueService->getConstructionQueue()[$buildingType][$i]) }}
@endif
</td>
@endfor
<td class="text-center">{{ number_format($dominionQueueService->getConstructionQueueTotalByBuilding($buildingType)) }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>

</div>
@endsection
12 changes: 11 additions & 1 deletion src/Http/Controllers/DominionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,17 @@ public function getAdvisorsLand()

public function getAdvisorsConstruction()
{
return view('pages.dominion.advisors.construction');
$buildingHelper = app()->make(BuildingHelper::class);
$buildingCalculator = app()->make(BuildingCalculator::class);
$landCalculator = app()->make(LandCalculator::class);
$dominionQueueService = app()->make(DominionQueueService::class);

return view('pages.dominion.advisors.construction', compact(
'buildingHelper',
'buildingCalculator',
'landCalculator',
'dominionQueueService'
));
}

// Actions
Expand Down
4 changes: 2 additions & 2 deletions src/Services/DominionQueueService.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ public function getConstructionQueue()
->where('dominion_id', $this->dominion->id)
->get(['building', 'amount', 'hours']);

$constructionQueue = array_fill_keys($this->buildingHelper->getBuildingTypes(), array_fill(0, 12, 0));
$constructionQueue = array_fill_keys($this->buildingHelper->getBuildingTypes(), array_fill(0, 13, 0));

foreach ($rows as $row) {
$constructionQueue[$row->building][$row->hours - 1] = (int)$row->amount;
$constructionQueue[$row->building][$row->hours] = (int)$row->amount;
}

$this->constructionQueue = $constructionQueue;
Expand Down

0 comments on commit fca2af1

Please sign in to comment.