Changed timer duration's default to 120 seconds.
[GoMoku3D.git] / src / core / ServerSettings.cpp
blob500e8b67fa2fd1ecfd30bb82c8032bbcb0b8ce43
1 /********************************************************************
3 * Copyright (C) 2008 Daniele Battaglia
5 * This file is part of GoMoku3D.
7 * GoMoku3D is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * GoMoku3D is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GoMoku3D. If not, see <http://www.gnu.org/licenses/>.
20 *******************************************************************/
22 #include "ServerSettings.h"
24 void ServerSettings::setPlayersInfo(QList<PlayerInfo> info)
26 if (info.size() == 2) {
27 info.append(PlayerInfo());
30 for (int i = 0; i < 3; i++) {
31 setValue("Server/player_" + QString::number(i) + "_name", info.at(i).name());
32 setValue("Server/player_" + QString::number(i) + "_color", info.at(i).color());
33 setValue("Server/player_" + QString::number(i) + "_type", info.at(i).type());
37 void ServerSettings::setDifficulty1(int d1)
39 setValue("Server/d1", d1);
42 void ServerSettings::setDifficulty2(int d2)
44 setValue("Server/d2", d2);
47 void ServerSettings::setServerPort(quint16 port)
49 setValue("Server/port", port);
52 void ServerSettings::setTimerDuration(int sec)
54 setValue("Server/timer", sec);
57 void ServerSettings::setMyColor(QColor color)
59 setValue("Server/my_color", color);
62 void ServerSettings::setMyName(QString name)
64 setValue("Server/my_name", name);
67 QList<PlayerInfo> ServerSettings::playersInfo() const
69 QList<PlayerInfo> info;
70 QList<QColor> defaultColors;
71 defaultColors.append(QColor(255, 0, 0));
72 defaultColors.append(QColor(0, 255, 0));
73 defaultColors.append(QColor(0, 0, 255));
75 for (int i = 0; i < 3; i++) {
76 QString n = value("Server/player_" + QString::number(i) + "_name", "").toString();
77 QColor c = value("Server/player_" + QString::number(i) + "_color",defaultColors[i]).value<QColor>();
78 QString t = value("Server/player_" + QString::number(i) + "_type", "R").toString();
79 if (t != "") {
80 info.append(PlayerInfo(n, c, t));
83 return info;
86 int ServerSettings::difficulty1() const
88 return value("Server/d1", 5).toInt();
91 int ServerSettings::difficulty2() const
93 return value("Server/d2", 1).toInt();
96 quint16 ServerSettings::serverPort() const
98 return value("Server/port", 42000).toUInt();
101 int ServerSettings::timerDuration() const
103 return value("Server/timer", 120).toInt();
106 QColor ServerSettings::myColor() const
108 return value("Server/my_color", QColor(255, 255, 0)).value<QColor>();
111 QString ServerSettings::myName() const
113 return value("Server/my_name","").toString();