Commit 74ed21c5 authored by Denis Kuplyakov's avatar Denis Kuplyakov
Browse files

Formatted source code

GIT_SILENT
parent cb6fc717
......@@ -33,19 +33,19 @@ QColor ColorScheme::background() const
{
return KStatefulBrush(KColorScheme::Tooltip,
KColorScheme::NormalBackground)
.brush(QPalette::Active).color();
.brush(QPalette::Active).color();
}
QColor ColorScheme::foreground() const
{
return KStatefulBrush(KColorScheme::Tooltip,
KColorScheme::NormalText)
.brush(QPalette::Active).color();
.brush(QPalette::Active).color();
}
QColor ColorScheme::border() const
{
return KStatefulBrush(KColorScheme::View,
KColorScheme::NormalText)
.brush(QPalette::Active).color();
.brush(QPalette::Active).color();
}
......@@ -34,7 +34,8 @@ ChipColor Utils::opponentColorFor(ChipColor color)
}
QString Utils::colorToString(const ChipColor &color) {
QString Utils::colorToString(const ChipColor &color)
{
if (Preferences::useColoredChips())
return (color == Black ? i18n("Blue") : i18n("Red"));
return (color == Black ? i18n("Black") : i18n("White"));
......@@ -54,7 +55,8 @@ QString Utils::moveToString(const KReversiMove& move)
return moveString;
}
int Utils::difficultyLevelToInt() {
int Utils::difficultyLevelToInt()
{
for (int i = 0; i < Kg::difficulty()->levels().size(); i++)
if (Kg::difficultyLevel()
......@@ -64,6 +66,7 @@ int Utils::difficultyLevelToInt() {
return -1;
}
const KgDifficultyLevel *Utils::intToDifficultyLevel(int skill) {
const KgDifficultyLevel *Utils::intToDifficultyLevel(int skill)
{
return Kg::difficulty()->levels()[skill];
}
......@@ -60,12 +60,13 @@ struct KReversiMove: public KReversiPos {
}
};
namespace Utils {
ChipColor opponentColorFor(ChipColor color);
QString colorToString(const ChipColor &color);
QString moveToString(const KReversiMove& move);
int difficultyLevelToInt();
const KgDifficultyLevel *intToDifficultyLevel(int skill);
namespace Utils
{
ChipColor opponentColorFor(ChipColor color);
QString colorToString(const ChipColor &color);
QString moveToString(const KReversiMove& move);
int difficultyLevelToInt();
const KgDifficultyLevel *intToDifficultyLevel(int skill);
}
typedef QList<KReversiMove> MoveList;
......
......@@ -3,7 +3,8 @@
#include <QString>
class GameStartInformation {
class GameStartInformation
{
public:
enum PlayerType {
......
......@@ -156,7 +156,7 @@ void KReversiMainWindow::loadSettings()
// Chip's color
m_coloredChipsAct->setChecked(Preferences::useColoredChips());
m_view->setChipsPrefix(Preferences::useColoredChips() ?
KReversiView::Colored : KReversiView::BlackWhite);
KReversiView::Colored : KReversiView::BlackWhite);
m_startDialog->setColoredChips(Preferences::useColoredChips());
}
......@@ -260,29 +260,29 @@ void KReversiMainWindow::slotGameOver()
score.setType(KExtHighscore::Lost);
}
} else if (m_nowPlayingInfo.type[White] == GameStartInformation::Human
&& m_nowPlayingInfo.type[Black] == GameStartInformation::AI) { // we are playing white
&& m_nowPlayingInfo.type[Black] == GameStartInformation::AI) { // we are playing white
storeScore = true;
KExtHighscore::setGameType(((KReversiComputerPlayer *)m_player[Black])->lowestSkill());
score.setScore(whiteScore);
if (blackScore == whiteScore) {
res = i18n("Game is drawn!");
score.setType(KExtHighscore::Draw);
res = i18n("Game is drawn!");
score.setType(KExtHighscore::Draw);
} else if (blackScore < whiteScore) {
res = i18n("You win!");
score.setType(KExtHighscore::Won);
res = i18n("You win!");
score.setType(KExtHighscore::Won);
} else {
res = i18n("You have lost!");
score.setType(KExtHighscore::Lost);
res = i18n("You have lost!");
score.setType(KExtHighscore::Lost);
}
} else if (m_nowPlayingInfo.type[Black] == GameStartInformation::Human
&& m_nowPlayingInfo.type[White] == GameStartInformation::Human) { // friends match
if (blackScore == whiteScore) {
res = i18n("Game is drawn!");
res = i18n("Game is drawn!");
} else if (blackScore > whiteScore) {
res = i18n("%1 has won!", m_nowPlayingInfo.name[Black]);
res = i18n("%1 has won!", m_nowPlayingInfo.name[Black]);
} else {
res = i18n("%1 has won!", m_nowPlayingInfo.name[White]);
res = i18n("%1 has won!", m_nowPlayingInfo.name[White]);
}
} else { // using Black White names in other cases
if (blackScore == whiteScore) {
......@@ -295,7 +295,7 @@ void KReversiMainWindow::slotGameOver()
}
if (m_nowPlayingInfo.type[Black] == GameStartInformation::AI
&& m_nowPlayingInfo.type[White] == GameStartInformation::AI) {
&& m_nowPlayingInfo.type[White] == GameStartInformation::AI) {
res += i18n("\n%1: %2", Utils::colorToString(Black), blackScore);
res += i18n("\n%1: %2", Utils::colorToString(White), whiteScore);
} else {
......@@ -318,7 +318,8 @@ void KReversiMainWindow::slotMoveFinished()
m_undoAct->setEnabled(m_game->canUndo());
}
void KReversiMainWindow::updateHistory() {
void KReversiMainWindow::updateHistory()
{
MoveList history = m_game->getHistory();
m_historyView->clear();
......@@ -360,8 +361,7 @@ void KReversiMainWindow::showEvent(QShowEvent*)
if (m_firstShow && m_startInDemoMode) {
kDebug() << "starting demo...";
startDemo();
}
else if (m_firstShow) {
} else if (m_firstShow) {
QTimer::singleShot(0, this, SLOT(slotNewGame()));
}
m_firstShow = false;
......@@ -384,7 +384,7 @@ void KReversiMainWindow::updateStatusBar()
if (!m_game->isGameOver()) {
statusBar()->changeItem(i18n("%1 turn",
Utils::colorToString(m_game->currentPlayer())),
Utils::colorToString(m_game->currentPlayer())),
COMMON_STATUSBAR_ID);
}
} else { // using player's names
......@@ -402,7 +402,8 @@ void KReversiMainWindow::updateStatusBar()
// TODO: test it!!!
void KReversiMainWindow::startDemo() {
void KReversiMainWindow::startDemo()
{
GameStartInformation info;
info.name[0] = info.name[1] = i18n("Computer");
info.type[0] = info.type[1] = GameStartInformation::AI;
......@@ -411,10 +412,10 @@ void KReversiMainWindow::startDemo() {
receivedGameStartInformation(info);
}
void KReversiMainWindow::clearPlayers() {
void KReversiMainWindow::clearPlayers()
{
for (int i = 0; i < 2; i++) // iterating through white to black
if (m_player[i])
{
if (m_player[i]) {
m_player[i]->disconnect();
delete m_player[i];
m_player[i] = 0;
......@@ -427,14 +428,11 @@ void KReversiMainWindow::receivedGameStartInformation(GameStartInformation info)
m_nowPlayingInfo = info;
for (int i = 0; i < 2; i++) // iterating through black and white
if (info.type[i] == GameStartInformation::AI)
{
if (info.type[i] == GameStartInformation::AI) {
m_player[i] = new KReversiComputerPlayer(ChipColor(i), info.name[i]);
((KReversiComputerPlayer *)(m_player[i]))->setSkill(info.skill[i]);
levelChanged();
}
else
{
} else {
m_player[i] = new KReversiHumanPlayer(ChipColor(i), info.name[i]);
}
......@@ -454,16 +452,14 @@ void KReversiMainWindow::receivedGameStartInformation(GameStartInformation info)
updateHistory();
if (info.type[White] == GameStartInformation::AI
&& info.type[Black] == GameStartInformation::Human) {
&& info.type[Black] == GameStartInformation::Human) {
Kg::difficulty()->setEditable(true);
Kg::difficulty()->select(Utils::intToDifficultyLevel(info.skill[White]));
}
else if (info.type[White] == GameStartInformation::Human
&& info.type[Black] == GameStartInformation::AI) {
} else if (info.type[White] == GameStartInformation::Human
&& info.type[Black] == GameStartInformation::AI) {
Kg::difficulty()->setEditable(true);
Kg::difficulty()->select(Utils::intToDifficultyLevel(info.skill[Black]));
}
else
} else
Kg::difficulty()->setEditable(false);
m_hintAct->setEnabled(m_game->isHintAllowed());
......
......@@ -42,8 +42,7 @@ StartGameDialog::StartGameDialog(QWidget *parent, KgThemeProvider *provider) :
for (int i = 0; i < diffList.size(); i++) {
ui->blackSkill->addItem(icon, diffList.at(i)->title());
ui->whiteSkill->addItem(icon, diffList.at(i)->title());
if (diffList.at(i)->isDefault())
{
if (diffList.at(i)->isDefault()) {
ui->whiteSkill->setCurrentIndex(i);
ui->blackSkill->setCurrentIndex(i);
}
......
......@@ -8,8 +8,9 @@
#include <KUser>
#include <KgThemeProvider>
namespace Ui {
class StartGameDialog;
namespace Ui
{
class StartGameDialog;
}
class StartGameDialog : public KDialog
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment