mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 08:14:47 -07:00
[Game][Arrow] Correctly call clear all arrows for player (#6951)
This commit is contained in:
parent
43c3bf5966
commit
6de55e9096
2 changed files with 19 additions and 3 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue