YouDunIt/modules/you_done_it/clue_data.cpp

48 lines
1.1 KiB
C++

#include "clue_data.h"
#include "core/config/engine.h"
#include "you_done_it/macros.h"
#include "you_done_it/ydi_client.h"
void ClueData::_bind_methods() {
BIND_HPROPERTY(Variant::INT, id, PROPERTY_HINT_ENUM, NetworkData::ClueID_hint());
}
void ClueData::set_revealed(bool value) {
this->revealed = value;
}
void ClueData::set_id(NetworkData::ClueID id) {
this->id = id;
}
NetworkData::ClueID ClueData::get_id() const {
return this->id;
}
void ClueData::reveal() {
if (this->id == NetworkData::CLUE_MAX) {
print_error("Attempt to reveal CLUE_MAX, invalid state, aborting");
abort();
}
if (this->revealed) {
print_error("Attempt to reveal clue that's already revealed, returning without action");
return;
}
this->revealed = true;
if (ydi::client::status() == NetworkData::CONNECTION_AUTHENTICATED) {
ydi::client::send::reveal_clue(this->id);
}
}
bool ClueData::get_revealed() const {
return this->revealed;
}
void ClueData::set_image(Ref<Image> image) {
this->image = image;
// TODO: Sync to server
}
Ref<Image> ClueData::get_image() const {
return this->image;
}