Permalink
Browse files

Fixes #99: Now there's a new press mode to match the Diplomacy rulebook.

  • Loading branch information...
1 parent 44da066 commit 24f761dc1913db3edeed21493242d40b915157de @TimothyJones TimothyJones committed Feb 1, 2016
View
@@ -62,7 +62,7 @@ public function findTab()
$msgCountryID = 0;
// Enforce Global and Notes tabs when its not Regular press game.
- if ( $Game->pressType != 'Regular' && !(isset($Member) && $Member->countryID == $msgCountryID) )
+ if ( ($Game->pressType != 'Regular' && $Game->pressType != 'RulebookPress') && !(isset($Member) && $Member->countryID == $msgCountryID) )
$msgCountryID = 0;
$_SESSION[$Game->id.'_msgCountryID'] = $msgCountryID;
@@ -94,7 +94,9 @@ public function postMessage($msgCountryID)
if ( isset($Member) &&
( $Game->pressType == 'Regular' || // All tabs allowed for Regular
- $Member->countryID == $msgCountryID || // Notes tab always allowed
+ $Member->countryID == $msgCountryID || // Notes tab always allowed
+ ($Game->pressType == 'RulebookPress' && // In rulebook press... allow
+ ($Game->phase == 'Diplomacy' || $Game->phase == 'Finished')) ||// press only in diplomacy or after the game
( $msgCountryID == 0 && // Global tab allowed for...
( $Game->pressType == 'PublicPressOnly' || // public press and
( $Game->pressType == 'NoPress' && $Game->phase == 'Finished' ))))) // finished nopress.
@@ -188,6 +190,8 @@ public function output ($msgCountryID)
( isset($Member) &&
( $Game->pressType == 'Regular' || // All tabs allowed for Regular
$Member->countryID == $msgCountryID || // Notes tab always allowed
+ ($Game->pressType == 'RulebookPress' && // In rulebook press... allow
+ ($Game->phase == 'Diplomacy' || $Game->phase == 'Finished')) ||// press only in diplomacy or after the game
( $msgCountryID == 0 && // Global tab allowed for...
( $Game->pressType == 'PublicPressOnly' || // public press and
( $Game->pressType == 'NoPress' && $Game->phase == 'Finished' )))))) // finished nopress.
@@ -219,6 +223,15 @@ public function output ($msgCountryID)
').'
</TABLE></DIV>';
}
+ else if ($Game->pressType == 'RulebookPress' && $Game->phase != 'Diplomacy' && $msgCountryID != 0) {
+ $chatbox .= '<div class="chatbox"><TABLE><TR class="barAlt2"><TD class="center">
+ <form method="post" name="markUnread" class="safeForm" action="board.php?gameID='.$Game->id.'&amp;msgCountryID='.$msgCountryID.'#chatboxanchor">
+ <input type="hidden" tabindex="2" value="" name="MarkAsUnread" />
+ </form>
+ <a href="#" onclick="document.markUnread.submit(); return false;" tabindex="3">Mark unread</a>
+ </TD></TR></TABLE></div>';
+
+ }
libHTML::$footerScript[] = '
var cbs = $("chatboxscroll");
@@ -253,7 +266,7 @@ protected function outputTabs ( $msgCountryID )
for( $countryID=0; $countryID<=count($Game->Variant->countries); $countryID++)
{
// Do not allow country specific tabs for restricted press games.
- if ($Game->pressType != 'Regular' && $countryID != 0 && $countryID != $Member->countryID ) continue;
+ if (($Game->pressType != 'Regular' && $Game->pressType != 'RulebookPress') && $countryID != 0 && $countryID != $Member->countryID ) continue;
$tabs .= ' <a href="./board.php?gameID='.$Game->id.'&amp;msgCountryID='.$countryID.'&amp;rand='.rand(1,100000).'#chatboxanchor" '.
'class="country'.$countryID.' '.( $msgCountryID == $countryID ? 'current"'
@@ -323,6 +323,7 @@ public function jsHTML() {
public function html()
{
+ global $Game;
//method="post" action="board.php?gameID='.$this->gameID.'#orders"
$html = $this->jsHTML();
@@ -341,9 +342,11 @@ public function html()
}
$html .= "</table>".'
- <div style="text-align:center;"><span id="ordersNoticeArea'.$this->memberID.'"></span>
- <input id="UpdateButton'.$this->memberID.'" type="Submit" class="form-submit spaced-button" name="'.
- l_t('Update').'" value="'.l_t('Save').'" disabled />
+ <div style="text-align:center;"><span id="ordersNoticeArea'.$this->memberID.'"></span>
+ '.
+ ($Game->pressType == 'RulebookPress' && $Game->phase != 'Diplomacy' ? '' :
+ '<input id="UpdateButton'.$this->memberID.'" type="Submit" class="form-submit spaced-button" name="'.
+ l_t('Update').'" value="'.l_t('Save').'" disabled />' ) .'
<input id="FinalizeButton'.$this->memberID.'" type="Submit" class="form-submit spaced-button" name="'.
l_t($this->orderStatus->Ready?'Not ready':'Ready').'" value="'.l_t($this->orderStatus->Ready?'Not ready':'Ready').'" disabled />
</div>
View
@@ -115,6 +115,9 @@
case 'NoPress':
$input['pressType'] = 'NoPress';
break;
+ case 'RulebookPress':
+ $input['pressType'] = 'RulebookPress';
+ break;
case 'Regular': // Regular is the default
default:
$input['pressType'] = 'Regular';
View
@@ -247,6 +247,8 @@ function gameVariants() {
$alternatives[]=$this->Variant->link();
if( $this->pressType=='NoPress')
$alternatives[]=l_t('No in-game messaging');
+ elseif( $this->pressType=='RulebookPress')
+ $alternatives[]=l_t('Rulebook press');
elseif( $this->pressType=='PublicPressOnly' )
$alternatives[]=l_t('Public messaging only');
if( $this->anon=='Yes' )
@@ -119,6 +119,8 @@ function titleBar()
$alternatives=array();
if( $this->pressType=='NoPress')
$alternatives[]=l_t('No chat');
+ elseif( $this->pressType=='RulebookPress' )
+ $alternatives[]=l_t('Rulebook chat');
elseif( $this->pressType=='PublicPressOnly' )
$alternatives[]=l_t('Public chat');
if( $this->anon=='Yes' )
@@ -483,7 +483,7 @@ class searchPressType extends searchItemCheckbox
{
public $name='pressType';
protected $label='Messaging rules';
- protected $options=array('Regular'=>'Normal', 'PublicPressOnly'=>'Public messages only', 'NoPress'=>'No messages');
+ protected $options=array('Regular'=>'Normal', 'PublicPressOnly'=>'Public messages only', 'NoPress'=>'No messages','RulebookPress'=>'Rulebook press');
function sql(&$TABLES,&$WHERE,&$ORDER)
{
@@ -24,7 +24,7 @@
defined('IN_CODE') or die('This script can not be run by itself.');
-define("VERSION", 141);
+define("VERSION", 142);
// Some integer values which are named for clarity.
@@ -47,7 +47,7 @@ function OrdersHTMLFormClass() {
else
{
this.updateFormButtons();
- this.UpdateButton.observe('click', this.onSave.bindAsEventListener(this));
+ if ( this.UpdateButton != null ) this.UpdateButton.observe('click', this.onSave.bindAsEventListener(this));
this.FinalizeButton.observe('click', this.onLock.bindAsEventListener(this));
}
}
@@ -156,16 +156,20 @@ function OrdersHTMLFormClass() {
this.buttonOff=function(buttonName){
var Button=$(buttonName+this.context.memberID);
- Button.removeClassName('form-submit');
- Button.setStyle({color:'#777777', backgroundColor:'#F5F5F5', fontWeight:'bold'});
- Button.disable();
+ if (Button != null) {
+ Button.removeClassName('form-submit');
+ Button.setStyle({color:'#777777', backgroundColor:'#F5F5F5', fontWeight:'bold'});
+ Button.disable();
+ }
};
this.buttonOn=function(buttonName){
var Button=$(buttonName+this.context.memberID);
- Button.addClassName('form-submit');
- Button.setStyle({color:'',backgroundColor:'', fontWeight:''});
- Button.enable();
+ if (Button != null) {
+ Button.addClassName('form-submit');
+ Button.setStyle({color:'',backgroundColor:'', fontWeight:''});
+ Button.enable();
+ }
};
this.updateFormButtons = function() {
@@ -443,4 +443,4 @@ function loadOrdersModel() {
MyOrders.push(OrderObj);
}
-}
+}
View
@@ -893,7 +893,7 @@ public static function likeCount($likeCount) {
static private function footerScripts() {
global $User, $Locale;
- $jsVersion = 4; // increment this to force clients to reload their JS files
+ $jsVersion = 5; // increment this to force clients to reload their JS files
$buf = '';
@@ -193,10 +193,12 @@
<input type="radio" name="newGame[pressType]" value="Regular" checked>Allow all
<input type="radio" name="newGame[pressType]" value="PublicPressOnly">Global messages only, no private chat/press
<input type="radio" name="newGame[pressType]" value="NoPress">No in-game messaging
+ <input type="radio" name="newGame[pressType]" value="RulebookPress">Per rulebook
</li>
<li class="formlistdesc">
Disable some types of messaging; allow only global in-game messages, or allow no in-game messages.
+ <br/><br/> "Per rulebook" means no discussion during builds and retreats as per the original Diplomacy rulebook. In this mode, saved retreats and builds are automatically readied for the next turn.
<br /><br /><strong>Default:</strong> Allow all
</li>
<li class="formlisttitle">
@@ -29,9 +29,14 @@
margin-left:30px;
}
</style>
+February 1st, 2016
+<ul>
+<li>New press mode: "Rulebook Press", where there is no discussion during builds and retreats, and builds/retreats are automatically readied.</li>
+</ul>
+<div class="hr"></div>
January 21st, 2016
<ul>
-<li>Now all members can see global press above the map without going to the chat archive</li>
+<li>Now all members can see global press above the map without going to the chat archive.</li>
</ul>
<div class="hr"></div>
December 30th, 2015

0 comments on commit 24f761d

Please sign in to comment.