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

List:       kde-commits
Subject:    kdegames/kreversi
From:       Anne-Marie Mahfouf <annma () kde ! org>
Date:       2004-09-21 15:03:15
Message-ID: 20040921150315.88BB8126D4 () office ! kde ! org
[Download RAW message or body]

CVS commit by annma: 

this fixes first part of bug 89829.
when you saved a game while playing the blue and then swich sides and load this game, \
the human color was wrong. This is fixed and the human color is saved second part of \
the bug report is about the Load... where the reporter expects a dialog for loading a \
game. But in KReversi only 1 game can be saved at a time thus Load is in fact Load \
the one saved game. Should KReversi save several games via a Save dialog as in KWin4? \
Is there a rule about extensions in that case? Or should it stays as it is?


  A            prefs_addons.h   1.1 [no copyright]
  M +9 -9      board.cpp   1.42
  M +1 -0      kreversi.cpp   1.25
  M +8 -0      kreversi.kcfg   1.7
  M +1 -1      prefs.kcfgc   1.5


--- kdegames/kreversi/board.cpp  #1.41:1.42
@@ -333,4 +333,7 @@ void Board::switchSides()
 
   m_humanColor = opponent(m_humanColor);
+  Prefs::setHumanColor((int) m_humanColor);
+  Prefs::setComputerColor((int) opponent(m_humanColor));
+  Prefs::writeConfig();
   emit score();
   kapp->processEvents();
@@ -667,5 +670,7 @@ bool Board::loadGame(KConfig *config, bo
 
   m_humanColor = (Color)config->readNumEntry("WhoseTurn");
-
+  Prefs::setHumanColor((int) m_humanColor);
+  Prefs::setComputerColor((int) opponent(m_humanColor));
+  Prefs::writeConfig();
   updateBoard(TRUE);
   setState(State(config->readNumEntry("State")));
@@ -676,12 +681,6 @@ bool Board::loadGame(KConfig *config, bo
   if (interrupted())
     doContinue();
-  else {
-    emit turn(Black);
-
-    // Computer makes first move.
-    if (m_humanColor == White)
-      computerMakeMove();
-  }
-
+  //it's always the human's turn to play in a load game as you cannot save a game \
while playing +  emit turn(m_humanColor);
   return true;
 }
@@ -690,4 +689,5 @@ bool Board::loadGame(KConfig *config, bo
 void Board::loadSettings()
 {
+  m_humanColor = (Color) Prefs::humanColor();
   if ( Prefs::grayscale() ) {
     if (chiptype != Grayscale)

--- kdegames/kreversi/kreversi.cpp  #1.24:1.25
@@ -226,4 +226,5 @@ void KReversi::openGame()
   if (m_board->loadGame(config))
     Prefs::setSkill(m_board->strength());
+  updateColors();
 }
 

--- kdegames/kreversi/kreversi.kcfg  #1.6:1.7
@@ -10,4 +10,12 @@
       <default>false</default>
     </entry>
+      <entry name="HumanColor" type="Int">
+      <label>The human color.</label>
+      <default>1</default>
+    </entry>
+      <entry name="ComputerColor" type="Int">
+      <label>The computer color.</label>
+      <default>0</default>
+    </entry>
     <entry name="Animation" type="Bool">
       <label>Whether to use animations.</label>

--- kdegames/kreversi/prefs.kcfgc  #1.4:1.5
@@ -4,4 +4,4 @@
 ClassName=Prefs
 Singleton=true
-#CustomAdditions=true
+CustomAdditions=true
 Mutators=skill,Zoom,MenubarVisible


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

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