mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-30 18:43:55 -07:00
Merge branch 'master' into 6186/target-older-x86-macos
This commit is contained in:
commit
19260484af
27 changed files with 3794 additions and 3170 deletions
2
.github/workflows/desktop-build.yml
vendored
2
.github/workflows/desktop-build.yml
vendored
|
|
@ -20,6 +20,7 @@ on:
|
||||||
- '.github/workflows/desktop-build.yml'
|
- '.github/workflows/desktop-build.yml'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
- 'vcpkg.json'
|
- 'vcpkg.json'
|
||||||
|
- 'vcpkg'
|
||||||
tags:
|
tags:
|
||||||
- '*'
|
- '*'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
@ -34,6 +35,7 @@ on:
|
||||||
- '.github/workflows/desktop-build.yml'
|
- '.github/workflows/desktop-build.yml'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
- 'vcpkg.json'
|
- 'vcpkg.json'
|
||||||
|
- 'vcpkg'
|
||||||
|
|
||||||
# Cancel earlier, unfinished runs of this workflow on the same branch (unless on master)
|
# Cancel earlier, unfinished runs of this workflow on the same branch (unless on master)
|
||||||
concurrency:
|
concurrency:
|
||||||
|
|
|
||||||
7
.github/workflows/desktop-lint.yml
vendored
7
.github/workflows/desktop-lint.yml
vendored
|
|
@ -1,18 +1,19 @@
|
||||||
name: Code Style (C++)
|
name: Code Style (C++)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
# push trigger not needed for linting, we do not allow direct pushes to master
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- '*/**' # matches all files not in root
|
- '*/**' # matches all files not in root
|
||||||
- '!**.md'
|
- '!**.md'
|
||||||
- '!.ci/**'
|
- '!.ci/**'
|
||||||
- '!.github/**'
|
- '!.github/**'
|
||||||
- '!.husky'
|
- '!.husky/**'
|
||||||
- '!.tx'
|
- '!.tx/**'
|
||||||
- '!doc/**'
|
- '!doc/**'
|
||||||
- '!webclient/**'
|
- '!webclient/**'
|
||||||
- '.github/workflows/desktop-lint.yml'
|
|
||||||
- '.ci/lint_cpp.sh'
|
- '.ci/lint_cpp.sh'
|
||||||
|
- '.github/workflows/desktop-lint.yml'
|
||||||
- '.clang-format'
|
- '.clang-format'
|
||||||
- '.cmake-format.json'
|
- '.cmake-format.json'
|
||||||
- 'format.sh'
|
- 'format.sh'
|
||||||
|
|
|
||||||
1
.github/workflows/translations-pull.yml
vendored
1
.github/workflows/translations-pull.yml
vendored
|
|
@ -7,6 +7,7 @@ on:
|
||||||
- cron: '0 0 15 1,4,7,10 *'
|
- cron: '0 0 15 1,4,7,10 *'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
|
- '.tx/**'
|
||||||
- '.github/workflows/translations-pull.yml'
|
- '.github/workflows/translations-pull.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
|
||||||
1
.github/workflows/translations-push.yml
vendored
1
.github/workflows/translations-push.yml
vendored
|
|
@ -7,6 +7,7 @@ on:
|
||||||
- cron: '0 0 1 1,4,7,10 *'
|
- cron: '0 0 1 1,4,7,10 *'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
|
- '.ci/update_translation_source_strings.sh'
|
||||||
- '.github/workflows/translations-push.yml'
|
- '.github/workflows/translations-push.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
|
||||||
6
.github/workflows/web-build.yml
vendored
6
.github/workflows/web-build.yml
vendored
|
|
@ -5,14 +5,16 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
paths:
|
paths:
|
||||||
- '.github/workflows/web-*.yml'
|
- '.husky/**'
|
||||||
- 'webclient/**'
|
- 'webclient/**'
|
||||||
- '!**.md'
|
- '!**.md'
|
||||||
|
- '.github/workflows/web-build.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- '.github/workflows/web-*.yml'
|
- '.husky/**'
|
||||||
- 'webclient/**'
|
- 'webclient/**'
|
||||||
- '!**.md'
|
- '!**.md'
|
||||||
|
- '.github/workflows/web-build.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-web:
|
build-web:
|
||||||
|
|
|
||||||
3
.github/workflows/web-lint.yml
vendored
3
.github/workflows/web-lint.yml
vendored
|
|
@ -1,11 +1,12 @@
|
||||||
name: Code Style (TypeScript)
|
name: Code Style (TypeScript)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
# push trigger not needed for linting, we do not allow direct pushes to master
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- '.github/workflows/web-*.yml'
|
|
||||||
- 'webclient/**'
|
- 'webclient/**'
|
||||||
- '!**.md'
|
- '!**.md'
|
||||||
|
- '.github/workflows/web-lint.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ESLint:
|
ESLint:
|
||||||
|
|
|
||||||
|
|
@ -478,8 +478,8 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
||||||
&SettingsCache::setAutoRotateSidewaysLayoutCards);
|
&SettingsCache::setAutoRotateSidewaysLayoutCards);
|
||||||
|
|
||||||
overrideAllCardArtWithPersonalPreferenceCheckBox.setChecked(settings.getOverrideAllCardArtWithPersonalPreference());
|
overrideAllCardArtWithPersonalPreferenceCheckBox.setChecked(settings.getOverrideAllCardArtWithPersonalPreference());
|
||||||
connect(&overrideAllCardArtWithPersonalPreferenceCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings,
|
connect(&overrideAllCardArtWithPersonalPreferenceCheckBox, &QCheckBox::QT_STATE_CHANGED, this,
|
||||||
&SettingsCache::setOverrideAllCardArtWithPersonalPreference);
|
&AppearanceSettingsPage::overrideAllCardArtWithPersonalPreferenceToggled);
|
||||||
|
|
||||||
bumpSetsWithCardsInDeckToTopCheckBox.setChecked(settings.getBumpSetsWithCardsInDeckToTop());
|
bumpSetsWithCardsInDeckToTopCheckBox.setChecked(settings.getBumpSetsWithCardsInDeckToTop());
|
||||||
connect(&bumpSetsWithCardsInDeckToTopCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings,
|
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
|
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.
|
* Updates the settings for cardViewInitialRowsMax.
|
||||||
* Forces expanded rows max to always be >= initial rows max
|
* 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"));
|
displayCardNamesCheckBox.setText(tr("Display card names on cards having a picture"));
|
||||||
autoRotateSidewaysLayoutCardsCheckBox.setText(tr("Auto-Rotate cards with sideways layout"));
|
autoRotateSidewaysLayoutCardsCheckBox.setText(tr("Auto-Rotate cards with sideways layout"));
|
||||||
overrideAllCardArtWithPersonalPreferenceCheckBox.setText(
|
overrideAllCardArtWithPersonalPreferenceCheckBox.setText(
|
||||||
tr("Override all card art with personal set preference (Pre-ProviderID change behavior) [Requires Client "
|
tr("Override all card art with personal set preference (Pre-ProviderID change behavior)"));
|
||||||
"restart]"));
|
|
||||||
bumpSetsWithCardsInDeckToTopCheckBox.setText(
|
bumpSetsWithCardsInDeckToTopCheckBox.setText(
|
||||||
tr("Bump sets that the deck contains cards from to the top in the printing selector"));
|
tr("Bump sets that the deck contains cards from to the top in the printing selector"));
|
||||||
cardScalingCheckBox.setText(tr("Scale cards on mouse over"));
|
cardScalingCheckBox.setText(tr("Scale cards on mouse over"));
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ private slots:
|
||||||
void themeBoxChanged(int index);
|
void themeBoxChanged(int index);
|
||||||
void openThemeLocation();
|
void openThemeLocation();
|
||||||
void showShortcutsChanged(QT_STATE_CHANGED_T enabled);
|
void showShortcutsChanged(QT_STATE_CHANGED_T enabled);
|
||||||
|
void overrideAllCardArtWithPersonalPreferenceToggled(QT_STATE_CHANGED_T enabled);
|
||||||
|
|
||||||
void cardViewInitialRowsMaxChanged(int value);
|
void cardViewInitialRowsMaxChanged(int value);
|
||||||
void cardViewExpandedRowsMaxChanged(int value);
|
void cardViewExpandedRowsMaxChanged(int value);
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,10 @@ void DeckEditorDatabaseDisplayWidget::databaseCustomMenu(QPoint point)
|
||||||
QAction *addToDeck, *addToSideboard, *selectPrinting, *edhRecCommander, *edhRecCard;
|
QAction *addToDeck, *addToSideboard, *selectPrinting, *edhRecCommander, *edhRecCard;
|
||||||
addToDeck = menu.addAction(tr("Add to Deck"));
|
addToDeck = menu.addAction(tr("Add to Deck"));
|
||||||
addToSideboard = menu.addAction(tr("Add to Sideboard"));
|
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())) {
|
if (canBeCommander(card.getInfo())) {
|
||||||
edhRecCommander = menu.addAction(tr("Show on EDHRec (Commander)"));
|
edhRecCommander = menu.addAction(tr("Show on EDHRec (Commander)"));
|
||||||
connect(edhRecCommander, &QAction::triggered, this,
|
connect(edhRecCommander, &QAction::triggered, this,
|
||||||
|
|
@ -213,7 +216,6 @@ void DeckEditorDatabaseDisplayWidget::databaseCustomMenu(QPoint point)
|
||||||
|
|
||||||
connect(addToDeck, &QAction::triggered, this, &DeckEditorDatabaseDisplayWidget::actAddCardToMainDeck);
|
connect(addToDeck, &QAction::triggered, this, &DeckEditorDatabaseDisplayWidget::actAddCardToMainDeck);
|
||||||
connect(addToSideboard, &QAction::triggered, this, &DeckEditorDatabaseDisplayWidget::actAddCardToSideboard);
|
connect(addToSideboard, &QAction::triggered, this, &DeckEditorDatabaseDisplayWidget::actAddCardToSideboard);
|
||||||
connect(selectPrinting, &QAction::triggered, this, [this, card] { deckEditor->showPrintingSelector(); });
|
|
||||||
connect(edhRecCard, &QAction::triggered, this,
|
connect(edhRecCard, &QAction::triggered, this,
|
||||||
[this, card] { deckEditor->getTabSupervisor()->addEdhrecTab(card.getCardPtr()); });
|
[this, card] { deckEditor->getTabSupervisor()->addEdhrecTab(card.getCardPtr()); });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,11 @@ void DeckEditorDeckDockWidget::createDeckDock()
|
||||||
deckView->sortByColumn(1, Qt::AscendingOrder);
|
deckView->sortByColumn(1, Qt::AscendingOrder);
|
||||||
deckView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
deckView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
deckView->installEventFilter(&deckViewKeySignals);
|
deckView->installEventFilter(&deckViewKeySignals);
|
||||||
deckView->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
deckView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
deckView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
connect(deckView->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
|
connect(deckView->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
|
||||||
&DeckEditorDeckDockWidget::updateCard);
|
&DeckEditorDeckDockWidget::updateCard);
|
||||||
connect(deckView, &QTreeView::doubleClicked, this, &DeckEditorDeckDockWidget::actSwapCard);
|
connect(deckView, &QTreeView::doubleClicked, this, &DeckEditorDeckDockWidget::actSwapCard);
|
||||||
|
deckView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(deckView, &QTreeView::customContextMenuRequested, this, &DeckEditorDeckDockWidget::decklistCustomMenu);
|
connect(deckView, &QTreeView::customContextMenuRequested, this, &DeckEditorDeckDockWidget::decklistCustomMenu);
|
||||||
connect(&deckViewKeySignals, &KeySignals::onShiftS, this, &DeckEditorDeckDockWidget::actSwapCard);
|
connect(&deckViewKeySignals, &KeySignals::onShiftS, this, &DeckEditorDeckDockWidget::actSwapCard);
|
||||||
connect(&deckViewKeySignals, &KeySignals::onEnter, this, &DeckEditorDeckDockWidget::actIncrement);
|
connect(&deckViewKeySignals, &KeySignals::onEnter, this, &DeckEditorDeckDockWidget::actIncrement);
|
||||||
|
|
@ -577,13 +577,14 @@ void DeckEditorDeckDockWidget::offsetCountAtIndex(const QModelIndex &idx, int of
|
||||||
|
|
||||||
void DeckEditorDeckDockWidget::decklistCustomMenu(QPoint point)
|
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()
|
void DeckEditorDeckDockWidget::refreshShortcuts()
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,9 @@ AbstractTabDeckEditor::AbstractTabDeckEditor(TabSupervisor *_tabSupervisor) : Ta
|
||||||
cardInfoDockWidget = new DeckEditorCardInfoDockWidget(this);
|
cardInfoDockWidget = new DeckEditorCardInfoDockWidget(this);
|
||||||
filterDockWidget = new DeckEditorFilterDockWidget(this);
|
filterDockWidget = new DeckEditorFilterDockWidget(this);
|
||||||
printingSelectorDockWidget = new DeckEditorPrintingSelectorDockWidget(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::deckChanged, this, &AbstractTabDeckEditor::onDeckChanged);
|
||||||
connect(deckDockWidget, &DeckEditorDeckDockWidget::deckModified, this, &AbstractTabDeckEditor::onDeckModified);
|
connect(deckDockWidget, &DeckEditorDeckDockWidget::deckModified, this, &AbstractTabDeckEditor::onDeckModified);
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,13 @@ void TabDeckEditor::createMenus()
|
||||||
aPrintingSelectorDockFloating->setCheckable(true);
|
aPrintingSelectorDockFloating->setCheckable(true);
|
||||||
connect(aPrintingSelectorDockFloating, &QAction::triggered, this, &TabDeckEditor::dockFloatingTriggered);
|
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();
|
viewMenu->addSeparator();
|
||||||
|
|
||||||
aResetLayout = viewMenu->addAction(QString());
|
aResetLayout = viewMenu->addAction(QString());
|
||||||
|
|
@ -171,6 +178,13 @@ void TabDeckEditor::loadLayout()
|
||||||
restoreGeometry(layouts.getDeckEditorGeometry());
|
restoreGeometry(layouts.getDeckEditorGeometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
|
||||||
|
if (!printingSelectorDockWidget->isHidden()) {
|
||||||
|
printingSelectorDockWidget->setHidden(true);
|
||||||
|
aPrintingSelectorDockVisible->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
aCardInfoDockVisible->setChecked(!cardInfoDockWidget->isHidden());
|
aCardInfoDockVisible->setChecked(!cardInfoDockWidget->isHidden());
|
||||||
aFilterDockVisible->setChecked(!filterDockWidget->isHidden());
|
aFilterDockVisible->setChecked(!filterDockWidget->isHidden());
|
||||||
aDeckDockVisible->setChecked(!deckDockWidget->isHidden());
|
aDeckDockVisible->setChecked(!deckDockWidget->isHidden());
|
||||||
|
|
@ -203,10 +217,11 @@ void TabDeckEditor::loadLayout()
|
||||||
|
|
||||||
void TabDeckEditor::restartLayout()
|
void TabDeckEditor::restartLayout()
|
||||||
{
|
{
|
||||||
|
|
||||||
aCardInfoDockVisible->setChecked(true);
|
aCardInfoDockVisible->setChecked(true);
|
||||||
aDeckDockVisible->setChecked(true);
|
aDeckDockVisible->setChecked(true);
|
||||||
aFilterDockVisible->setChecked(true);
|
aFilterDockVisible->setChecked(true);
|
||||||
aPrintingSelectorDockVisible->setChecked(true);
|
aPrintingSelectorDockVisible->setChecked(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
|
||||||
|
|
||||||
aCardInfoDockFloating->setChecked(false);
|
aCardInfoDockFloating->setChecked(false);
|
||||||
aDeckDockFloating->setChecked(false);
|
aDeckDockFloating->setChecked(false);
|
||||||
|
|
@ -227,7 +242,7 @@ void TabDeckEditor::restartLayout()
|
||||||
deckDockWidget->setVisible(true);
|
deckDockWidget->setVisible(true);
|
||||||
cardInfoDockWidget->setVisible(true);
|
cardInfoDockWidget->setVisible(true);
|
||||||
filterDockWidget->setVisible(true);
|
filterDockWidget->setVisible(true);
|
||||||
printingSelectorDockWidget->setVisible(true);
|
printingSelectorDockWidget->setVisible(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
|
||||||
|
|
||||||
splitDockWidget(cardInfoDockWidget, printingSelectorDockWidget, Qt::Horizontal);
|
splitDockWidget(cardInfoDockWidget, printingSelectorDockWidget, Qt::Horizontal);
|
||||||
splitDockWidget(printingSelectorDockWidget, deckDockWidget, Qt::Horizontal);
|
splitDockWidget(printingSelectorDockWidget, deckDockWidget, Qt::Horizontal);
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,13 @@ void TabDeckEditorVisual::createMenus()
|
||||||
aPrintingSelectorDockFloating->setCheckable(true);
|
aPrintingSelectorDockFloating->setCheckable(true);
|
||||||
connect(aPrintingSelectorDockFloating, SIGNAL(triggered()), this, SLOT(dockFloatingTriggered()));
|
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();
|
viewMenu->addSeparator();
|
||||||
|
|
||||||
aResetLayout = viewMenu->addAction(QString());
|
aResetLayout = viewMenu->addAction(QString());
|
||||||
|
|
@ -236,6 +243,13 @@ void TabDeckEditorVisual::loadLayout()
|
||||||
restoreGeometry(layouts.getDeckEditorGeometry());
|
restoreGeometry(layouts.getDeckEditorGeometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
|
||||||
|
if (!printingSelectorDockWidget->isHidden()) {
|
||||||
|
printingSelectorDockWidget->setHidden(true);
|
||||||
|
aPrintingSelectorDockVisible->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
aCardInfoDockVisible->setChecked(!cardInfoDockWidget->isHidden());
|
aCardInfoDockVisible->setChecked(!cardInfoDockWidget->isHidden());
|
||||||
aFilterDockVisible->setChecked(!filterDockWidget->isHidden());
|
aFilterDockVisible->setChecked(!filterDockWidget->isHidden());
|
||||||
aDeckDockVisible->setChecked(!deckDockWidget->isHidden());
|
aDeckDockVisible->setChecked(!deckDockWidget->isHidden());
|
||||||
|
|
@ -271,7 +285,7 @@ void TabDeckEditorVisual::restartLayout()
|
||||||
aCardInfoDockVisible->setChecked(true);
|
aCardInfoDockVisible->setChecked(true);
|
||||||
aDeckDockVisible->setChecked(true);
|
aDeckDockVisible->setChecked(true);
|
||||||
aFilterDockVisible->setChecked(false);
|
aFilterDockVisible->setChecked(false);
|
||||||
aPrintingSelectorDockVisible->setChecked(true);
|
aPrintingSelectorDockVisible->setChecked(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
|
||||||
|
|
||||||
aCardInfoDockFloating->setChecked(false);
|
aCardInfoDockFloating->setChecked(false);
|
||||||
aDeckDockFloating->setChecked(false);
|
aDeckDockFloating->setChecked(false);
|
||||||
|
|
@ -279,22 +293,21 @@ void TabDeckEditorVisual::restartLayout()
|
||||||
aPrintingSelectorDockFloating->setChecked(false);
|
aPrintingSelectorDockFloating->setChecked(false);
|
||||||
|
|
||||||
setCentralWidget(centralWidget);
|
setCentralWidget(centralWidget);
|
||||||
|
|
||||||
addDockWidget(Qt::RightDockWidgetArea, deckDockWidget);
|
addDockWidget(Qt::RightDockWidgetArea, deckDockWidget);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, cardInfoDockWidget);
|
addDockWidget(Qt::RightDockWidgetArea, cardInfoDockWidget);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, filterDockWidget);
|
addDockWidget(Qt::RightDockWidgetArea, filterDockWidget);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, printingSelectorDockWidget);
|
addDockWidget(Qt::RightDockWidgetArea, printingSelectorDockWidget);
|
||||||
|
|
||||||
|
deckDockWidget->setVisible(true);
|
||||||
|
cardInfoDockWidget->setVisible(true);
|
||||||
|
filterDockWidget->setVisible(false);
|
||||||
|
printingSelectorDockWidget->setVisible(!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference());
|
||||||
|
|
||||||
deckDockWidget->setFloating(false);
|
deckDockWidget->setFloating(false);
|
||||||
cardInfoDockWidget->setFloating(false);
|
cardInfoDockWidget->setFloating(false);
|
||||||
filterDockWidget->setFloating(false);
|
filterDockWidget->setFloating(false);
|
||||||
printingSelectorDockWidget->setFloating(false);
|
printingSelectorDockWidget->setFloating(false);
|
||||||
|
|
||||||
deckDockWidget->setVisible(true);
|
|
||||||
cardInfoDockWidget->setVisible(true);
|
|
||||||
filterDockWidget->setVisible(false);
|
|
||||||
printingSelectorDockWidget->setVisible(true);
|
|
||||||
|
|
||||||
splitDockWidget(cardInfoDockWidget, printingSelectorDockWidget, Qt::Vertical);
|
splitDockWidget(cardInfoDockWidget, printingSelectorDockWidget, Qt::Vertical);
|
||||||
splitDockWidget(cardInfoDockWidget, deckDockWidget, Qt::Horizontal);
|
splitDockWidget(cardInfoDockWidget, deckDockWidget, Qt::Horizontal);
|
||||||
splitDockWidget(cardInfoDockWidget, filterDockWidget, Qt::Horizontal);
|
splitDockWidget(cardInfoDockWidget, filterDockWidget, Qt::Horizontal);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -18,6 +18,7 @@ set(common_SOURCES
|
||||||
rng_abstract.cpp
|
rng_abstract.cpp
|
||||||
rng_sfmt.cpp
|
rng_sfmt.cpp
|
||||||
server/game/server_abstract_participant.cpp
|
server/game/server_abstract_participant.cpp
|
||||||
|
server/game/server_abstract_player.cpp
|
||||||
server/game/server_arrow.cpp
|
server/game/server_arrow.cpp
|
||||||
server/game/server_arrowtarget.cpp
|
server/game/server_arrowtarget.cpp
|
||||||
server/game/server_card.cpp
|
server/game/server_card.cpp
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ Server_AbstractParticipant::cmdJudge(const Command_Judge &cmd, ResponseContainer
|
||||||
return Response::RespFunctionNotAllowed;
|
return Response::RespFunctionNotAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Server_Player *player = this->game->getPlayer(cmd.target_id());
|
auto *player = this->game->getPlayer(cmd.target_id());
|
||||||
|
|
||||||
ges.setForcedByJudge(playerId);
|
ges.setForcedByJudge(playerId);
|
||||||
if (player == nullptr) {
|
if (player == nullptr) {
|
||||||
|
|
|
||||||
1611
common/server/game/server_abstract_player.cpp
Normal file
1611
common/server/game/server_abstract_player.cpp
Normal file
File diff suppressed because it is too large
Load diff
152
common/server/game/server_abstract_player.h
Normal file
152
common/server/game/server_abstract_player.h
Normal 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
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
|
|
||||||
#include "../rng_abstract.h"
|
#include "../rng_abstract.h"
|
||||||
#include "pb/command_move_card.pb.h"
|
#include "pb/command_move_card.pb.h"
|
||||||
|
#include "server_abstract_player.h"
|
||||||
#include "server_card.h"
|
#include "server_card.h"
|
||||||
#include "server_player.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
Server_CardZone::Server_CardZone(Server_Player *_player,
|
Server_CardZone::Server_CardZone(Server_AbstractPlayer *_player,
|
||||||
const QString &_name,
|
const QString &_name,
|
||||||
bool _has_coords,
|
bool _has_coords,
|
||||||
ServerInfo_Zone::ZoneType _type)
|
ServerInfo_Zone::ZoneType _type)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class Server_Card;
|
class Server_Card;
|
||||||
class Server_Player;
|
class Server_AbstractPlayer;
|
||||||
class Server_AbstractParticipant;
|
class Server_AbstractParticipant;
|
||||||
class Server_Game;
|
class Server_Game;
|
||||||
class GameEventStorage;
|
class GameEventStorage;
|
||||||
|
|
@ -36,7 +36,7 @@ class GameEventStorage;
|
||||||
class Server_CardZone
|
class Server_CardZone
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Server_Player *player;
|
Server_AbstractPlayer *player;
|
||||||
QString name;
|
QString name;
|
||||||
bool has_coords; // having coords means this zone has x and y coordinates
|
bool has_coords; // having coords means this zone has x and y coordinates
|
||||||
ServerInfo_Zone::ZoneType type;
|
ServerInfo_Zone::ZoneType type;
|
||||||
|
|
@ -52,7 +52,10 @@ private:
|
||||||
void insertCardIntoCoordMap(Server_Card *card, int x, int y);
|
void insertCardIntoCoordMap(Server_Card *card, int x, int y);
|
||||||
|
|
||||||
public:
|
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();
|
~Server_CardZone();
|
||||||
|
|
||||||
const QList<Server_Card *> &getCards() const
|
const QList<Server_Card *> &getCards() const
|
||||||
|
|
@ -84,7 +87,7 @@ public:
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
Server_Player *getPlayer() const
|
Server_AbstractPlayer *getPlayer() const
|
||||||
{
|
{
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
#include "pb/event_set_active_player.pb.h"
|
#include "pb/event_set_active_player.pb.h"
|
||||||
#include "pb/game_replay.pb.h"
|
#include "pb/game_replay.pb.h"
|
||||||
#include "pb/serverinfo_playerping.pb.h"
|
#include "pb/serverinfo_playerping.pb.h"
|
||||||
|
#include "server_abstract_player.h"
|
||||||
#include "server_arrow.h"
|
#include "server_arrow.h"
|
||||||
#include "server_card.h"
|
#include "server_card.h"
|
||||||
#include "server_cardzone.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);
|
QMutexLocker locker(&gameMutex);
|
||||||
for (int id : participants.keys()) {
|
for (int id : participants.keys()) {
|
||||||
auto *participant = participants[id];
|
auto *participant = participants[id];
|
||||||
if (!participant->getSpectator()) {
|
if (!participant->getSpectator()) {
|
||||||
players[id] = static_cast<Server_Player *>(participant);
|
players[id] = static_cast<Server_AbstractPlayer *>(participant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
Server_Player *Server_Game::getPlayer(int id) const
|
Server_AbstractPlayer *Server_Game::getPlayer(int id) const
|
||||||
{
|
{
|
||||||
auto *participant = participants.value(id);
|
auto *participant = participants.value(id);
|
||||||
if (!participant->getSpectator()) {
|
if (!participant->getSpectator()) {
|
||||||
return static_cast<Server_Player *>(participant);
|
return static_cast<Server_AbstractPlayer *>(participant);
|
||||||
} else {
|
} else {
|
||||||
return nullptr;
|
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();
|
player->setupZones();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -534,7 +535,7 @@ void Server_Game::removeParticipant(Server_AbstractParticipant *participant, Eve
|
||||||
bool spectator = participant->getSpectator();
|
bool spectator = participant->getSpectator();
|
||||||
GameEventStorage ges;
|
GameEventStorage ges;
|
||||||
if (!spectator) {
|
if (!spectator) {
|
||||||
auto *player = static_cast<Server_Player *>(participant);
|
auto *player = static_cast<Server_AbstractPlayer *>(participant);
|
||||||
removeArrowsRelatedToPlayer(ges, player);
|
removeArrowsRelatedToPlayer(ges, player);
|
||||||
unattachCards(ges, player);
|
unattachCards(ges, player);
|
||||||
}
|
}
|
||||||
|
|
@ -577,14 +578,14 @@ void Server_Game::removeParticipant(Server_AbstractParticipant *participant, Eve
|
||||||
emit gameInfoChanged(gameInfo);
|
emit gameInfoChanged(gameInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_Game::removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_Player *player)
|
void Server_Game::removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_AbstractPlayer *player)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&gameMutex);
|
QMutexLocker locker(&gameMutex);
|
||||||
|
|
||||||
// Remove all arrows of other players pointing to the player being removed or to one of his cards.
|
// 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
|
// 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.
|
// 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 *> arrows = anyPlayer->getArrows().values();
|
||||||
QList<Server_Arrow *> toDelete;
|
QList<Server_Arrow *> toDelete;
|
||||||
for (int i = 0; i < arrows.size(); ++i) {
|
for (int i = 0; i < arrows.size(); ++i) {
|
||||||
|
|
@ -593,7 +594,7 @@ void Server_Game::removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_Play
|
||||||
if (targetCard) {
|
if (targetCard) {
|
||||||
if (targetCard->getZone() != nullptr && targetCard->getZone()->getPlayer() == player)
|
if (targetCard->getZone() != nullptr && targetCard->getZone()->getPlayer() == player)
|
||||||
toDelete.append(arrow);
|
toDelete.append(arrow);
|
||||||
} else if (static_cast<Server_Player *>(arrow->getTargetItem()) == player)
|
} else if (static_cast<Server_AbstractPlayer *>(arrow->getTargetItem()) == player)
|
||||||
toDelete.append(arrow);
|
toDelete.append(arrow);
|
||||||
|
|
||||||
// Don't use else here! It has to happen regardless of whether targetCard == 0.
|
// 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);
|
QMutexLocker locker(&gameMutex);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class QTimer;
|
||||||
class GameEventContainer;
|
class GameEventContainer;
|
||||||
class GameReplay;
|
class GameReplay;
|
||||||
class Server_Room;
|
class Server_Room;
|
||||||
class Server_Player;
|
class Server_AbstractPlayer;
|
||||||
class Server_AbstractParticipant;
|
class Server_AbstractParticipant;
|
||||||
class ServerInfo_User;
|
class ServerInfo_User;
|
||||||
class ServerInfo_Game;
|
class ServerInfo_Game;
|
||||||
|
|
@ -130,8 +130,8 @@ public:
|
||||||
}
|
}
|
||||||
int getPlayerCount() const;
|
int getPlayerCount() const;
|
||||||
int getSpectatorCount() const;
|
int getSpectatorCount() const;
|
||||||
QMap<int, Server_Player *> getPlayers() const;
|
QMap<int, Server_AbstractPlayer *> getPlayers() const;
|
||||||
Server_Player *getPlayer(int id) const;
|
Server_AbstractPlayer *getPlayer(int id) const;
|
||||||
const QMap<int, Server_AbstractParticipant *> &getParticipants() const
|
const QMap<int, Server_AbstractParticipant *> &getParticipants() const
|
||||||
{
|
{
|
||||||
return participants;
|
return participants;
|
||||||
|
|
@ -185,8 +185,8 @@ public:
|
||||||
bool judge,
|
bool judge,
|
||||||
bool broadcastUpdate = true);
|
bool broadcastUpdate = true);
|
||||||
void removeParticipant(Server_AbstractParticipant *participant, Event_Leave::LeaveReason reason);
|
void removeParticipant(Server_AbstractParticipant *participant, Event_Leave::LeaveReason reason);
|
||||||
void removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_Player *player);
|
void removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_AbstractPlayer *player);
|
||||||
void unattachCards(GameEventStorage &ges, Server_Player *player);
|
void unattachCards(GameEventStorage &ges, Server_AbstractPlayer *player);
|
||||||
bool kickParticipant(int playerId);
|
bool kickParticipant(int playerId);
|
||||||
void startGameIfReady(bool forceStartGame);
|
void startGameIfReady(bool forceStartGame);
|
||||||
void stopGameIfFinished();
|
void stopGameIfFinished();
|
||||||
|
|
|
||||||
26
common/server/game/server_move_card_struct.h
Normal file
26
common/server/game/server_move_card_struct.h
Normal 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
|
|
@ -1,37 +1,14 @@
|
||||||
#ifndef PLAYER_H
|
#ifndef PLAYER_H
|
||||||
#define PLAYER_H
|
#define PLAYER_H
|
||||||
|
|
||||||
#include "../../serverinfo_user_container.h"
|
#include "server_abstract_player.h"
|
||||||
#include "server_abstract_participant.h"
|
|
||||||
|
|
||||||
#include <QList>
|
class Server_Player : public Server_AbstractPlayer
|
||||||
#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
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
class MoveCardCompareFunctor;
|
|
||||||
DeckList *deck;
|
|
||||||
QMap<QString, Server_CardZone *> zones;
|
|
||||||
QMap<int, Server_Counter *> counters;
|
QMap<int, Server_Counter *> counters;
|
||||||
QMap<int, Server_Arrow *> arrows;
|
|
||||||
QList<int> lastDrawList;
|
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:
|
public:
|
||||||
Server_Player(Server_Game *_game,
|
Server_Player(Server_Game *_game,
|
||||||
|
|
@ -40,79 +17,23 @@ public:
|
||||||
bool _judge,
|
bool _judge,
|
||||||
Server_AbstractUserInterface *_handler);
|
Server_AbstractUserInterface *_handler);
|
||||||
~Server_Player() override;
|
~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
|
const QMap<int, Server_Counter *> &getCounters() const
|
||||||
{
|
{
|
||||||
return counters;
|
return counters;
|
||||||
}
|
}
|
||||||
const QMap<int, Server_Arrow *> &getArrows() const
|
|
||||||
{
|
|
||||||
return arrows;
|
|
||||||
}
|
|
||||||
|
|
||||||
int newCardId();
|
|
||||||
int newCounterId() const;
|
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 addCounter(Server_Counter *counter);
|
||||||
|
|
||||||
void clearZones();
|
void setupZones() override;
|
||||||
void setupZones();
|
void clearZones() override;
|
||||||
|
|
||||||
Response::ResponseCode drawCards(GameEventStorage &ges, int number);
|
Response::ResponseCode drawCards(GameEventStorage &ges, int number);
|
||||||
Response::ResponseCode moveCard(GameEventStorage &ges,
|
void onCardBeingMoved(GameEventStorage &ges,
|
||||||
Server_CardZone *startzone,
|
const MoveCardStruct &cardStruct,
|
||||||
const QList<const CardToMove *> &_cards,
|
Server_CardZone *startzone,
|
||||||
Server_CardZone *targetzone,
|
Server_CardZone *targetzone,
|
||||||
int xCoord,
|
bool undoingDraw) override;
|
||||||
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);
|
|
||||||
|
|
||||||
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
|
Response::ResponseCode
|
||||||
cmdDeckSelect(const Command_DeckSelect &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
|
cmdDeckSelect(const Command_DeckSelect &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
|
||||||
Response::ResponseCode
|
Response::ResponseCode
|
||||||
|
|
@ -124,30 +45,10 @@ public:
|
||||||
Response::ResponseCode
|
Response::ResponseCode
|
||||||
cmdMulligan(const Command_Mulligan &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
|
cmdMulligan(const Command_Mulligan &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
|
||||||
Response::ResponseCode
|
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;
|
cmdDrawCards(const Command_DrawCards &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
|
||||||
Response::ResponseCode
|
Response::ResponseCode
|
||||||
cmdUndoDraw(const Command_UndoDraw &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
|
cmdUndoDraw(const Command_UndoDraw &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
|
||||||
Response::ResponseCode
|
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;
|
cmdIncCounter(const Command_IncCounter &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
|
||||||
Response::ResponseCode
|
Response::ResponseCode
|
||||||
cmdCreateCounter(const Command_CreateCounter &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
|
cmdCreateCounter(const Command_CreateCounter &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
|
||||||
|
|
@ -160,10 +61,6 @@ public:
|
||||||
Response::ResponseCode
|
Response::ResponseCode
|
||||||
cmdSetActivePhase(const Command_SetActivePhase &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
|
cmdSetActivePhase(const Command_SetActivePhase &cmd, ResponseContainer &rc, GameEventStorage &ges) override;
|
||||||
Response::ResponseCode
|
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;
|
cmdReverseTurn(const Command_ReverseTurn & /*cmd*/, ResponseContainer & /*rc*/, GameEventStorage &ges) override;
|
||||||
Response::ResponseCode cmdChangeZoneProperties(const Command_ChangeZoneProperties &cmd,
|
Response::ResponseCode cmdChangeZoneProperties(const Command_ChangeZoneProperties &cmd,
|
||||||
ResponseContainer &rc,
|
ResponseContainer &rc,
|
||||||
|
|
|
||||||
10
format.sh
10
format.sh
|
|
@ -12,18 +12,18 @@ olddir="$PWD"
|
||||||
cd "${BASH_SOURCE%/*}/" || exit 2 # could not find path, this could happen with special links etc.
|
cd "${BASH_SOURCE%/*}/" || exit 2 # could not find path, this could happen with special links etc.
|
||||||
|
|
||||||
# defaults
|
# defaults
|
||||||
include=("common" \
|
include=("cockatrice/src" \
|
||||||
"cockatrice/src" \
|
"common" \
|
||||||
"dbconverter/src" \
|
"dbconverter/src" \
|
||||||
"oracle/src" \
|
"oracle/src" \
|
||||||
"servatrice/src" \
|
"servatrice/src" \
|
||||||
"tests")
|
"tests")
|
||||||
exclude=("servatrice/src/smtp" \
|
exclude=("common/sfmt" \
|
||||||
"common/sfmt" \
|
|
||||||
"common/lib" \
|
"common/lib" \
|
||||||
"oracle/src/zip" \
|
"oracle/src/zip" \
|
||||||
"oracle/src/lzma" \
|
"oracle/src/lzma" \
|
||||||
"oracle/src/qt-json")
|
"oracle/src/qt-json" \
|
||||||
|
"servatrice/src/smtp")
|
||||||
exts=("cpp" "h" "proto")
|
exts=("cpp" "h" "proto")
|
||||||
cf_cmd="clang-format"
|
cf_cmd="clang-format"
|
||||||
branch="origin/master"
|
branch="origin/master"
|
||||||
|
|
|
||||||
2
vcpkg
2
vcpkg
|
|
@ -1 +1 @@
|
||||||
Subproject commit 29ff5b8131d0c6c8fcb8fbaef35992f0d507cd7c
|
Subproject commit 62324000504cdd27282f8275c99135cfb2bd1dc0
|
||||||
Loading…
Add table
Add a link
Reference in a new issue