File indexing completed on 2024-07-14 04:00:54

0001 /*
0002     SPDX-FileCopyrightText: 2007 Paolo Capriotti <p.capriotti@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef NETWORKENTITY_H
0008 #define NETWORKENTITY_H
0009 
0010 #include "entity.h"
0011 #include "message.h"
0012 
0013 class Sea;
0014 class SeaView;
0015 class Protocol;
0016 
0017 class NetworkEntity : public Entity, private MessageVisitor
0018 {
0019 Q_OBJECT
0020     Sea* m_sea;
0021     Protocol* m_protocol;
0022     Shot* m_pending_shot;
0023     bool m_client;
0024     bool m_winner;
0025     
0026 public:
0027     NetworkEntity(Sea::Player player, Sea* sea, SeaView* seaview, Protocol* device, bool client);
0028     ~NetworkEntity() override;
0029 
0030     void notify(Sea::Player player, const Coord& c, const HitInfo& info) override;
0031     void notifyChat(const Entity* entity, const QString& text) override;
0032     void notifyNick(Sea::Player player, const QString& nick) override;
0033     void start() override;
0034     void startPlacing() override;
0035     void startPlaying() override;
0036     void notifyReady(Sea::Player player) override;
0037     void notifyShips(Sea::Player winner) override;
0038     void notifyGameOver(Sea::Player winner) override;
0039     void notifyGameOptions() override;
0040     void hit(Shot* shot) override;
0041 
0042     QIcon icon() const override;
0043 private Q_SLOTS:
0044     void received(MessagePtr msg);
0045     void notifyAbort() override;
0046     void notifyRestartPlacing(Sea::Player) override { }
0047 protected:
0048     void visit(const HeaderMessage& msg) override;
0049     void visit(const RejectMessage& msg) override;
0050     void visit(const NickMessage& msg) override;
0051     void visit(const BeginMessage& msg) override;
0052     void visit(const MoveMessage& msg) override;
0053     void visit(const NotificationMessage& msg) override;
0054     void visit(const GameOverMessage& msg) override;
0055     void visit(const RestartMessage& msg) override;
0056     void visit(const ChatMessage& msg) override;
0057     void visit(const GameOptionsMessage& msg) override;
0058 Q_SIGNALS:
0059     void restartRequested();
0060 };
0061 
0062 #endif // NETWORKENTITY_H
0063