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

List:       kde-commits
Subject:    playground/games/backgammon
From:       Dmitry Vladimirovich Chernov <diman4ik.chernov () gmail ! com>
Date:       2012-11-24 19:51:22
Message-ID: 20121124195122.DEF3EAC85F () svn ! kde ! org
[Download RAW message or body]

SVN commit 1325990 by dmitryvchernov:

login failed dialog and bugfix

 M  +1 -3      backgammonscene.cpp  
 M  +1 -1      backgammonview.cpp  
 M  +9 -0      games/backgammon/fibs/backgammon_fibs.cpp  
 M  +4 -2      games/backgammon/fibs/backgammon_fibs.h  
 M  +3 -4      games/backgammon/fibs/backgammon_fibs_connect.cpp  
 M  +7 -4      games/backgammon/fibs/clip.cpp  
 M  +3 -0      games/backgammon/fibs/clip.h  
 M  +7 -0      games/backgammon/fibs/fibs_widget.cpp  
 M  +2 -2      main.cpp  
 M  +10 -0     mainwindow.cpp  
 M  +1 -0      mainwindow.h  


--- trunk/playground/games/backgammon/backgammonscene.cpp #1325989:1325990
@@ -114,7 +114,6 @@
 
 void BackgammonScene::resizeScene( int width, int height )
 {
-    kDebug() << "resizeScene" << width << "x" << height;
     setSceneRect( 0, 0, width, height );
 
     Board::resize(width, height);
@@ -393,8 +392,6 @@
 	
 	connect( d->m_game, SIGNAL( selectChecker(int) ), this, SLOT( selectChecker(int) ) \
);  connect( d->m_game, SIGNAL( deselectChecker() ), this, SLOT( deselectChecker() ) \
                );
-
-    kDebug() << Board::state();
 }
 
 void BackgammonScene::arrangeCheckers( const QStringList& newBoardState )
@@ -594,6 +591,7 @@
         Checker* checker = qgraphicsitem_cast<Checker*>(item);
         if(checker)
         {
+			if( checker->cell() != Board::home( checker->color() ) )
             moveChecker(checker, Board::home( checker->color() ) );
         }
 
--- trunk/playground/games/backgammon/backgammonview.cpp #1325989:1325990
@@ -38,7 +38,7 @@
             QGraphicsView::DontSavePainterState |
             QGraphicsView::DontAdjustForAntialiasing );
 	
-	m_scene->resizeScene( this->width(), this->height() );
+	m_scene->resizeScene( parent->width(), parent->height() );
 }
 
 void BackgammonView::resizeEvent( QResizeEvent* ev )
--- trunk/playground/games/backgammon/games/backgammon/fibs/backgammon_fibs.cpp \
#1325989:1325990 @@ -46,6 +46,7 @@
     getOpponent().setDirection( IPlayer::positive );
     
     m_yourTurn = false;
+	m_loginFailed = false;
 }
     
 BackgammonFibs::~BackgammonFibs()
@@ -402,6 +403,13 @@
             case Clip::patternMatchContinue:
                 emit( showMatchContinueQuestion() );
                 break;
+			case Clip::patternLoginFailed: {
+					if( !m_loginFailed ) {
+						m_loginFailed = true;
+						emit( loginFailed() );
+					}
+				}
+				break;
             case Clip::patternDone:
                 break;
             case Clip::noPattern:
@@ -445,6 +453,7 @@
 void BackgammonFibs::login( const QString& login, const QString& password )
 {
     kDebug() << "trying to login";
+	m_loginFailed = false;
     
     getYou().setName(login);
     
--- trunk/playground/games/backgammon/games/backgammon/fibs/backgammon_fibs.h \
#1325989:1325990 @@ -176,6 +176,8 @@
 	
 	void clientStateChanged(int);
 
+	void loginFailed();
+
 protected slots:
 
     void handleServerData( QString& line );
@@ -186,8 +188,6 @@
     QString getFirstWord( const QString& line );
     QString getLastWord( const QString& line );
     
-    //BackgammonFibsConnect* m_connection;
-    
     QMap< int, bool > m_toggles;
     
     QString m_name;
@@ -227,6 +227,8 @@
     
     int reverseIndex(int);
     
+	bool m_loginFailed;
+    
 #ifdef TEST
     void testReadBoard();
 #endif
--- trunk/playground/games/backgammon/games/backgammon/fibs/backgammon_fibs_connect.cpp \
#1325989:1325990 @@ -62,8 +62,6 @@
 	{
 #ifdef LOG_FIBS
 		toFibsLog() << line.toLatin1();
-#else
-		kDebug() << line.toLatin1();
 #endif
         m_socket->write( line.toLatin1() + "\r\n" );        
 	}
@@ -77,8 +75,6 @@
 
 #ifdef LOG_FIBS
 	fromFibsLog() << line;
-#else
-	kDebug() << line;
 #endif
     
     if( line.length() != 0 )
@@ -101,7 +97,10 @@
 	
     emit( connectionEstablished() );
 	
+	toFibsLog() << txBuffer;
 	m_socket->write( txBuffer.toLatin1() );
+	
+	txBuffer.clear();
 }
 
 bool BackgammonFibsConnect::isConnected()
--- trunk/playground/games/backgammon/games/backgammon/fibs/clip.cpp #1325989:1325990
@@ -112,6 +112,8 @@
     str_patternResign           = QRegExp( " wants to resign. You will win " );
     
     str_patternMatchContinue    = QRegExp( "Type 'join' if you want to play the next \
game" ); +	
+	str_patternLoginFailed		= QRegExp( "^> 5" );
 }
 
 Clip::pattern Clip::getPattern( const QString& line )
@@ -317,13 +319,12 @@
 	if( line.contains( str_patternStartRoll ) )
 		return noPattern;
     
+	if( line.contains( str_patternLoginFailed ) )
+		return patternLoginFailed;
+    
     if( line.compare("\n") ==  0 )
         return noPattern;
 	
-    
-    kDebug() << "unparsed line " << line;
-   
-    
     return noPattern;    
 }
 
@@ -519,3 +520,5 @@
 QRegExp Clip::str_patternBoard;
 
 QRegExp Clip::str_patternStartRoll;
+
+QRegExp Clip::str_patternLoginFailed;
--- trunk/playground/games/backgammon/games/backgammon/fibs/clip.h #1325989:1325990
@@ -107,6 +107,7 @@
         patternDone,
         patternResign,
         patternMatchContinue,
+		patternLoginFailed,
         noPattern,
     };
     
@@ -204,6 +205,8 @@
     static QRegExp str_patternMatchContinue;
 	
 	static QRegExp str_patternStartRoll;
+	
+	static QRegExp str_patternLoginFailed;
 };
 
 #endif
--- trunk/playground/games/backgammon/games/backgammon/fibs/fibs_widget.cpp \
#1325989:1325990 @@ -457,21 +457,28 @@
 		case BackgammonFibs::authorized:
 			{
 				chatButton->setEnabled(true);
+				m_currentAction = m_shoutAction;
+				chatButton->setText( i18n( "Shout" ) );
 			}	
 			break;
 		case BackgammonFibs::playing:
 			{
+				chatButton->setText( i18n( "Say" ) );
 				chatButton->setMenu( m_gameMenu );
+				m_currentAction = m_sayAction;
 			}
 			break;
 		case BackgammonFibs::watching:
 			{
 				chatButton->setMenu( m_watchMenu );
+				m_currentAction = m_shoutAction;
+				chatButton->setText( i18n( "Shout" ) );
 			}
 		case BackgammonFibs::waiting:
 			{
 				chatButton->setMenu( m_menu );
 				m_currentAction = m_shoutAction;
+				chatButton->setText( i18n( "Shout" ) );
 			}
 		default:
 			break;
--- trunk/playground/games/backgammon/main.cpp #1325989:1325990
@@ -28,12 +28,12 @@
 static const char description[] =
     I18N_NOOP("KDE Backgammon Game");
 
-static const char version[] = "0.16";
+static const char version[] = "0.18";
 
 int main(int argc, char **argv)
 {
     KAboutData about("backgammon", 0, ki18n("KBackgammon"), version, \
                ki18n(description),
-                     KAboutData::License_GPL, ki18n("(C) 2009 Alexander Smirnov\n(C) \
2011 Dmitry Chernov"), KLocalizedString(), 0, "diman4ik.chernov@gmail.com"); +        \
KAboutData::License_GPL, ki18n("(C) 2009 Alexander Smirnov\n(C) 2011-2012 Dmitry \
                Chernov"), KLocalizedString(), 0, "diman4ik.chernov@gmail.com");
     about.addAuthor( ki18n("Alexander Smirnov"), KLocalizedString(), \
                "alexander.v.smirnov@gmail.com" );
     about.addAuthor( ki18n("Dmitry Chernov"), KLocalizedString(), \
"diman4ik.chernov@gmail.com" );  
--- trunk/playground/games/backgammon/mainwindow.cpp #1325989:1325990
@@ -476,6 +476,8 @@
 	connect( ret, SIGNAL( clientStateChanged(int) ), m_fibsWidget, SLOT( \
stateChanged(int) ) );  connect( ret, SIGNAL( clientStateChanged(int) ), SLOT( \
stateChanged(int) ) );  
+	connect( ret, SIGNAL( loginFailed() ), SLOT( loginFailed() ) );
+
     return ret;
 }
 
@@ -726,3 +728,11 @@
 {
 	actionCollection()->action( "actions_menu" )->setEnabled(true);
 }
+
+void BackgammonMainWindow::loginFailed()
+{
+	KMessageBox::information( this, 
+		i18n( "Login failed. Maybe your account has expired? FIBS accounts expire if not \
active. Try to re-register with the same name or create new account." ) ); +	
+	fibsLogout();
+}
--- trunk/playground/games/backgammon/mainwindow.h #1325989:1325990
@@ -107,6 +107,7 @@
 	void reportToggled(bool);
 	void resign(bool);
 	void walletOpened(bool);
+	void loginFailed();
 
 private:
     


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

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