mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
servatrice: stub for reveal_card, database changes
This commit is contained in:
parent
03847a9b36
commit
08df264556
5 changed files with 49 additions and 5 deletions
|
|
@ -20,6 +20,7 @@
|
|||
#include "servergame.h"
|
||||
#include "random.h"
|
||||
#include "serversocket.h"
|
||||
#include <QSqlQuery>
|
||||
|
||||
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)
|
||||
|
|
@ -88,6 +89,20 @@ void ServerGame::startGameIfReady()
|
|||
if (players.at(i)->getStatus() != StatusReadyStart)
|
||||
return;
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("insert into games (id, descr, password, time_started) values(:id, :descr, :password, now())");
|
||||
query.bindValue(":id", gameId);
|
||||
query.bindValue(":descr", description);
|
||||
query.bindValue(":password", !password.isEmpty());
|
||||
query.exec();
|
||||
|
||||
for (int i = 0; i < players.size(); i++) {
|
||||
query.prepare("insert into games_players (id_game, player) values(:id, :player)");
|
||||
query.bindValue(":id", gameId);
|
||||
query.bindValue(":player", players.at(i)->PlayerName);
|
||||
query.exec();
|
||||
}
|
||||
|
||||
if (!rnd) {
|
||||
rnd = new Random(this);
|
||||
rnd->init();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue