mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
Player refactor (#6112)
* Player refactor. Took 1 hour 43 minutes Took 1 minute Took 23 seconds * Tiny lint. Took 3 minutes * Hook up tap logic again. Took 13 minutes * Fix an include. Took 3 minutes * Stuff. Took 6 minutes * Fix typo. Took 7 minutes * Include. Took 1 minute * Reorganize method/variable definitions, remove unused ones. Took 1 hour 8 minutes Took 24 seconds * Clean up some unused imports. Took 6 minutes * Player holds the deck, emits deckChanged(), other elements player->getDeck() to respond to changes. Took 37 minutes * Connect player->openDeckEditor signal directly in the player constructor Took 6 minutes * Emit openDeckEditor signal in player_actions again. Took 3 minutes * Do to-do's Took 3 hours 32 minutes * Lint. Took 3 minutes * Lint again. Took 2 minutes * Fix include. Took 32 minutes * The stack should ensure card visibility. Took 21 minutes * Fine, the game can remember the tab. Took 10 minutes Took 21 seconds Took 9 seconds * zoneId is a dynamic gameplay property and thus belongs in player.cpp Took 11 minutes Took 19 seconds * Signal view removal, addition. Took 5 minutes * Ensure all players are considered local in local game. Took 10 minutes * ENSURE they are. Took 8 minutes * Bounds check data sent by QAction() Took 54 minutes * Move comment. Took 20 seconds * Reimplement logging category for game_event_handler.cpp, remove linebreaks. Took 36 seconds * PlayerGraphicsItem is responsible for retranslateUi, not Player. Took 14 seconds * Set menu for sideboard again, translate some menu titles, reimplement actIncPT action Took 54 seconds * Comment spacing. Took 43 seconds * Change message_log_widget.cpp slots to take CardZoneLogic parameters as emitted by PlayerEventHandler. Took 7 minutes Took 14 seconds * Remove unused player_logger.cpp Took 2 minutes * Query local game state correctly from tab_supervisor again Took 3 minutes * Revert Deck legality checker. Took 3 minutes * Instantiate menu before graphics item. Took 1 hour 5 minutes Took 55 minutes * Differentiate games and replays. Took 9 seconds * Lint. Took 10 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
b8e545bfa4
commit
9601a1fa4e
92 changed files with 7104 additions and 5827 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include "../settings/cache_settings.h"
|
||||
#include "board/card_item.h"
|
||||
#include "player/player.h"
|
||||
#include "player/player_graphics_item.h"
|
||||
#include "zones/view_zone.h"
|
||||
#include "zones/view_zone_widget.h"
|
||||
|
||||
|
|
@ -46,23 +47,22 @@ void GameScene::retranslateUi()
|
|||
|
||||
void GameScene::addPlayer(Player *player)
|
||||
{
|
||||
qCInfo(GameScenePlayerAdditionRemovalLog) << "GameScene::addPlayer name=" << player->getName();
|
||||
players << player;
|
||||
addItem(player);
|
||||
connect(player, &Player::sizeChanged, this, &GameScene::rearrange);
|
||||
connect(player, &Player::playerCountChanged, this, &GameScene::rearrange);
|
||||
qCInfo(GameScenePlayerAdditionRemovalLog) << "GameScene::addPlayer name=" << player->getPlayerInfo()->getName();
|
||||
players << player->getGraphicsItem();
|
||||
addItem(player->getGraphicsItem());
|
||||
connect(player->getGraphicsItem(), &PlayerGraphicsItem::sizeChanged, this, &GameScene::rearrange);
|
||||
}
|
||||
|
||||
void GameScene::removePlayer(Player *player)
|
||||
{
|
||||
qCInfo(GameScenePlayerAdditionRemovalLog) << "GameScene::removePlayer name=" << player->getName();
|
||||
qCInfo(GameScenePlayerAdditionRemovalLog) << "GameScene::removePlayer name=" << player->getPlayerInfo()->getName();
|
||||
for (ZoneViewWidget *zone : zoneViews) {
|
||||
if (zone->getPlayer() == player) {
|
||||
zone->close();
|
||||
}
|
||||
}
|
||||
players.removeOne(player);
|
||||
removeItem(player);
|
||||
players.removeOne(player->getGraphicsItem());
|
||||
removeItem(player->getGraphicsItem());
|
||||
rearrange();
|
||||
}
|
||||
|
||||
|
|
@ -80,12 +80,12 @@ void GameScene::rearrange()
|
|||
QList<Player *> playersPlaying;
|
||||
int firstPlayerIndex = 0;
|
||||
bool firstPlayerFound = false;
|
||||
QListIterator<Player *> playersIter(players);
|
||||
QListIterator<PlayerGraphicsItem *> playersIter(players);
|
||||
while (playersIter.hasNext()) {
|
||||
Player *p = playersIter.next();
|
||||
Player *p = playersIter.next()->getPlayer();
|
||||
if (p && !p->getConceded()) {
|
||||
playersPlaying.append(p);
|
||||
if (!firstPlayerFound && (p->getLocal())) {
|
||||
if (!firstPlayerFound && (p->getPlayerInfo()->getLocal())) {
|
||||
firstPlayerIndex = playersPlaying.size() - 1;
|
||||
firstPlayerFound = true;
|
||||
}
|
||||
|
|
@ -111,19 +111,19 @@ void GameScene::rearrange()
|
|||
|
||||
QListIterator<Player *> playersPlayingIter(playersPlaying);
|
||||
for (int col = 0; col < columns; ++col) {
|
||||
playersByColumn.append(QList<Player *>());
|
||||
playersByColumn.append(QList<PlayerGraphicsItem *>());
|
||||
columnWidth.append(0);
|
||||
qreal thisColumnHeight = -playerAreaSpacing;
|
||||
const int rowsInColumn = rows - (playersCount % columns) * col; // only correct for max. 2 cols
|
||||
for (int j = 0; j < rowsInColumn; ++j) {
|
||||
Player *player = playersPlayingIter.next();
|
||||
if (col == 0)
|
||||
playersByColumn[col].prepend(player);
|
||||
playersByColumn[col].prepend(player->getGraphicsItem());
|
||||
else
|
||||
playersByColumn[col].append(player);
|
||||
thisColumnHeight += player->boundingRect().height() + playerAreaSpacing;
|
||||
if (player->boundingRect().width() > columnWidth[col])
|
||||
columnWidth[col] = player->boundingRect().width();
|
||||
playersByColumn[col].append(player->getGraphicsItem());
|
||||
thisColumnHeight += player->getGraphicsItem()->boundingRect().height() + playerAreaSpacing;
|
||||
if (player->getGraphicsItem()->boundingRect().width() > columnWidth[col])
|
||||
columnWidth[col] = player->getGraphicsItem()->boundingRect().width();
|
||||
}
|
||||
if (thisColumnHeight > sceneHeight)
|
||||
sceneHeight = thisColumnHeight;
|
||||
|
|
@ -138,7 +138,7 @@ void GameScene::rearrange()
|
|||
for (int col = 0; col < columns; ++col) {
|
||||
qreal y = 0;
|
||||
for (int row = 0; row < playersByColumn[col].size(); ++row) {
|
||||
Player *player = playersByColumn[col][row];
|
||||
PlayerGraphicsItem *player = playersByColumn[col][row];
|
||||
player->setPos(x, y);
|
||||
player->setMirrored(row != rows - 1);
|
||||
y += player->boundingRect().height() + playerAreaSpacing;
|
||||
|
|
@ -154,7 +154,8 @@ void GameScene::toggleZoneView(Player *player, const QString &zoneName, int numb
|
|||
{
|
||||
for (auto &view : zoneViews) {
|
||||
ZoneViewZone *temp = view->getZone();
|
||||
if (temp->getName() == zoneName && temp->getPlayer() == player && temp->getNumberCards() == numberCards) {
|
||||
if (temp->getLogic()->getName() == zoneName && temp->getLogic()->getPlayer() == player &&
|
||||
qobject_cast<ZoneViewZoneLogic *>(temp->getLogic())->getNumberCards() == numberCards) {
|
||||
view->close();
|
||||
}
|
||||
}
|
||||
|
|
@ -174,7 +175,7 @@ void GameScene::toggleZoneView(Player *player, const QString &zoneName, int numb
|
|||
}
|
||||
|
||||
void GameScene::addRevealedZoneView(Player *player,
|
||||
CardZone *zone,
|
||||
CardZoneLogic *zone,
|
||||
const QList<const ServerInfo_Card *> &cardList,
|
||||
bool withWritePermission)
|
||||
{
|
||||
|
|
@ -272,9 +273,9 @@ void GameScene::updateHover(const QPointF &scenePos)
|
|||
if (!card)
|
||||
continue;
|
||||
if (card->getAttachedTo()) {
|
||||
if (card->getAttachedTo()->getZone() != zone)
|
||||
if (card->getAttachedTo()->getZone() != zone->getLogic())
|
||||
continue;
|
||||
} else if (card->getZone() != zone)
|
||||
} else if (card->getZone() != zone->getLogic())
|
||||
continue;
|
||||
|
||||
if (card->getRealZValue() > maxZ) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue