+ for( $p=$call_re;$p<=120; $p+=30 )
+ {
+ mysql_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'against$p')");
+ }
+
+ for( $p=$call_re; $p<120; $p+=30)
+ {
+ if( $contra>=$p )
+ mysql_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'made$p')");
+ }
+ }
+
+ /* point in case contra won */
+ if($winning_party=="contra")
+ {
+ mysql_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'againstqueens')");
+ }
+
+ /* one point each for winning and each 30 points + calls */
+ if($winning_party=="re")
+ {
+ foreach(array(120,150,180,210,240) as $p)
+ {
+ $offset = 0;
+ if($p==240 || $call_contra!=NULL)
+ $offset = 1;
+
+ if($re>$p-$offset)
+ mysql_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'".(240-$p)."')");
+ }
+ /* re called something and won */
+ foreach(array(0,30,60,90,120) as $p)
+ {
+ if($call_re!=NULL && $call_re<$p+1)
+ mysql_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'call$p')");
+ }
+ }
+ else if( $winning_party=="contra")
+ {
+ foreach(array(120,150,180,210,240) as $p)
+ {
+ $offset = 0;
+ if($p==240 || $call_re!=NULL)
+ $offset = 1;
+
+ if($contra>$p-$offset)
+ mysql_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'".(240-$p)."')");
+ }
+ /* re called something and won */
+ foreach(array(0,30,60,90,120) as $p)
+ {
+ if($call_contra!=NULL && $call_contra<$p+1)
+ mysql_query("INSERT INTO Score".
+ " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'call$p')");
+ }
+ }
+
+
+ /* add score points to email */
+ $message .= "\n";
+ $Tpoint = 0;
+ $message .= " Points Re: \n";
+ $queryresult = mysql_query("SELECT score FROM Score ".
+ " WHERE game_id=$gameid AND party='re'".
+ " ");
+ while($r = mysql_fetch_array($queryresult,MYSQL_NUM) )
+ {
+ $message .= " ".$r[0]."\n";
+ $Tpoint ++;
+ }
+ $message .= " Points Contra: \n";
+ $queryresult = mysql_query("SELECT score FROM Score ".
+ " WHERE game_id=$gameid AND party='contra'".
+ " ");
+ while($r = mysql_fetch_array($queryresult,MYSQL_NUM) )
+ {
+ $message .= " ".$r[0]."\n";
+ $Tpoint --;
+ }
+ $message .= " Total Points (from Re points of view): $Tpoint\n";
+ $message .= "\n";
+
+ /* send out final email */
+ $all = array();
+
+ foreach($userids as $user)
+ $all[] = DB_get_email_by_userid($user);
+ $To = implode(",",$all);
+
+ $help = "\n\n (you can use reply all on this email to reach all the players.)\n";
+ mymail($To,$EmailName."game over (game ".DB_format_gameid($gameid).") part 1(2)",$message.$help);
+
+ foreach($userids as $user)
+ {
+ $To = DB_get_email_by_userid($user);
+ $hash = DB_get_hash_from_gameid_and_userid($gameid,$user);
+
+ $link = "Use this link to have a look at game ".DB_format_gameid($gameid).": ".$host."?me=".$hash."\n\n" ;
+ if( DB_get_email_pref_by_uid($user) != "emailaddict" )
+ mymail($To,$EmailName."game over (game ".DB_format_gameid($gameid).") part 2(2)",$link);