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

List:       kde-docbook
Subject:    KDE/kdegames/ksame
From:       Rafał Miłecki <zajec5 () gmail ! com>
Date:       2008-04-03 17:17:03
Message-ID: 1207243023.713580.25237.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 793332 by rmilecki:

GUI: added displaying of score player will get for removing selected stones

 M  +10 -1     board.cpp  
 M  +1 -0      board.h  
 M  +3 -1      mainwindow.cpp  


--- trunk/KDE/kdegames/ksame/board.cpp #793331:793332
@@ -251,7 +251,7 @@
 	m_undoList.push( KSame::GameState( this ) );
 
 	// Increase the score
-	m_score += ( m_markedStones.count() - 2 ) * ( m_markedStones.count() - 2 );
+	m_score += KSame::Board::calculateScore( m_markedStones.count() );
 
 	// Remove the marked stones
 	foreach( const KSame::Coordinate &s, m_markedStones )
@@ -426,4 +426,13 @@
 
 }
 
+int KSame::Board::calculateScore( int markedStones )
+{
+	if (markedStones<2)
+	{
+		return 0;
+	}
+	return ( markedStones - 2 ) * ( markedStones - 2 );
+}
+
 #include "board.moc"
--- trunk/KDE/kdegames/ksame/board.h #793331:793332
@@ -93,6 +93,7 @@
 			quint8  count( quint8 color ) const { return m_boardData.count( color ); }
 
 			int markedStones() const { return m_markedStones.count(); }
+			static int calculateScore( int markedStones );
 
 			bool changed() const { return m_changed; }
 			bool canUndo() const { return !m_undoList.empty(); }
--- trunk/KDE/kdegames/ksame/mainwindow.cpp #793331:793332
@@ -189,7 +189,9 @@
 
 void KSame::MainWindow::setMarked( int markedStones )
 {
-	m_statusBar->changeItem( ki18n( "Marked: %1" ).subs( markedStones, 6 ).toString(), 3);
+	qint32 markedScore = KSame::Board::calculateScore( markedStones );
+	KLocalizedString markedText = ki18n("Marked: %1 (%2 Points)");
+	m_statusBar->changeItem( markedText.subs( markedStones, 3 ).subs( markedScore, 3 ).toString(), 3);
 }
 
 void KSame::MainWindow::setScore( quint32 score )
_______________________________________________
kde-docbook mailing list
kde-docbook@kde.org
https://mail.kde.org/mailman/listinfo/kde-docbook
[prev in list] [next in list] [prev in thread] [next in thread] 

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