single player fixes

This commit is contained in:
Max-Wilhelm Bruker 2010-09-07 02:46:54 +02:00
parent 4d0c9962f4
commit 90ffc76730
4 changed files with 39 additions and 30 deletions

View file

@ -343,7 +343,7 @@ Player *TabGame::addPlayer(int playerId, const QString &playerName)
return newPlayer; return newPlayer;
} }
void TabGame::processGameEventContainer(GameEventContainer *cont) void TabGame::processGameEventContainer(GameEventContainer *cont, AbstractClient *client)
{ {
const QList<GameEvent *> &eventList = cont->getEventList(); const QList<GameEvent *> &eventList = cont->getEventList();
GameEventContext *context = cont->getContext(); GameEventContext *context = cont->getContext();
@ -359,7 +359,12 @@ void TabGame::processGameEventContainer(GameEventContainer *cont)
break; break;
} }
} }
} else switch (event->getItemId()) { } else {
if ((clients.size() > 1) && (event->getPlayerId() != -1))
if (clients.at(event->getPlayerId()) != client)
continue;
switch (event->getItemId()) {
case ItemId_Event_GameStateChanged: eventGameStateChanged(qobject_cast<Event_GameStateChanged *>(event), context); break; case ItemId_Event_GameStateChanged: eventGameStateChanged(qobject_cast<Event_GameStateChanged *>(event), context); break;
case ItemId_Event_PlayerPropertiesChanged: eventPlayerPropertiesChanged(qobject_cast<Event_PlayerPropertiesChanged *>(event), context); break; case ItemId_Event_PlayerPropertiesChanged: eventPlayerPropertiesChanged(qobject_cast<Event_PlayerPropertiesChanged *>(event), context); break;
case ItemId_Event_Join: eventJoin(qobject_cast<Event_Join *>(event), context); break; case ItemId_Event_Join: eventJoin(qobject_cast<Event_Join *>(event), context); break;
@ -381,6 +386,7 @@ void TabGame::processGameEventContainer(GameEventContainer *cont)
} }
} }
} }
}
void TabGame::sendGameCommand(GameCommand *command, int playerId) void TabGame::sendGameCommand(GameCommand *command, int playerId)
{ {

View file

@ -153,7 +153,7 @@ public:
bool getSpectatorsSeeEverything() const { return spectatorsSeeEverything; } bool getSpectatorsSeeEverything() const { return spectatorsSeeEverything; }
Player *getActiveLocalPlayer() const; Player *getActiveLocalPlayer() const;
void processGameEventContainer(GameEventContainer *cont); void processGameEventContainer(GameEventContainer *cont, AbstractClient *client);
public slots: public slots:
void sendGameCommand(GameCommand *command, int playerId); void sendGameCommand(GameCommand *command, int playerId);
void sendCommandContainer(CommandContainer *cont, int playerId); void sendCommandContainer(CommandContainer *cont, int playerId);

View file

@ -181,7 +181,7 @@ void TabSupervisor::processGameEventContainer(GameEventContainer *cont)
TabGame *tab = gameTabs.value(cont->getGameId()); TabGame *tab = gameTabs.value(cont->getGameId());
if (tab) { if (tab) {
qDebug() << "gameEvent gameId =" << cont->getGameId(); qDebug() << "gameEvent gameId =" << cont->getGameId();
tab->processGameEventContainer(cont); tab->processGameEventContainer(cont, qobject_cast<AbstractClient *>(sender()));
} else } else
qDebug() << "gameEvent: invalid gameId"; qDebug() << "gameEvent: invalid gameId";
} }

View file

@ -111,9 +111,7 @@ void TableZone::reorganizeCards()
QPointF mapPoint = mapFromGrid(gridPoint); QPointF mapPoint = mapFromGrid(gridPoint);
qreal x = mapPoint.x(); qreal x = mapPoint.x();
qreal y = mapPoint.y(); qreal y = mapPoint.y();
qDebug() << "gridPos=" << gridPoint << "mapPoint=" << mapPoint;
if (player->getMirrored())
y = height - CARD_HEIGHT - y;
int numberAttachedCards = cards[i]->getAttachedCards().size(); int numberAttachedCards = cards[i]->getAttachedCards().size();
qreal actualX = x + numberAttachedCards * CARD_WIDTH / 3.0; qreal actualX = x + numberAttachedCards * CARD_WIDTH / 3.0;
@ -207,7 +205,6 @@ CardItem *TableZone::getCardFromCoords(const QPointF &point) const
return getCardFromGrid(gridPoint); return getCardFromGrid(gridPoint);
} }
QPointF TableZone::mapFromGrid(const QPoint &gridPoint) const QPointF TableZone::mapFromGrid(const QPoint &gridPoint) const
{ {
if ((gridPoint.y() == 3) && (settingsCache->getEconomicGrid())) if ((gridPoint.y() == 3) && (settingsCache->getEconomicGrid()))
@ -220,17 +217,23 @@ QPointF TableZone::mapFromGrid(const QPoint &gridPoint) const
for (int i = 0; i < gridPoint.x(); ++i) for (int i = 0; i < gridPoint.x(); ++i)
x += gridPointWidth.value(gridPoint.y() * 1000 + i, CARD_WIDTH); x += gridPointWidth.value(gridPoint.y() * 1000 + i, CARD_WIDTH);
return QPointF( qreal y = boxLineWidth + (CARD_HEIGHT + paddingY) * gridPoint.y();
x,
boxLineWidth + (CARD_HEIGHT + paddingY) * gridPoint.y() if (player->getMirrored())
); y = height - CARD_HEIGHT - y;
return QPointF(x, y);
} }
} }
QPoint TableZone::mapToGrid(const QPointF &mapPoint) const QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
{ {
qreal x = mapPoint.x() - marginX; qreal x = mapPoint.x() - marginX;
qreal y = mapPoint.y() + paddingY / 2 - boxLineWidth; qreal y = mapPoint.y();
if (player->getMirrored())
y = height - y;
y += paddingY / 2 - boxLineWidth;
if (x < 0) if (x < 0)
x = 0; x = 0;
else if (x > width - CARD_WIDTH - marginX) else if (x > width - CARD_WIDTH - marginX)