processMessages(); // processes the messages (undo, resign, etc) (chessdb.inc.php) // are we undoing ? if ($undoing && 0 < $num_moves) { call("UNDO REQUEST"); // just remove the last FEN entered into the history table $query = "\n\t\tSELECT MAX(h_time)\n\t\tFROM " . T_HISTORY . "\n\t\tWHERE h_game_id = '{$_SESSION['game_id']}'\n\t"; $max_time = $mysql->fetch_value($query, __LINE__, __FILE__); $query = "\n\t\tDELETE FROM " . T_HISTORY . "\n\t\tWHERE h_game_id = '{$_SESSION['game_id']}'\n\t\t\tAND h_time = '{$max_time}'\n\t\tLIMIT 1\n\t"; $mysql->query($query, __LINE__, __FILE__); if (!DEBUG) { header("Location: ./chess.php"); } } elseif (isset($_POST['promotion']) && '' != $_POST['promotion'] && false != $_POST['promoting']) { call("SAVING PROMOTION"); savePromotion(); // inserts promoted piece and saves to database (chessdb.inc.php) if (!DEBUG) { header("Location: ./chess.php"); } } elseif (isset($_POST['fromRow']) && '' != $_POST['fromRow'] && '' != $_POST['fromCol'] && '' != $_POST['toRow'] && '' != $_POST['toCol'] || isset($_POST['castleMove']) && 'false' != $_POST['castleMove']) { call("MAKING A MOVE"); call($_POST); call($_POST['fromRow']); /* ensure it's the current player moving */ /* NOTE: if not, this will currently ignore the command... */ /* perhaps the status should be instead? */ /* (Could be confusing to player if they double-click or something */ $is_valid = true; if ('white' == $curTurn) { call("WHITE");
//WTF?? $color = "b"; if ($rounds == ($row2[0] + 1) / 2) { $color = "w"; } if ($rounds != 0) { $rounds = $rounds . $color; } $notemsg = $_POST['note_msg']; $temparray = array($notemsg, $rounds); $_POST['note_msg'] = implode(" - MOVE #", $temparray); //Ahh I see now the purpose of colors mysql_query("insert into notes (fromID,note,game_id) VALUES ('" . $_SESSION[player_id] . "','" . $_POST['note_msg'] . "','" . $_SESSION[game_id] . "')"); } else { if (!empty($_POST['promotion']) && $_POST['to_row'] != "" && $_POST['to_col'] != "") { $promoting_pawn = savePromotion(); $board[$_POST['to_row']][$_POST['to_col']] = $_POST['promotion'] | $board[$_POST['to_row']][$_POST['to_col']] & BLACK; //Interesting shit- how does this work? better way to do it? $save_game_to_db = saveGame(); } elseif ($_POST['from_row'] != "" && $_POST['from_col'] != "" && $_POST['to_row'] != "" && $_POST['to_col'] != "") { //DUMP the values here- this should be hit when submitting a move. // ensure it's the current player moving // NOTE: if not, this will currently ignore the command... // perhaps the status should be instead? // (Could be confusing to player if they double-click or something $tmpIsValid = true; //num moves comes from history - supposed to show whose move it is.. //we have whose_turn available above. I'll work with this as-is for now til templating and //adodb are in, then get it *working* first before breaking it further. if ($numMoves == -1 || $numMoves % 2 == 1) { // White's move... ensure that piece being moved is white