Move game state and event handling out of tab_game and into separate classes (#6090)

* Move game state and event handling out of tab_game and into separate classes.

Took 6 hours 38 minutes

Took 23 seconds

* Meta Info

Took 14 hours 36 minutes

* Properly respond to game started again.

Took 49 minutes

* Hook up the message log widgets to game events again.

Took 33 minutes

Took 7 seconds

* Lint.

Took 4 minutes

* Hook up playerListWidget.

Took 1 hour 2 minutes

Took 10 seconds

* Hook up playerListWidget properly.

Took 1 hour 17 minutes

* Fix regressions.

Took 17 minutes

Took 9 seconds

* Log the local player joining too.

Took 2 minutes

* Connect some player signals unrelated to this refactor again.

Took 5 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2025-09-11 00:40:29 +02:00 committed by GitHub
parent 5c16f0d027
commit b8e545bfa4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 1482 additions and 788 deletions

View file

@ -157,7 +157,7 @@ void DeckViewContainer::switchToDeckSelectView()
deckViewLayout->update();
setVisibility(loadLocalButton, true);
setVisibility(loadRemoteButton, !parentGame->getIsLocalGame());
setVisibility(loadRemoteButton, !parentGame->getGameState()->getIsLocalGame());
setVisibility(loadFromClipboardButton, true);
setVisibility(loadFromWebsiteButton, true);
setVisibility(unloadDeckButton, false);
@ -190,7 +190,7 @@ void DeckViewContainer::switchToDeckLoadedView()
setVisibility(readyStartButton, true);
setVisibility(sideboardLockButton, true);
if (parentGame->isHost()) {
if (parentGame->getGameState()->isHost()) {
setVisibility(forceStartGameButton, true);
}
}
@ -287,9 +287,9 @@ void DeckViewContainer::loadDeckFromDeckLoader(const DeckLoader *deck)
Command_DeckSelect cmd;
cmd.set_deck(deckString.toStdString());
PendingCommand *pend = parentGame->prepareGameCommand(cmd);
PendingCommand *pend = parentGame->getGameEventHandler()->prepareGameCommand(cmd);
connect(pend, &PendingCommand::finished, this, &DeckViewContainer::deckSelectFinished);
parentGame->sendGameCommand(pend, playerId);
parentGame->getGameEventHandler()->sendGameCommand(pend, playerId);
}
void DeckViewContainer::loadRemoteDeck()
@ -298,9 +298,9 @@ void DeckViewContainer::loadRemoteDeck()
if (dlg.exec()) {
Command_DeckSelect cmd;
cmd.set_deck_id(dlg.getDeckId());
PendingCommand *pend = parentGame->prepareGameCommand(cmd);
PendingCommand *pend = parentGame->getGameEventHandler()->prepareGameCommand(cmd);
connect(pend, &PendingCommand::finished, this, &DeckViewContainer::deckSelectFinished);
parentGame->sendGameCommand(pend, playerId);
parentGame->getGameEventHandler()->sendGameCommand(pend, playerId);
}
}
@ -354,7 +354,7 @@ void DeckViewContainer::forceStart()
Command_ReadyStart cmd;
cmd.set_force_start(true);
cmd.set_ready(true);
parentGame->sendGameCommand(cmd, playerId);
parentGame->getGameEventHandler()->sendGameCommand(cmd, playerId);
}
void DeckViewContainer::sideboardLockButtonClicked()
@ -362,7 +362,7 @@ void DeckViewContainer::sideboardLockButtonClicked()
Command_SetSideboardLock cmd;
cmd.set_locked(sideboardLockButton->getState());
parentGame->sendGameCommand(cmd, playerId);
parentGame->getGameEventHandler()->sendGameCommand(cmd, playerId);
}
void DeckViewContainer::sideboardPlanChanged()
@ -371,7 +371,7 @@ void DeckViewContainer::sideboardPlanChanged()
const QList<MoveCard_ToZone> &newPlan = deckView->getSideboardPlan();
for (const auto &i : newPlan)
cmd.add_move_list()->CopyFrom(i);
parentGame->sendGameCommand(cmd, playerId);
parentGame->getGameEventHandler()->sendGameCommand(cmd, playerId);
}
/**
@ -381,7 +381,7 @@ void DeckViewContainer::sendReadyStartCommand(bool ready)
{
Command_ReadyStart cmd;
cmd.set_ready(ready);
parentGame->sendGameCommand(cmd, playerId);
parentGame->getGameEventHandler()->sendGameCommand(cmd, playerId);
}
/**