X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=0350d9e4adf2287889960674f3cea520c78808c5;hp=ceed8bbba49d25191fe4cf940d9358b8d7d95c3e;hb=11429eb9238bb0ba7a10a783d293d9051b146795;hpb=be7fad04dae48d5fa0c209b84be3e9cf9b763472 diff --git a/include/game.php b/include/game.php index ceed8bb..0350d9e 100644 --- a/include/game.php +++ b/include/game.php @@ -107,23 +107,54 @@ set_gametype('normal'); /* put everyting in a form */ echo "
\n"; -/* output game */ +/* handle user notes (only possible while game is running)*/ +if( $mystatus!='gameover' ) + if(myisset("note")) +{ + $note = $_REQUEST['note']; + + if($note != "") + DB_insert_note($note,$gameid,$myid); +}; +output_user_notes($myid,$gameid,$mystatus); + +/* handle calls */ +if(myisset("call") && $_REQUEST["call"] == "120" && can_call(120,$me)) + $result = DB_query("UPDATE Hand SET point_call='120' WHERE hash='$me' "); +if(myisset("call") && $_REQUEST["call"] == "90" && can_call(90,$me)) + $result = DB_query("UPDATE Hand SET point_call='90' WHERE hash='$me' "); +if(myisset("call") && $_REQUEST["call"] == "60" && can_call(60,$me)) + $result = DB_query("UPDATE Hand SET point_call='60' WHERE hash='$me' "); +if(myisset("call") && $_REQUEST["call"] == "30" && can_call(30,$me)) + $result = DB_query("UPDATE Hand SET point_call='30' WHERE hash='$me' "); +if(myisset("call") && $_REQUEST["call"] == "0" && can_call(0,$me)) + $result = DB_query("UPDATE Hand SET point_call='0' WHERE hash='$me' "); /* output extra division in case this game is part of a session */ if($session) { - echo "
\n". - "This game is part of session $session: \n"; + echo "
\n"; + echo "
Rules (+icons fur rules) \n"; + echo "
\n"; + echo " 10ofhearts : ".$RULES["dullen"] ."
\n"; + echo " schweinchen: ".$RULES["schweinchen"] ."
\n"; + echo " call: ".$RULES["call"] ."
\n"; + echo "
\n
\n"; + echo "
Score \n"; + $score = generate_score_table($session); + echo format_score_table_html($score,$myid); + echo "
\n"; $hashes = DB_get_hashes_by_session($session,$myid); $i = 1; foreach($hashes as $hash) { - if($hash == $me) - echo "$i \n"; - else - echo "$i \n"; - $i++; + if($hash == $me) + $j=$i; + $i++; + $lasthash=$hash; } + $i--; + echo "This is game number $j of $i in session $session."; echo "
\n"; } @@ -155,7 +186,7 @@ switch($mystatus) else { /* check the result, if player wants to join, got next stage, else cancel game */ - if($_REQUEST["in"] == "no" && !$skip) + if(!$skip && $_REQUEST["in"] == "no" ) { /* cancel the game */ $message = "Hello, \n\n". @@ -605,7 +636,7 @@ switch($mystatus) { /* email startplayer */ $message = "It's your turn now in game ".DB_format_gameid($gameid).".\n". - "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ; + "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ; mymail($email,$EmailName."ready, set, go... (game ".DB_format_gameid($gameid).") ",$message); } } @@ -631,7 +662,7 @@ switch($mystatus) { /* email player for poverty */ $message = "Poverty: It's your turn now in game ".DB_format_gameid($gameid).".\n". - "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$whohash."\n\n" ; + "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$whohash."\n\n" ; mymail($email,$EmailName."Poverty (game ".DB_format_gameid($gameid).") ",$message); } } @@ -713,7 +744,7 @@ switch($mystatus) { /* email startplayer */ $message = "It's your turn now in game ".DB_format_gameid($gameid).".\n". - "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ; + "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ; mymail($email,$EmailName."ready, set, go... (game ".DB_format_gameid($gameid).") ",$message); } } @@ -902,7 +933,7 @@ switch($mystatus) DB_set_hand_status_by_hash($userhash,'poverty'); $message = "Two people have poverty, it's your turn to decide, if you want to take the trump. Please visit:". - " ".$HOST.$INDEX."?action=game&me=".$userhash."\n\n" ; + " ".$HOST.$INDEX."?action=game&me=".$userhash."\n\n" ; mymail($To,$EmailName." double poverty (game ".DB_format_gameid($gameid).")",$message); @@ -955,7 +986,7 @@ switch($mystatus) { /* email startplayer) */ $message = "It's your turn now in game ".DB_format_gameid($gameid).".\n". - "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ; + "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ; mymail($email,$EmailName."ready, set, go... (game ".DB_format_gameid($gameid).") ",$message); } } @@ -1017,16 +1048,6 @@ switch($mystatus) DB_insert_comment($comment,$playid,$myid); }; - /* handle notes in case player didn't play a card, allow notes only during a game */ - if( (!myisset("card") && $mystatus=='play') ) - if(myisset("note")) - { - $note = $_REQUEST["note"]; - - if($note != "") - DB_insert_note($note,$gameid,$myid); - }; - /* get everything relevant to display the tricks */ $result = DB_query("SELECT Hand_Card.card_id as card,". " Hand.position as position,". @@ -1045,7 +1066,7 @@ switch($mystatus) "WHERE Trick.game_id='".$gameid."' ". "GROUP BY Trick.id, sequence ". "ORDER BY Trick.id, sequence ASC"); - $trickNR = 1; + $trickNR = 0; $lasttrick = DB_get_max_trickid($gameid); $play = array(); /* needed to calculate winner later */ @@ -1061,7 +1082,7 @@ switch($mystatus) if($mygametype != 'normal' && $mygametype != 'silent') /* only show when needed */ { echo "
  • Pre\n". - "
    \n"; + "
    \n"; $show = 1; for($mypos=1;$mypos<5;$mypos++) { @@ -1089,6 +1110,10 @@ switch($mystatus) $comment = $r[4]; $user = $r[6]; + /* count number of tricks */ + if($seq==1) + $trickNR++; + /* check if first schweinchen has been played */ if( $GAME['schweinchen-who'] && ($r[0] == 19 || $r[0] == 20) ) if(!$GAME['schweinchen-first']) @@ -1136,7 +1161,6 @@ switch($mystatus) /* end of trick? */ if($seq==4) { - $trickNR++; echo "
    \n
  • \n"; /* end div trick, end li trick */ } } @@ -1178,18 +1202,6 @@ switch($mystatus) /* update Game timestamp */ DB_update_game_timestamp($gameid); - /* check if a call was made, must do this before we set the card status to played */ - if(myisset("call") && $_REQUEST["call"] == "120" && can_call(120,$me)) - $result = DB_query("UPDATE Hand SET point_call='120' WHERE hash='$me' "); - if(myisset("call") && $_REQUEST["call"] == "90" && can_call(90,$me)) - $result = DB_query("UPDATE Hand SET point_call='90' WHERE hash='$me' "); - if(myisset("call") && $_REQUEST["call"] == "60" && can_call(60,$me)) - $result = DB_query("UPDATE Hand SET point_call='60' WHERE hash='$me' "); - if(myisset("call") && $_REQUEST["call"] == "30" && can_call(30,$me)) - $result = DB_query("UPDATE Hand SET point_call='30' WHERE hash='$me' "); - if(myisset("call") && $_REQUEST["call"] == "0" && can_call(0,$me)) - $result = DB_query("UPDATE Hand SET point_call='0' WHERE hash='$me' "); - /* mark card as played */ DB_query("UPDATE Hand_Card SET played='true' WHERE hand_id='$handid' AND card_id=". DB_quote_smart($card)); @@ -1419,7 +1431,7 @@ switch($mystatus) $message = "A card has been played in game ".DB_format_gameid($gameid).".\n\n". "It's your turn now.\n". - "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$next_hash."\n\n" ; + "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$next_hash."\n\n" ; if( DB_get_email_pref_by_uid($who)!="emailaddict" ) mymail($email,$EmailName."a card has been played in game ".DB_format_gameid($gameid),$message); } @@ -1646,35 +1658,9 @@ switch($mystatus) $session = DB_get_session_by_gameid($gameid); $score = generate_score_table($session); - /* convert html to ascii */ - $score = str_replace("
    \n\n \n","",$score); - $score = str_replace("
    \n","",$score); - $score = str_replace("\n","",$score); - $score = str_replace(array("","","",""),array("","\n","","|"),$score); - $score = explode("\n",$score); - - $header = array_slice($score,0,1); - $header = explode("|",$header[0]); - for($i=0;$i5) $header.= " ... \n"; - - if(sizeof($score)>5) $score = array_slice($score,-5,5); - for($i=0;$iprev\n"; - echo "
  • next
  • \n\n"; /* end ul tricks*/ - - echo "
    Personal notes:
    \n"; - $notes = DB_get_notes_by_userid_and_gameid($myid,$gameid); - foreach($notes as $note) - echo "$note
    \n"; - echo "Insert note:\n"; - echo "
    \n"; + echo "
  • next
  • \n"; + echo "\n"; /* end ul tricks*/ $mycards = DB_get_hand($me); $mycards = mysort($mycards,$gametype); @@ -1865,15 +1845,6 @@ switch($mystatus) /* display rule set for this game */ echo "
    \n"; - if($gamestatus != 'pre') - echo " Gametype: $GT
    \n"; - - echo "Rules:
    \n"; - echo "10ofhearts : ".$RULES["dullen"] ."
    \n"; - echo "schweinchen: ".$RULES["schweinchen"] ."
    \n"; - echo "call: ".$RULES["call"] ."
    \n"; - - echo "
    \n"; if($gamestatus == 'play' ) output_form_calls($me); @@ -1884,15 +1855,9 @@ switch($mystatus) if($gamestatus == 'play' || $gameend < 60*60*24*7) { echo "
    \nA short comment:\n"; - echo "
    "; } - echo "\n
    \n"; - - $session = DB_get_session_by_gameid($gameid); - $score = generate_score_table($session); - - echo $score; + echo "\n"; echo "
    \n"; @@ -1930,7 +1895,6 @@ switch($mystatus) } } - output_footer(); DB_close(); exit();