[Player] Rename player to player logic (#6913)

Took 13 minutes

Took 6 seconds

Took 2 minutes

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-05-19 12:36:31 +02:00 committed by GitHub
parent 71790d8e10
commit 5219cffa6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
79 changed files with 397 additions and 386 deletions

View file

@ -1,35 +1,35 @@
#include "player_manager.h"
#include "../abstract_game.h"
#include "player.h"
#include "player_logic.h"
PlayerManager::PlayerManager(AbstractGame *_game,
int _localPlayerId,
bool _localPlayerIsJudge,
bool localPlayerIsSpectator)
: QObject(_game), game(_game), players(QMap<int, Player *>()), localPlayerId(_localPlayerId),
: QObject(_game), game(_game), players(QMap<int, PlayerLogic *>()), localPlayerId(_localPlayerId),
localPlayerIsJudge(_localPlayerIsJudge), localPlayerIsSpectator(localPlayerIsSpectator)
{
}
bool PlayerManager::isMainPlayerConceded() const
{
Player *player = players.value(localPlayerId, nullptr);
PlayerLogic *player = players.value(localPlayerId, nullptr);
return player && player->getConceded();
}
Player *PlayerManager::getActiveLocalPlayer(int activePlayer) const
PlayerLogic *PlayerManager::getActiveLocalPlayer(int activePlayer) const
{
Player *active = players.value(activePlayer, 0);
PlayerLogic *active = players.value(activePlayer, 0);
if (active) {
if (active->getPlayerInfo()->getLocal()) {
return active;
}
}
QMapIterator<int, Player *> playerIterator(players);
QMapIterator<int, PlayerLogic *> playerIterator(players);
while (playerIterator.hasNext()) {
Player *temp = playerIterator.next().value();
PlayerLogic *temp = playerIterator.next().value();
if (temp->getPlayerInfo()->getLocal()) {
return temp;
}
@ -43,11 +43,11 @@ bool PlayerManager::isLocalPlayer(int playerId)
return game->getGameState()->getIsLocalGame() || playerId == localPlayerId;
}
Player *PlayerManager::addPlayer(int playerId, const ServerInfo_User &info)
PlayerLogic *PlayerManager::addPlayer(int playerId, const ServerInfo_User &info)
{
auto *newPlayer = new Player(info, playerId, isLocalPlayer(playerId) || game->getGameState()->getIsLocalGame(),
isJudge(), getGame());
connect(newPlayer, &Player::concededChanged, this, &PlayerManager::onPlayerConceded);
auto *newPlayer = new PlayerLogic(info, playerId, isLocalPlayer(playerId) || game->getGameState()->getIsLocalGame(),
isJudge(), getGame());
connect(newPlayer, &PlayerLogic::concededChanged, this, &PlayerManager::onPlayerConceded);
players.insert(playerId, newPlayer);
emit playerAdded(newPlayer);
emit playerCountChanged();
@ -56,7 +56,7 @@ Player *PlayerManager::addPlayer(int playerId, const ServerInfo_User &info)
void PlayerManager::removePlayer(int playerId)
{
Player *player = getPlayer(playerId);
PlayerLogic *player = getPlayer(playerId);
if (!player) {
return;
}
@ -66,9 +66,9 @@ void PlayerManager::removePlayer(int playerId)
player->deleteLater();
}
Player *PlayerManager::getPlayer(int playerId) const
PlayerLogic *PlayerManager::getPlayer(int playerId) const
{
Player *player = players.value(playerId, 0);
PlayerLogic *player = players.value(playerId, 0);
if (!player) {
return nullptr;
}