Skip to content

Commit

Permalink
WIP: Archipelago
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschwarzer committed Aug 29, 2024
1 parent cf9986a commit a9bfc88
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion projects/Randomizer/archipelago/archipelago.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace randomizer::archipelago {
modloader::info("archipelago", "AP client connected.");
}

bool ArchipelagoClient::is_connected() {
bool ArchipelagoClient::is_connected() const {
return m_websocket.getReadyState() == ix::ReadyState::Open;
}

Expand Down
2 changes: 1 addition & 1 deletion projects/Randomizer/archipelago/archipelago.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace randomizer::archipelago {
ArchipelagoClient();
void connect(std::string_view url, std::string_view password);
void disconnect();
bool is_connected();
bool is_connected() const;

private:
template<typename Jsonable>
Expand Down
9 changes: 8 additions & 1 deletion projects/Randomizer/archipelago/archipelago_ids.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <Randomizer/location_data/location.h>
#include <nlohmann/json.hpp>
#include <variant>

namespace randomizer::archipelago::ids {
Expand Down Expand Up @@ -45,20 +46,26 @@ namespace randomizer::archipelago::ids {
int8_t uber_group;
int16_t uber_state;
int8_t value;

NLOHMANN_DEFINE_TYPE_INTRUSIVE(Location, uber_group, uber_state, value);
};

struct BooleanItem {
int16_t uber_group;
int16_t uber_state;

NLOHMANN_DEFINE_TYPE_INTRUSIVE(BooleanItem, uber_group, uber_state);
};

struct ResourceItem {
ResourceType type;
int16_t value; // Only used for Spirit Light

NLOHMANN_DEFINE_TYPE_INTRUSIVE(ResourceItem, type, value);
};

archipelago_id_t get_boolean_item_id(int uber_group, int uber_state);
archipelago_id_t get_resource_item_id(ResourceType type, archipelago_id_t uid);
archipelago_id_t get_resource_item_id(ResourceType type, int16_t value);
archipelago_id_t get_location_id(const location_data::Location& location);
std::variant<Location, BooleanItem, ResourceItem> get_item(archipelago_id_t id);
} // namespace randomizer::archipelago::ids

0 comments on commit a9bfc88

Please sign in to comment.