forum.webdiplomacy.net

webDip dev coordination forum / public access todo list
It is currently Mon Sep 25, 2017 12:52 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Anonymous draw votes
PostPosted: Tue Feb 25, 2014 12:55 am 
Offline

Joined: Sat Feb 01, 2014 5:49 pm
Posts: 7
See this discussion on the forum: http://webdiplomacy.net/forum.php?viewthread=1104684

Summary: It would be nice to have an option at game creation to have anonymous draw votes.

I've implemented this option. The implementation involves minor changes to the following files:
- gamecreate.php
- gamemaster/game.php
- gamepanel/game.php
- gamepanel/member.php
- install/install.sql
- locales/English/gamecreate.php
- objects/game.php

The diff for these changes is at the bottom of this post. Note that the changes to locales/English/gamecreate.php would have to be made to other locales as well. I don't speak Italian though. I'm not sure if this is the preferred format to submit a mod. If not, please tell me how to submit it.

In addition the following lines should be included in the next update.sql:
Code:
ALTER TABLE `wD_Backup_Games` ADD `anonDraw` ENUM( 'Yes', 'No' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'No' AFTER `pressType`;
ALTER TABLE `wD_Games` ADD `anonDraw` ENUM( 'Yes', 'No' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'No' AFTER `pressType`;

Diff for modified files:
Code:
diff --git a/gamecreate.php b/gamecreate.php
index 70e7b9f..3877539 100755
--- a/gamecreate.php
+++ b/gamecreate.php
@@ -49,7 +49,7 @@ if( isset($_REQUEST['newGame']) and is_array($_REQUEST['newGame']) )
                $form = $_REQUEST['newGame']; // This makes $form look harmless when it is unsanitized; the parameters must all be sanitized
 
                $input = array();
-               $required = array('variantID', 'name', 'password', 'passwordcheck', 'bet', 'potType', 'phaseMinutes', 'joinPeriod', 'anon', 'pressType', 'missingPlayerPolicy');
+               $required = array('variantID', 'name', 'password', 'passwordcheck', 'bet', 'potType', 'phaseMinutes', 'joinPeriod', 'anon', 'pressType', 'anonDraw', 'missingPlayerPolicy');
 
                if ( !isset($form['missingPlayerPolicy']) )
                        $form['missingPlayerPolicy'] = 'Normal';
@@ -106,6 +106,7 @@ if( isset($_REQUEST['newGame']) and is_array($_REQUEST['newGame']) )
                }
               
                $input['anon'] = ( (strtolower($input['anon']) == 'yes') ? 'Yes' : 'No' );
+               $input['anonDraw'] = ( (strtolower($input['anonDraw']) == 'yes') ? 'Yes' : 'No' );
               
                switch($input['pressType']) {
                        case 'PublicPressOnly':
@@ -139,6 +140,7 @@ if( isset($_REQUEST['newGame']) and is_array($_REQUEST['newGame']) )
                        $input['joinPeriod'],
                        $input['anon'],
                        $input['pressType'],
+                       $input['anonDraw'],
                        $input['missingPlayerPolicy']);
 
                // Create first Member record & object
diff --git a/gamemaster/game.php b/gamemaster/game.php
index deb5624..a93824f 100755
--- a/gamemaster/game.php
+++ b/gamemaster/game.php
@@ -286,7 +286,7 @@ class processGame extends Game
         *
         * @return Game The object corresponding to the new game
         */
-       public static function create($variantID, $name, $password, $bet, $potType, $phaseMinutes, $joinPeriod, $anon, $press, $missingPlayerPolicy='Normal')
+       public static function create($variantID, $name, $password, $bet, $potType, $phaseMinutes, $joinPeriod, $anon, $press, $anonDraw, $missingPlayerPolicy='Normal')
        {
                global $DB;
 
@@ -322,6 +322,7 @@ class processGame extends Game
                                                minimumBet = ".$bet.",
                                                anon = '".$anon."',
                                                pressType = '".$press."',
+                                               anonDraw = '".$anonDraw."',
                                                ".( $password ? "password = UNHEX('".md5($password)."')," : "").
                                                "processTime = ".$pTime.",
                                                phaseMinutes = ".$phaseMinutes.",
diff --git a/gamepanel/game.php b/gamepanel/game.php
index afc9f81..5d411b1 100755
--- a/gamepanel/game.php
+++ b/gamepanel/game.php
@@ -262,6 +262,8 @@ class panelGame extends Game
                        $alternatives[]=l_t('Anonymous players');
                if( $this->potType=='Winner-takes-all' )
                        $alternatives[]=l_t($this->potType);
+               if( $this->anonDraw=='Yes' )
+                       $alternatives[]=l_t('Anonymous draw votes');
                if( $this->missingPlayerPolicy=='Wait' )
                        $alternatives[]=l_t('Wait for orders');
 
diff --git a/gamepanel/member.php b/gamepanel/member.php
index 5f511dd..1dabe25 100755
--- a/gamepanel/member.php
+++ b/gamepanel/member.php
@@ -361,7 +361,7 @@ class panelMember extends Member
                {
                        if ( $voteName == 'Pause' && $this->Game->processStatus=='Paused' )
                                $voteName = 'Unpause';
-                       $buf[]=l_t($voteName);
+                       if ($this->Game->anonDraw == 'No' || $voteName != 'Draw') $buf[]=l_t($voteName);
                }
 
                if( count($buf) )
diff --git a/install/install.sql b/install/install.sql
index 88c2e48..a68a27b 100755
--- a/install/install.sql
+++ b/install/install.sql
@@ -56,6 +56,7 @@ CREATE TABLE `wD_Backup_Games` (
   `phaseMinutes` smallint(5) unsigned NOT NULL DEFAULT '1440',
   `anon` enum('Yes','No') CHARACTER SET utf8 NOT NULL DEFAULT 'No',
   `pressType` enum('Regular','PublicPressOnly','NoPress') CHARACTER SET utf8 NOT NULL DEFAULT 'Regular',
+  `anonDraw` enum('Yes','No') CHARACTER SET utf8 NOT NULL DEFAULT 'No',
   `attempts` smallint(5) unsigned NOT NULL DEFAULT '0',
   `missingPlayerPolicy` enum('Normal','Strict') CHARACTER SET utf8 NOT NULL DEFAULT 'Normal'
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@@ -273,6 +274,7 @@ CREATE TABLE `wD_Games` (
   `phaseMinutes` smallint(5) unsigned NOT NULL DEFAULT '1440',
   `anon` enum('Yes','No') NOT NULL DEFAULT 'No',
   `pressType` enum('Regular','PublicPressOnly','NoPress') NOT NULL DEFAULT 'Regular',
+  `anonDraw` enum('Yes','No') CHARACTER SET utf8 NOT NULL DEFAULT 'No',
   `attempts` smallint(5) unsigned NOT NULL DEFAULT '0',
   `missingPlayerPolicy` enum('Normal','Strict') NOT NULL DEFAULT 'Normal',
   PRIMARY KEY (`id`),
diff --git a/locales/English/gamecreate.php b/locales/English/gamecreate.php
index 63e80f7..48f4cd4 100755
--- a/locales/English/gamecreate.php
+++ b/locales/English/gamecreate.php
@@ -191,6 +191,19 @@ else
        </li>
 
        <li class="formlisttitle">
+               Anonymous draw votes:
+       </li>
+       <li class="formlistfield">
+               <input type="radio" name="newGame[anonDraw]" value="No" checked>No
+               <input type="radio" name="newGame[anonDraw]" value="Yes">Yes
+       </li>
+       <li class="formlistdesc">
+               If enabled players will not see each others draw votes.<br /><br />
+
+               <strong>Default:</strong> No, draw votes aren't anonymous
+       </li>
+
+       <li class="formlisttitle">
                Joining pre-game period length: (5 minutes - 10 days)
        </li>
        <li class="formlistfield">
diff --git a/objects/game.php b/objects/game.php
index 66a5aad..af94162 100755
--- a/objects/game.php
+++ b/objects/game.php
@@ -202,6 +202,13 @@ class Game
         */
        public $pressType;
 
+       /**
+        * Anonymous draw votes or not, Yes or No
+        *
+        * @var string
+        */
+       public $anonDraw;
+
        public $lockMode='';
 
        /**
@@ -327,6 +334,7 @@ class Game
                        g.minimumBet,
                        g.anon,
                        g.pressType,
+                       g.anonDraw,
                        g.missingPlayerPolicy
                        FROM wD_Games g
                        WHERE g.id=".$this->id.' '.$this->lockMode);


Top
 Profile  
 
 Post subject: Re: Anonymous draw votes
PostPosted: Tue Feb 25, 2014 8:49 am 
Offline

Joined: Sat Feb 01, 2014 5:49 pm
Posts: 7
I have created a fork on github and branched it with the changes. The fork is at https://github.com/oscarjd74/webDiplomacy and the branch is called anondraw. I hope this helps if anyone wants to test this on their install. I'm kind of a github noob so help me out if I need to change anything for this to be mergeable. Also note that after you've merged this you'll still have to add the anonDraw column to the wD_Games and wD_Backup_Games tables as per the SQL code in the OP.


Top
 Profile  
 
 Post subject: Re: Anonymous draw votes
PostPosted: Tue Feb 25, 2014 12:38 pm 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
Hi oscar.
Instead of the original webdip-code you have forked my vDip-code (this is already a quite heavily patched webdip-fork).. :-)
That said I will integrate your changes soon in my installation. Thanks.


Top
 Profile  
 
 Post subject: Re: Anonymous draw votes
PostPosted: Tue Feb 25, 2014 1:33 pm 
Offline

Joined: Sat Feb 01, 2014 5:49 pm
Posts: 7
Thanks for warning me of this Sleepcap. However, I had already noticed it. I deleted the incorrect fork and forked Kestas' repository instead. So, unless I'm mistaken, it should be correctly forked of the original webdip code. Anyway, I look forward to your feedback once you have merged it into your install and tested it.


Top
 Profile  
 
 Post subject: Re: Anonymous draw votes
PostPosted: Fri Feb 28, 2014 1:57 pm 
Offline
Site Admin

Joined: Sat Jun 28, 2008 6:24 am
Posts: 892
Nice change oscar, looks comprehensive and ready to be patched in. I'll add a note for the weekend after next to get my dev server back up and running and to put this into the main install.

Since you're a new contributor I'll need to carefully pick over the code etc before putting it live so I can't push a button and do it (I've been stung doing that in the past), but at a glance it looks fine so I doubt it'll be much trouble to put it in


Top
 Profile  
 
 Post subject: Re: Anonymous draw votes
PostPosted: Fri Feb 28, 2014 8:09 pm 
Offline

Joined: Sat Feb 01, 2014 5:49 pm
Posts: 7
Thanks Kestas. And yeah sure, I understand that you need to be a bit cautious with new contributors. In fact I'd appreciate the feedback if you have any.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group