/** * Handler for player data * $Id$ * $HeadURL$ * $Author$ * Created by gr, SLSE, 2017-02-20 */ #pragma once #include #include #include #include #include #include #include // Handling for participants within buildings namespace CesParticipantBuildings { class HandlerParticipantBuilding : public QObject , protected TrainingAreaBase::Interface::Ftc::SendCesHitReplyHandler { Q_OBJECT public: explicit HandlerParticipantBuilding(const std::shared_ptr &ddsHandler, const std::shared_ptr &participantHandler, const std::shared_ptr &handlerBuildingData, QObject *parent = nullptr); ~HandlerParticipantBuilding(); /** * Initialize the handler to manage information from player management */ bool init(); int getDamagePercentFromBuilding(const int buildingId) const; int getDamagePercentFromRoom(const int roomId) const; Q_SIGNALS: void newBuildingState(const int32_t buildingId); protected: void onSendCesHitReply(const Core::FunctionReplyObject &replyObject) override final; private Q_SLOTS: /** * Handle BuildingState from 'BLD' */ void onBuildingStateChanged(const Buildings::BuildingState &data, DataModification modType); /** * Handle MainStructureElement from 'ISM' */ void sendFtcCesHitRequestTimeout(); void sendCesHitToParticipant(const Buildings::BuildingState &data, const int32_t participantId, const int32_t remainingEffectPercent); private: // attributes struct RoomState { int buildingId = 0; int damagePercent = 0; }; std::shared_ptr m_ddsHandler; ///< Pointer to DDS handler std::shared_ptr m_handlerParticipant; std::shared_ptr m_handlerBuildingData; QHash m_buildingStates; QHash m_roomIdDamageState; // Key = roomId, value = damageState QHash m_requestMap; // Key = participantId QTimer *m_timer; CentralEffectSimulation::LOGGER_T &m_logger; ///< Interface to the Logging-Facility }; } // namespace CesParticipantBuildings