unimportant changes
This commit is contained in:
parent
4054afc759
commit
7f659573bc
21 changed files with 89 additions and 51 deletions
|
@ -43,6 +43,7 @@ public:
|
||||||
CardItem *takeCard(int position, int cardId, const QString &cardName);
|
CardItem *takeCard(int position, int cardId, const QString &cardName);
|
||||||
void setCardAttr(int cardId, const QString &aname, const QString &avalue);
|
void setCardAttr(int cardId, const QString &aname, const QString &avalue);
|
||||||
void hoverCardEvent(CardItem *card);
|
void hoverCardEvent(CardItem *card);
|
||||||
|
ZoneViewZone *getView() const { return view; }
|
||||||
void setView(ZoneViewZone *_view);
|
void setView(ZoneViewZone *_view);
|
||||||
virtual void reorganizeCards() = 0;
|
virtual void reorganizeCards() = 0;
|
||||||
void moveAllToZone(const QString &targetZone, int targetX);
|
void moveAllToZone(const QString &targetZone, int targetX);
|
||||||
|
|
|
@ -43,6 +43,7 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
|
||||||
connect(aDraw, SIGNAL(triggered()), this, SLOT(actDrawCard()));
|
connect(aDraw, SIGNAL(triggered()), this, SLOT(actDrawCard()));
|
||||||
aDrawCards = new QAction(tr("D&raw cards..."), this);
|
aDrawCards = new QAction(tr("D&raw cards..."), this);
|
||||||
connect(aDrawCards, SIGNAL(triggered()), this, SLOT(actDrawCards()));
|
connect(aDrawCards, SIGNAL(triggered()), this, SLOT(actDrawCards()));
|
||||||
|
aDrawCards->setShortcut(tr("Ctrl+C"));
|
||||||
aRollDice = new QAction(tr("R&oll dice..."), this);
|
aRollDice = new QAction(tr("R&oll dice..."), this);
|
||||||
aRollDice->setShortcut(tr("Ctrl+I"));
|
aRollDice->setShortcut(tr("Ctrl+I"));
|
||||||
connect(aRollDice, SIGNAL(triggered()), this, SLOT(actRollDice()));
|
connect(aRollDice, SIGNAL(triggered()), this, SLOT(actRollDice()));
|
||||||
|
@ -182,10 +183,8 @@ void Game::gameEvent(const ServerEventData &msg)
|
||||||
if (started) {
|
if (started) {
|
||||||
started = false;
|
started = false;
|
||||||
emit logReadyStart(p->getName());
|
emit logReadyStart(p->getName());
|
||||||
if (!p->getLocal()) {
|
if (!p->getLocal())
|
||||||
// XXX Zoneviews schließen
|
|
||||||
restartGameDialog();
|
restartGameDialog();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case eventGameStart:
|
case eventGameStart:
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "cardzone.h"
|
#include "cardzone.h"
|
||||||
#include "playerarea.h"
|
#include "playerarea.h"
|
||||||
#include "counter.h"
|
#include "counter.h"
|
||||||
|
#include "zoneviewzone.h"
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ void Player::actMoveHandToBottomLibrary()
|
||||||
|
|
||||||
void Player::actViewLibrary()
|
void Player::actViewLibrary()
|
||||||
{
|
{
|
||||||
emit addZoneView(this, "deck", 0);
|
emit toggleZoneView(this, "deck", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actViewTopCards()
|
void Player::actViewTopCards()
|
||||||
|
@ -94,23 +95,23 @@ void Player::actViewTopCards()
|
||||||
int number = QInputDialog::getInteger(0, tr("View top cards of library"), tr("Number of cards:"), defaultNumberTopCards, 1, 2000000000, 1, &ok);
|
int number = QInputDialog::getInteger(0, tr("View top cards of library"), tr("Number of cards:"), defaultNumberTopCards, 1, 2000000000, 1, &ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
defaultNumberTopCards = number;
|
defaultNumberTopCards = number;
|
||||||
emit addZoneView(this, "deck", number);
|
emit toggleZoneView(this, "deck", number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actViewGraveyard()
|
void Player::actViewGraveyard()
|
||||||
{
|
{
|
||||||
emit addZoneView(this, "grave", 0);
|
emit toggleZoneView(this, "grave", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actViewRfg()
|
void Player::actViewRfg()
|
||||||
{
|
{
|
||||||
emit addZoneView(this, "rfg", 0);
|
emit toggleZoneView(this, "rfg", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actViewSideboard()
|
void Player::actViewSideboard()
|
||||||
{
|
{
|
||||||
emit addZoneView(this, "sb", 0);
|
emit toggleZoneView(this, "sb", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::addZone(CardZone *z)
|
void Player::addZone(CardZone *z)
|
||||||
|
@ -155,8 +156,11 @@ void Player::gameEvent(const ServerEventData &event)
|
||||||
// XXX Fehlerbehandlung
|
// XXX Fehlerbehandlung
|
||||||
|
|
||||||
// Clean up existing zones first
|
// Clean up existing zones first
|
||||||
for (int i = 0; i < zones.size(); i++)
|
for (int i = 0; i < zones.size(); i++) {
|
||||||
|
if (ZoneViewZone *view = zones.at(i)->getView())
|
||||||
|
emit closeZoneView(view);
|
||||||
zones.at(i)->clearContents();
|
zones.at(i)->clearContents();
|
||||||
|
}
|
||||||
|
|
||||||
area->clearCounters();
|
area->clearCounters();
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,15 @@ class CardDatabase;
|
||||||
class QMenu;
|
class QMenu;
|
||||||
class QAction;
|
class QAction;
|
||||||
class PlayerArea;
|
class PlayerArea;
|
||||||
|
class ZoneViewZone;
|
||||||
|
|
||||||
class Player : public QObject {
|
class Player : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
signals:
|
signals:
|
||||||
void moveCard(int cardId, QString startZone, QString targetZone, int x, int y);
|
void moveCard(int cardId, QString startZone, QString targetZone, int x, int y);
|
||||||
void hoverCard(QString name);
|
void hoverCard(QString name);
|
||||||
void addZoneView(Player *player, QString zoneName, int number);
|
void closeZoneView(ZoneViewZone *zone);
|
||||||
|
void toggleZoneView(Player *player, QString zoneName, int number);
|
||||||
void sigShowCardMenu(QPoint p);
|
void sigShowCardMenu(QPoint p);
|
||||||
// Log events
|
// Log events
|
||||||
void logMoveCard(QString playerName, QString cardName, QString startZone, QString targetZone);
|
void logMoveCard(QString playerName, QString cardName, QString startZone, QString targetZone);
|
||||||
|
|
|
@ -43,7 +43,8 @@ void MainWindow::hoverCard(QString name)
|
||||||
void MainWindow::playerAdded(Player *player)
|
void MainWindow::playerAdded(Player *player)
|
||||||
{
|
{
|
||||||
menuBar()->addMenu(player->getPlayerMenu());
|
menuBar()->addMenu(player->getPlayerMenu());
|
||||||
connect(player, SIGNAL(addZoneView(Player *, QString, int)), zoneLayout, SLOT(addItem(Player *, QString, int)));
|
connect(player, SIGNAL(toggleZoneView(Player *, QString, int)), zoneLayout, SLOT(toggleZoneView(Player *, QString, int)));
|
||||||
|
connect(player, SIGNAL(closeZoneView(ZoneViewZone *)), zoneLayout, SLOT(removeItem(ZoneViewZone *)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::playerRemoved(Player *player)
|
void MainWindow::playerRemoved(Player *player)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "zoneviewlayout.h"
|
#include "zoneviewlayout.h"
|
||||||
#include "zoneviewwidget.h"
|
#include "zoneviewwidget.h"
|
||||||
|
#include "zoneviewzone.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
|
||||||
ZoneViewLayout::ZoneViewLayout(CardDatabase *_db, QGraphicsItem *parent)
|
ZoneViewLayout::ZoneViewLayout(CardDatabase *_db, QGraphicsItem *parent)
|
||||||
|
@ -30,8 +31,17 @@ void ZoneViewLayout::reorganize()
|
||||||
emit sizeChanged();
|
emit sizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneViewLayout::addItem(Player *player, const QString &zoneName, int numberCards)
|
void ZoneViewLayout::toggleZoneView(Player *player, const QString &zoneName, int numberCards)
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < views.size(); i++) {
|
||||||
|
ZoneViewZone *temp = views[i]->getZone();
|
||||||
|
if ((temp->getName() == zoneName) && (temp->getPlayer() == player)) { // view is already open
|
||||||
|
removeItem(views[i]);
|
||||||
|
if (temp->getNumberCards() == numberCards)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ZoneViewWidget *item = new ZoneViewWidget(db, player, player->getZones()->findZone(zoneName), numberCards, this);
|
ZoneViewWidget *item = new ZoneViewWidget(db, player, player->getZones()->findZone(zoneName), numberCards, this);
|
||||||
views.append(item);
|
views.append(item);
|
||||||
connect(item, SIGNAL(closePressed(ZoneViewWidget *)), this, SLOT(removeItem(ZoneViewWidget *)));
|
connect(item, SIGNAL(closePressed(ZoneViewWidget *)), this, SLOT(removeItem(ZoneViewWidget *)));
|
||||||
|
@ -46,6 +56,11 @@ void ZoneViewLayout::removeItem(ZoneViewWidget *item)
|
||||||
reorganize();
|
reorganize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZoneViewLayout::removeItem(ZoneViewZone *item)
|
||||||
|
{
|
||||||
|
removeItem(dynamic_cast<ZoneViewWidget *>(item->parentItem()));
|
||||||
|
}
|
||||||
|
|
||||||
void ZoneViewLayout::closeMostRecentZoneView()
|
void ZoneViewLayout::closeMostRecentZoneView()
|
||||||
{
|
{
|
||||||
if (views.isEmpty())
|
if (views.isEmpty())
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
class CardDatabase;
|
class CardDatabase;
|
||||||
class ZoneViewWidget;
|
class ZoneViewWidget;
|
||||||
|
class ZoneViewZone;
|
||||||
class Player;
|
class Player;
|
||||||
|
|
||||||
class ZoneViewLayout : public QGraphicsWidget {
|
class ZoneViewLayout : public QGraphicsWidget {
|
||||||
|
@ -18,8 +19,9 @@ public:
|
||||||
ZoneViewLayout(CardDatabase *_db, QGraphicsItem *parent = 0);
|
ZoneViewLayout(CardDatabase *_db, QGraphicsItem *parent = 0);
|
||||||
void reorganize();
|
void reorganize();
|
||||||
public slots:
|
public slots:
|
||||||
void addItem(Player *player, const QString &zoneName, int numberCards = 0);
|
void toggleZoneView(Player *player, const QString &zoneName, int numberCards = 0);
|
||||||
void removeItem(ZoneViewWidget *item);
|
void removeItem(ZoneViewWidget *item);
|
||||||
|
void removeItem(ZoneViewZone *item);
|
||||||
void closeMostRecentZoneView();
|
void closeMostRecentZoneView();
|
||||||
void clear();
|
void clear();
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,6 +30,7 @@ private slots:
|
||||||
void zoneDumpReceived(int commandId, QList<ServerZoneCard *> cards);
|
void zoneDumpReceived(int commandId, QList<ServerZoneCard *> cards);
|
||||||
public:
|
public:
|
||||||
ZoneViewWidget(CardDatabase *_db, Player *_player, CardZone *_origZone, int numberCards = 0, QGraphicsItem *parent = 0);
|
ZoneViewWidget(CardDatabase *_db, Player *_player, CardZone *_origZone, int numberCards = 0, QGraphicsItem *parent = 0);
|
||||||
|
ZoneViewZone *getZone() const { return zone; }
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,6 +23,7 @@ public:
|
||||||
bool initializeCards();
|
bool initializeCards();
|
||||||
void removeCard(int position);
|
void removeCard(int position);
|
||||||
void setHeight(int _height) { height = _height; }
|
void setHeight(int _height) { height = _height; }
|
||||||
|
int getNumberCards() const { return numberCards; }
|
||||||
protected:
|
protected:
|
||||||
void addCardImpl(CardItem *card, int x, int y);
|
void addCardImpl(CardItem *card, int x, int y);
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,8 @@ HEADERS += src/server.h src/servergame.h src/serversocket.h \
|
||||||
src/card.h \
|
src/card.h \
|
||||||
src/version.h \
|
src/version.h \
|
||||||
src/counter.h \
|
src/counter.h \
|
||||||
src/random.h \
|
src/abstractrng.h \
|
||||||
|
src/rng_qt.h \
|
||||||
src/returnmessage.h
|
src/returnmessage.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/server.cpp \
|
src/server.cpp \
|
||||||
|
@ -28,5 +29,5 @@ SOURCES += src/main.cpp \
|
||||||
src/playerzone.cpp \
|
src/playerzone.cpp \
|
||||||
src/card.cpp \
|
src/card.cpp \
|
||||||
src/counter.cpp \
|
src/counter.cpp \
|
||||||
src/random.cpp \
|
src/rng_qt.cpp \
|
||||||
src/returnmessage.cpp
|
src/returnmessage.cpp
|
||||||
|
|
13
servatrice/src/abstractrng.h
Normal file
13
servatrice/src/abstractrng.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef ABSTRACTRNG_H
|
||||||
|
#define ABSTRACTRNG_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class AbstractRNG : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
AbstractRNG(QObject *parent = 0) : QObject(parent) { }
|
||||||
|
virtual unsigned int getNumber(unsigned int min, unsigned int max) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -18,7 +18,7 @@
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "playerzone.h"
|
#include "playerzone.h"
|
||||||
#include "random.h"
|
#include "abstractrng.h"
|
||||||
#include "card.h"
|
#include "card.h"
|
||||||
|
|
||||||
PlayerZone::PlayerZone(QString _name, bool _has_coords, bool _is_public, bool _is_private, bool _id_access)
|
PlayerZone::PlayerZone(QString _name, bool _has_coords, bool _is_public, bool _is_private, bool _id_access)
|
||||||
|
@ -32,7 +32,7 @@ PlayerZone::~PlayerZone()
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerZone::shuffle(Random *rnd)
|
void PlayerZone::shuffle(AbstractRNG *rnd)
|
||||||
{
|
{
|
||||||
QList<Card *> temp;
|
QList<Card *> temp;
|
||||||
for (int i = cards.size(); i; i--)
|
for (int i = cards.size(); i; i--)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class Card;
|
class Card;
|
||||||
class Random;
|
class AbstractRNG;
|
||||||
|
|
||||||
class PlayerZone {
|
class PlayerZone {
|
||||||
private:
|
private:
|
||||||
|
@ -52,7 +52,7 @@ public:
|
||||||
|
|
||||||
QList<Card *> cards;
|
QList<Card *> cards;
|
||||||
void insertCard(Card *card, int x, int y);
|
void insertCard(Card *card, int x, int y);
|
||||||
void shuffle(Random *rnd);
|
void shuffle(AbstractRNG *rnd);
|
||||||
void clear();
|
void clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
#ifndef RANDOM_H
|
|
||||||
#define RANDOM_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
class Random : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
Random(QObject *parent = 0);
|
|
||||||
unsigned int getNumber(unsigned int min, unsigned int max);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,16 +1,16 @@
|
||||||
#include "random.h"
|
#include "rng_qt.h"
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
Random::Random(QObject *parent)
|
RNG_Qt::RNG_Qt(QObject *parent)
|
||||||
: QObject(parent)
|
: AbstractRNG(parent)
|
||||||
{
|
{
|
||||||
int seed = QDateTime::currentDateTime().toTime_t();
|
int seed = QDateTime::currentDateTime().toTime_t();
|
||||||
qDebug(QString("qsrand(%1)").arg(seed).toLatin1());
|
qDebug(QString("qsrand(%1)").arg(seed).toLatin1());
|
||||||
qsrand(seed);
|
qsrand(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Random::getNumber(unsigned int min, unsigned int max)
|
unsigned int RNG_Qt::getNumber(unsigned int min, unsigned int max)
|
||||||
{
|
{
|
||||||
int r = qrand();
|
int r = qrand();
|
||||||
return min + (unsigned int) (((double) (max + 1 - min)) * r / (RAND_MAX + 1.0));
|
return min + (unsigned int) (((double) (max + 1 - min)) * r / (RAND_MAX + 1.0));
|
13
servatrice/src/rng_qt.h
Normal file
13
servatrice/src/rng_qt.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef RNG_QT_H
|
||||||
|
#define RNG_QT_H
|
||||||
|
|
||||||
|
#include "abstractrng.h"
|
||||||
|
|
||||||
|
class RNG_Qt : public AbstractRNG {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
RNG_Qt(QObject *parent = 0);
|
||||||
|
unsigned int getNumber(unsigned int min, unsigned int max);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -21,12 +21,15 @@
|
||||||
#include "servergame.h"
|
#include "servergame.h"
|
||||||
#include "serversocket.h"
|
#include "serversocket.h"
|
||||||
#include "counter.h"
|
#include "counter.h"
|
||||||
|
#include "rng_qt.h"
|
||||||
#include <QtSql>
|
#include <QtSql>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
Server::Server(QObject *parent)
|
Server::Server(QObject *parent)
|
||||||
: QTcpServer(parent), nextGameId(0)
|
: QTcpServer(parent), nextGameId(0)
|
||||||
{
|
{
|
||||||
|
rng = new RNG_Qt(this);
|
||||||
|
|
||||||
settings = new QSettings("servatrice.ini", QSettings::IniFormat, this);
|
settings = new QSettings("servatrice.ini", QSettings::IniFormat, this);
|
||||||
|
|
||||||
QString dbType = settings->value("database/type").toString();
|
QString dbType = settings->value("database/type").toString();
|
||||||
|
|
|
@ -26,6 +26,7 @@ class ServerGame;
|
||||||
class ServerSocket;
|
class ServerSocket;
|
||||||
class QSqlDatabase;
|
class QSqlDatabase;
|
||||||
class QSettings;
|
class QSettings;
|
||||||
|
class AbstractRNG;
|
||||||
|
|
||||||
enum AuthenticationResult { PasswordWrong = 0, PasswordRight = 1, UnknownUser = 2 };
|
enum AuthenticationResult { PasswordWrong = 0, PasswordRight = 1, UnknownUser = 2 };
|
||||||
|
|
||||||
|
@ -45,10 +46,12 @@ public:
|
||||||
AuthenticationResult checkUserPassword(const QString &user, const QString &password);
|
AuthenticationResult checkUserPassword(const QString &user, const QString &password);
|
||||||
QList<ServerGame *> listOpenGames();
|
QList<ServerGame *> listOpenGames();
|
||||||
ServerGame *getGame(int gameId);
|
ServerGame *getGame(int gameId);
|
||||||
|
AbstractRNG *getRNG() const { return rng; }
|
||||||
private:
|
private:
|
||||||
void incomingConnection(int SocketId);
|
void incomingConnection(int SocketId);
|
||||||
QList<ServerGame *> games;
|
QList<ServerGame *> games;
|
||||||
int nextGameId;
|
int nextGameId;
|
||||||
|
AbstractRNG *rng;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,19 +18,17 @@
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "servergame.h"
|
#include "servergame.h"
|
||||||
#include "random.h"
|
|
||||||
#include "serversocket.h"
|
#include "serversocket.h"
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
|
|
||||||
ServerGame::ServerGame(ServerSocket *_creator, int _gameId, QString _description, QString _password, int _maxPlayers, QObject *parent)
|
ServerGame::ServerGame(ServerSocket *_creator, int _gameId, QString _description, QString _password, int _maxPlayers, QObject *parent)
|
||||||
: QObject(parent), gameStarted(false), rnd(0), creator(_creator), gameId(_gameId), description(_description), password(_password), maxPlayers(_maxPlayers)
|
: QObject(parent), gameStarted(false), creator(_creator), gameId(_gameId), description(_description), password(_password), maxPlayers(_maxPlayers)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerGame::~ServerGame()
|
ServerGame::~ServerGame()
|
||||||
{
|
{
|
||||||
emit gameClosing();
|
emit gameClosing();
|
||||||
delete rnd;
|
|
||||||
qDebug("ServerGame destructor");
|
qDebug("ServerGame destructor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,11 +101,6 @@ void ServerGame::startGameIfReady()
|
||||||
query.exec();
|
query.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rnd) {
|
|
||||||
rnd = new Random(this);
|
|
||||||
rnd->init();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < players.size(); i++)
|
for (int i = 0; i < players.size(); i++)
|
||||||
players.at(i)->setupZones();
|
players.at(i)->setupZones();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
class ServerSocket;
|
class ServerSocket;
|
||||||
class Random;
|
|
||||||
|
|
||||||
class ServerGame : public QObject {
|
class ServerGame : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -37,7 +36,6 @@ signals:
|
||||||
public slots:
|
public slots:
|
||||||
void broadcastEvent(const QString &event, ServerSocket *player);
|
void broadcastEvent(const QString &event, ServerSocket *player);
|
||||||
public:
|
public:
|
||||||
Random *rnd;
|
|
||||||
ServerSocket *creator;
|
ServerSocket *creator;
|
||||||
int gameId;
|
int gameId;
|
||||||
QString description;
|
QString description;
|
||||||
|
@ -57,7 +55,6 @@ public:
|
||||||
int getActivePhase() { return activePhase; }
|
int getActivePhase() { return activePhase; }
|
||||||
void setActivePlayer(int _activePlayer);
|
void setActivePlayer(int _activePlayer);
|
||||||
void setActivePhase(int _activePhase);
|
void setActivePhase(int _activePhase);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "playerzone.h"
|
#include "playerzone.h"
|
||||||
#include "counter.h"
|
#include "counter.h"
|
||||||
#include "card.h"
|
#include "card.h"
|
||||||
#include "random.h"
|
#include "abstractrng.h"
|
||||||
|
|
||||||
ServerSocket::ServerSocket(Server *_server, QObject *parent)
|
ServerSocket::ServerSocket(Server *_server, QObject *parent)
|
||||||
: QTcpSocket(parent), server(_server), game(0), authState(PasswordWrong)
|
: QTcpSocket(parent), server(_server), game(0), authState(PasswordWrong)
|
||||||
|
@ -105,7 +105,7 @@ void ServerSocket::setupZones()
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (DeckIterator.hasNext())
|
while (DeckIterator.hasNext())
|
||||||
deck->cards.append(new Card(DeckIterator.next(), i++, 0, 0));
|
deck->cards.append(new Card(DeckIterator.next(), i++, 0, 0));
|
||||||
deck->shuffle(game->rnd);
|
deck->shuffle(server->getRNG());
|
||||||
|
|
||||||
QListIterator<QString> SBIterator(SideboardList);
|
QListIterator<QString> SBIterator(SideboardList);
|
||||||
while (SBIterator.hasNext())
|
while (SBIterator.hasNext())
|
||||||
|
@ -315,7 +315,7 @@ ReturnMessage::ReturnCode ServerSocket::cmdReadyStart(const QList<QVariant> &par
|
||||||
ReturnMessage::ReturnCode ServerSocket::cmdShuffle(const QList<QVariant> ¶ms)
|
ReturnMessage::ReturnCode ServerSocket::cmdShuffle(const QList<QVariant> ¶ms)
|
||||||
{
|
{
|
||||||
Q_UNUSED(params);
|
Q_UNUSED(params);
|
||||||
getZone("deck")->shuffle(game->rnd);
|
getZone("deck")->shuffle(server->getRNG());
|
||||||
emit broadcastEvent("shuffle", this);
|
emit broadcastEvent("shuffle", this);
|
||||||
return ReturnMessage::ReturnOk;
|
return ReturnMessage::ReturnOk;
|
||||||
}
|
}
|
||||||
|
@ -367,6 +367,8 @@ ReturnMessage::ReturnCode ServerSocket::cmdMoveCard(const QList<QVariant> ¶m
|
||||||
if (!card)
|
if (!card)
|
||||||
return ReturnMessage::ReturnContextError;
|
return ReturnMessage::ReturnContextError;
|
||||||
int x = params[3].toInt();
|
int x = params[3].toInt();
|
||||||
|
if (x == -1)
|
||||||
|
x = targetzone->cards.size();
|
||||||
int y = 0;
|
int y = 0;
|
||||||
if (targetzone->hasCoords())
|
if (targetzone->hasCoords())
|
||||||
y = params[4].toInt();
|
y = params[4].toInt();
|
||||||
|
@ -571,7 +573,7 @@ ReturnMessage::ReturnCode ServerSocket::cmdDumpZone(const QList<QVariant> ¶m
|
||||||
ReturnMessage::ReturnCode ServerSocket::cmdRollDice(const QList<QVariant> ¶ms)
|
ReturnMessage::ReturnCode ServerSocket::cmdRollDice(const QList<QVariant> ¶ms)
|
||||||
{
|
{
|
||||||
int sides = params[0].toInt();
|
int sides = params[0].toInt();
|
||||||
emit broadcastEvent(QString("roll_dice|%1|%2").arg(sides).arg(game->rnd->getNumber(1, sides)), this);
|
emit broadcastEvent(QString("roll_dice|%1|%2").arg(sides).arg(server->getRNG()->getNumber(1, sides)), this);
|
||||||
return ReturnMessage::ReturnOk;
|
return ReturnMessage::ReturnOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue