X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Ffunctions.php;h=9103c6f517fc9e19501fc2364f1283315e66f582;hp=466b4ae34f631d7c6a08414ebbbdd079aa0943b9;hb=44e91af3fd631752e4de74673b591bce17ce7a79;hpb=b568d14fe83e919b41452d8ae5b57a7dedc671cf diff --git a/include/functions.php b/include/functions.php index 466b4ae..9103c6f 100644 --- a/include/functions.php +++ b/include/functions.php @@ -727,7 +727,7 @@ function can_call($what,$hash) function display_table () { - global $gameid, $GT, $debug,$INDEX,$defaulttimezone; + global $gameid, $GT, $debug,$INDEX,$defaulttimezone,$session; global $RULES,$GAME,$gametype; $result = DB_query("SELECT User.fullname as name,". @@ -779,12 +779,12 @@ function display_table () $cards = DB_get_all_hand($userhash); $trumpNR = count_trump($cards); if($trumpNR) - echo " \"poverty"; + echo " \"poverty"; else - echo " \"poverty"; + echo " \"poverty"; } else - echo " \"poverty\" />"; + echo " \"poverty\" title=\"poverty partner\" />"; if($GT=="dpoverty") if($party=="re") @@ -794,12 +794,12 @@ function display_table () $cards = DB_get_all_hand($userhash); $trumpNR = count_trump($cards); if($trumpNR) - echo " \"poverty"; + echo " \"poverty"; else - echo " \"poverty"; + echo " \"poverty"; } else - echo " \"poverty\" />"; + echo " \"poverty\" title=\"poverty partner\" />"; else if($sickness=="poverty") { @@ -807,64 +807,64 @@ function display_table () $cards = DB_get_all_hand($userhash); $trumpNR = count_trump($cards); if($trumpNR) - echo " \"poverty2"; + echo " \"poverty2"; else - echo " \"poverty2"; + echo " \"poverty2"; } else - echo " \"poverty2\" />"; + echo " \"poverty2\" title=\"poverty2 partner\" />"; if($GT=="wedding" && $party=="re") if($sickness=="wedding") - echo " \"wedding\""; + echo " \"wedding\""; else - echo " \"wedding"; + echo " \"wedding"; if(ereg("solo",$GT) && $party=="re") { if(ereg("queen",$GT)) - echo " \"$GT\""; + echo " \"$GT\""; else if(ereg("jack",$GT)) - echo " \"$GT\""; + echo " \"$GT\""; else if(ereg("club",$GT)) - echo " \"$GT\""; + echo " \"$GT\""; else if(ereg("spade",$GT)) - echo " \"$GT\""; + echo " \"$GT\""; else if(ereg("heart",$GT)) - echo " \"$GT\""; + echo " \"$GT\""; else if(ereg("trumpless",$GT)) - echo " \"$GT\""; + echo " \"$GT\""; else if(ereg("trump",$GT)) - echo " \"$GT\""; + echo " \"$GT\""; } /* add point calls */ if($call!=NULL) { if($party=="re") - echo " \"re\""; + echo " \"re\""; else - echo " \"contra\""; + echo " \"contra\""; switch($call) { case "0": - echo " \"0\""; + echo " \"0\""; break; case "30": - echo " \"30\""; + echo " \"30\""; break; case "60": - echo " \"60\""; + echo " \"60\""; break; case "90": - echo " \"90\""; + echo " \"90\""; break; } } echo "
\n"; - echo " local time\n"; - echo " last login\n"; + echo " time info\n"; echo " \n"; } @@ -939,11 +939,12 @@ function generate_score_table($session) foreach($gameids as $gameid) { $re_score = DB_get_score_by_gameid($gameid); + $gametype = DB_get_gametype_by_gameid($gameid); foreach($player as $id=>$points) { $party = DB_get_party_by_gameid_and_userid($gameid,$id); if($party == "re") - if(DB_get_gametype_by_gameid($gameid)=="solo") + if($gametype=="solo") $player[$id] += 3*$re_score; else $player[$id] += $re_score; @@ -953,7 +954,7 @@ function generate_score_table($session) $score[$i]['gameid'] = $gameid ; $score[$i]['players'] = $player; $score[$i]['points'] = abs($re_score); - $score[$i]['solo'] = (DB_get_gametype_by_gameid($gameid)=="solo"); + $score[$i]['solo'] = ($gametype=="solo"); $i++; } @@ -982,12 +983,14 @@ function generate_global_score_table() foreach($gameids as $gameid) { $re_score = DB_get_score_by_gameid($gameid); + $gametype = DB_get_gametype_by_gameid($gameid); + /* TODO: this shouldn't loop over all players, just the 4 players that are in the game */ foreach($player as $key=>$pl) { $party = DB_get_party_by_gameid_and_userid($gameid,$pl['id']); if($party == "re") - if(DB_get_gametype_by_gameid($gameid)=="solo") + if($gametype=="solo") $player[$key]['points'] += 3*$re_score; else $player[$key]['points'] += $re_score; @@ -1070,39 +1073,60 @@ function format_score_table_html($score,$userid) if(sizeof($score)==0) return ""; - $output = "
\n\n \n \n"; + $output = "
\n
\n"; /* output header */ - $output.= " "; + $header = ""; + $header.= " \n \n"; + $header.= " "; foreach($score[0]['players'] as $id=>$points) { $name = DB_get_name('userid',$id); /*TODO*/ - $output.= ""; + $header.= ""; } - $output.="\n \n \n \n"; + $header.="\n \n \n"; + /* use the same as footer */ + $footer = ""; + $footer.= " \n \n"; + $footer.= " "; + foreach($score[0]['players'] as $id=>$points) + { + $name = DB_get_name('userid',$id); /*TODO*/ + $footer.= ""; + } + $footer.="\n \n \n"; + + /* body */ + $body = ""; + $body.= " \n"; $i=0; foreach($score as $game) { $i++; - $output.=" "; + $body.=" "; $userhash = DB_get_hash_from_gameid_and_userid($game['gameid'],$userid); /* create link to old games only if you are logged in and its your game*/ if(isset($_SESSION['id']) && $_SESSION['id']==$userid) - $output.=" "; + $body.=" "; else - $output.=" "; + $body.=" "; foreach($game['players'] as $id=>$points) - $output.=""; - $output.=""; + $body.="\n"; + $body.= " S"; + $body.="\n"; } + $output.=$header; + if($i>12) + $output.=$footer; + $output.=$body; + $output.=" \n
No
No ".substr($name,0,2)." ".substr($name,0,2)." P
P
No ".substr($name,0,2)." P
$i $i$i$i".$points."".$game['points']; + $body.="".$points."".$game['points']; /* check for solo */ if($game['solo']) - $output.= " S"; - $output.="
\n
\n"; return $output;