2023-11-25 19:41:55 +01:00
|
|
|
#pragma once
|
|
|
|
|
2023-11-26 01:27:40 +01:00
|
|
|
#include <cstdint>
|
|
|
|
#include <memory>
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-11-25 19:41:55 +01:00
|
|
|
#include <solanaceae/contact/contact_model3.hpp>
|
|
|
|
#include <solanaceae/tox_contacts/tox_contact_model2.hpp>
|
|
|
|
|
2023-11-26 01:27:40 +01:00
|
|
|
#include "./toxic_game_i.hpp"
|
|
|
|
|
|
|
|
// TODO events:
|
|
|
|
// got invite
|
|
|
|
|
2023-11-25 19:41:55 +01:00
|
|
|
class ToxicGames : public ToxEventI {
|
|
|
|
Contact3Registry& _cr;
|
|
|
|
ToxI& _t;
|
2024-10-25 12:57:00 +02:00
|
|
|
ToxEventProviderI::SubscriptionReference _tep_sr;
|
2023-11-25 19:41:55 +01:00
|
|
|
ToxContactModel2& _tcm;
|
|
|
|
|
2023-11-26 01:27:40 +01:00
|
|
|
std::map<uint8_t, std::unique_ptr<ToxicGameI>> _game_types;
|
|
|
|
std::map<uint8_t, std::map<uint32_t, std::unique_ptr<ToxicGameI::InstanceI>>> _game_instances;
|
|
|
|
|
2023-11-25 19:41:55 +01:00
|
|
|
public:
|
|
|
|
ToxicGames(
|
|
|
|
Contact3Registry& cr,
|
|
|
|
ToxI& t,
|
|
|
|
ToxEventProviderI& tep,
|
|
|
|
ToxContactModel2& tcm
|
|
|
|
);
|
|
|
|
|
2023-11-26 01:27:40 +01:00
|
|
|
~ToxicGames(void) {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
// TODO: a setup game, for configurability?
|
|
|
|
void createGame(uint8_t game_type, std::vector<Contact3> with);
|
|
|
|
// with (contact list) ?
|
|
|
|
void acceptInvite(Contact3 from, uint8_t game_type, uint32_t game_id);
|
|
|
|
|
|
|
|
public: // internal, for games (TODO: extract?)
|
|
|
|
bool sendPacket(Contact3 to, uint8_t game_type, uint32_t game_id, const uint8_t* data, const size_t data_size);
|
|
|
|
|
2023-11-25 19:41:55 +01:00
|
|
|
private: // tox events
|
|
|
|
bool onToxEvent(const Tox_Event_Friend_Lossless_Packet* e) override;
|
|
|
|
bool onToxEvent(const Tox_Event_Group_Custom_Packet* e) override;
|
|
|
|
bool onToxEvent(const Tox_Event_Group_Custom_Private_Packet* e) override;
|
|
|
|
};
|
|
|
|
|