Esempio n. 1
0
                 $nextPlayer = $game['turn'];
             } else {
                 // if not, call a draw
                 $newStatus = 'draw';
             }
         }
     }
 }
 // Update database
 try {
     $db->startTransaction();
     // insert played piece
     $db->insert("played", $newPieces);
     // are we in overtime? remove from overtime bin
     if ($game['status'] === 'overtime') {
         $db->deleteWhere("overtime", "id='" . $piece . "' AND player='" . $game['turn'] . "'");
     }
     if (sizeof($newLockouts) > 0) {
         // insert lockouts
         $db->insert("lockouts", $newLockouts);
         if ($jumpedPieces) {
             // delete jumped pieces
             $db->deleteIn("played", "tile", $jumpedPieces['tiles']);
             // delete lockouts from jumped pieces
             $db->deleteWhereAll("lockouts", array('fromTile', 'toTile'), $jumpedPieces['tiles'], "OR");
             // add jumped pieces to overtime bins
             $db->insert("overtime", $overtimePieces);
         }
     }
     // update player turn
     $db->update("game", array('turn' => $nextPlayer), array('gameID' => $gameID));