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