summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2007-06-29 19:18:51 +0200
committerArun Persaud <arun@nubati.net>2007-07-18 22:53:13 -0700
commit35687ace49ce0b41b1380603513d1f04cd6b458f (patch)
tree7fdc8d2f9a63998b463812fe8e0452ddf8f71131
parentb5f096688faaebf7846b3e725e1bd2dd9251b203 (diff)
downloade-DoKo-35687ace49ce0b41b1380603513d1f04cd6b458f.tar.gz
e-DoKo-35687ace49ce0b41b1380603513d1f04cd6b458f.tar.bz2
e-DoKo-35687ace49ce0b41b1380603513d1f04cd6b458f.zip
NEW FEATURE+BUGFIX: changed calling re/contra
you can call re/contra, etc. now even if it is not your turn. Also fixed rule where you can say 90 with 9 cards, etc. so that you need to say 120 to say 90, 90 to say 60, etc.
-rw-r--r--db.php41
-rw-r--r--functions.php46
-rw-r--r--index.php21
-rw-r--r--output.php22
4 files changed, 108 insertions, 22 deletions
diff --git a/db.php b/db.php
index 21a77f8..03de7f4 100644
--- a/db.php
+++ b/db.php
@@ -842,4 +842,45 @@ function DB_get_current_playid($gameid)
return "";
}
+function DB_get_call_by_hash($hash)
+{
+ $queryresult = mysql_query("SELECT point_call FROM Hand WHERE hash='$hash'");
+
+ $r = mysql_fetch_array($queryresult,MYSQL_NUM);
+ if($r)
+ return $r[0];
+
+ return NULL;
+}
+
+function DB_get_partner_call_by_hash($hash)
+{
+ $partner = DB_get_partner_hash_by_hash($hash);
+
+ if($partner)
+ {
+ $queryresult = mysql_query("SELECT point_call FROM Hand WHERE hash='$partner'");
+
+ $r = mysql_fetch_array($queryresult,MYSQL_NUM);
+ if($r)
+ return $r[0];
+ }
+
+ return NULL;
+}
+
+function DB_get_partner_hash_by_hash($hash)
+{
+ $gameid = DB_get_gameid_by_hash($hash);
+ $party = DB_get_party_by_hash($hash);
+
+ $queryresult = mysql_query("SELECT hash FROM Hand WHERE game_id='$gameid' AND party='$party' AND hash<>'$hash'");
+
+ $r = mysql_fetch_array($queryresult,MYSQL_NUM);
+ if($r)
+ return $r[0];
+
+ return NULL;
+}
+
?> \ No newline at end of file
diff --git a/functions.php b/functions.php
index 66cc57f..af34345 100644
--- a/functions.php
+++ b/functions.php
@@ -526,10 +526,16 @@ function can_call($what,$hash)
{
global $RULES;
- /*TODO: check if this already has been call by teammate */
-
$gameid = DB_get_gameid_by_hash($hash);
$gametype = DB_get_gametype_by_gameid($gameid);
+ $oldcall = DB_get_call_by_hash($hash);
+ $pcall = DB_get_partner_call_by_hash($hash);
+
+ if( ($pcall!=NULL && $what >= $pcall) ||
+ ($oldcall!=NULL && $what >=$oldcall) )
+ {
+ return 0;
+ }
$NRcards = count(DB_get_hand($hash));
@@ -560,8 +566,40 @@ function can_call($what,$hash)
return 1;
break;
case "9-cards":
- if( ($what/10) <= $NRcards + $offset)
- return 1;
+
+ if($oldcall!=NULL && $pcall!=NULL)
+ $mincall = ($oldcall>$pcall) ? $pcall : $oldcall;
+ else if($oldcall!=NULL)
+ $mincall = $oldcall;
+ else if ($pcall!=NULL)
+ $mincall = $pcall;
+ else
+ $mincall = -1;
+
+ if( 12 <= ($NRcards + $offset))
+ {
+ return 1;
+ }
+ else if ( 9 <= ($NRcards + $offset))
+ {
+ if( ($mincall>=0 && $mincall==120) )
+ return 1;
+ }
+ else if ( 6 <= ($NRcards + $offset))
+ {
+ if( ($mincall>=0 && $mincall<=90 && $what<=60 ) )
+ return 1;
+ }
+ else if ( 3 <= ($NRcards + $offset))
+ {
+ if( ($mincall>=0 && $mincall<=60 && $what<=30 ) )
+ return 1;
+ }
+ else if ( 0 <= ($NRcards + $offset))
+ {
+ if( ($mincall>=0 && $mincall<=30 && $what==0 ) )
+ return 1;
+ };
break;
}
diff --git a/index.php b/index.php
index 1d6dfff..08ae14c 100644
--- a/index.php
+++ b/index.php
@@ -1564,24 +1564,8 @@ else if(myisset("me"))
display_link_card($card,$PREF["cardset"]);
}
- if( can_call(120,$me) )
- echo " re/contra (120):".
- " <input type=\"radio\" name=\"call120\" value=\"yes\" /> ";
- if( can_call(90,$me) )
- echo " 90:".
- " <input type=\"radio\" name=\"call90\" value=\"yes\" /> ";
- if( can_call(60,$me) )
- echo " 60:".
- " <input type=\"radio\" name=\"call60\" value=\"yes\" /> ";
- if( can_call(30,$me) )
- echo " 30:".
- " <input type=\"radio\" name=\"call30\" value=\"yes\" /> ";
- if( can_call(0,$me) )
- echo " 0:".
- " <input type=\"radio\" name=\"call0\" value=\"yes\" /> ".
- " no call:".
- " <input type=\"radio\" name=\"call0\" value=\"no\" /> ";
-
+ output_form_calls($me);
+
echo "<br />\nA short comment:<input name=\"comment\" type=\"text\" size=\"30\" maxlength=\"100\" />\n";
echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
echo "<input type=\"submit\" value=\"submit\" />\n";
@@ -1594,6 +1578,7 @@ else if(myisset("me"))
display_card($card,$PREF["cardset"]);
echo "<form action=\"index.php?me=$me\" method=\"post\">\n";
+ output_form_calls($me);
echo "<br />\nA short comment:<input name=\"comment\" type=\"text\" size=\"30\" maxlength=\"100\" />\n";
echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
echo "<input type=\"submit\" value=\"submit\" />\n";
diff --git a/output.php b/output.php
index 9919a97..89aedff 100644
--- a/output.php
+++ b/output.php
@@ -240,6 +240,28 @@ function output_check_for_sickness($me,$mycards)
return;
}
+function output_form_calls($me)
+{
+ if( can_call(120,$me) )
+ echo " re/contra (120):".
+ " <input type=\"radio\" name=\"call120\" value=\"yes\" /> <br />";
+ if( can_call(90,$me) )
+ echo " 90:".
+ " <input type=\"radio\" name=\"call90\" value=\"yes\" /> <br />";
+ if( can_call(60,$me) )
+ echo " 60:".
+ " <input type=\"radio\" name=\"call60\" value=\"yes\" /> ";
+ if( can_call(30,$me) )
+ echo " 30:".
+ " <input type=\"radio\" name=\"call30\" value=\"yes\" /> ";
+ if( can_call(0,$me) )
+ echo " 0:".
+ " <input type=\"radio\" name=\"call0\" value=\"yes\" /> ".
+ " no call:".
+ " <input type=\"radio\" name=\"call0\" value=\"no\" /> ";
+}
+
+
function output_check_want_to_play($me)
{
?>