diff options
author | Arun Persaud <arun@nubati.net> | 2009-03-16 22:06:21 -0700 |
---|---|---|
committer | Arun Persaud <arun@nubati.net> | 2009-03-29 10:47:55 -0700 |
commit | 6206ef89ad9a9a1a541ecb67971815d11f12199b (patch) | |
tree | 86af68a4ce38a5c88d3c491a707b6df8c9ded337 /include/functions.php | |
parent | 3fd01c7b9fa78fb08ca1ad61c1de850b9a6b9870 (diff) | |
download | e-DoKo-6206ef89ad9a9a1a541ecb67971815d11f12199b.tar.gz e-DoKo-6206ef89ad9a9a1a541ecb67971815d11f12199b.tar.bz2 e-DoKo-6206ef89ad9a9a1a541ecb67971815d11f12199b.zip |
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.
Diffstat (limited to 'include/functions.php')
-rw-r--r-- | include/functions.php | 31 |
1 files changed, 31 insertions, 0 deletions
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; +} + ?> |