Merge branch 'master' into 6186/target-older-x86-macos

This commit is contained in:
Bruno Alexandre Rosa 2025-10-08 09:44:18 -03:00
commit 19260484af
27 changed files with 3794 additions and 3170 deletions

View file

@ -20,6 +20,7 @@ on:
- '.github/workflows/desktop-build.yml'
- 'CMakeLists.txt'
- 'vcpkg.json'
- 'vcpkg'
tags:
- '*'
pull_request:
@ -34,6 +35,7 @@ on:
- '.github/workflows/desktop-build.yml'
- 'CMakeLists.txt'
- 'vcpkg.json'
- 'vcpkg'
# Cancel earlier, unfinished runs of this workflow on the same branch (unless on master)
concurrency:

View file

@ -1,18 +1,19 @@
name: Code Style (C++)
on:
# push trigger not needed for linting, we do not allow direct pushes to master
pull_request:
paths:
- '*/**' # matches all files not in root
- '!**.md'
- '!.ci/**'
- '!.github/**'
- '!.husky'
- '!.tx'
- '!.husky/**'
- '!.tx/**'
- '!doc/**'
- '!webclient/**'
- '.github/workflows/desktop-lint.yml'
- '.ci/lint_cpp.sh'
- '.github/workflows/desktop-lint.yml'
- '.clang-format'
- '.cmake-format.json'
- 'format.sh'

View file

@ -7,6 +7,7 @@ on:
- cron: '0 0 15 1,4,7,10 *'
pull_request:
paths:
- '.tx/**'
- '.github/workflows/translations-pull.yml'
jobs:

View file

@ -7,6 +7,7 @@ on:
- cron: '0 0 1 1,4,7,10 *'
pull_request:
paths:
- '.ci/update_translation_source_strings.sh'
- '.github/workflows/translations-push.yml'
jobs:

View file

@ -5,14 +5,16 @@ on:
branches:
- master
paths:
- '.github/workflows/web-*.yml'
- '.husky/**'
- 'webclient/**'
- '!**.md'
- '.github/workflows/web-build.yml'
pull_request:
paths:
- '.github/workflows/web-*.yml'
- '.husky/**'
- 'webclient/**'
- '!**.md'
- '.github/workflows/web-build.yml'
jobs:
build-web:

View file

@ -1,11 +1,12 @@
name: Code Style (TypeScript)
on:
# push trigger not needed for linting, we do not allow direct pushes to master
pull_request:
paths:
- '.github/workflows/web-*.yml'
- 'webclient/**'
- '!**.md'
- '.github/workflows/web-lint.yml'
jobs:
ESLint:

View file

@ -478,8 +478,8 @@ AppearanceSettingsPage::AppearanceSettingsPage()
&SettingsCache::setAutoRotateSidewaysLayoutCards);
overrideAllCardArtWithPersonalPreferenceCheckBox.setChecked(settings.getOverrideAllCardArtWithPersonalPreference());
connect(&overrideAllCardArtWithPersonalPreferenceCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings,
&SettingsCache::setOverrideAllCardArtWithPersonalPreference);
connect(&overrideAllCardArtWithPersonalPreferenceCheckBox, &QCheckBox::QT_STATE_CHANGED, this,
&AppearanceSettingsPage::overrideAllCardArtWithPersonalPreferenceToggled);
bumpSetsWithCardsInDeckToTopCheckBox.setChecked(settings.getBumpSetsWithCardsInDeckToTop());
connect(&bumpSetsWithCardsInDeckToTopCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings,
@ -652,6 +652,45 @@ void AppearanceSettingsPage::showShortcutsChanged(QT_STATE_CHANGED_T value)
qApp->setAttribute(Qt::AA_DontShowShortcutsInContextMenus, value == 0); // 0 = unchecked
}
void AppearanceSettingsPage::overrideAllCardArtWithPersonalPreferenceToggled(QT_STATE_CHANGED_T value)
{
bool enable = static_cast<bool>(value);
QString message;
if (enable) {
message = tr("Enabling this feature will disable the use of the Printing Selector.\n\n"
"You will not be able to manage printing preferences on a per-deck basis, "
"or see printings other people have selected for their decks.\n\n"
"You will have to use the Set Manager, available through Card Database -> Manage Sets.\n\n"
"Are you sure you would like to enable this feature?");
} else {
message =
tr("Disabling this feature will enable the Printing Selector.\n\n"
"You can now choose printings on a per-deck basis in the Deck Editor and configure which printing "
"gets added to a deck by default by pinning it in the Printing Selector.\n\n"
"You can also use the Set Manager to adjust custom sort order for printings in the Printing Selector"
" (other sort orders like alphabetical or release date are available).\n\n"
"Are you sure you would like to disable this feature?");
}
QMessageBox::StandardButton result =
QMessageBox::question(this, tr("Confirm Change"), message, QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) {
SettingsCache::instance().setOverrideAllCardArtWithPersonalPreference(value);
// Caches are now invalid.
PictureLoader::clearPixmapCache();
PictureLoader::clearNetworkCache();
} else {
// If user cancels, revert the checkbox/state back
QTimer::singleShot(0, this, [this, enable]() {
overrideAllCardArtWithPersonalPreferenceCheckBox.blockSignals(true);
overrideAllCardArtWithPersonalPreferenceCheckBox.setChecked(!enable);
overrideAllCardArtWithPersonalPreferenceCheckBox.blockSignals(false);
});
}
}
/**
* Updates the settings for cardViewInitialRowsMax.
* Forces expanded rows max to always be >= initial rows max
@ -694,8 +733,7 @@ void AppearanceSettingsPage::retranslateUi()
displayCardNamesCheckBox.setText(tr("Display card names on cards having a picture"));
autoRotateSidewaysLayoutCardsCheckBox.setText(tr("Auto-Rotate cards with sideways layout"));
overrideAllCardArtWithPersonalPreferenceCheckBox.setText(
tr("Override all card art with personal set preference (Pre-ProviderID change behavior) [Requires Client "
"restart]"));
tr("Override all card art with personal set preference (Pre-ProviderID change behavior)"));
bumpSetsWithCardsInDeckToTopCheckBox.setText(
tr("Bump sets that the deck contains cards from to the top in the printing selector"));
cardScalingCheckBox.setText(tr("Scale cards on mouse over"));

View file

@ -105,6 +105,7 @@ private slots:
void themeBoxChanged(int index);
void openThemeLocation();
void showShortcutsChanged(QT_STATE_CHANGED_T enabled);
void overrideAllCardArtWithPersonalPreferenceToggled(QT_STATE_CHANGED_T enabled);
void cardViewInitialRowsMaxChanged(int value);
void cardViewExpandedRowsMaxChanged(int value);

View file

@ -203,7 +203,10 @@ void DeckEditorDatabaseDisplayWidget::databaseCustomMenu(QPoint point)
QAction *addToDeck, *addToSideboard, *selectPrinting, *edhRecCommander, *edhRecCard;
addToDeck = menu.addAction(tr("Add to Deck"));
addToSideboard = menu.addAction(tr("Add to Sideboard"));
selectPrinting = menu.addAction(tr("Select Printing"));
if (!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
selectPrinting = menu.addAction(tr("Select Printing"));
connect(selectPrinting, &QAction::triggered, this, [this, card] { deckEditor->showPrintingSelector(); });
}
if (canBeCommander(card.getInfo())) {
edhRecCommander = menu.addAction(tr("Show on EDHRec (Commander)"));
connect(edhRecCommander, &QAction::triggered, this,
@ -213,7 +216,6 @@ void DeckEditorDatabaseDisplayWidget::databaseCustomMenu(QPoint point)
connect(addToDeck, &QAction::triggered, this, &DeckEditorDatabaseDisplayWidget::actAddCardToMainDeck);
connect(addToSideboard, &QAction::triggered, this, &DeckEditorDatabaseDisplayWidget::actAddCardToSideboard);
connect(selectPrinting, &QAction::triggered, this, [this, card] { deckEditor->showPrintingSelector(); });
connect(edhRecCard, &QAction::triggered, this,
[this, card] { deckEditor->getTabSupervisor()->addEdhrecTab(card.getCardPtr()); });

View file

@ -37,11 +37,11 @@ void DeckEditorDeckDockWidget::createDeckDock()
deckView->sortByColumn(1, Qt::AscendingOrder);
deckView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
deckView->installEventFilter(&deckViewKeySignals);
deckView->setContextMenuPolicy(Qt::CustomContextMenu);
deckView->setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(deckView->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
&DeckEditorDeckDockWidget::updateCard);
connect(deckView, &QTreeView::doubleClicked, this, &DeckEditorDeckDockWidget::actSwapCard);
deckView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(deckView, &QTreeView::customContextMenuRequested, this, &DeckEditorDeckDockWidget::decklistCustomMenu);
connect(&deckViewKeySignals, &KeySignals::onShiftS, this, &DeckEditorDeckDockWidget::actSwapCard);
connect(&deckViewKeySignals, &KeySignals::onEnter, this, &DeckEditorDeckDockWidget::actIncrement);
@ -577,13 +577,14 @@ void DeckEditorDeckDockWidget::offsetCountAtIndex(const QModelIndex &idx, int of
void DeckEditorDeckDockWidget::decklistCustomMenu(QPoint point)
{
QMenu menu;
if (!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
QMenu menu;
QAction *selectPrinting = menu.addAction(tr("Select Printing"));
QAction *selectPrinting = menu.addAction(tr("Select Printing"));
connect(selectPrinting, &QAction::triggered, deckEditor, &AbstractTabDeckEditor::showPrintingSelector);
connect(selectPrinting, &QAction::triggered, deckEditor, &AbstractTabDeckEditor::showPrintingSelector);
menu.exec(deckView->mapToGlobal(point));
menu.exec(deckView->mapToGlobal(point));
}
}
void DeckEditorDeckDockWidget::refreshShortcuts()

View file

@ -49,6 +49,9 @@ AbstractTabDeckEditor::AbstractTabDeckEditor(TabSupervisor *_tabSupervisor) : Ta
cardInfoDockWidget = new DeckEditorCardInfoDockWidget(this);
filterDockWidget = new DeckEditorFilterDockWidget(this);
printingSelectorDockWidget = new DeckEditorPrintingSelectorDockWidget(this);
connect(&SettingsCache::instance(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this, [this] {
printingSelectorDockWidget->setHidden(SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
});
connect(deckDockWidget, &DeckEditorDeckDockWidget::deckChanged, this, &AbstractTabDeckEditor::onDeckChanged);
connect(deckDockWidget, &DeckEditorDeckDockWidget::deckModified, this, &AbstractTabDeckEditor::onDeckModified);

View file

@ -93,6 +93,13 @@ void TabDeckEditor::createMenus()
aPrintingSelectorDockFloating->setCheckable(true);
connect(aPrintingSelectorDockFloating, &QAction::triggered, this, &TabDeckEditor::dockFloatingTriggered);
if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
printingSelectorDockMenu->setEnabled(false);
}
connect(&SettingsCache::instance(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this,
[this](bool enabled) { printingSelectorDockMenu->setEnabled(!enabled); });
viewMenu->addSeparator();
aResetLayout = viewMenu->addAction(QString());
@ -171,6 +178,13 @@ void TabDeckEditor::loadLayout()
restoreGeometry(layouts.getDeckEditorGeometry());
}
if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
if (!printingSelectorDockWidget->isHidden()) {
printingSelectorDockWidget->setHidden(true);
aPrintingSelectorDockVisible->setChecked(false);
}
}
aCardInfoDockVisible->setChecked(!cardInfoDockWidget->isHidden());
aFilterDockVisible->setChecked(!filterDockWidget->isHidden());
aDeckDockVisible->setChecked(!deckDockWidget->isHidden());
@ -203,10 +217,11 @@ void TabDeckEditor::loadLayout()
void TabDeckEditor::restartLayout()
{
aCardInfoDockVisible->setChecked(true);
aDeckDockVisible->setChecked(true);
aFilterDockVisible->setChecked(true);
aPrintingSelectorDockVisible->setChecked(true);
aPrintingSelectorDockVisible->setChecked(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
aCardInfoDockFloating->setChecked(false);
aDeckDockFloating->setChecked(false);
@ -227,7 +242,7 @@ void TabDeckEditor::restartLayout()
deckDockWidget->setVisible(true);
cardInfoDockWidget->setVisible(true);
filterDockWidget->setVisible(true);
printingSelectorDockWidget->setVisible(true);
printingSelectorDockWidget->setVisible(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
splitDockWidget(cardInfoDockWidget, printingSelectorDockWidget, Qt::Horizontal);
splitDockWidget(printingSelectorDockWidget, deckDockWidget, Qt::Horizontal);

View file

@ -126,6 +126,13 @@ void TabDeckEditorVisual::createMenus()
aPrintingSelectorDockFloating->setCheckable(true);
connect(aPrintingSelectorDockFloating, SIGNAL(triggered()), this, SLOT(dockFloatingTriggered()));
if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
printingSelectorDockMenu->setEnabled(false);
}
connect(&SettingsCache::instance(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this,
[this](bool enabled) { printingSelectorDockMenu->setEnabled(!enabled); });
viewMenu->addSeparator();
aResetLayout = viewMenu->addAction(QString());
@ -236,6 +243,13 @@ void TabDeckEditorVisual::loadLayout()
restoreGeometry(layouts.getDeckEditorGeometry());
}
if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
if (!printingSelectorDockWidget->isHidden()) {
printingSelectorDockWidget->setHidden(true);
aPrintingSelectorDockVisible->setChecked(false);
}
}
aCardInfoDockVisible->setChecked(!cardInfoDockWidget->isHidden());
aFilterDockVisible->setChecked(!filterDockWidget->isHidden());
aDeckDockVisible->setChecked(!deckDockWidget->isHidden());
@ -271,7 +285,7 @@ void TabDeckEditorVisual::restartLayout()
aCardInfoDockVisible->setChecked(true);
aDeckDockVisible->setChecked(true);
aFilterDockVisible->setChecked(false);
aPrintingSelectorDockVisible->setChecked(true);
aPrintingSelectorDockVisible->setChecked(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
aCardInfoDockFloating->setChecked(false);
aDeckDockFloating->setChecked(false);
@ -279,22 +293,21 @@ void TabDeckEditorVisual::restartLayout()
aPrintingSelectorDockFloating->setChecked(false);
setCentralWidget(centralWidget);
addDockWidget(Qt::RightDockWidgetArea, deckDockWidget);
addDockWidget(Qt::RightDockWidgetArea, cardInfoDockWidget);
addDockWidget(Qt::RightDockWidgetArea, filterDockWidget);
addDockWidget(Qt::RightDockWidgetArea, printingSelectorDockWidget);
deckDockWidget->setVisible(true);
cardInfoDockWidget->setVisible(true);
filterDockWidget->setVisible(false);
printingSelectorDockWidget->setVisible(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
deckDockWidget->setFloating(false);
cardInfoDockWidget->setFloating(false);
filterDockWidget->setFloating(false);
printingSelectorDockWidget->setFloating(false);
deckDockWidget->setVisible(true);
cardInfoDockWidget->setVisible(true);
filterDockWidget->setVisible(false);
printingSelectorDockWidget->setVisible(true);
splitDockWidget(cardInfoDockWidget, printingSelectorDockWidget, Qt::Vertical);
splitDockWidget(cardInfoDockWidget, deckDockWidget, Qt::Horizontal);
splitDockWidget(cardInfoDockWidget, filterDockWidget, Qt::Horizontal);

File diff suppressed because it is too large Load diff

View file

@ -18,6 +18,7 @@ set(common_SOURCES
rng_abstract.cpp
rng_sfmt.cpp
server/game/server_abstract_participant.cpp
server/game/server_abstract_player.cpp
server/game/server_arrow.cpp
server/game/server_arrowtarget.cpp
server/game/server_card.cpp

View file

@ -202,7 +202,7 @@ Server_AbstractParticipant::cmdJudge(const Command_Judge &cmd, ResponseContainer
return Response::RespFunctionNotAllowed;
}
Server_Player *player = this->game->getPlayer(cmd.target_id());
auto *player = this->game->getPlayer(cmd.target_id());
ges.setForcedByJudge(playerId);
if (player == nullptr) {

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,152 @@
#ifndef ABSTRACT_PLAYER_H
#define ABSTRACT_PLAYER_H
#include "../../serverinfo_user_container.h"
#include "server_abstract_participant.h"
#include <QList>
#include <QMap>
#include <QString>
class CardToMove;
class DeckList;
class Server_Arrow;
class Server_Card;
class Server_CardZone;
class Server_Counter;
struct MoveCardStruct;
class Server_AbstractPlayer : public Server_AbstractParticipant
{
Q_OBJECT
private:
class MoveCardCompareFunctor;
QMap<int, Server_Arrow *> arrows;
void sendCreateTokenEvents(Server_CardZone *zone, Server_Card *card, int xCoord, int yCoord, GameEventStorage &ges);
void getPlayerProperties(ServerInfo_PlayerProperties &result) override;
protected:
bool conceded;
DeckList *deck;
bool sideboardLocked;
QMap<QString, Server_CardZone *> zones;
bool readyStart;
int nextCardId;
void revealTopCardIfNeeded(Server_CardZone *zone, GameEventStorage &ges);
public:
Server_AbstractPlayer(Server_Game *_game,
int _playerId,
const ServerInfo_User &_userInfo,
bool _judge,
Server_AbstractUserInterface *_handler);
~Server_AbstractPlayer() override;
void prepareDestroy() override;
const DeckList *getDeckList() const
{
return deck;
}
bool getReadyStart() const
{
return readyStart;
}
void setReadyStart(bool _readyStart)
{
readyStart = _readyStart;
}
bool getConceded() const
{
return conceded;
}
void setConceded(bool _conceded)
{
conceded = _conceded;
}
const QMap<QString, Server_CardZone *> &getZones() const
{
return zones;
}
const QMap<int, Server_Arrow *> &getArrows() const
{
return arrows;
}
int newCardId();
int newArrowId() const;
void addZone(Server_CardZone *zone);
void addArrow(Server_Arrow *arrow);
void updateArrowId(int id);
bool deleteArrow(int arrowId);
virtual void setupZones();
virtual void clearZones();
Response::ResponseCode moveCard(GameEventStorage &ges,
Server_CardZone *startzone,
const QList<const CardToMove *> &_cards,
Server_CardZone *targetzone,
int xCoord,
int yCoord,
bool fixFreeSpaces = true,
bool undoingDraw = false,
bool isReversed = false);
virtual void onCardBeingMoved(GameEventStorage &ges,
const MoveCardStruct &cardStruct,
Server_CardZone *startzone,
Server_CardZone *targetzone,
bool undoingDraw);
void unattachCard(GameEventStorage &ges, Server_Card *card);
Response::ResponseCode setCardAttrHelper(GameEventStorage &ges,
int targetPlayerId,
const QString &zone,
int cardId,
CardAttribute attribute,
const QString &attrValue,
Server_Card *unzonedCard = nullptr);
virtual Response::ResponseCode
cmdConcede(const Command_Concede &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode
cmdUnconcede(const Command_Unconcede &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode
cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode
cmdRollDie(const Command_RollDie &cmd, ResponseContainer &rc, GameEventStorage &ges) const override;
virtual Response::ResponseCode
cmdMoveCard(const Command_MoveCard &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode
cmdFlipCard(const Command_FlipCard &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode
cmdAttachCard(const Command_AttachCard &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode
cmdCreateToken(const Command_CreateToken &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode
cmdCreateArrow(const Command_CreateArrow &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode
cmdDeleteArrow(const Command_DeleteArrow &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode
cmdSetCardAttr(const Command_SetCardAttr &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode
cmdSetCardCounter(const Command_SetCardCounter &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode
cmdIncCardCounter(const Command_IncCardCounter &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode
cmdDumpZone(const Command_DumpZone &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode
cmdRevealCards(const Command_RevealCards &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
virtual Response::ResponseCode cmdChangeZoneProperties(const Command_ChangeZoneProperties &cmd,
ResponseContainer &rc,
GameEventStorage &ges) override;
virtual void getInfo(ServerInfo_Player *info,
Server_AbstractParticipant *playerWhosAsking,
bool omniscient,
bool withUserInfo) override;
};
#endif

View file

@ -21,13 +21,13 @@
#include "../rng_abstract.h"
#include "pb/command_move_card.pb.h"
#include "server_abstract_player.h"
#include "server_card.h"
#include "server_player.h"
#include <QDebug>
#include <QSet>
Server_CardZone::Server_CardZone(Server_Player *_player,
Server_CardZone::Server_CardZone(Server_AbstractPlayer *_player,
const QString &_name,
bool _has_coords,
ServerInfo_Zone::ZoneType _type)

View file

@ -28,7 +28,7 @@
#include <QString>
class Server_Card;
class Server_Player;
class Server_AbstractPlayer;
class Server_AbstractParticipant;
class Server_Game;
class GameEventStorage;
@ -36,7 +36,7 @@ class GameEventStorage;
class Server_CardZone
{
private:
Server_Player *player;
Server_AbstractPlayer *player;
QString name;
bool has_coords; // having coords means this zone has x and y coordinates
ServerInfo_Zone::ZoneType type;
@ -52,7 +52,10 @@ private:
void insertCardIntoCoordMap(Server_Card *card, int x, int y);
public:
Server_CardZone(Server_Player *_player, const QString &_name, bool _has_coords, ServerInfo_Zone::ZoneType _type);
Server_CardZone(Server_AbstractPlayer *_player,
const QString &_name,
bool _has_coords,
ServerInfo_Zone::ZoneType _type);
~Server_CardZone();
const QList<Server_Card *> &getCards() const
@ -84,7 +87,7 @@ public:
{
return name;
}
Server_Player *getPlayer() const
Server_AbstractPlayer *getPlayer() const
{
return player;
}

View file

@ -41,6 +41,7 @@
#include "pb/event_set_active_player.pb.h"
#include "pb/game_replay.pb.h"
#include "pb/serverinfo_playerping.pb.h"
#include "server_abstract_player.h"
#include "server_arrow.h"
#include "server_card.h"
#include "server_cardzone.h"
@ -221,24 +222,24 @@ void Server_Game::pingClockTimeout()
}
}
QMap<int, Server_Player *> Server_Game::getPlayers() const // copies pointers to new map
QMap<int, Server_AbstractPlayer *> Server_Game::getPlayers() const // copies pointers to new map
{
QMap<int, Server_Player *> players;
QMap<int, Server_AbstractPlayer *> players;
QMutexLocker locker(&gameMutex);
for (int id : participants.keys()) {
auto *participant = participants[id];
if (!participant->getSpectator()) {
players[id] = static_cast<Server_Player *>(participant);
players[id] = static_cast<Server_AbstractPlayer *>(participant);
}
}
return players;
}
Server_Player *Server_Game::getPlayer(int id) const
Server_AbstractPlayer *Server_Game::getPlayer(int id) const
{
auto *participant = participants.value(id);
if (!participant->getSpectator()) {
return static_cast<Server_Player *>(participant);
return static_cast<Server_AbstractPlayer *>(participant);
} else {
return nullptr;
}
@ -339,7 +340,7 @@ void Server_Game::doStartGameIfReady(bool forceStartGame)
}
}
for (Server_Player *player : players.values()) {
for (Server_AbstractPlayer *player : players.values()) {
player->setupZones();
}
@ -534,7 +535,7 @@ void Server_Game::removeParticipant(Server_AbstractParticipant *participant, Eve
bool spectator = participant->getSpectator();
GameEventStorage ges;
if (!spectator) {
auto *player = static_cast<Server_Player *>(participant);
auto *player = static_cast<Server_AbstractPlayer *>(participant);
removeArrowsRelatedToPlayer(ges, player);
unattachCards(ges, player);
}
@ -577,14 +578,14 @@ void Server_Game::removeParticipant(Server_AbstractParticipant *participant, Eve
emit gameInfoChanged(gameInfo);
}
void Server_Game::removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_Player *player)
void Server_Game::removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_AbstractPlayer *player)
{
QMutexLocker locker(&gameMutex);
// Remove all arrows of other players pointing to the player being removed or to one of his cards.
// Also remove all arrows starting at one of his cards. This is necessary since players can create
// arrows that start at another person's cards.
for (Server_Player *anyPlayer : getPlayers().values()) {
for (Server_AbstractPlayer *anyPlayer : getPlayers().values()) {
QList<Server_Arrow *> arrows = anyPlayer->getArrows().values();
QList<Server_Arrow *> toDelete;
for (int i = 0; i < arrows.size(); ++i) {
@ -593,7 +594,7 @@ void Server_Game::removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_Play
if (targetCard) {
if (targetCard->getZone() != nullptr && targetCard->getZone()->getPlayer() == player)
toDelete.append(arrow);
} else if (static_cast<Server_Player *>(arrow->getTargetItem()) == player)
} else if (static_cast<Server_AbstractPlayer *>(arrow->getTargetItem()) == player)
toDelete.append(arrow);
// Don't use else here! It has to happen regardless of whether targetCard == 0.
@ -610,7 +611,7 @@ void Server_Game::removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_Play
}
}
void Server_Game::unattachCards(GameEventStorage &ges, Server_Player *player)
void Server_Game::unattachCards(GameEventStorage &ges, Server_AbstractPlayer *player)
{
QMutexLocker locker(&gameMutex);

View file

@ -36,7 +36,7 @@ class QTimer;
class GameEventContainer;
class GameReplay;
class Server_Room;
class Server_Player;
class Server_AbstractPlayer;
class Server_AbstractParticipant;
class ServerInfo_User;
class ServerInfo_Game;
@ -130,8 +130,8 @@ public:
}
int getPlayerCount() const;
int getSpectatorCount() const;
QMap<int, Server_Player *> getPlayers() const;
Server_Player *getPlayer(int id) const;
QMap<int, Server_AbstractPlayer *> getPlayers() const;
Server_AbstractPlayer *getPlayer(int id) const;
const QMap<int, Server_AbstractParticipant *> &getParticipants() const
{
return participants;
@ -185,8 +185,8 @@ public:
bool judge,
bool broadcastUpdate = true);
void removeParticipant(Server_AbstractParticipant *participant, Event_Leave::LeaveReason reason);
void removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_Player *player);
void unattachCards(GameEventStorage &ges, Server_Player *player);
void removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_AbstractPlayer *player);
void unattachCards(GameEventStorage &ges, Server_AbstractPlayer *player);
bool kickParticipant(int playerId);
void startGameIfReady(bool forceStartGame);
void stopGameIfFinished();

View file

@ -0,0 +1,26 @@
#ifndef MOVE_CARD_STRUCT
#define MOVE_CARD_STRUCT
#include "server_card.h"
class CardToMove;
struct MoveCardStruct
{
Server_Card *card;
int position;
const CardToMove *cardToMove;
int xCoord, yCoord;
MoveCardStruct(Server_Card *_card, int _position, const CardToMove *_cardToMove)
: card(_card), position(_position), cardToMove(_cardToMove), xCoord(_card->getX()), yCoord(_card->getY())
{
}
bool operator<(const MoveCardStruct &other) const
{
return (yCoord == other.yCoord &&
((xCoord == other.xCoord && position < other.position) || xCoord < other.xCoord)) ||
yCoord < other.yCoord;
}
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,37 +1,14 @@
#ifndef PLAYER_H
#define PLAYER_H
#include "../../serverinfo_user_container.h"
#include "server_abstract_participant.h"
#include "server_abstract_player.h"
#include <QList>
#include <QMap>
#include <QString>
class DeckList;
class Server_CardZone;
class Server_Counter;
class Server_Arrow;
class Server_Card;
class CardToMove;
class Server_Player : public Server_AbstractParticipant
class Server_Player : public Server_AbstractPlayer
{
Q_OBJECT
private:
class MoveCardCompareFunctor;
DeckList *deck;
QMap<QString, Server_CardZone *> zones;
QMap<int, Server_Counter *> counters;
QMap<int, Server_Arrow *> arrows;
QList<int> lastDrawList;
int nextCardId;
bool readyStart;
bool conceded;
bool sideboardLocked;
void revealTopCardIfNeeded(Server_CardZone *zone, GameEventStorage &ges);
void sendCreateTokenEvents(Server_CardZone *zone, Server_Card *card, int xCoord, int yCoord, GameEventStorage &ges);
void getPlayerProperties(ServerInfo_PlayerProperties &result) override;
public:
Server_Player(Server_Game *_game,
@ -40,79 +17,23 @@ public:
bool _judge,
Server_AbstractUserInterface *_handler);
~Server_Player() override;
void prepareDestroy() override;
const DeckList *getDeckList() const
{
return deck;
}
bool getReadyStart() const
{
return readyStart;
}
void setReadyStart(bool _readyStart)
{
readyStart = _readyStart;
}
bool getConceded() const
{
return conceded;
}
void setConceded(bool _conceded)
{
conceded = _conceded;
}
const QMap<QString, Server_CardZone *> &getZones() const
{
return zones;
}
const QMap<int, Server_Counter *> &getCounters() const
{
return counters;
}
const QMap<int, Server_Arrow *> &getArrows() const
{
return arrows;
}
int newCardId();
int newCounterId() const;
int newArrowId() const;
void addZone(Server_CardZone *zone);
void addArrow(Server_Arrow *arrow);
void updateArrowId(int id);
bool deleteArrow(int arrowId);
void addCounter(Server_Counter *counter);
void clearZones();
void setupZones();
void setupZones() override;
void clearZones() override;
Response::ResponseCode drawCards(GameEventStorage &ges, int number);
Response::ResponseCode moveCard(GameEventStorage &ges,
Server_CardZone *startzone,
const QList<const CardToMove *> &_cards,
Server_CardZone *targetzone,
int xCoord,
int yCoord,
bool fixFreeSpaces = true,
bool undoingDraw = false,
bool isReversed = false);
void unattachCard(GameEventStorage &ges, Server_Card *card);
Response::ResponseCode setCardAttrHelper(GameEventStorage &ges,
int targetPlayerId,
const QString &zone,
int cardId,
CardAttribute attribute,
const QString &attrValue,
Server_Card *unzonedCard = nullptr);
void onCardBeingMoved(GameEventStorage &ges,
const MoveCardStruct &cardStruct,
Server_CardZone *startzone,
Server_CardZone *targetzone,
bool undoingDraw) override;
Response::ResponseCode
cmdConcede(const Command_Concede &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdUnconcede(const Command_Unconcede &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdDeckSelect(const Command_DeckSelect &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
@ -124,30 +45,10 @@ public:
Response::ResponseCode
cmdMulligan(const Command_Mulligan &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdRollDie(const Command_RollDie &cmd, ResponseContainer &rc, GameEventStorage &ges) const override;
Response::ResponseCode
cmdDrawCards(const Command_DrawCards &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdUndoDraw(const Command_UndoDraw &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdMoveCard(const Command_MoveCard &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdFlipCard(const Command_FlipCard &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdAttachCard(const Command_AttachCard &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdCreateToken(const Command_CreateToken &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdCreateArrow(const Command_CreateArrow &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdDeleteArrow(const Command_DeleteArrow &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdSetCardAttr(const Command_SetCardAttr &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdSetCardCounter(const Command_SetCardCounter &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdIncCardCounter(const Command_IncCardCounter &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdIncCounter(const Command_IncCounter &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdCreateCounter(const Command_CreateCounter &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
@ -160,10 +61,6 @@ public:
Response::ResponseCode
cmdSetActivePhase(const Command_SetActivePhase &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdDumpZone(const Command_DumpZone &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdRevealCards(const Command_RevealCards &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
Response::ResponseCode
cmdReverseTurn(const Command_ReverseTurn & /*cmd*/, ResponseContainer & /*rc*/, GameEventStorage &ges) override;
Response::ResponseCode cmdChangeZoneProperties(const Command_ChangeZoneProperties &cmd,
ResponseContainer &rc,

View file

@ -12,18 +12,18 @@ olddir="$PWD"
cd "${BASH_SOURCE%/*}/" || exit 2 # could not find path, this could happen with special links etc.
# defaults
include=("common" \
"cockatrice/src" \
include=("cockatrice/src" \
"common" \
"dbconverter/src" \
"oracle/src" \
"servatrice/src" \
"tests")
exclude=("servatrice/src/smtp" \
"common/sfmt" \
exclude=("common/sfmt" \
"common/lib" \
"oracle/src/zip" \
"oracle/src/lzma" \
"oracle/src/qt-json")
"oracle/src/qt-json" \
"servatrice/src/smtp")
exts=("cpp" "h" "proto")
cf_cmd="clang-format"
branch="origin/master"

2
vcpkg

@ -1 +1 @@
Subproject commit 29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c
Subproject commit 62324000504cdd27282f8275c99135cfb2bd1dc0