summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2008-06-01 01:17:36 -0700
committerArun Persaud <arun@nubati.net>2008-06-01 01:17:36 -0700
commit077ab356084fa26910200f28a9cd44a954f291eb (patch)
treee730e93102b9179b8036b8c1165ec5e1b8e6b07e /include
parent0049ad8507bb304c0f755dd156fd5f3082b1d6b5 (diff)
downloade-DoKo-077ab356084fa26910200f28a9cd44a954f291eb.tar.gz
e-DoKo-077ab356084fa26910200f28a9cd44a954f291eb.tar.bz2
e-DoKo-077ab356084fa26910200f28a9cd44a954f291eb.zip
LAYOUT: moved score table and rules to the top
removed more of the side layout into the top session bar. removed the list of games in a session and have it now accessable via the score table Signed-off-by: Arun Persaud <arun@nubati.net>
Diffstat (limited to 'include')
-rw-r--r--include/functions.php131
-rw-r--r--include/game.php71
-rw-r--r--include/output.php8
3 files changed, 127 insertions, 83 deletions
diff --git a/include/functions.php b/include/functions.php
index 7b29a28..fafcf36 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -863,7 +863,7 @@ function display_user_menu()
echo "<div class=\"usermenu\">\n";
echo "It's your turn in these games:<br />\n";
}
-
+
$i++;
echo "<a href=\"".$INDEX."?action=game&amp;me=".$r[0]."\">game ".DB_format_gameid($r[1])." </a><br />\n";
if($i>4)
@@ -880,14 +880,20 @@ function display_user_menu()
function generate_score_table($session)
{
+ /* returns an array with N entries
+ * $score[$i]["gameid"] = gameid
+ * $score[$i]["players"] = array (id=>total points)
+ * $score[$i]["points"] = points for this game
+ * $score[$i]["solo"] = 1 or 0
+ */
+ $score = array();
+ $i=0;
+
/* get all ids */
$gameids = DB_get_gameids_of_finished_games_by_session($session);
if($gameids == NULL)
- return "";
-
- $output = "<div class=\"scoretable\">\n<table class=\"score\">\n <tr>\n";
-
+ return $score;
/* get player id, names... from the first game */
$player = array();
@@ -895,42 +901,32 @@ function generate_score_table($session)
" LEFT JOIN User On Hand.user_id=User.id".
" WHERE Hand.game_id=".$gameids[0]);
while( $r = DB_fetch_array($result))
- {
- $player[] = array( 'id' => $r[0], 'points' => 0 );
- $output.= " <td> ".substr($r[1],0,2)." </td>\n";
- }
- $output.=" <td>P</td>\n </tr>\n";
+ $player[$r[0]] = 0;
/* get points and generate table */
foreach($gameids as $gameid)
{
- $output.=" <tr>\n";
-
$re_score = DB_get_score_by_gameid($gameid);
- foreach($player as $key=>$pl)
+ foreach($player as $id=>$points)
{
- $party = DB_get_party_by_gameid_and_userid($gameid,$pl['id']);
+ $party = DB_get_party_by_gameid_and_userid($gameid,$id);
if($party == "re")
if(DB_get_gametype_by_gameid($gameid)=="solo")
- $player[$key]['points'] += 3*$re_score;
+ $player[$id] += 3*$re_score;
else
- $player[$key]['points'] += $re_score;
+ $player[$id] += $re_score;
else if ($party == "contra")
- $player[$key]['points'] -= $re_score;
-
- $output.=" <td>".$player[$key]['points']."</td>\n";
+ $player[$id] -= $re_score;
}
- $output.=" <td>".abs($re_score);
+ $score[$i]['gameid'] = $gameid ;
+ $score[$i]['players'] = $player;
+ $score[$i]['points'] = abs($re_score);
+ $score[$i]['solo'] = (DB_get_gametype_by_gameid($gameid)=="solo");
- /* check for solo */
- if(DB_get_gametype_by_gameid($gameid)=="solo")
- $output.= " S";
- $output.="</td>\n </tr>\n";
+ $i++;
}
- $output.="</table></div>\n";
-
- return $output;
+ return $score;
}
function generate_global_score_table()
@@ -994,6 +990,87 @@ function generate_global_score_table()
return $return;
}
+function format_score_table_ascii($score)
+{
+ $output="";
+ if(sizeof($score)==0)
+ return "";
+
+ // if(sizeof($score)>5) $header.= " ... \n";
+
+ /* output header */
+ foreach($score[0]['players'] as $id=>$points)
+ {
+ $name = DB_get_name('userid',$id); /*TODO*/
+ $output.= " ".substr($name,0,2)." |";
+ }
+ $output.=" P |\n ";
+ $output.= "------+------+------+------+------+\n";
+
+ $max = sizeof($score);
+ $i=0;
+
+ if($i<$max-6) $output.=" ...\n";
+
+ foreach($score as $game)
+ {
+ $i++;
+ if($i-1<$max-6) continue;
+ foreach($game['players'] as $id=>$points)
+ $output.=str_pad($points,6," ",STR_PAD_LEFT)."|";
+ $output.=str_pad($game['points'],4," ",STR_PAD_LEFT);
+
+ /* check for solo */
+ if($game['solo'])
+ $output.= " S|";
+ else
+ $output.= " |";
+
+ $output.="\n";
+ }
+ return $output;
+}
+
+function format_score_table_html($score,$userid)
+{
+ global $INDEX;
+
+ if(sizeof($score)==0)
+ return "";
+
+ $output = "<div class=\"scoretable\">\n<table class=\"score\">\n <thead><tr>\n";
+
+ /* output header */
+ $output.= " <th> Nr </th>";
+ foreach($score[0]['players'] as $id=>$points)
+ {
+ $name = DB_get_name('userid',$id); /*TODO*/
+ $output.= "<th> ".substr($name,0,2)." </th>";
+ }
+ $output.="<th>P</th>\n </tr>\n</thead>\n<tbody>\n";
+
+ $i=0;
+ foreach($score as $game)
+ {
+ $i++;
+ $output.=" <tr>";
+ $userhash = DB_get_hash_from_gameid_and_userid($game['gameid'],$userid);
+ $output.=" <td> <a href=\"".$INDEX."?action=game&amp;me=".$userhash."\">$i</a></td>";
+ foreach($game['players'] as $id=>$points)
+ $output.="<td>".$points."</td>";
+ $output.="<td>".$game['points'];
+
+ /* check for solo */
+ if($game['solo'])
+ $output.= " S";
+ $output.="</td></tr>\n";
+ }
+
+ $output.="</tbody>\n</table></div>\n";
+
+ return $output;
+}
+
?>
diff --git a/include/game.php b/include/game.php
index 3fbc451..4f506f5 100644
--- a/include/game.php
+++ b/include/game.php
@@ -112,18 +112,28 @@ echo "<form action=\"index.php?action=game&amp;me=$me\" method=\"post\">\n";
/* output extra division in case this game is part of a session */
if($session)
{
- echo "<div class=\"session\">\n".
- "This game is part of session $session: \n";
+ echo "<div class=\"session\">\n";
+ echo " <div class=\"sessionrules\">Rules (+icons fur rules) \n";
+ echo " <div>\n";
+ echo " 10ofhearts : ".$RULES["dullen"] ."<br />\n";
+ echo " schweinchen: ".$RULES["schweinchen"] ."<br />\n";
+ echo " call: ".$RULES["call"] ."<br />\n";
+ echo " </div>\n </div>\n";
+ echo " <div class=\"sessionscore\">Score \n";
+ $score = generate_score_table($session);
+ echo format_score_table_html($score,$myid);
+ echo " </div>\n";
$hashes = DB_get_hashes_by_session($session,$myid);
$i = 1;
foreach($hashes as $hash)
{
- if($hash == $me)
- echo "$i \n";
- else
- echo "<a href=\"".$INDEX."?action=game&amp;me=".$hash."\">$i</a> \n";
- $i++;
+ if($hash == $me)
+ $j=$i;
+ $i++;
+ $lasthash=$hash;
}
+ $i--;
+ echo "This is game number $j of <a href=\"".$INDEX."?action=game&amp;me=$lasthash\">$i</a> in session $session.";
echo "</div>\n";
}
@@ -1649,35 +1659,9 @@ switch($mystatus)
$session = DB_get_session_by_gameid($gameid);
$score = generate_score_table($session);
- /* convert html to ascii */
- $score = str_replace("<div class=\"scoretable\">\n<table class=\"score\">\n <tr>\n","",$score);
- $score = str_replace("</table></div>\n","",$score);
- $score = str_replace("\n","",$score);
- $score = str_replace(array("<tr>","</tr>","<td>","</td>"),array("","\n","","|"),$score);
- $score = explode("\n",$score);
-
- $header = array_slice($score,0,1);
- $header = explode("|",$header[0]);
- for($i=0;$i<sizeof($header);$i++)
- $header[$i]=str_pad($header[$i],6," ",STR_PAD_BOTH);
- $header = implode("|",$header);
- $header.= "\n------+------+------+------+------+\n";
- if(sizeof($score)>5) $header.= " ... \n";
-
- if(sizeof($score)>5) $score = array_slice($score,-5,5);
- for($i=0;$i<sizeof($score);$i++)
- {
- $line = explode("|",$score[$i]);
- for($j=0;$j<sizeof($line);$j++)
- $line[$j]=str_pad($line[$j],6," ",STR_PAD_LEFT);
- $score[$i] = implode("|",$line);
- }
-
- $score = implode("\n",$score);
- $score = $header.$score;
$message .= "Score Table:\n";
- $message .= $score;
+ $message .= format_score_table_ascii($score);
/* send out final email */
$all = array();
@@ -1746,7 +1730,7 @@ switch($mystatus)
$notes = DB_get_notes_by_userid_and_gameid($myid,$gameid);
foreach($notes as $note)
echo "$note <hr />\n";
- echo "Insert note:<input name=\"note\" type=\"text\" size=\"15\" maxlength=\"100\" />\n";
+ echo "<input name=\"note\" type=\"text\" size=\"15\" maxlength=\"100\" />\n";
echo "</div> \n";
$mycards = DB_get_hand($me);
@@ -1869,15 +1853,6 @@ switch($mystatus)
/* display rule set for this game */
echo "<div class=\"gameinfo\">\n";
- if($gamestatus != 'pre')
- echo " Gametype: $GT <br />\n";
-
- echo "Rules: <br />\n";
- echo "10ofhearts : ".$RULES["dullen"] ."<br />\n";
- echo "schweinchen: ".$RULES["schweinchen"] ."<br />\n";
- echo "call: ".$RULES["call"] ."<br />\n";
-
- echo "<hr />\n";
if($gamestatus == 'play' )
output_form_calls($me);
@@ -1888,15 +1863,9 @@ switch($mystatus)
if($gamestatus == 'play' || $gameend < 60*60*24*7)
{
echo "<br />\nA short comment:<input name=\"comment\" type=\"text\" size=\"15\" maxlength=\"100\" />\n";
- echo "<hr />";
}
- echo "<input type=\"submit\" value=\"submit\" />\n<hr />\n";
-
- $session = DB_get_session_by_gameid($gameid);
- $score = generate_score_table($session);
-
- echo $score;
+ echo "<input type=\"submit\" value=\"submit\" />\n";
echo "</div>\n";
diff --git a/include/output.php b/include/output.php
index 2fcfaca..86db0a0 100644
--- a/include/output.php
+++ b/include/output.php
@@ -99,9 +99,9 @@ function output_table($data,$caption="",$class="")
$HTML = "\n<table class=\"$class\">\n";
else
$HTML = "\n<table>\n";
-
+
$i=0;
-
+
if($caption!="")
$HTML .= " <caption> $caption </caption>\n";
@@ -270,7 +270,7 @@ function output_header()
<title>e-Doko</title>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
<link rel="shortcut icon" type="image/x-icon" href="pics/edoko-favicon.png" />
- <link rel="stylesheet" type="text/css" href="css/standard005.css" />
+ <link rel="stylesheet" type="text/css" href="css/standard006.css" />
<script type="text/javascript">
var current=0;
function hl(num) {
@@ -397,8 +397,6 @@ function output_select_timezone($name,$timezone="")
return;
}
-
-
function output_password_recovery($email,$password)
{
?>