File indexing completed on 2024-10-06 03:46:38
0001 /* 0002 SPDX-FileCopyrightText: 2006 Pierre Ducroquet <pinaraf@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "neutralplayer.h" 0008 #include "../game.h" 0009 #include "../planet.h" 0010 #include <QDebug> 0011 0012 NeutralPlayer::NeutralPlayer(Game *game) : 0013 Player(game, QString(), Qt::gray) 0014 { 0015 } 0016 0017 bool NeutralPlayer::isNeutral() 0018 { 0019 return true; 0020 } 0021 0022 bool NeutralPlayer::isDead() 0023 { 0024 return false; 0025 } 0026 0027 void NeutralPlayer::play() 0028 { 0029 //qDebug() << "NeutralPlayer::play"; 0030 0031 // Go on each attack... 0032 for (Player *player : m_game->players()) { 0033 player->resetTurnStats(); 0034 0035 for (AttackFleet *fleet : player->attackList()) { 0036 if (m_game->doFleetArrival(fleet)) { 0037 player->attackDone(fleet); 0038 fleet->deleteLater(); 0039 } 0040 else { 0041 0042 // Only add the number of ships of the fleet to the player's 0043 // total fleet size if the fleet does not arrive this turn. 0044 0045 player->statShipCount(fleet->shipCount()); 0046 } 0047 } 0048 } 0049 0050 // Go over each planet, adding its ships 0051 for (Planet *planet : m_game->map()->planets()) { 0052 //qDebug() << "Turn for planet " << planet->name(); 0053 planet->turn(m_game->options()); 0054 } 0055 0056 m_game->findWinner(); 0057 0058 // After all that mess... It's done 0059 Q_EMIT donePlaying(); 0060 }