sporz

PHP implementation of the board game "sporz"
git clone https://0x1A4.1337.cx/code2/sporz.git
Log | Files | Refs

commit 6803a4a0d62db4671c705377214d6bf58e6cab74
parent 13fa55f61e6f00e0608ded4c3ad67cb813288c39
Author: gitus <git@shroomrider.com>
Date:   Mon Nov 21 23:54:36 +0100

Merge pull request #11 from pips-/master

hackin' by night
Diffstat:
app/Models/Game.php | 9+++++++++
app/Views/game/dashboard.tpl.php | 30+++++++++++++++++-------------
app/Views/index.tpl.php | 31++++++++++++++++---------------
app/Views/layout.tpl.php | 38++++++++++++++++++++++----------------
4 files changed, 64 insertions(+), 44 deletions(-)
diff --git a/app/Models/Game.php b/app/Models/Game.php @@ -30,6 +30,15 @@ class Game extends \Pragma\ORM\Model return $ret; } + public function openWithFields($data) + { + $ret = parent::openWithFields($data); + + $this->players = Player::forge()->where('game_id', '=', $this->id)->get_objects(); + + return $ret; + } + //the KeyId is the string used by a player in order to authenticate in-game (security is not a concern here) public static function genKeyId() { diff --git a/app/Views/game/dashboard.tpl.php b/app/Views/game/dashboard.tpl.php @@ -1,23 +1,27 @@ -<h2><?= $this->get('game')->name; ?></h2> +<h2>Game: <strong><?= $this->get('game')->name; ?></strong></h2> <div class="container-fluid"> <div class="row"> <div class="col-sm-3 col-md-2 sidebar"> - <ul class="nav nav-sidebar"> + <h3 class="sub-header">Summary</h3> + <ul class="nav nav-sidebar"> <li>Turn: <?= $this->get('game')->turn; ?></li> <li>Your role: <?= $this->get('player')->role; ?></li> <li>Your condition: <?= $this->get('player')->mutated?"Mutant":"Human"; ?></li> - </ul> + </ul> </div> - <h2 class="sub-header">Joueurs décédés</h2> - <div class="table-responsive"> - <table class="table table-striped"> - <thead> - <tr> - <th>Name</th> - <th>Role</th> - <th>State</th> - </tr> - </thead> + <div class="col-sm-12 col-md-10"> + <h3 class="sub-header">Joueurs décédés</h3> + <div class="table-responsive"> + <table class="table table-striped"> + <thead> + <tr> + <th>Name</th> + <th>Role</th> + <th>State</th> + </tr> + </thead> + </table> + </div> </div> </div> </div> diff --git a/app/Views/index.tpl.php b/app/Views/index.tpl.php @@ -1,26 +1,27 @@ <h1 class="page-header">Lobby</h1> <div class="table-responsive"> <table class="table table-striped"> - <thead> - <tr> - <th>#</th> - <th>Name</th> - <th>Player count</th> - <th>Joined</th> - </tr> - </thead> - <tbody> + <thead> + <tr> + <th>#</th> + <th>Name</th> + <th>Player count</th> + <th>Joined</th> + </tr> + </thead> + <tbody> <?php foreach ($this->get('joinableGames') as $game) { ?> <tr> - <a href="<?= $this->get('router')->url_for('game-detail', ['gameid' => $game->id]); ?>"> - <td><?= $game->id; ?></td> - <td><?= $game->name; ?></td> - <td><?= $game->name; ?></td> - <td><?= $game->name; ?></td> - </a> + + <td><a href="<?= $this->get('router')->url_for('game-detail', ['gameid' => $game->id]); ?>"><?= $game->id; ?></a></td> + <td><a href="<?= $this->get('router')->url_for('game-detail', ['gameid' => $game->id]); ?>"><?= $game->name; ?></a></td> + <td><a href="<?= $this->get('router')->url_for('game-detail', ['gameid' => $game->id]); ?>"><?= count($game->players); ?></a></td> + <td><?= $game->name; ?></a></td> </tr> <?php } ?> + </table> +</div> diff --git a/app/Views/layout.tpl.php b/app/Views/layout.tpl.php @@ -6,7 +6,7 @@ <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet"> </head> <body> -<nav class="navbar navbar-inverse navbar-fixed-top"> +<nav class="navbar navbar-inverse navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> @@ -15,12 +15,12 @@ <span class="icon-bar"></span> <span class="icon-bar"></span> </button> - <a class="navbar-brand" href="#">Sporz</a> + <a class="navbar-brand" href="/">Sporz</a> <?php - if ($this->get('username') != null) { - ?> + if ($this->get('username') != null) { + ?> <p class="navbar-text">Hello, <?= $this->get('username'); ?>!</p> - <?php + <?php } ?> </div> @@ -34,23 +34,29 @@ </div> </nav> <div class="container-fluid"> - <div class="row"> - <br> - <br> - <br> - <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> - <div class="table-responsive"> <?php - foreach ($this->flushFlash() as $flash) { + $flashMessages = $this->flushFlash(); + if (!empty($flashMessages)) { ?> - <div class="alert alert-<?= $flash['class']; ?>"> - <?= $flash['message']; ?> + <div class="row"> + <div class="col-sm-12 col-md-12"> + <?php + foreach ($flashMessages as $flash) { + ?> + <div class="alert alert-<?= $flash['class']; ?>"> + <?= $flash['message']; ?> + </div> + <?php + } + ?> + </div> </div> <?php } ?> - <?php $this->yields(); ?> - </div> + <div class="row"> + <div class="col-sm-12 col-md-12 main"> + <?php $this->yields(); ?> </div> </div> </div>