function getPlayerGameScores(PDO $conn, $gameID, $playerID)
{
    $levels = getGame($conn, $gameID)->Levels;
    $scoreArray = array_fill(0, $levels, 0);
    for ($level = 1; $level <= $levels; $level++) {
        $retrieveScorePreSql = "SELECT COUNT(*) FROM Game_Record WHERE `GameID` = ? AND `PlayerID` = ? AND `Level` = ?";
        $retrieveScorePreQuery = $conn->prepare($retrieveScorePreSql);
        $retrieveScorePreQuery->execute(array($gameID, $playerID, $level));
        if ($retrieveScorePreQuery->fetchColumn() > 0) {
            $retrieveScoreSql = "SELECT GameID,PlayerID,`Level`,Score FROM Game_Record WHERE `GameID` = ? AND `PlayerID` = ? AND `Level` = ?";
            $retrieveScoreQuery = $conn->prepare($retrieveScoreSql);
            $retrieveScoreQuery->execute(array($gameID, $playerID, $level));
            $retrieveScoreResult = $retrieveScoreQuery->fetch(PDO::FETCH_OBJ);
            $scoreArray[$level - 1] = $retrieveScoreResult->Score;
        } else {
            $scoreArray[$level - 1] = 0;
        }
    }
    return $scoreArray;
}
    <!--Add Participant form-->
    <form action="/includes/modules/tournamentManagement/tournaments.php" class="form-horizontal" method="POST">
      <div class="form-group" id="tournamentNameInputDiv">
        <label for="tournamentName" class="col-sm-2 control-label">Name</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="tournamentName" name="tournamentName" placeholder="Tournament name" value="<?php 
        echo $thisTournament->name;
        ?>
" required>
        </div>
      </div>
      <div class="form-group" id="gameInputDiv">
        <label for="game" class="col-sm-2 control-label">Game</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="game" name="game" placeholder="Game name" value="<?php 
        echo getGame($thisTournament->game, 'name');
        ?>
" disabled>
        </div>
      </div>
      <button type="submit" name="action" value="edit" class="btn btn-primary">Edit</button>
    </form>
    <form action="/includes/modules/tournamentManagement/tournaments.php?start" class="form-horizontal" method="POST">
      <input type="hidden" value="<?php 
        echo $thisTournament->tournamentid;
        ?>
" name="tournamentID"/>
      <button type="submit" class="btn btn-primary">Start Tournament</button>
    </form>
    <?php 
        if ($thisTournament->team == 1) {
<?php

session_start();
require_once "../../../include/config.php";
require_once $basedir . "/admin/include/functions.php";
include $basedir . '/admin/include/isadmin.php';
$cats = getCategories();
$gamemenu = 'active';
$game_id = isset($_GET['game_id']) ? $_GET['game_id'] : '';
if (!$game_id) {
    header('Location: ' . $baseurl . '/admin/games?lang=' . $LANGUAGE);
    exit;
} else {
    $game = getGame($game_id);
    //$game['g_categories'] = explode(",", $game['g_categories']);
    $bet_items = getBetItems($game_id);
    $reserve_time = getDateFormat($game['g_schedFrom']) . ' - ' . getDateFormat($game['g_schedTo']);
}
$total_placed_coins = getGameTotalPlacedCoins($game_id);
$location = $_SERVER['PHP_SELF'] . '?lang=' . $LANGUAGE . '&game_id=' . $game_id;
if (isset($_SESSION['error'])) {
    if ($_SESSION['error']['error'] == 0) {
        $alert_type = "alert-success";
    } else {
        $alert_type = "alert-warning";
    }
    $display = "block";
    $alert_message = $_SESSION['error']['status'];
    unset($_SESSION['error']);
} else {
    $display = "none";
Example #4
0
<?php

require "api/utils/games.php";
$app->group('/games', function () {
    //get games list
    $this->get('', function ($req, $res, $args) {
        $games = getAllGames();
        if ($games) {
            return $res->withStatus(200)->write(json_encode($games));
        } else {
            return $res->withStatus(400)->write($e->getMessage());
        }
    })->setName('games');
    //get ban with id
    $this->get('/{id}', function ($req, $res, $args) {
        $game = getGame($args['id']);
        if ($game) {
            return $res->withStatus(200)->write(json_encode($game));
        } else {
            return $res->withStatus(400)->write($e->getMessage());
        }
    });
    //post new ban
    $this->post('', function ($req, $res, $args) {
        $game = $req->getParsedBody();
        $sql = "INSERT INTO games (region, date, blue, red, blue_compo, red_compo, blue_bans, red_bans, winner) VALUES (:region, :date, :blue, :red, :blueCompo, :redCompo, :blueBans, :redBans, :winner)";
        try {
            $db = getConnection();
            $stmt = $db->prepare($sql);
            $stmt->bindParam("region", $game['region']);
            $stmt->bindParam("date", $game['date']);
Example #5
0
$game = Game::instance();
$resp = new Response();
$out = '';
switch ($cmd->cmdName) {
    case 'load':
        $out = '{"respStatus":"ok", "respData":' . $game->getFromFile() . '}';
        break;
    case 'wipe':
        $game->saveToFile(NEW_GAME);
        $out = '{"respStatus":"ok", "respData":' . NEW_GAME . '}';
        break;
    case 'poll':
        $lastMove = $cmd->cmdData;
        $game->load();
        if ($game->state->lastMove->moveTime > $lastMove->moveTime || $lastMove->moveTime && !$game->state->lastMove->moveTime) {
            $out = '{"respStatus":"update", "respData":' . getGame() . '}';
        } else {
            $resp->respStatus = 'nochange';
            $out = $json->encode($resp);
        }
        break;
    case 'move':
        $move = $cmd->cmdData;
        $movePieceId = $move->movePiece->id;
        $takePieceId = $move->takePieceId;
        $moveTime = strftime('%Y-%m-%d %T', time());
        $game->load();
        $game->state->pieceList->{$movePieceId}->pos[0] = $move->movePiece->pos[0];
        $game->state->pieceList->{$movePieceId}->pos[1] = $move->movePiece->pos[1];
        if ($takePieceId) {
            unset($game->state->pieceList->{$takePieceId});
function notifyWonUsers($won_users, $game_id)
{
    global $config;
    $game = getGame($game_id);
    $game_title = $game['g_title'];
    foreach ($won_users as $d) {
        $notify = $d['user_notify'];
        if ($notify == 'all' or $notify == 'won') {
            $users[] = $d['user_email'];
        }
    }
    $message = 'Congratulations! You won the game "$game_title"';
    $headers = array();
    $headers[] = "MIME-Version: 1.0";
    $headers[] = "Content-type: text/plain; charset=utf-8";
    $headers[] = "From: noreply <{$noreplyemail}>";
    $headers[] = "Reply-To: Recipient Name <{$noreplyemail}>";
    $headers[] = "Subject: {$subject}";
    $headers[] = 'BCC: ' . implode(",", $users) . "\r\n";
    $headers[] = "X-Mailer: PHP/" . phpversion();
    mail(null, $subject, $message, implode("\r\n", $headers));
    return true;
}
     } else {
         echo json_encode("userid and gameid must be set");
     }
 } elseif ($action == 'getHistories') {
     $histories = getHistory();
     echo json_encode($histories);
 } elseif ($action == 'getHistory') {
     if (isset($_GET['gameid'])) {
         $histories = getHistory($_GET['gameid']);
         echo json_encode($histories);
     } else {
         echo json_encode('gameid must be set');
     }
 } elseif ($action == 'addHistory') {
     if (isset($_GET['gameid']) && isset($_GET['text'])) {
         $games = getGame($_GET['gameid']);
         if (count($games) == 0) {
             echo json_encode('Game not found');
         } else {
             addHistory($_GET['gameid'], $_GET['text']);
             echo json_encode('history added');
         }
     } else {
         echo json_encode('gameid and text must be set');
     }
 } elseif ($action == 'getPlayerCount') {
     if (isset($_GET['gameid'])) {
         $count = getPlayerCount($_GET['gameid']);
         echo json_encode($count);
     } else {
         echo json_encode('gameid must be set');
Example #8
0
    $temp = "SELECT p.id, p.first_name, p.last_name, p.position, t.name\n      FROM player p\n      INNER JOIN team t ON p.team_id = t.id\n      WHERE t.id IN ('{$home_id}','{$away_id}')  ";
    $rows = $mysqli->query($temp)->fetch_all();
    for ($i = 0; $i < count($rows); $i++) {
        echo "<tr><td>" . $rows[$i][1] . "</td><td>" . $rows[$i][2] . "</td><td>" . $rows[$i][3] . "</td><td>" . $rows[$i][4] . "</td>";
        echo "<td><input type='number' name=" . $rows[$i][0] . " value=0 min=0 max=99>";
        //Set name equal to player's id.
    }
    //"Hidden" variables Re-POST previous information regarding teams, scores.
    echo "</table>\n        <input type='hidden' name='home_team' value='" . $_POST['home_team'] . "'/>\n      <input type='hidden' name='away_team' value='" . $_POST['away_team'] . "'/>\n      <input type='hidden' name='home_score' value='" . $_POST['home_score'] . "'/>\n      <input type='hidden' name='away_score' value='" . $_POST['away_score'] . "'/>\n      <input type='hidden' name='date' value='" . $_POST['date'] . "'/>\n        <input type='submit'>\n        </form>";
}
?>
<h4>Want to look at the results of a specific game?  Select a game below!</h4>
Select Game:
    <?php 
showGame();
getGame();
?>

<br />
  
  <h4>Some games are so ugly, you want to pretend they never happened. Now you can! Get rid of evidence that your favorite team is a perennial disappointment.</h4>
  Select Game:
    <?php 
deleteGame();
?>

  
<?php 
include "footer.php";
?>
</body>
Example #9
0
        return $lockedTile;
    }
    // Diagonal
    if ($pieceRow > $connectingRow) {
        if ($pieceColumn > $connectingColumn) {
            $lockedTile = $pieceTile - $GRID_COLUMNS - 1;
        } else {
            $lockedTile = $pieceTile - $GRID_COLUMNS + 1;
        }
    } else {
        if ($pieceColumn > $connectingColumn) {
            $lockedTile = $pieceTile + $GRID_COLUMNS - 1;
        } else {
            $lockedTile = $pieceTile + $GRID_COLUMNS + 1;
        }
    }
    return $lockedTile;
}
$app->get('/test', function () {
    $game = getGame(1);
    $win = hasWon($game, array('tile' => 50, 'piece' => 'pawn-2'));
    echoResponse(200, $win);
});
function echoResponse($status_code, $response)
{
    global $app;
    $app->status($status_code);
    $app->contentType('application/json');
    echo json_encode($response, JSON_NUMERIC_CHECK);
}
$app->run();
Example #10
0
					
					
					
					
				</form>
				
				<?php 
$totalCount = getCount();
$avgPrice = getAvgPrice();
echo "<h2>Total Games: " . $totalCount[0] . "</h2>";
echo "<h4>Average Price: \$" . number_format($avgPrice[0], 2) . "</h4>";
?>
			</nav>
				<?php 
if (isset($_POST['moreInfo'])) {
    $gameInfo = getGame($_POST['gameId']);
    $currentGenre = getGenre($gameInfo['gameGenre']);
    $currentRating = getRating($gameInfo['gameRating']);
    $currentPublisher = getPublisher($gameInfo['gamePublisher']);
    echo "<div id=\"moreInfoPanel\">";
    echo "<img src = \"_images/_boxart/" . $gameInfo['gameId'] . ".jpg\" class = \"gameArt\" height = \"295px\" width = \"225px\">";
    echo "<h3>" . $gameInfo['gameTitle'] . "</h3>";
    echo "<p> Players: " . $gameInfo['players'] . "</p>";
    echo "<p> Co-Op Play: " . $gameInfo['co-op'] . "</p>";
    echo "<p>Rating: " . $currentRating[0] . "</p>";
    echo "<p>Genre: " . $currentGenre[0] . "</p>";
    echo "<p>Publisher: " . $currentPublisher[0] . "</p>";
    echo "<p>Release Date: " . $gameInfo['releaseDate'] . "</p>";
    echo "<a href=\"index.php\">Close More Info</a>";
    echo "</div>";
}
Example #11
0
            $keycount++;
        } else {
            $number .= $keycount . $str[$i];
            //echo $keycount . ' ' . $str[$i] . '<br>';
            $keycount = 1;
        }
    }
    return $number;
}
/*$str = '1321131112';
echo "str: $str<br>";
$number = '';
$keycount = 1;
for ($i = 0; $i < strlen($str); $i++) {

    if ($i + 1 < strlen($str) && $str[$i] == $str[$i + 1]) {
        $keycount++;
    } else {
        $number .= $keycount . $str[$i];
        echo $keycount . ' ' . $str[$i] . '<br>';
        $keycount = 1;
    }
}*/
$num = '1321131112';
for ($k = 0; $k < 50; $k++) {
    $num = getGame($num);
}
echo $num;
$lenght = strlen($num);
echo "<hr>len: {$lenght}";
//95798 too low
Example #12
0
function nexthand($firsthand = false)
{
    global $players, $table;
    foreach ($players as $p) {
        query('UPDATE `' . $GLOBALS['MySQLprefix'] . 'player`', 'SET `action`="none"', ', `allinpot`=0', $p['tablemoney'] ? '' : ', `status="out", timeout=' . time(), ', `showcards`=0', ', `actiontime`=' . time(), 'WHERE `id`=' . $p['id']);
    }
    if (!$table['handcount'] % $table['size'] and !$firsthand) {
        if ($table['inc'] == 'slow') {
            $table['sb'] = round($table['sb'] + $table['sbstart'] * 0.5);
        }
        if ($table['inc'] == 'norm') {
            $table['sb'] = round($table['sb'] * 1.5);
        }
        if ($table['inc'] == 'fast') {
            $table['sb'] = round(exp($table['sb'], 1.5));
        }
    }
    getGame();
    mt_srand();
    $table['dealer'] = nextseated($table['dealer']);
    query('UPDATE `' . $GLOBALS['MySQLprefix'] . 'table`', 'SET `dealer`=' . $table['dealer'], ', `deck`="' . randdeck() . '"', ', `bettinground`=0', ', `onturn`=' . nextactive($table['dealer']), ', `sb`=' . $table['sb'], 'WHERE `id`=' . $table['id']);
    getGame();
}