single player fixes
This commit is contained in:
parent
4d0c9962f4
commit
90ffc76730
4 changed files with 39 additions and 30 deletions
|
@ -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,24 +359,30 @@ void TabGame::processGameEventContainer(GameEventContainer *cont)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else switch (event->getItemId()) {
|
} else {
|
||||||
case ItemId_Event_GameStateChanged: eventGameStateChanged(qobject_cast<Event_GameStateChanged *>(event), context); break;
|
if ((clients.size() > 1) && (event->getPlayerId() != -1))
|
||||||
case ItemId_Event_PlayerPropertiesChanged: eventPlayerPropertiesChanged(qobject_cast<Event_PlayerPropertiesChanged *>(event), context); break;
|
if (clients.at(event->getPlayerId()) != client)
|
||||||
case ItemId_Event_Join: eventJoin(qobject_cast<Event_Join *>(event), context); break;
|
continue;
|
||||||
case ItemId_Event_Leave: eventLeave(qobject_cast<Event_Leave *>(event), context); break;
|
|
||||||
case ItemId_Event_GameClosed: eventGameClosed(qobject_cast<Event_GameClosed *>(event), context); break;
|
switch (event->getItemId()) {
|
||||||
case ItemId_Event_SetActivePlayer: eventSetActivePlayer(qobject_cast<Event_SetActivePlayer *>(event), context); break;
|
case ItemId_Event_GameStateChanged: eventGameStateChanged(qobject_cast<Event_GameStateChanged *>(event), context); break;
|
||||||
case ItemId_Event_SetActivePhase: eventSetActivePhase(qobject_cast<Event_SetActivePhase *>(event), context); break;
|
case ItemId_Event_PlayerPropertiesChanged: eventPlayerPropertiesChanged(qobject_cast<Event_PlayerPropertiesChanged *>(event), context); break;
|
||||||
case ItemId_Event_Ping: eventPing(qobject_cast<Event_Ping *>(event), context); break;
|
case ItemId_Event_Join: eventJoin(qobject_cast<Event_Join *>(event), context); break;
|
||||||
|
case ItemId_Event_Leave: eventLeave(qobject_cast<Event_Leave *>(event), context); break;
|
||||||
default: {
|
case ItemId_Event_GameClosed: eventGameClosed(qobject_cast<Event_GameClosed *>(event), context); break;
|
||||||
Player *player = players.value(event->getPlayerId(), 0);
|
case ItemId_Event_SetActivePlayer: eventSetActivePlayer(qobject_cast<Event_SetActivePlayer *>(event), context); break;
|
||||||
if (!player) {
|
case ItemId_Event_SetActivePhase: eventSetActivePhase(qobject_cast<Event_SetActivePhase *>(event), context); break;
|
||||||
qDebug() << "unhandled game event: invalid player id";
|
case ItemId_Event_Ping: eventPing(qobject_cast<Event_Ping *>(event), context); break;
|
||||||
break;
|
|
||||||
|
default: {
|
||||||
|
Player *player = players.value(event->getPlayerId(), 0);
|
||||||
|
if (!player) {
|
||||||
|
qDebug() << "unhandled game event: invalid player id";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
player->processGameEvent(event, context);
|
||||||
|
emit userEvent();
|
||||||
}
|
}
|
||||||
player->processGameEvent(event, context);
|
|
||||||
emit userEvent();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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";
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()))
|
||||||
|
@ -219,18 +216,24 @@ QPointF TableZone::mapFromGrid(const QPoint &gridPoint) const
|
||||||
qreal x = marginX + 0.5 * CARD_WIDTH * gridPoint.x();
|
qreal x = marginX + 0.5 * CARD_WIDTH * gridPoint.x();
|
||||||
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)
|
||||||
|
|
Loading…
Reference in a new issue