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

Formatted source code

GIT_SILENT
parent cb6fc717
......@@ -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 {
......
......@@ -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;
......@@ -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]);
}
......@@ -457,13 +455,11 @@ void KReversiMainWindow::receivedGameStartInformation(GameStartInformation info)
&& info.type[Black] == GameStartInformation::Human) {
Kg::difficulty()->setEditable(true);
Kg::difficulty()->select(Utils::intToDifficultyLevel(info.skill[White]));
}
else if (info.type[White] == GameStartInformation::Human
} 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