From 6206ef89ad9a9a1a541ecb67971815d11f12199b Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Mon, 16 Mar 2009 22:06:21 -0700 Subject: BUGFIX: store canceled games, don't delete them deleting the games could result in the same people getting the same hand redealt over and over again. By just keeping track of the hands in the game table, this problem should be gone. Fixed issue #50. --- include/functions.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index 0559895..981cabc 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1253,4 +1253,35 @@ function check_vacation($userid) return NULL; } +function cancel_game($why,$gameid) +{ + $gameid = DB_quote_smart($gameid); + + /* update the game table */ + switch($why) + { + case 'timedout': + DB_query("UPDATE Game SET status='cancel-timedout' WHERE id=$gameid"); + break; + case 'nines': + DB_query("UPDATE Game SET status='cancel-nines' WHERE id=$gameid"); + break; + case 'trump': + DB_query("UPDATE Game SET status='cancel-trump' WHERE id=$gameid"); + break; + case 'noplay': + DB_query("UPDATE Game SET status='cancel-noplay' WHERE id=$gameid"); + break; + } + /* set each player to gameover */ + $result = DB_query("SELECT id FROM Hand WHERE game_id=".DB_quote_smart($gameid)); + while($r = DB_fetch_array($result)) + { + $id = $r[0]; + DB_query("UPDATE Hand SET status='gameover' WHERE id=".DB_quote_smart($id)); + } + + return; +} + ?> -- cgit v1.2.3-18-g5258