Example #1
0
    // add date to array
    $matchDays[] = $newDateTime;
}
foreach ($matchDays as $matchDay) {
    $endOfMatchDay = clone $matchDay;
    $endOfMatchDay->modify('+1 day -1 second');
    // Select the matches
    $matches = $database->select('matches', ['[><]players (winner)' => ['winner' => 'id'], '[><]players (loser)' => ['loser' => 'id']], ['matches.id', 'matches.datetime', 'matches.sent-by', 'winner.id(winner-id)', 'loser.id(loser-id)', 'winner.name(winner-name)', 'loser.name(loser-name)', 'matches.winner', 'matches.loser', 'matches.accepted', 'matches.declined', 'matches.winner-original-rating', 'matches.loser-original-rating', 'matches.difference', 'matches.winner-new-rating', 'matches.loser-new-rating'], ["AND" => ['accepted' => '1', 'matches.datetime[<>]' => [$matchDay->format("Y-m-d H:i:s"), $endOfMatchDay->format("Y-m-d H:i:s")]], 'ORDER' => "matches.sent-datetime DESC"]);
    if (!empty($matches)) {
        echo '
		<section class="block results">
		<h1 class="h1">' . $matchDay->format('l jS') . '</h1>';
        // each match
        foreach ($matches as $match) {
            $winnerStats = playerStats($match['winner-id']);
            $loserStats = playerStats($match['loser-id']);
            if ($match['declined'] == 1) {
                $isDisputed = ' is--disputed';
            } else {
                $isDisputed = '';
            }
            echo '
				<li>
					<a href="/match.php?match=' . $match['id'] . '" class="g2 slate is--result' . $isDisputed . '">
					
						<div class="base"></div>

						<div class="col1 player is--a is--winner is--level' . $winnerStats['levelId'] . '">
						
							<figure class="position-triangle">' . file_get_contents('src/img/position-triangle.svg') . '</figure>';
            playerPhoto($match['winner-id']);
Example #2
0
} else {
    $countPlayersGames = countPlayersGames($player['id']);
    $gamesRemaining = 10 - $countPlayersGames;
    echo '<h3 class="h3 block is--textcentre prompt is--inline is--prompted">' . $gamesRemaining . ' games left to play!</h1>';
}
?>

<section class="block results">
    
	<ul>
    
<?php 
$mostRecentResults = $database->select('matches', ['[><]players (winner)' => ['winner' => 'id'], '[><]players (loser)' => ['loser' => 'id']], ['matches.id', 'matches.datetime', 'matches.sent-by', 'winner.id(winner-id)', 'loser.id(loser-id)', 'winner.name(winner-name)', 'loser.name(loser-name)', 'matches.winner', 'matches.loser', 'matches.accepted', 'matches.declined', 'matches.winner-original-rating', 'matches.loser-original-rating', 'matches.difference', 'matches.winner-new-rating', 'matches.loser-new-rating'], ['AND' => ['OR' => ['winner' => $player['id'], 'loser' => $player['id']]], 'ORDER' => "matches.sent-datetime DESC", "LIMIT" => 5]);
foreach ($mostRecentResults as $result) {
    $winnerStats = playerStats($result['winner-id']);
    $loserStats = playerStats($result['loser-id']);
    if ($result['declined'] == 1) {
        $isDisputed = ' is--disputed';
    } else {
        $isDisputed = '';
    }
    echo '
				<li>
					<a href="/match.php?match=' . $result['id'] . '" class="g2 slate is--result' . $isDisputed . '">
					
						<div class="base"></div>
						
						<div class="col1 player is--a is--winner is--level' . $winnerStats['levelId'] . '">
						
							<figure class="position-triangle">' . file_get_contents('src/img/position-triangle.svg') . '</figure>';
    playerPhoto($result['winner-id']);
Example #3
0
<?php

$notifications = $database->count('matches', ['AND' => ['OR' => ['winner' => $you['id'], 'loser' => $you['id']], 'sent-by[!]' => $you['id'], 'accepted' => '0', 'declined' => '0']]);
$playerStats = playerStats($you['id']);
?>

<nav class="menu">

	<label class="menu__toggle" data-toggles="menu">
		<div class="player-photo-wrap is--level<?php 
echo $playerStats['levelId'];
?>
"><?php 
playerPhoto($you['id']);
?>
</div>
		<figure class="menu__icon"><?php 
if ($notifications > 0) {
    echo '<span class="new">' . $notifications . '</span>';
}
?>
</span><?php 
echo file_get_contents('src/img/menu.svg');
?>
</figure>
	</label>

	<div class="fullscreen is--menu" data-is="menu">

		<label class="close" data-toggles="menu">X</label>
$gamesPlayed = $database->count('matches', ['id'], ['AND' => ['OR' => ['winner' => $player['id'], 'loser' => $player['id']], 'accepted' => '1']]);
$gamesWon = $database->count('matches', ['id'], ['AND' => ['winner' => $player['id'], 'accepted' => '1']]);
$gamesLost = $database->count('matches', ['id'], ['AND' => ['loser' => $player['id'], 'accepted' => '1']]);
echo $gamesPlayed . ' Total (' . $gamesWon . ' won / ' . $gamesLost . ' lost)';
?>
		</p>
	</li>

	<?php 
$bestWin = $database->select('matches', ['[><]players (winner)' => ['winner' => 'id'], '[><]players (loser)' => ['loser' => 'id']], ['matches.id', 'matches.datetime', 'matches.sent-by', 'winner.id(winner-id)', 'loser.id(loser-id)', 'winner.name(winner-name)', 'loser.name(loser-name)', 'loser.photo(loser-photo)', 'matches.winner', 'matches.loser', 'matches.accepted', 'matches.declined', 'matches.winner-original-rating', 'matches.loser-original-rating'], ['AND' => ['OR' => ['winner' => $player['id']], 'accepted' => '1'], "ORDER" => "matches.loser-original-rating DESC", "LIMIT" => 1]);
if (!empty($bestWin)) {
    ?>
	
		<li class="row">
			<h3 class="h4">Best win:</h3>
			<p>
				<?php 
    $bestLoserStats = playerStats($bestWin[0]['loser-id']);
    echo '<a href="/match.php?match=' . $bestWin[0]['id'] . '">';
    echo 'Versus. ';
    playerPhotoInline($bestWin[0]['loser-id']);
    echo ' ' . $bestWin[0]['loser-name'] . ' (' . $bestWin[0]['loser-original-rating'] * 5 . ')</a>';
    ?>
			</p>
		</li>

	<?php 
}
?>
	
</ol>