solanaceae_ecosystem/plugins/dice_tool.hpp
Green Sky a5b5ab97df
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Failing after 3m18s
ContinuousIntegration / linux (push) Successful in 2m42s
ContinuousIntegration / android (push) Failing after 5m25s
ContinuousDelivery / windows (push) Has been cancelled
ContinuousIntegration / macos (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled
dice tool working with >2 peers
2024-08-07 21:33:46 +02:00

39 lines
862 B
C++

#pragma once
#include <solanaceae/tox_p2prng/p2prng.hpp>
#include <solanaceae/contact/contact_model3.hpp>
#include <vector>
class DiceTool : public P2PRNGEventI {
P2PRNGI& _p2prng;
Contact3Registry& _cr;
struct Rolls {
std::vector<uint8_t> id;
uint16_t sides {};
P2PRNG::State state {P2PRNG::State::UNKNOWN};
uint16_t state_number_1 {};
uint16_t state_number_2 {};
uint16_t final_result{};
};
std::vector<Rolls> _rolls;
public:
DiceTool(P2PRNGI& p2prng, Contact3Registry& cr);
~DiceTool(void);
float render(float time_delta);
protected: // p2prng
bool onEvent(const P2PRNG::Events::Init&) override;
bool onEvent(const P2PRNG::Events::HMAC&) override;
bool onEvent(const P2PRNG::Events::Secret&) override;
bool onEvent(const P2PRNG::Events::Done&) override;
bool onEvent(const P2PRNG::Events::ValError&) override;
};