Skip to content

Commit

Permalink
Show gaming time to everybody if set
Browse files Browse the repository at this point in the history
  • Loading branch information
repli2dev committed Aug 13, 2023
1 parent 94b6a23 commit 78016e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions App/Presenters/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ protected function beforeRender()
}

$this->template->currentTime = $this->gameClockService->get();
$this->template->isTimeOverridden = $this->gameClockService->isOverridden();
if ($this->user->isAllowed(Resource::ADMIN_COMMON, Action::CHANGE_GAME_CLOCK) || $this->isImpersonated()) {
$this->template->gameClockChange = true;
$this->template->hasDatetimepicker = true;
Expand Down
2 changes: 1 addition & 1 deletion App/Presenters/templates/menu.latte
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
</li>
</ul>
{/if}
<div class="bg-yellow-tmou lg:rounded-sm p-4 my-4 text-base pl-8" n:if="isset($gameClockChange) && $gameClockChange">
<div class="bg-yellow-tmou lg:rounded-sm p-4 my-4 text-base pl-8" n:if="(isset($gameClockChange) && $gameClockChange) || (isset($isTimeOverridden) && $isTimeOverridden)">
<div class="game-clock" n:ifset="$currentTime">
<span class="font-bold text-lg">Herní čas</span><br>
<span id="time" class="text-lg" data-time="{$currentTime|date: 'U.u'}">{$currentTime|date: 'j. n. Y G:i:s'}</span>
Expand Down
9 changes: 9 additions & 0 deletions App/Services/System/GameClockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ public function get(): DateTimeImmutable
return $current;
}

/**
* Returns true if game time is overridden, false otherwise
* @return bool
*/
public function isOverridden(): bool
{
return $this->interval !== null;
}

/**
* Sets game time from given datetime which should be considered as new now.
*
Expand Down

0 comments on commit 78016e8

Please sign in to comment.