Esempio n. 1
0
         // Does the next player have enough pieces for overtime?
         if (!hasOvertimePieces($nextPlayer, $game['overtime'], $jumpedPieces['pieces'], '')) {
             // If not, does THIS player have enough peices?
             if (hasOvertimePieces($game['turn'], $game['overtime'], array(), $piece)) {
                 // if yes, repeat player's turn
                 $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