From 0aad6312c31c9f3e4e35978db636b2848e32afde Mon Sep 17 00:00:00 2001 From: Oliver Auth Date: Sun, 19 Aug 2012 23:19:44 +0200 Subject: [PATCH] Final attempt to solve the NMR/CD option in gamecreate... --- gamecreate.php | 7 ++-- gamepanel/game.php | 9 ++--- locales/English/gamecreate.php | 63 +++++++++++++++++++++++++--------- objects/game.php | 4 +-- 4 files changed, 58 insertions(+), 25 deletions(-) diff --git a/gamecreate.php b/gamecreate.php index a5893fc12..2c3b83836 100755 --- a/gamecreate.php +++ b/gamecreate.php @@ -146,12 +146,13 @@ $input['targetSCs'] = (int)$input['targetSCs']; $input['countryID'] = (int)$input['countryID']; - if ( $input['specialCDturn'] == '∞' ) $input['specialCDturn'] = 999; $input['specialCDturn'] = (int)$input['specialCDturn']; - if ( $input['specialCDturn'] < 0 ) $input['specialCDturn'] = 0; + if ( $input['specialCDturn'] < 0 ) $input['specialCDturn'] = 0; + if ( $input['specialCDturn'] > 99 ) $input['specialCDturn'] = 99; $input['specialCDcount'] = (int)$input['specialCDcount']; - if ( $input['specialCDcount'] < 0 ) $input['specialCDcount'] = 0; + if ( $input['specialCDcount'] < 0 ) $input['specialCDcount'] = 0; + if ( $input['specialCDcount'] > 99 ) $input['specialCDcount'] = 99; // Create Game record & object require_once('gamemaster/game.php'); diff --git a/gamepanel/game.php b/gamepanel/game.php index b4705c87c..577118a86 100755 --- a/gamepanel/game.php +++ b/gamepanel/game.php @@ -263,16 +263,17 @@ function gameVariants() { $alternatives[]='WTA'; // The NMR-policy defaults - if( $this->specialCDturn != Config::$specialCDturnsDefault && $this->specialCDcount != Config::$specialCDcountDefault && $this->specialCDturn >= $this->turn) + if( ($this->specialCDturn != Config::$specialCDturnsDefault || $this->specialCDcount != Config::$specialCDcountDefault) && $this->specialCDturn >= $this->turn) { - if ( $this->specialCDturn == 0 && $this->specialCDcount == 0 ) + if ( $this->specialCDturn == 0 ) $alternatives[]='NMR: Off'; elseif( $this->specialCDturn == 5 && $this->specialCDcount == 2 ) $alternatives[]='NMR: Committed'; - elseif( $this->specialCDturn == 99 && $this->specialCDcount == 5 ) + elseif( $this->specialCDturn > 90 && $this->specialCDcount > 90 ) $alternatives[]='NMR: Serious'; else - $alternatives[]='NMR:'.$this->specialCDturn.'/'.$this->specialCDcount; + + $alternatives[]='NMR:'.($this->specialCDturn > 90 ? '∞' : $this->specialCDturn).'/'.($this->specialCDcount > 90 ? '∞' : ($this->specialCDcount == 0 ? 'off' : $this->specialCDcount)); } // Show the end of the game in the options if set. diff --git a/locales/English/gamecreate.php b/locales/English/gamecreate.php index 5ad8b6719..6343d863d 100755 --- a/locales/English/gamecreate.php +++ b/locales/English/gamecreate.php @@ -307,34 +307,66 @@ function changeMinPhases(i){ NMR policy:
  • + 99 ? '∞' : Config::$specialCDturnsDefault) ); + $specialCDcountTxt = ( Config::$specialCDcountDefault == 0 ? 'off' : (Config::$specialCDcountDefault > 99 ? '∞' : Config::$specialCDcountDefault) ); + ?> + + + + + + - - Turns: - - Delay: + - Turns: - Delay:
  • @@ -343,8 +375,7 @@ function changeMinPhases(i){
  • Turns: How many turns this action will be in effect for.
  • Delay: How much time to advertise and find a replacement player (the current phase will be extended by the current phase length that many times).
  • - Attention: A custom entered "0" for deleay will not turn this feature off, but delay the processing till a replacement is found. -

    Default: / +
    Default: /
  • diff --git a/objects/game.php b/objects/game.php index cfa646ee7..cd7ac256f 100755 --- a/objects/game.php +++ b/objects/game.php @@ -557,7 +557,7 @@ function needsProcess() $search = 'Missing orders for '.$this->Variant->turnAsDate($this->turn).' ('.$this->phase.')'; $sql='SELECT COUNT(*) FROM wD_GameMessages WHERE message LIKE "%'.$search.'%" AND toCountryID = 0 AND fromCountryID = 0 AND gameID='.$this->id; list($extCount)=$DB->sql_row($sql); - if ($extCount < $this->specialCDcount || $this->specialCDcount == 0) + if ($extCount < $this->specialCDcount || $this->specialCDcount > 90) { $this->processTime = time() + $this->phaseMinutes*60; $this->minimumBet = $this->Members->pointsLowestCD(); @@ -568,7 +568,7 @@ function needsProcess() WHERE id = ".$this->id); $gameMasterText = 'Missing orders for '.$this->Variant->turnAsDate($this->turn).' ('.$this->phase.'). Extending phase.'; $repeat = $this->specialCDcount - $extCount - 1; - if ($this->specialCDcount == 0) + if ($this->specialCDcount > 90) $gameMasterText .= 'The phase will extend again till you find a replacement.'; elseif ($repeat > 0) $gameMasterText .= 'The phase will extend '.$repeat.' time'.($repeat > 1 ? 's':'').' again if you do not find a replacement.';