mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 14:32:15 -07:00
zoneId is a dynamic gameplay property and thus belongs in player.cpp
Took 11 minutes Took 19 seconds
This commit is contained in:
parent
270bdefd87
commit
aaf3c1e3b2
11 changed files with 31 additions and 32 deletions
|
|
@ -766,13 +766,13 @@ void TabGame::createZoneForPlayer(Player *newPlayer, int playerId)
|
|||
for (int i = 1; i <= game->getPlayerManager()->getPlayerCount(); ++i) {
|
||||
bool aPlayerHasThisZone = false;
|
||||
for (auto &player : game->getPlayerManager()->getPlayers()) {
|
||||
if (player->getPlayerInfo()->getZoneId() == i) {
|
||||
if (player->getZoneId() == i) {
|
||||
aPlayerHasThisZone = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!aPlayerHasThisZone) {
|
||||
newPlayer->getPlayerInfo()->setZoneId(i);
|
||||
newPlayer->setZoneId(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, Game *_parent)
|
||||
: QObject(_parent), game(_parent), playerInfo(new PlayerInfo(info, _id, _local, _judge)),
|
||||
playerEventHandler(new PlayerEventHandler(this)), playerActions(new PlayerActions(this)), active(false),
|
||||
conceded(false), deck(nullptr), dialogSemaphore(false)
|
||||
conceded(false), deck(nullptr), zoneId(0), dialogSemaphore(false)
|
||||
{
|
||||
initializeZones();
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, G
|
|||
connect(this, &Player::deckChanged, playerMenu, &PlayerMenu::enableOpenInDeckEditorAction);
|
||||
connect(this, &Player::deckChanged, playerMenu, &PlayerMenu::populatePredefinedTokensMenu);
|
||||
|
||||
// connect(this, &Player::openDeckEditor, game, &TabGame::openDeckEditor);
|
||||
connect(this, &Player::openDeckEditor, game->getTab(), &TabGame::openDeckEditor);
|
||||
}
|
||||
|
||||
void Player::initializeZones()
|
||||
|
|
@ -109,6 +109,12 @@ void Player::setConceded(bool _conceded)
|
|||
}
|
||||
}
|
||||
|
||||
void Player::setZoneId(int _zoneId)
|
||||
{
|
||||
zoneId = _zoneId;
|
||||
graphicsItem->getPlayerArea()->setPlayerZoneId(zoneId);
|
||||
}
|
||||
|
||||
void Player::processPlayerInfo(const ServerInfo_Player &info)
|
||||
{
|
||||
static QSet<QString> builtinZones{/* PileZones */
|
||||
|
|
|
|||
|
|
@ -217,6 +217,13 @@ public:
|
|||
dialogSemaphore = _active;
|
||||
}
|
||||
|
||||
int getZoneId() const
|
||||
{
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
void setZoneId(int _zoneId);
|
||||
|
||||
private:
|
||||
Game *game;
|
||||
PlayerInfo *playerInfo;
|
||||
|
|
@ -230,6 +237,7 @@ private:
|
|||
|
||||
DeckLoader *deck;
|
||||
|
||||
int zoneId;
|
||||
QMap<QString, CardZoneLogic *> zones;
|
||||
QMap<int, AbstractCounter *> counters;
|
||||
QMap<int, ArrowItem *> arrows;
|
||||
|
|
|
|||
|
|
@ -146,7 +146,6 @@ void PlayerActions::actViewTopCards()
|
|||
{
|
||||
int deckSize = player->getDeckZone()->getCards().size();
|
||||
bool ok;
|
||||
// TODO: Signal this
|
||||
int number = QInputDialog::getInt(player->getGame()->getTab(), tr("View top cards of library"),
|
||||
tr("Number of cards: (max. %1)").arg(deckSize), defaultNumberTopCards, 1,
|
||||
deckSize, 1, &ok);
|
||||
|
|
|
|||
|
|
@ -53,6 +53,11 @@ public:
|
|||
return player;
|
||||
}
|
||||
|
||||
PlayerArea *getPlayerArea() const
|
||||
{
|
||||
return playerArea;
|
||||
}
|
||||
|
||||
PlayerTarget *getPlayerTarget() const
|
||||
{
|
||||
return playerTarget;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,8 @@
|
|||
#include "player_info.h"
|
||||
|
||||
PlayerInfo::PlayerInfo(const ServerInfo_User &info, int _id, bool _local, bool _judge)
|
||||
: id(_id), local(_local), judge(_judge), handVisible(false), zoneId(0)
|
||||
: id(_id), local(_local), judge(_judge), handVisible(false)
|
||||
{
|
||||
userInfo = new ServerInfo_User;
|
||||
userInfo->CopyFrom(info);
|
||||
}
|
||||
|
||||
void PlayerInfo::setZoneId(int _zoneId)
|
||||
{
|
||||
// TODO: deal with this
|
||||
zoneId = _zoneId;
|
||||
// playerArea->setPlayerZoneId(_zoneId);
|
||||
}
|
||||
|
|
@ -22,14 +22,6 @@ public:
|
|||
bool local;
|
||||
bool judge;
|
||||
bool handVisible;
|
||||
int zoneId;
|
||||
|
||||
int getZoneId() const
|
||||
{
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
void setZoneId(int _zoneId);
|
||||
|
||||
int getId() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -519,8 +519,7 @@ void PlayerMenu::playerListActionTriggered()
|
|||
} else if (menu == mRevealTopCard) {
|
||||
int deckSize = player->getDeckZone()->getCards().size();
|
||||
bool ok;
|
||||
// TODO: Correctly parent this
|
||||
int number = QInputDialog::getInt(/* player->getGame() */ nullptr, tr("Reveal top cards of library"),
|
||||
int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Reveal top cards of library"),
|
||||
tr("Number of cards: (max. %1)").arg(deckSize), /* defaultNumberTopCards */ 1,
|
||||
1, deckSize, 1, &ok);
|
||||
if (ok) {
|
||||
|
|
@ -822,9 +821,9 @@ void PlayerMenu::addRelatedCardView(const CardItem *card, QMenu *cardMenu)
|
|||
CardRef cardRef = {relatedCardName, exactCard.getPrinting().getUuid()};
|
||||
QAction *viewCard = viewRelatedCards->addAction(relatedCardName);
|
||||
Q_UNUSED(viewCard);
|
||||
// TODO: Signal this
|
||||
/*connect(viewCard, &QAction::triggered, player->getGame(),
|
||||
[this, cardRef] { player->getGame()->viewCardInfo(cardRef); });*/
|
||||
|
||||
connect(viewCard, &QAction::triggered, player->getGame(),
|
||||
[this, cardRef] { player->getGame()->getTab()->viewCardInfo(cardRef); });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,8 +62,7 @@ QRectF HandZone::boundingRect() const
|
|||
|
||||
void HandZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||
{
|
||||
QBrush brush =
|
||||
themeManager->getExtraBgBrush(ThemeManager::Hand, getLogic()->getPlayer()->getPlayerInfo()->getZoneId());
|
||||
QBrush brush = themeManager->getExtraBgBrush(ThemeManager::Hand, getLogic()->getPlayer()->getZoneId());
|
||||
painter->fillRect(boundingRect(), brush);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ QRectF StackZone::boundingRect() const
|
|||
|
||||
void StackZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||
{
|
||||
QBrush brush =
|
||||
themeManager->getExtraBgBrush(ThemeManager::Stack, getLogic()->getPlayer()->getPlayerInfo()->getZoneId());
|
||||
QBrush brush = themeManager->getExtraBgBrush(ThemeManager::Stack, getLogic()->getPlayer()->getZoneId());
|
||||
painter->fillRect(boundingRect(), brush);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,8 +58,7 @@ bool TableZone::isInverted() const
|
|||
|
||||
void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||
{
|
||||
QBrush brush =
|
||||
themeManager->getExtraBgBrush(ThemeManager::Table, getLogic()->getPlayer()->getPlayerInfo()->getZoneId());
|
||||
QBrush brush = themeManager->getExtraBgBrush(ThemeManager::Table, getLogic()->getPlayer()->getZoneId());
|
||||
painter->fillRect(boundingRect(), brush);
|
||||
|
||||
if (active) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue