[Game][Arrow] Correctly call clear all arrows for player (#6951)

This commit is contained in:
RickyRister 2026-05-28 23:51:12 -07:00 committed by GitHub
parent 43c3bf5966
commit 6de55e9096
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 3 deletions

View file

@ -88,7 +88,7 @@ void GameScene::addPlayer(PlayerLogic *player)
connect(player, &PlayerLogic::concededChanged, this, [this](int id, bool conceded) {
if (conceded) {
requestClearArrowsForPlayer(id);
clearArrowsForPlayer(id);
}
rearrange();
});
@ -97,7 +97,7 @@ void GameScene::addPlayer(PlayerLogic *player)
connect(player, &PlayerLogic::arrowCreateRequested, this, &GameScene::addArrow);
connect(player, &PlayerLogic::arrowDeleteRequested, this, &GameScene::requestArrowDeletion);
connect(player, &PlayerLogic::arrowsCleared, this,
[this, id = player->getPlayerInfo()->getId()]() { requestClearArrowsForPlayer(id); });
[this, id = player->getPlayerInfo()->getId()]() { clearArrowsForPlayer(id); });
connect(player->getPlayerEventHandler(), &PlayerEventHandler::cardZoneChanged, this, &GameScene::onCardZoneChanged);
@ -114,7 +114,7 @@ void GameScene::removePlayer(PlayerLogic *player)
{
qCInfo(GameScenePlayerAdditionRemovalLog) << "GameScene::removePlayer name=" << player->getPlayerInfo()->getName();
requestClearArrowsForPlayer(player->getPlayerInfo()->getId());
clearArrowsForPlayer(player->getPlayerInfo()->getId());
for (ZoneViewWidget *zone : zoneViews) {
if (zone->getPlayer() == player) {
@ -412,6 +412,21 @@ void GameScene::deleteArrow(int arrowId)
}
}
void GameScene::clearArrowsForPlayer(int playerId)
{
QList<int> toDelete;
for (auto i = arrowRegistry.cbegin(); i != arrowRegistry.cend(); ++i) {
auto *arrow = i.value();
if (arrow->getPlayer()->getPlayerInfo()->getId() == playerId) {
toDelete.append(i.key());
}
}
for (int arrowId : toDelete) {
arrowRegistry.take(arrowId)->delArrow();
}
}
void GameScene::requestArrowDeletion(int arrowId)
{
if (arrowRegistry.contains(arrowId)) {

View file

@ -204,6 +204,7 @@ public slots:
/// Directly modifies the scene
void addArrow(const ArrowData &data);
void deleteArrow(int arrowId);
void clearArrowsForPlayer(int playerId);
/// Queues up arrow deletion but doesn't directly modify the scene
void requestArrowDeletion(int arrowId);