mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-16 15:32:15 -07:00
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 11 (push) Blocked by required conditions
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Fedora 42 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 11 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 22.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
55 lines
No EOL
1.4 KiB
C++
55 lines
No EOL
1.4 KiB
C++
#include "abstract_game.h"
|
|
|
|
#include "../interface/widgets/tabs/tab_game.h"
|
|
#include "player/player.h"
|
|
|
|
AbstractGame::AbstractGame(TabGame *_tab) : QObject(_tab), tab(_tab)
|
|
{
|
|
gameMetaInfo = new GameMetaInfo(this);
|
|
gameEventHandler = new GameEventHandler(this);
|
|
|
|
activeCard = nullptr;
|
|
}
|
|
|
|
bool AbstractGame::isHost() const
|
|
{
|
|
return gameState->getHostId() == playerManager->getLocalPlayerId();
|
|
}
|
|
|
|
AbstractClient *AbstractGame::getClientForPlayer(int playerId) const
|
|
{
|
|
if (gameState->getClients().size() > 1) {
|
|
if (playerId == -1) {
|
|
playerId = playerManager->getActiveLocalPlayer(gameState->getActivePlayer())->getPlayerInfo()->getId();
|
|
}
|
|
|
|
return gameState->getClients().at(playerId);
|
|
} else if (gameState->getClients().isEmpty())
|
|
return nullptr;
|
|
else
|
|
return gameState->getClients().first();
|
|
}
|
|
|
|
void AbstractGame::loadReplay(GameReplay *replay)
|
|
{
|
|
gameMetaInfo->setFromProto(replay->game_info());
|
|
gameMetaInfo->setSpectatorsOmniscient(true);
|
|
}
|
|
|
|
void AbstractGame::setActiveCard(CardItem *card)
|
|
{
|
|
activeCard = card;
|
|
}
|
|
|
|
CardItem *AbstractGame::getCard(int playerId, const QString &zoneName, int cardId) const
|
|
{
|
|
Player *player = playerManager->getPlayer(playerId);
|
|
if (!player)
|
|
return nullptr;
|
|
|
|
CardZoneLogic *zone = player->getZones().value(zoneName, 0);
|
|
if (!zone)
|
|
return nullptr;
|
|
|
|
return zone->getCard(cardId);
|
|
} |