} else { if ($ga['p1'] > 0 && $ga['p2'] == 0 || $ga['p1'] == 0 && $ga['p2'] > 0) { $waittxt = "Waiting for another person to join..."; $vstxt = ""; } } } if ($move) { if ($userid == $ga['p1']) { $missfield = "p1missed"; } if ($userid == $ga['p2']) { $missfield = "p2missed"; } $db->query("UPDATE {$gpre}room SET {$missfield}=0 WHERE id={$roomid}"); make_move($move, $userid, $roomid); } if ($begin) { player_ready($begin, $userid, $roomid); } if ($setup) { place_piece($setup, $userid, $roomid); } if ($endturn) { end_turn($userid, $roomid); } print "<h1>{$gamename}</h1>"; if ($waittxt) { print "{$waittxt}"; } else { if ($defaultwin) {
$ir = $db->fetch_row($is); $userid = $ir['userid']; include "s_{$gpre}func.php"; $pp = $db->query("SELECT * FROM {$gpre}game WHERE gameover=0 AND userid={$userid}"); $pany = $db->num_rows($pp); $move = abs((int) $_POST['move']); $select = abs((int) $_POST['select']); print "<center>"; //This code is essentially the code that executes in the if($pany && $_GET['act']=='play') statement within s_pp_game.php if ($pany) { $p = $db->fetch_row($pp); print "<h2>Poker Patience</h2><a href='s_pp_game.php?act=highscores'><b><font color=green>View Highscores</font></b></a> | \n\t<b>How to play:</b><br /><font size=1> Get the best 5 card hand possible on each row, column, and the two diagonals. <br />\n\tYour final score is the total points you earned from all 12 of those hands.<br />\n\tClick one of the two decks at top to select a card to play, and click an open square to play it.</font><br /><br />\n\t<div id = \"gamediv\">"; $gameid = $p['id']; $boardtxt = draw_board($userid, $gameid); if ($move != 0 && $p['gameover'] == 0) { make_move($move, $userid); $points = check_win($userid); if ($points > 0) { $ins = $db->query("SELECT * FROM pp_scores WHERE userid={$userid} AND {$points}<score"); $insn = $db->num_rows($ins); //keep old score only if there's a score in the DB that has a higher value than $points if (!$insn) { $db->query("DELETE FROM pp_scores WHERE userid={$userid}"); $db->query("DELETE FROM pp_game WHERE userid={$userid} AND id!={$gameid}"); $db->query("INSERT INTO pp_scores (userid, score, gameid) VALUES({$userid}, {$points}, {$gameid})"); } print "Game over, you got <b>{$points} points</b> <br /><br>"; print "<form method='post' action='?act=replay'>\n\t\t\t<input type='submit' value='New Game?'>\n\t\t\t</form><br /><br />"; print "<form method='post' action='?act=post'>\n\t\t\tVictory Message (optional): <input type=text name='victory'><br />\n\t\t\t<input type='submit' value='Post to Facebook?'>\n\t\t\t</form>"; } }
function turn() { if ($_SESSION['select']) { include 'connection.php'; $req = "SELECT player_1_obj, player_2_obj, player_3_obj, player_4_obj, asteroid FROM party WHERE `id`=" . $_SESSION['id_party'] . ""; $pl = array(); foreach ($bdd->query($req) as $test) { if ($test['player_1_obj'] !== "" && intval($_SESSION['player_id']) === 1) { $_SESSION['player_obj'] = $test['player_1_obj']; } if ($test['player_2_obj'] !== "" && intval($_SESSION['player_id']) === 2) { $_SESSION['player_obj'] = $test['player_2_obj']; } if ($test['player_3_obj'] !== "" && intval($_SESSION['player_id']) === 3) { $_SESSION['player_obj'] = $test['player_3_obj']; } if ($test['player_4_obj'] !== "" && intval($_SESSION['player_id']) === 4) { $_SESSION['player_obj'] = $test['player_4_obj']; } if ($test['asteroid'] !== "") { $_SESSION['asteroid'] = $test['asteroid']; } } make_select(); } else { if ($_SESSION['order']) { // $move = 1; make_order($_POST); } else { if ($_SESSION['mvt']) { // $move = 1; make_mvt($_POST); } else { if ($_SESSION['make_move']) { // $move = 1; make_move($_POST); } else { // $move = 1; make_fire(); } } } } if (kill_ship()) { $_SESSION['select'] = 1; $_SESSION['order'] = 0; $_SESSION['mvt'] = 0; $_SESSION['make_move'] = 0; $_SESSION['fire'] = 0; include 'connection.php'; $req = $bdd->prepare("UPDATE `party` SET turn = (turn % player) + 1 where id=" . $_SESSION['id_party']); $req->execute(); $req->closeCursor(); } }