[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [knights] src
From:       Miha Čančula <miha.cancula () gmail ! com>
Date:       2011-01-20 9:54:25
Message-ID: 20110120095425.A483CA60CC () git ! kde ! org
[Download RAW message or body]

Git commit 3cb9a8672fdeeb77cc44137bd720b69406859c3a by Miha Čančula
Pushed by mihac into branch protocols

Start major overhaul to enable two separately configured protocols

M  +1    -1    src/CMakeLists.txt     
M  +5    -39   src/gamedialog.cpp     
M  +462  -361  src/gamedialog.ui     
M  +22   -18   src/proto/ficsprotocol.cpp     
M  +6    -27   src/proto/localprotocol.cpp     
M  +0    -3    src/proto/localprotocol.h     
M  +13   -241  src/proto/protocol.cpp     
M  +12   -48   src/proto/protocol.h     
M  +17   -27   src/proto/xboardproto.cpp     

http://commits.kde.org/knights/3cb9a8672fdeeb77cc44137bd720b69406859c3a

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 65fbd55..7c3c3ce 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(knights_SRCS proto/textprotocol.cpp
+set(knights_SRCS gamemanager.cpp proto/textprotocol.cpp
     core/pos.cpp
     core/move.cpp
     core/renderer.cpp
diff --git a/src/gamedialog.cpp b/src/gamedialog.cpp
index ad640a3..72a128d 100644
--- a/src/gamedialog.cpp
+++ b/src/gamedialog.cpp
@@ -31,22 +31,15 @@ GameDialog::GameDialog ( QWidget* parent, Qt::WindowFlags f ) : \
QWidget ( parent  ui->setupUi ( this );
     setObjectName ( QLatin1String ( "GameDialogWidget" ) );
     connect ( ui->timeGroup, SIGNAL ( toggled ( bool ) ), this, SLOT ( timeEnabled ( \
                bool ) ) );
-    connect ( ui->sameTimeCheckBox, SIGNAL ( toggled ( bool ) ), this, SLOT ( \
                sameTimeChanged ( bool ) ) );
     connect ( ui->oppHuman, SIGNAL ( toggled ( bool ) ), this, SLOT ( \
                hotseatModeToggled ( bool ) ) );
     connect ( ui->oppFics, SIGNAL ( toggled ( bool ) ), this, SLOT ( ficsModeToggled \
( bool ) ) );  
     m_timeEnabled = Settings::timeEnabled();
     ui->timeGroup->setChecked ( m_timeEnabled );
 
-    m_sameTime  = Settings::sameTime();
-    ui->sameTimeCheckBox->setChecked ( m_sameTime );
-
-    ui->playerTimeEdit->setTime ( Settings::playerTime().time() );
-    ui->oppTimeEdit->setTime ( Settings::opponentTime().time() );
-    ui->playerIncTimeEdit->setTime ( Settings::playerTimeIncrement().time() );
-    ui->oppIncTimeEdit->setTime ( Settings::opponentTimeIncrement().time() );
-    ui->playerMoves->setValue ( Settings::playerMoves() );
-    ui->oppMoves->setValue ( Settings::opponentMoves() );
+    ui->startingTimeBasic->setTime ( Settings::playerTime().time() );
+    ui->timeIncrementBasic->setTime ( Settings::playerTimeIncrement().time() );
+    ui->numberOfMovesBasic->setValue ( Settings::playerMoves() );
 
     switch ( Settings::protocol() )
     {
@@ -74,16 +67,6 @@ GameDialog::GameDialog ( QWidget* parent, Qt::WindowFlags f ) : \
QWidget ( parent  break;
     }
 
-    switch ( Settings::controlType() )
-    {
-        case Settings::EnumControlType::Conventional:
-            ui->conventionalTimeRadio->setChecked ( true );
-            break;
-        case Settings::EnumControlType::Incremental:
-            ui->incTimeRadio->setChecked ( true );
-            break;
-    }
-
     ui->programComboBox->setHistoryItems( Settings::programs() );
     ui->programComboBox->setCurrentItem( Settings::currentProgram(), true );
     ui->serverComboBox->setHistoryItems( Settings::servers() );
@@ -130,25 +113,8 @@ void GameDialog::writeConfig()
     Settings::setTimeEnabled ( timeLimitEnabled );
     if ( timeLimitEnabled )
     {
-        Settings::setSameTime ( ui->sameTimeCheckBox->isChecked() );
-        Settings::setPlayerTime ( QDateTime ( QDate::currentDate(), \
                ui->playerTimeEdit->time() ) );
-        Settings::setOpponentTime ( QDateTime ( QDate::currentDate(), \
                ui->oppTimeEdit->time() ) );
-        if ( ui->conventionalTimeRadio->isChecked() )
-        {
-            Settings::setOpponentMoves ( ui->oppMoves->value() );
-            Settings::setPlayerMoves ( ui->playerMoves->value() );
-            Settings::setControlType ( Settings::EnumControlType::Conventional );
-        }
-        else if ( ui->incTimeRadio->isChecked() )
-        {
-            Settings::setPlayerTimeIncrement ( QDateTime ( QDate::currentDate(), \
                ui->playerIncTimeEdit->time() ) );
-            Settings::setOpponentTimeIncrement ( QDateTime ( QDate::currentDate(), \
                ui->oppIncTimeEdit->time() ) );
-            Settings::setControlType ( Settings::EnumControlType::Incremental );
-        }
-        else
-        {
-            Settings::setControlType ( Settings::EnumControlType::Fixed );
-        }
+        Settings::setPlayerTime ( QDateTime ( QDate::currentDate(), \
ui->startingTimeBasic->time() ) ); +        Settings::setPlayerTimeIncrement( \
QDateTime ( QDate::currentDate(), ui->timeIncrementBasic->time() ) );  }
     Settings::self()->writeConfig();
 }
diff --git a/src/gamedialog.ui b/src/gamedialog.ui
index 709aeda..7aaf86b 100644
--- a/src/gamedialog.ui
+++ b/src/gamedialog.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>552</width>
-    <height>393</height>
+    <width>628</width>
+    <height>275</height>
    </rect>
   </property>
   <layout class="QGridLayout" name="gridLayout">
@@ -15,248 +15,402 @@
     <number>0</number>
    </property>
    <item row="3" column="0">
-    <widget class="QGroupBox" name="opponentGroup">
-     <property name="title">
-      <string>Opponent</string>
+    <widget class="QTabWidget" name="tabWidget">
+     <property name="currentIndex">
+      <number>1</number>
      </property>
-     <layout class="QVBoxLayout" name="verticalLayout">
-      <item>
-       <widget class="QRadioButton" name="oppHuman">
-        <property name="text">
-         <string>Human at the same computer</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <layout class="QHBoxLayout" name="horizontalLayout">
-        <item>
-         <widget class="QRadioButton" name="oppComp">
-          <property name="text">
-           <string>Computer engine:</string>
+     <widget class="QWidget" name="basicTab">
+      <attribute name="title">
+       <string>Normal games</string>
+      </attribute>
+      <layout class="QGridLayout" name="gridLayout_2">
+       <item row="0" column="0" colspan="2">
+        <widget class="QGroupBox" name="opponentGroup">
+         <property name="title">
+          <string>Opponent</string>
+         </property>
+         <layout class="QVBoxLayout" name="verticalLayout">
+          <item>
+           <widget class="QRadioButton" name="oppHuman">
+            <property name="text">
+             <string>Human at the same computer</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <layout class="QHBoxLayout" name="compLayout">
+            <item>
+             <widget class="QRadioButton" name="oppComp">
+              <property name="text">
+               <string>Computer engine:</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="KHistoryComboBox" name="programComboBox">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="historyItems">
+               <stringlist/>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </item>
+          <item>
+           <layout class="QHBoxLayout" name="ficsLayout">
+            <item>
+             <widget class="QRadioButton" name="oppFics">
+              <property name="text">
+               <string>Human at a chess server:</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="KHistoryComboBox" name="serverComboBox">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="historyItems">
+               <stringlist/>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item row="1" column="0">
+        <widget class="QGroupBox" name="colorGroup">
+         <property name="title">
+          <string>Your Color</string>
+         </property>
+         <layout class="QVBoxLayout" name="verticalLayout_2">
+          <item>
+           <widget class="QRadioButton" name="colorWhite">
+            <property name="text">
+             <string>White</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QRadioButton" name="colorBlack">
+            <property name="text">
+             <string>Black</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QRadioButton" name="colorRandom">
+            <property name="text">
+             <string>Choose randomly</string>
+            </property>
+            <property name="checked">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item row="1" column="1">
+        <widget class="QGroupBox" name="timeGroup">
+         <property name="title">
+          <string>Time Limit</string>
+         </property>
+         <property name="checkable">
+          <bool>true</bool>
+         </property>
+         <layout class="QFormLayout" name="formLayout_3">
+          <property name="fieldGrowthPolicy">
+           <enum>QFormLayout::ExpandingFieldsGrow</enum>
           </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="KHistoryComboBox" name="programComboBox">
-          <property name="enabled">
-           <bool>false</bool>
-          </property>
-          <property name="historyItems">
-           <stringlist/>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
-      <item>
-       <layout class="QHBoxLayout" name="horizontalLayout_3">
-        <item>
-         <widget class="QRadioButton" name="oppFics">
-          <property name="text">
-           <string>Human at a chess server:</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="KHistoryComboBox" name="serverComboBox">
-          <property name="enabled">
-           <bool>false</bool>
-          </property>
-          <property name="historyItems">
-           <stringlist/>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item row="4" column="0">
-    <widget class="QGroupBox" name="colorGroup">
-     <property name="title">
-      <string>Your Color</string>
-     </property>
-     <layout class="QHBoxLayout" name="horizontalLayout_2">
-      <item>
-       <widget class="QRadioButton" name="colorWhite">
-        <property name="text">
-         <string>White</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QRadioButton" name="colorBlack">
-        <property name="text">
-         <string>Black</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QRadioButton" name="colorRandom">
-        <property name="text">
-         <string>Choose randomly</string>
-        </property>
-        <property name="checked">
-         <bool>true</bool>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item row="6" column="0">
-    <widget class="QGroupBox" name="timeGroup">
-     <property name="title">
-      <string>Time Limit</string>
-     </property>
-     <property name="checkable">
-      <bool>true</bool>
-     </property>
-     <layout class="QVBoxLayout" name="verticalLayout_2">
-      <item>
-       <widget class="QCheckBox" name="sameTimeCheckBox">
-        <property name="text">
-         <string>Same for both players</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="KButtonGroup" name="kbuttongroup">
-        <layout class="QHBoxLayout" name="horizontalLayout_4">
-         <item>
-          <widget class="QRadioButton" name="conventionalTimeRadio">
-           <property name="text">
-            <string>Conventional</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QRadioButton" name="incTimeRadio">
-           <property name="text">
-            <string>Incremental</string>
-           </property>
-           <property name="checked">
-            <bool>true</bool>
-           </property>
-          </widget>
-         </item>
-        </layout>
-       </widget>
-      </item>
-      <item>
-       <layout class="QGridLayout" name="gridLayout_2">
-        <item row="1" column="0">
-         <widget class="QLabel" name="playerLabel">
-          <property name="text">
-           <string>Player</string>
-          </property>
-         </widget>
-        </item>
-        <item row="1" column="2">
-         <widget class="QTimeEdit" name="playerTimeEdit">
-          <property name="currentSection">
-           <enum>QDateTimeEdit::HourSection</enum>
-          </property>
-          <property name="displayFormat">
-           <string>H:mm:ss</string>
-          </property>
-         </widget>
-        </item>
-        <item row="2" column="0">
-         <widget class="QLabel" name="oppLabel">
-          <property name="text">
-           <string>Opponent</string>
-          </property>
-         </widget>
-        </item>
-        <item row="2" column="2">
-         <widget class="QTimeEdit" name="oppTimeEdit">
-          <property name="currentSection">
-           <enum>QDateTimeEdit::HourSection</enum>
-          </property>
-          <property name="displayFormat">
-           <string>H:mm:ss</string>
-          </property>
-         </widget>
-        </item>
-        <item row="1" column="4">
-         <widget class="QTimeEdit" name="playerIncTimeEdit">
-          <property name="currentSection">
-           <enum>QDateTimeEdit::HourSection</enum>
-          </property>
-          <property name="displayFormat">
-           <string>H:mm:ss</string>
-          </property>
-         </widget>
-        </item>
-        <item row="2" column="4">
-         <widget class="QTimeEdit" name="oppIncTimeEdit">
-          <property name="currentSection">
-           <enum>QDateTimeEdit::HourSection</enum>
-          </property>
-          <property name="displayFormat">
-           <string>H:mm:ss</string>
-          </property>
-         </widget>
-        </item>
-        <item row="0" column="4">
-         <widget class="QLabel" name="incrementLabel">
-          <property name="text">
-           <string>Increment per move</string>
-          </property>
-         </widget>
-        </item>
-        <item row="0" column="2">
-         <widget class="QLabel" name="startTimeLabel">
-          <property name="text">
-           <string>Starting time</string>
-          </property>
-         </widget>
-        </item>
-        <item row="0" column="1">
-         <widget class="QLabel" name="movesLabel">
-          <property name="text">
-           <string>Number of moves</string>
-          </property>
-         </widget>
-        </item>
-        <item row="1" column="1">
-         <widget class="KIntNumInput" name="playerMoves">
-          <property name="value">
-           <number>40</number>
-          </property>
-          <property name="minimum">
-           <number>1</number>
-          </property>
-          <property name="sliderEnabled">
-           <bool>false</bool>
-          </property>
-         </widget>
-        </item>
-        <item row="2" column="1">
-         <widget class="KIntNumInput" name="oppMoves">
-          <property name="value">
-           <number>40</number>
-          </property>
-          <property name="minimum">
-           <number>1</number>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
-     </layout>
+          <item row="0" column="0">
+           <widget class="QLabel" name="startingTimeLabel_3">
+            <property name="text">
+             <string>Starting &amp;Time</string>
+            </property>
+            <property name="buddy">
+             <cstring>startingTimeWhite</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="1">
+           <widget class="QTimeEdit" name="startingTimeBasic"/>
+          </item>
+          <item row="1" column="0">
+           <widget class="QLabel" name="numberOfMovesLabel_3">
+            <property name="text">
+             <string>Number of &amp;moves</string>
+            </property>
+            <property name="buddy">
+             <cstring>numberOfMovesWhite</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="1">
+           <widget class="KIntSpinBox" name="numberOfMovesBasic"/>
+          </item>
+          <item row="2" column="0">
+           <widget class="QLabel" name="timeIncrementLabel_3">
+            <property name="text">
+             <string>Time &amp;Increment</string>
+            </property>
+            <property name="buddy">
+             <cstring>timeIncrementWhite</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="2" column="1">
+           <widget class="QTimeEdit" name="timeIncrementBasic"/>
+          </item>
+         </layout>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="customTab">
+      <attribute name="title">
+       <string>Custom configuration</string>
+      </attribute>
+      <layout class="QHBoxLayout" name="horizontalLayout_5">
+       <item>
+        <widget class="QGroupBox" name="whiteBox">
+         <property name="title">
+          <string>White</string>
+         </property>
+         <layout class="QVBoxLayout" name="verticalLayout_4">
+          <item>
+           <widget class="QRadioButton" name="radioButton">
+            <property name="text">
+             <string>Human</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <layout class="QHBoxLayout" name="compLayout_2">
+            <item>
+             <widget class="QRadioButton" name="oppComp_2">
+              <property name="text">
+               <string>Computer engine:</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="KHistoryComboBox" name="programComboBox_2">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="historyItems">
+               <stringlist/>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </item>
+          <item>
+           <layout class="QHBoxLayout" name="ficsLayout_2">
+            <item>
+             <widget class="QRadioButton" name="oppFics_2">
+              <property name="text">
+               <string>Human at a chess server:</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="KHistoryComboBox" name="serverComboBox_2">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="historyItems">
+               <stringlist/>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </item>
+          <item>
+           <widget class="QGroupBox" name="timeGroup_2">
+            <property name="title">
+             <string>Time Limit</string>
+            </property>
+            <property name="checkable">
+             <bool>true</bool>
+            </property>
+            <layout class="QFormLayout" name="formLayout">
+             <property name="fieldGrowthPolicy">
+              <enum>QFormLayout::ExpandingFieldsGrow</enum>
+             </property>
+             <item row="0" column="0">
+              <widget class="QLabel" name="startingTimeLabel">
+               <property name="text">
+                <string>Starting &amp;Time</string>
+               </property>
+               <property name="buddy">
+                <cstring>startingTimeWhite</cstring>
+               </property>
+              </widget>
+             </item>
+             <item row="0" column="1">
+              <widget class="QTimeEdit" name="startingTimeWhite"/>
+             </item>
+             <item row="1" column="0">
+              <widget class="QLabel" name="numberOfMovesLabel">
+               <property name="text">
+                <string>Number of &amp;moves</string>
+               </property>
+               <property name="buddy">
+                <cstring>numberOfMovesWhite</cstring>
+               </property>
+              </widget>
+             </item>
+             <item row="1" column="1">
+              <widget class="KIntSpinBox" name="numberOfMovesWhite"/>
+             </item>
+             <item row="2" column="0">
+              <widget class="QLabel" name="timeIncrementLabel">
+               <property name="text">
+                <string>Time &amp;Increment</string>
+               </property>
+               <property name="buddy">
+                <cstring>timeIncrementWhite</cstring>
+               </property>
+              </widget>
+             </item>
+             <item row="2" column="1">
+              <widget class="QTimeEdit" name="timeIncrementWhite"/>
+             </item>
+            </layout>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
+        <widget class="QGroupBox" name="blackBox">
+         <property name="title">
+          <string>Black</string>
+         </property>
+         <layout class="QVBoxLayout" name="verticalLayout_3">
+          <item>
+           <widget class="QRadioButton" name="blackHuman">
+            <property name="text">
+             <string>Human</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <layout class="QHBoxLayout" name="compLayout_3">
+            <item>
+             <widget class="QRadioButton" name="oppComp_3">
+              <property name="text">
+               <string>Computer engine:</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="KHistoryComboBox" name="programComboBox_3">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="historyItems">
+               <stringlist/>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </item>
+          <item>
+           <layout class="QHBoxLayout" name="ficsLayout_3">
+            <item>
+             <widget class="QRadioButton" name="oppFics_3">
+              <property name="text">
+               <string>Human at a chess server:</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="KHistoryComboBox" name="serverComboBox_3">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="historyItems">
+               <stringlist/>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </item>
+          <item>
+           <widget class="QGroupBox" name="timeGroup_3">
+            <property name="title">
+             <string>Time Limit</string>
+            </property>
+            <property name="checkable">
+             <bool>true</bool>
+            </property>
+            <layout class="QFormLayout" name="formLayout_2">
+             <property name="fieldGrowthPolicy">
+              <enum>QFormLayout::ExpandingFieldsGrow</enum>
+             </property>
+             <item row="0" column="0">
+              <widget class="QLabel" name="startingTimeLabel_2">
+               <property name="text">
+                <string>Starting &amp;Time</string>
+               </property>
+               <property name="buddy">
+                <cstring>startingTimeWhite</cstring>
+               </property>
+              </widget>
+             </item>
+             <item row="0" column="1">
+              <widget class="QTimeEdit" name="startingTimeBlack"/>
+             </item>
+             <item row="1" column="0">
+              <widget class="QLabel" name="numberOfMovesLabel_2">
+               <property name="text">
+                <string>Number of &amp;moves</string>
+               </property>
+               <property name="buddy">
+                <cstring>numberOfMovesWhite</cstring>
+               </property>
+              </widget>
+             </item>
+             <item row="1" column="1">
+              <widget class="KIntSpinBox" name="numberOfMovesBlack"/>
+             </item>
+             <item row="2" column="0">
+              <widget class="QLabel" name="timeIncrementLabel_2">
+               <property name="text">
+                <string>Time &amp;Increment</string>
+               </property>
+               <property name="buddy">
+                <cstring>timeIncrementWhite</cstring>
+               </property>
+              </widget>
+             </item>
+             <item row="2" column="1">
+              <widget class="QTimeEdit" name="timeIncrementBlack"/>
+             </item>
+            </layout>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+      </layout>
+     </widget>
     </widget>
    </item>
   </layout>
  </widget>
  <customwidgets>
   <customwidget>
-   <class>KButtonGroup</class>
-   <extends>QGroupBox</extends>
-   <header>kbuttongroup.h</header>
-   <container>1</container>
+   <class>KIntSpinBox</class>
+   <extends>QSpinBox</extends>
+   <header>knuminput.h</header>
   </customwidget>
   <customwidget>
    <class>KComboBox</class>
@@ -264,11 +418,6 @@
    <header>kcombobox.h</header>
   </customwidget>
   <customwidget>
-   <class>KIntNumInput</class>
-   <extends>QWidget</extends>
-   <header>knuminput.h</header>
-  </customwidget>
-  <customwidget>
    <class>KHistoryComboBox</class>
    <extends>KComboBox</extends>
    <header>khistorycombobox.h</header>
@@ -283,12 +432,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>89</x>
-     <y>77</y>
+     <x>105</x>
+     <y>106</y>
     </hint>
     <hint type="destinationlabel">
-     <x>543</x>
-     <y>78</y>
+     <x>535</x>
+     <y>107</y>
     </hint>
    </hints>
   </connection>
@@ -299,8 +448,8 @@
    <slot>setDisabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>48</x>
-     <y>42</y>
+     <x>63</x>
+     <y>79</y>
     </hint>
     <hint type="destinationlabel">
      <x>235</x>
@@ -315,188 +464,140 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>127</x>
-     <y>106</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>543</x>
-     <y>107</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>conventionalTimeRadio</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>movesLabel</receiver>
-   <slot>setVisible(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>115</x>
-     <y>294</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>188</x>
-     <y>320</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>conventionalTimeRadio</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>playerMoves</receiver>
-   <slot>setVisible(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>168</x>
-     <y>296</y>
+     <x>143</x>
+     <y>136</y>
     </hint>
     <hint type="destinationlabel">
-     <x>183</x>
-     <y>344</y>
+     <x>573</x>
+     <y>137</y>
     </hint>
    </hints>
   </connection>
   <connection>
-   <sender>conventionalTimeRadio</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>oppMoves</receiver>
-   <slot>setVisible(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>75</x>
-     <y>296</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>157</x>
-     <y>375</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>incTimeRadio</sender>
+   <sender>oppFics</sender>
    <signal>toggled(bool)</signal>
-   <receiver>incrementLabel</receiver>
-   <slot>setVisible(bool)</slot>
+   <receiver>numberOfMovesLabel_3</receiver>
+   <slot>setHidden(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>342</x>
-     <y>298</y>
+     <x>20</x>
+     <y>126</y>
     </hint>
     <hint type="destinationlabel">
-     <x>451</x>
-     <y>327</y>
+     <x>414</x>
+     <y>220</y>
     </hint>
    </hints>
   </connection>
   <connection>
-   <sender>incTimeRadio</sender>
+   <sender>oppFics</sender>
    <signal>toggled(bool)</signal>
-   <receiver>playerIncTimeEdit</receiver>
-   <slot>setVisible(bool)</slot>
+   <receiver>numberOfMovesBasic</receiver>
+   <slot>setHidden(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>299</x>
-     <y>296</y>
+     <x>69</x>
+     <y>125</y>
     </hint>
     <hint type="destinationlabel">
-     <x>453</x>
-     <y>344</y>
+     <x>452</x>
+     <y>222</y>
     </hint>
    </hints>
   </connection>
   <connection>
-   <sender>incTimeRadio</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>oppIncTimeEdit</receiver>
-   <slot>setVisible(bool)</slot>
+   <sender>numberOfMovesBasic</sender>
+   <signal>valueChanged(int)</signal>
+   <receiver>numberOfMovesWhite</receiver>
+   <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>322</x>
-     <y>300</y>
+     <x>465</x>
+     <y>218</y>
     </hint>
     <hint type="destinationlabel">
-     <x>446</x>
-     <y>379</y>
+     <x>164</x>
+     <y>213</y>
     </hint>
    </hints>
   </connection>
   <connection>
-   <sender>sameTimeCheckBox</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>oppMoves</receiver>
-   <slot>setDisabled(bool)</slot>
+   <sender>numberOfMovesBasic</sender>
+   <signal>valueChanged(int)</signal>
+   <receiver>numberOfMovesWhite</receiver>
+   <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>51</x>
-     <y>262</y>
+     <x>465</x>
+     <y>218</y>
     </hint>
     <hint type="destinationlabel">
-     <x>152</x>
-     <y>377</y>
+     <x>164</x>
+     <y>213</y>
     </hint>
    </hints>
   </connection>
   <connection>
-   <sender>sameTimeCheckBox</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>oppTimeEdit</receiver>
-   <slot>setDisabled(bool)</slot>
+   <sender>startingTimeBasic</sender>
+   <signal>timeChanged(QTime)</signal>
+   <receiver>startingTimeWhite</receiver>
+   <slot>setTime(QTime)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>349</x>
-     <y>266</y>
+     <x>473</x>
+     <y>191</y>
     </hint>
     <hint type="destinationlabel">
-     <x>349</x>
-     <y>372</y>
+     <x>172</x>
+     <y>186</y>
     </hint>
    </hints>
   </connection>
   <connection>
-   <sender>sameTimeCheckBox</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>oppIncTimeEdit</receiver>
-   <slot>setDisabled(bool)</slot>
+   <sender>startingTimeBasic</sender>
+   <signal>timeChanged(QTime)</signal>
+   <receiver>startingTimeBlack</receiver>
+   <slot>setTime(QTime)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>488</x>
-     <y>268</y>
+     <x>473</x>
+     <y>191</y>
     </hint>
     <hint type="destinationlabel">
-     <x>523</x>
-     <y>366</y>
+     <x>480</x>
+     <y>186</y>
     </hint>
    </hints>
   </connection>
   <connection>
-   <sender>oppFics</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>conventionalTimeRadio</receiver>
-   <slot>setDisabled(bool)</slot>
+   <sender>timeIncrementBasic</sender>
+   <signal>timeChanged(QTime)</signal>
+   <receiver>timeIncrementWhite</receiver>
+   <slot>setTime(QTime)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>18</x>
-     <y>96</y>
+     <x>473</x>
+     <y>245</y>
     </hint>
     <hint type="destinationlabel">
-     <x>25</x>
-     <y>293</y>
+     <x>172</x>
+     <y>240</y>
     </hint>
    </hints>
   </connection>
   <connection>
-   <sender>oppFics</sender>
-   <signal>clicked()</signal>
-   <receiver>incTimeRadio</receiver>
-   <slot>click()</slot>
+   <sender>timeIncrementBasic</sender>
+   <signal>timeChanged(QTime)</signal>
+   <receiver>timeIncrementBlack</receiver>
+   <slot>setTime(QTime)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>168</x>
-     <y>93</y>
+     <x>473</x>
+     <y>245</y>
     </hint>
     <hint type="destinationlabel">
-     <x>332</x>
-     <y>296</y>
+     <x>480</x>
+     <y>240</y>
     </hint>
    </hints>
   </connection>
diff --git a/src/proto/ficsprotocol.cpp b/src/proto/ficsprotocol.cpp
index 19c01a3..d2b157a 100644
--- a/src/proto/ficsprotocol.cpp
+++ b/src/proto/ficsprotocol.cpp
@@ -32,6 +32,7 @@
 #include <QtNetwork/QTcpSocket>
 #include <QtGui/QApplication>
 #include <QtCore/QPointer>
+#include <gamemanager.h>
 
 using namespace Knights;
 
@@ -113,7 +114,6 @@ void FicsProtocol::startGame()
 void FicsProtocol::move ( const Move& m )
 {
     write(m.string(false));
-    changeActivePlayer();
 }
 
 void FicsProtocol::init ( const QVariantMap& options )
@@ -151,7 +151,7 @@ QList< Protocol::ToolWidgetData > FicsProtocol::toolWidgets()
 
     ToolWidgetData chatData;
     chatData.widget = m_chat;
-    chatData.title = i18n("Chat with %1", opponentName());
+    chatData.title = i18n("Chat with %1", playerName());
     chatData.name = QLatin1String("chat");
 
     return QList<ToolWidgetData>() << consoleData << chatData;
@@ -372,13 +372,13 @@ void FicsProtocol::parseLine(const QString& line)
                 QString player2 = gameStartedExp.cap ( 3 );
                 if ( player1 == playerName() )
                 {
-                    setPlayerColor ( White );
-                    setOpponentName ( player2 );
+                    setColor ( Black );
+                    setPlayerName ( player2 );
                 }
                 else
                 {
-                    setPlayerColor ( Black );
-                    setOpponentName ( player1 );
+                    setColor ( White );
+                    setPlayerName ( player1 );
                 }
                 m_stage = PlayStage;
                 emit initSuccesful();
@@ -388,8 +388,8 @@ void FicsProtocol::parseLine(const QString& line)
             if ( moveRegExp.indexIn ( line ) > -1 )
             {
                 display = false;
-                bool validMove = !( moveRegExp.cap ( 1 ) == QLatin1String("B") && \
                playerColor() == White )
-                        && !( moveRegExp.cap ( 1 ) == QLatin1String("W") && \
playerColor() == Black ); +                bool validMove = !( moveRegExp.cap ( 1 ) \
== QLatin1String("B") && color() == White ) +                        && !( \
moveRegExp.cap ( 1 ) == QLatin1String("W") && color() == Black );  
                 const int whiteTimeLimit = moveRegExp.cap ( 3 ).toInt();
                 const int blackTimeLimit = moveRegExp.cap ( 4 ).toInt();
@@ -399,7 +399,11 @@ void FicsProtocol::parseLine(const QString& line)
 
                 if ( moveString == QLatin1String("none") )
                 {
-                    setTimeControl ( NoColor, 0, QTime().addSecs(whiteTimeLimit), \
moveRegExp.cap(2).toInt() ); +                    TimeControl tc;
+                    tc.moves = 0;
+                    tc.baseTime = QTime().addSecs(whiteTimeLimit);
+                    tc.increment = moveRegExp.cap(2).toInt();
+                    manager->setTimeControl(NoColor, tc);
                     break;
                 }
 
@@ -409,12 +413,12 @@ void FicsProtocol::parseLine(const QString& line)
                     if ( moveString == QLatin1String("o-o") )
                     {
                         // Short (king's rook) castling
-                        m = Move::castling ( Move::KingSide, oppositeColor ( \
playerColor() ) ); +                        m = Move::castling ( Move::KingSide, \
color() );  }
                     else if ( moveString == QLatin1String("o-o-o") )
                     {
                         // Long (Queen's rock) castling
-                        m = Move::castling ( Move::QueenSide, oppositeColor ( \
playerColor() ) ); +                        m = Move::castling ( Move::QueenSide, \
color() );  }
                     else if ( moveStringExp.indexIn ( moveString ) > -1 )
                     {
@@ -428,14 +432,14 @@ void FicsProtocol::parseLine(const QString& line)
                         }
                     }
                     emit pieceMoved ( m );
-                    changeActivePlayer();
+                    manager->changeActivePlayer();
                 }
-                setCurrentTime ( White, QTime().addSecs ( whiteTimeLimit ) );
-                setCurrentTime ( Black, QTime().addSecs ( blackTimeLimit ) );
+                manager->setCurrentTime ( White, QTime().addSecs ( whiteTimeLimit ) \
); +                manager->setCurrentTime ( Black, QTime().addSecs ( blackTimeLimit \
) );  
                 if ( moveRegExp.cap(5).toInt() == 2 )
                 {
-                    startTime();
+                    manager->startTime();
                 }
             }
             else if ( line.contains ( QLatin1String(") says:") ) )
@@ -512,13 +516,13 @@ void FicsProtocol::setSeeking ( bool seek )
                     + QString::number(increment) );
         }
         seekStr += QLatin1String(" unrated");
-        switch ( playerColor() )
+        switch ( oppositeColor( color() ) )
         {
             case White:
-                seekStr += QLatin1String("white");
+                seekStr += QLatin1String(" white");
                 break;
             case Black:
-                seekStr += QLatin1String("black");
+                seekStr += QLatin1String(" black");
                 break;
             default:
                 break;
diff --git a/src/proto/localprotocol.cpp b/src/proto/localprotocol.cpp
index fc1bdc6..6b5163a 100644
--- a/src/proto/localprotocol.cpp
+++ b/src/proto/localprotocol.cpp
@@ -23,6 +23,7 @@
 #include "localprotocol.h"
 
 #include <KDE/KLocale>
+#include "gamemanager.h"
 
 using namespace Knights;
 
@@ -32,31 +33,17 @@ void LocalProtocol::init ( const QVariantMap& options )
     emit initSuccesful();
 }
 
-void LocalProtocol::startGame()
-{
-    if ( timeControlEnabled(White) )
-    {
-	emit timeChanged ( White, timeControl(White).baseTime );
-    }
-    if ( timeControlEnabled(Black) )
-    {
-	emit timeChanged ( Black, timeControl(White).baseTime );
-    }
-}
-
 void LocalProtocol::move ( const Knights::Move& m )
 {
+    
     ++movesSoFar;
-    addMoveToHistory(m);
-    movesSoFar > 1 ? startTime() : stopTime();
+    manager->addMoveToHistory(m);
+    movesSoFar > 1 ? manager->startTime() : manager->stopTime();
 }
 
 LocalProtocol::LocalProtocol ( QObject* parent ) : Protocol ( parent ),
   movesSoFar(0)
 {
-    setPlayerColors( White | Black );
-    setPlayerName( i18n("White") );
-    setOpponentName( i18n("Black") );
 }
 
 LocalProtocol::~LocalProtocol()
@@ -69,23 +56,15 @@ Knights::Protocol::Features LocalProtocol::supportedFeatures()
     return Pause | Undo | TimeLimit;
 }
 
-void LocalProtocol::pauseGame()
-{
-}
-
-void LocalProtocol::resumeGame()
-{
-}
-
 void LocalProtocol::undoLastMove()
 {
     --movesSoFar;
-    emit pieceMoved(nextUndoMove());
+    emit pieceMoved(manager->nextUndoMove());
 }
 
 void LocalProtocol::redoLastMove()
 {
     ++movesSoFar;
-    emit pieceMoved(nextRedoMove());
+    emit pieceMoved(manager->nextRedoMove());
 }
 
diff --git a/src/proto/localprotocol.h b/src/proto/localprotocol.h
index a3fed69..5293f9e 100644
--- a/src/proto/localprotocol.h
+++ b/src/proto/localprotocol.h
@@ -32,13 +32,10 @@ class LocalProtocol : public Knights::Protocol
 
 public:
     virtual void init(const QVariantMap& options);
-    virtual void startGame();
     virtual void move(const Knights::Move& m);
     LocalProtocol(QObject* parent = 0);
     virtual ~LocalProtocol();
     virtual Features supportedFeatures();
-    virtual void pauseGame();
-    virtual void resumeGame();
     virtual void undoLastMove();
     virtual void redoLastMove();
 
diff --git a/src/proto/protocol.cpp b/src/proto/protocol.cpp
index 55b1ce3..6376a3b 100644
--- a/src/proto/protocol.cpp
+++ b/src/proto/protocol.cpp
@@ -41,23 +41,14 @@ namespace Knights
             ProtocolPrivate();
             
             QVariantMap attributes;
-            QList<Move> moveHistory;
-            QStack<Move> moveUndoStack;
-            Protocol::TimeControl whiteTimeControl;
-            Protocol::TimeControl blackTimeControl;
-            Color activePlayer;
-            bool whiteTimeEnabled;
-            bool blackTimeEnabled;
-
-            int timer;
-            bool running;
+            Protocol* white;
+            Protocol* black;
+            Color color;
     };
 
     ProtocolPrivate::ProtocolPrivate()
-    : timer(0)
-    , running(false)
-    , whiteTimeEnabled(false)
-    , blackTimeEnabled(false)
+    : white(0)
+    , black(0)
     {
 
     }
@@ -65,7 +56,6 @@ namespace Knights
 
     Protocol::Protocol ( QObject* parent ) : QObject ( parent ), d_ptr ( new \
ProtocolPrivate )  {
-        setActivePlayer ( White );
     }
 
     Protocol::~Protocol()
@@ -73,64 +63,6 @@ namespace Knights
 
     }
 
-void Protocol::startTime()
-{
-    Q_D(Protocol);
-    if ( !d->running )
-    {
-        d->timer = startTimer ( TimerInterval );
-        d->running = true;
-    }
-}
-
-void Protocol::stopTime()
-{
-    Q_D(Protocol);
-    if ( d->running )
-    {
-        killTimer(d->timer);
-        d->running = false;
-    }
-}
-
-void Protocol::setCurrentTime(Color color, const QTime& time)
-{
-    Q_D(Protocol);
-    switch ( color )
-    {
-        case White:
-            d->whiteTimeControl.currentTime = time;
-            break;
-        case Black:
-            d->blackTimeControl.currentTime = time;
-            break;
-        default:
-            return;
-    }
-    emit timeChanged ( color, time );
-}
-
-    void Protocol::timerEvent(QTimerEvent* )
-    {
-        Q_D(Protocol);
-        QTime time;
-        switch ( d->activePlayer )
-        {
-            case White:
-                d->whiteTimeControl.currentTime = \
                d->whiteTimeControl.currentTime.addMSecs ( -TimerInterval );
-                time = d->whiteTimeControl.currentTime;
-                break;
-            case Black:
-                d->blackTimeControl.currentTime = \
                d->blackTimeControl.currentTime.addMSecs ( -TimerInterval );
-                time = d->blackTimeControl.currentTime;
-                break;
-            default:
-                time = QTime();
-                break;
-        }
-        emit timeChanged ( d->activePlayer, time );
-    }
-
     QString Protocol::stringFromErrorCode ( Protocol::ErrorCode code )
     {
         switch ( code )
@@ -155,43 +87,16 @@ void Protocol::setCurrentTime(Color color, const QTime& time)
         }
     }
 
-    void Protocol::setPlayerColor ( Color color )
-    {
-        setPlayerColors( color );
-    }
-
-    Color Protocol::playerColor() const
-    {
-        Colors colors = playerColors();
-        if ( colors == White )
-        {
-            return White;
-        }
-        if ( colors == Black )
-        {
-            return Black;
-        }
-        return NoColor;
-    }
-
-    void Protocol::setPlayerColors( Colors colors )
-    {
-        setAttribute ( "PlayerColors", QVariant::fromValue<Colors>( colors ) );
-    }
-
-    Colors Protocol::playerColors() const
-    {
-        return attribute("PlayerColors").value<Colors>();
-    }
-
-    void Protocol::setOpponentName ( const QString& name )
+    void Protocol::setColor ( Color color )
     {
-        setAttribute ( QLatin1String ( "OpponentName" ), name );
+        Q_D(Protocol);
+        d->color = color;
     }
 
-    QString Protocol::opponentName() const
+    Color Protocol::color() const
     {
-        return attribute ( QLatin1String ( "OpponentName" ) ).toString();
+        Q_D(const Protocol);
+        return d->color;
     }
 
     void Protocol::setPlayerName ( const QString& name )
@@ -232,71 +137,12 @@ void Protocol::setCurrentTime(Color color, const QTime& time)
         return this->attribute ( QLatin1String ( attribute ) );
     }
 
-    void Protocol::addMoveToHistory ( const Move& move )
-    {
-        Q_D ( Protocol );
-        if ( d->moveHistory.isEmpty() )
-        {
-            emit undoPossible(true);
-        }
-        d->moveHistory << move;
-        if ( !d->moveUndoStack.isEmpty() )
-        {
-            emit redoPossible(false);
-        }
-        d->moveUndoStack.clear();
-    }
-
-    Move Protocol::nextUndoMove()
-    {
-        Q_D ( Protocol );
-        Move m = d->moveHistory.takeLast();
-        if ( d->moveHistory.isEmpty() )
-        {
-            emit undoPossible(false);
-        }
-        if ( d->moveUndoStack.isEmpty() )
-        {
-            emit redoPossible(true);
-        }
-        d->moveUndoStack.push( m );
-        Move ret = m.reverse();
-        ret.setFlag ( Move::Forced, true );
-        return ret;
-    }
-
-    Move Protocol::nextRedoMove()
-    {
-        Q_D ( Protocol );
-        Move m = d->moveUndoStack.pop();
-        if ( d->moveUndoStack.isEmpty() )
-        {
-            emit redoPossible(false);
-        }
-        if ( d->moveHistory.isEmpty() )
-        {
-            emit undoPossible(true);
-        }
-        d->moveHistory << m;
-        m.setFlag ( Move::Forced, true );
-        return m;
-    }
 
     Protocol::Features Protocol::supportedFeatures()
     {
         return NoFeatures;
     }
 
-    void Protocol::setOpponentTimeLimit ( int seconds )
-    {
-        Q_UNUSED ( seconds )
-    }
-
-    void Protocol::setPlayerTimeLimit ( int seconds )
-    {
-        Q_UNUSED ( seconds )
-    }
-
     int Protocol::timeRemaining()
     {
         return -1;
@@ -309,12 +155,10 @@ void Protocol::setCurrentTime(Color color, const QTime& time)
 
     void Protocol::pauseGame()
     {
-        startTime();
     }
 
     void Protocol::resumeGame()
     {
-        stopTime();
     }
 
     void Protocol::undoLastMove()
@@ -327,11 +171,6 @@ void Protocol::setCurrentTime(Color color, const QTime& time)
 
     }
 
-    Move::List Protocol::moveHistory()
-    {
-        return Move::List();
-    }
-
     void Protocol::adjourn()
     {
 
@@ -350,61 +189,11 @@ void Protocol::setWinner(Color winner)
     Q_UNUSED(winner);
 }
 
-void Protocol::setTimeControl(Color color, int moves, int baseTime, int increment)
-{
-    setTimeControl(color, moves, baseTime > 0 ? QTime().addSecs(60 * baseTime) : \
                QTime(), increment);
-}
-
-void Protocol::setTimeControl(Color color, int moves, const QTime& baseTime, int \
                increment)
-{
-    TimeControl c;
-    c.baseTime = baseTime;
-    c.moves = moves;
-    c.increment = increment;
-    setTimeControl ( color, c );
-}
-
-void Protocol::setTimeControl(Color color, const TimeControl& control)
+void Protocol::setTimeControl(const Knights::TimeControl& c)
 {
-    Q_D(Protocol);
-    TimeControl c = control;
-    c.currentTime = c.baseTime;
-    if ( color == NoColor )
-    {
-        setTimeControl ( White, c );
-        setTimeControl ( Black, c );
-        return;
-    }
-    if ( color == White )
-    {
-        d->whiteTimeControl = c;
-        d->whiteTimeEnabled = c.baseTime.isValid();
-    }
-    else
-    {
-        d->blackTimeControl = c;
-        d->blackTimeEnabled = c.baseTime.isValid();
-    }
-    emit timeLimitChanged ( color, c.baseTime );
-}
-
-Protocol::TimeControl Protocol::timeControl(Color color) const
-{
-    Q_D(const Protocol);
-    return (color == White) ? d->whiteTimeControl : d->blackTimeControl;
+    Q_UNUSED(c);
 }
 
-bool Protocol::timeControlEnabled(Color color) const
-{
-    Q_D(const Protocol);
-    return (color == White) ? d->whiteTimeEnabled : d->blackTimeEnabled;
-}
-
-QTime Protocol::timeLimit(Color color)
-{
-    Q_D(Protocol);
-    return ( color == White ) ? d->whiteTimeControl.baseTime : \
                d->blackTimeControl.baseTime;
-}
 
 ChatWidget* Protocol::createChatWidget()
 {
@@ -418,23 +207,6 @@ ChatWidget* Protocol::createConsoleWidget()
     return console;
 }
 
-void Protocol::setActivePlayer(Color player)
-{
-    Q_D(Protocol);
-    d->activePlayer = player;
-}
-
-void Protocol::changeActivePlayer()
-{
-    setActivePlayer ( oppositeColor ( activePlayer() ) );
-}
-
-Color Protocol::activePlayer() const
-{
-    Q_D(const Protocol);
-    return d->activePlayer;
-}
-
 }
 
 // kate: indent-mode cstyle; space-indent on; indent-width 4; replace-tabs on;  \
replace-tabs on;  replace-tabs on;  replace-tabs on;  replace-tabs on;  replace-tabs \
                on;
diff --git a/src/proto/protocol.h b/src/proto/protocol.h
index a4cd28f..252938d 100644
--- a/src/proto/protocol.h
+++ b/src/proto/protocol.h
@@ -31,6 +31,9 @@
 namespace Knights
 {
 
+struct TimeControl;
+
+
 class ChatWidget;
 
     class ProtocolPrivate;
@@ -41,10 +44,9 @@ class ChatWidget;
             Q_ENUMS ( Feature )
             Q_ENUMS ( ErrorCode )
             Q_FLAGS ( Features )
-            Q_PROPERTY ( Color playerColor READ playerColor WRITE setPlayerColor )
+            Q_PROPERTY ( Color color READ color WRITE setColor )
             Q_PROPERTY ( QString playerName READ playerName WRITE setPlayerName )
-            Q_PROPERTY ( QString opponentName READ opponentName WRITE \
                setOpponentName )
-
+            
         public:
             enum Feature
             {
@@ -77,95 +79,57 @@ class ChatWidget;
                 QString title;
                 QString name;
             };
-
-            struct TimeControl
-            {
-                int moves;
-                QTime baseTime;
-                int increment;
-                QTime currentTime;
-            };
             
             static QString stringFromErrorCode ( ErrorCode code );
+            static Protocol* white();
+            static void setWhiteProtocol ( Protocol* p );
+            static Protocol* black();
+            static void setBlackProtocol ( Protocol* p );
 
             Protocol ( QObject* parent = 0 );
             virtual ~Protocol();
 
             // Needed functions
 
-            Color playerColor() const;
-            Colors playerColors() const;
-            QString opponentName() const;
+            Color color() const;
             QString playerName() const;
             QVariant attribute ( const QString& attribute ) const;
             QVariant attribute ( const char* attribute ) const;
 
         protected:
-            void setPlayerColor ( Color color );
-            void setPlayerColors ( Colors colors );
-            void setOpponentName ( const QString& name );
+            void setColor ( Color color );
             void setPlayerName ( const QString& name );
             void setAttribute ( const QString& attribute, QVariant value );
             void setAttribute ( const char* attribute, QVariant value );
             void setAttributes ( QVariantMap attributes );
 
-            void changeActivePlayer();
-            void setActivePlayer ( Color player );
-            Color activePlayer() const;
-
-            void addMoveToHistory ( const Move& move );
-            Move nextUndoMove();
-            Move nextRedoMove();
-
             ChatWidget* createChatWidget();
             ChatWidget* createConsoleWidget();
 
-            void startTime();
-            void stopTime();
-            void setCurrentTime ( Color color, const QTime& time );
-
             virtual void timerEvent(QTimerEvent* );
 
         public Q_SLOTS:
             virtual void move ( const Move& m ) = 0;
-            virtual void startGame() = 0;
             virtual void init ( const QVariantMap& options ) = 0;
 
             // Optional features
         public:
             virtual Features supportedFeatures();
-            virtual Move::List moveHistory();
             virtual int timeRemaining();
             virtual QList<ToolWidgetData> toolWidgets();
-            /**
-             * Sets the time control parameters in the same format as XBoard's @c \
                level command works
-             * @param color specifis to which player this setting will apply. If @p \
                color is NoColor then both player use this setting.
-             * @param moves the number of moves to be completed before @p baseTime \
                runs out.
-             * Setting this to 0 causes the timing to be incremental only
-             * @param baseTime the time in minutes in which the player has to \
                complete @p moves moves, or finish the game if @p moves is zero.
-             * @param increment the time in seconds that is added to the player's \
                clock for his every move.
-             */
-            void setTimeControl(Color color, int moves, int baseTime, int \
                increment);
-            void setTimeControl ( Color color, const TimeControl& control );
-            TimeControl timeControl ( Color color ) const;
-            bool timeControlEnabled ( Color color ) const;
-            virtual void setTimeControl(Color color, int moves, const QTime& \
                baseTime, int increment);
-            virtual QTime timeLimit ( Color color );
+            virtual void setTimeControl ( const TimeControl& c );
 
         public Q_SLOTS:
             virtual void pauseGame();
             virtual void resumeGame();
             virtual void undoLastMove();
             virtual void redoLastMove();
-            virtual void setOpponentTimeLimit ( int seconds );
-            virtual void setPlayerTimeLimit ( int seconds );
 
             virtual void proposeDraw();
             virtual void resign();
             virtual void adjourn();
             virtual void setWinner ( Color winner );
 
-
         Q_SIGNALS:
             void pieceMoved ( const Move& m );
             void illegalMove();
diff --git a/src/proto/xboardproto.cpp b/src/proto/xboardproto.cpp
index deff956..a16d728 100644
--- a/src/proto/xboardproto.cpp
+++ b/src/proto/xboardproto.cpp
@@ -21,6 +21,7 @@
 
 #include "proto/xboardproto.h"
 #include "proto/chatwidget.h"
+#include "gamemanager.h"
 
 #include <KProcess>
 #include <KDebug>
@@ -65,15 +66,15 @@ void XBoardProtocol::move ( const Move& m )
 {
     kDebug() << "Player's move:" << m.string(false);
     write ( m.string(false) );
-    addMoveToHistory( m );
+    manager->addMoveToHistory( m );
     lastMoveString.clear();
     emit undoPossible ( false );
-    changeActivePlayer();
+    manager->changeActivePlayer();
     if ( resumePending )
     {
         resumeGame();
     }
-    startTime();
+    manager->startTime();
 }
 
 void XBoardProtocol::init ( const QVariantMap& options )
@@ -85,7 +86,7 @@ void XBoardProtocol::init ( const QVariantMap& options )
     {
         args << QLatin1String ( "xboard" );
     }
-    setOpponentName ( program );
+    setPlayerName ( program );
     mProcess = new KProcess ( this );
     mProcess->setProgram ( program, args );
     mProcess->setNextOpenMode ( QIODevice::ReadWrite | QIODevice::Unbuffered | \
QIODevice::Text ); @@ -100,19 +101,12 @@ void XBoardProtocol::init ( const \
                QVariantMap& options )
         emit error ( InstallationError, i18n ( "Program <code>%1</code> could not be \
started, please check that it is installed.", program ) );  return;
     }
-    TimeControl c = timeControl ( White );
+    TimeControl c = manager->timeControl ( White );
     if ( c.baseTime != QTime() )
     {
         write(QString(QLatin1String("level %1 %2 \
%3")).arg(c.moves).arg(QTime().secsTo(c.baseTime)/60).arg(c.increment));  }
-    if ( playerColors() == NoColor )
-    {
-        setPlayerColor ( ( qrand() % 2 == 0 ) ? White : Black );
-    }
-
-    kDebug() << playerColors();
-
-    if ( playerColors() & Black )
+    if ( color() == Black )
     {
         write("go");
     }
@@ -148,7 +142,7 @@ void XBoardProtocol::parseLine(const QString& line)
         if ( line.contains ( QLatin1String ( "Illegal move" ) ) )
         {
             type = ChatWidget::ErrorMessage;
-            changeActivePlayer();
+            manager->changeActivePlayer();
             emit illegalMove();
         }
         else if ( line.contains ( QLatin1String ( "..." ) ) || \
line.contains(QLatin1String("move")) ) @@ -165,11 +159,11 @@ void \
XBoardProtocol::parseLine(const QString& line)  kDebug() << "Computer's move:" << \
moveString;  lastMoveString = moveString;
                     Move m = Move ( moveString );
-                    addMoveToHistory ( m );
-                    changeActivePlayer();
+                    manager->addMoveToHistory ( m );
+                    manager->changeActivePlayer();
                     emit pieceMoved ( m );
                     emit undoPossible ( true );
-                    startTime();
+                    manager->startTime();
                 }
             }
         }
@@ -223,17 +217,15 @@ void XBoardProtocol::resign()
 
 void XBoardProtocol::undoLastMove()
 {
-    changeActivePlayer();
-    kDebug();
     write("undo");
-    emit pieceMoved(nextUndoMove());
+    manager->changeActivePlayer();
+    emit pieceMoved(manager->nextUndoMove());
 }
 
 void XBoardProtocol::redoLastMove()
 {
-    changeActivePlayer();
-    Move m = nextRedoMove();
-    kDebug().nospace() << m;
+    manager->changeActivePlayer();
+    Move m = manager->nextRedoMove();
     write(m.string(false));
     emit pieceMoved(m);
 }
@@ -247,22 +239,20 @@ void XBoardProtocol::proposeDraw()
 void XBoardProtocol::pauseGame()
 {
     write("force");
-    stopTime();
 }
 
 void XBoardProtocol::resumeGame()
 {
-    if ( playerColors() & activePlayer() )
+    if ( manager->activePlayer() != color() )
     {
         resumePending = true;
     }
     else
     {
-        kDebug();
         write("go");
         emit undoPossible ( false );
         emit redoPossible ( false );
-        startTime();
+        manager->startTime();
     }
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic