#include "StructureController.hpp" namespace Screeps { StructureController::StructureController(JS::Value value) : OwnedStructure(std::move(value)) { } bool StructureController::isPowerEnabled() const { return value()["isPowerEnabled"].as(); } int StructureController::level() const { return value()["level"].as(); } int StructureController::progress() const { return value()["progress"].as(); } int StructureController::progressTotal() const { return value()["progressTotal"].as(); } std::optional StructureController::reservation() const { auto obj = value()["reservation"]; if (obj.isUndefined()) return std::nullopt; else { Reservation result; result.username = obj["username"].as(); result.ticksToEnd = obj["ticksToEnd"].as(); return result; } } std::optional StructureController::safeMode() const { auto result = value()["safeMode"]; if (result.isUndefined()) return std::nullopt; return result.as(); } int StructureController::safeModeAvailable() const { return value()["safeModeAvailable"].as(); } std::optional StructureController::safeModeCooldown() const { auto result = value()["safeModeCooldown"]; if (result.isUndefined()) return std::nullopt; return result.as(); } std::optional StructureController::sign() const { auto obj = value()["sign"]; if (obj.isUndefined()) return std::nullopt; else { Sign result; result.username = obj["username"].as(); result.text = obj["text"].as(); result.time = obj["time"].as(); result.datetime = obj["datetime"].call("valueOf"); return result; } } int StructureController::ticksToDowngrade() const { return value()["ticksToDowngrade"].as(); } int StructureController::upgradeBlocked() const { return value()["upgradeBlocked"].as(); } int StructureController::activateSafeMode() { return value().call("activateSafeMode"); } int StructureController::unclaim() { return value().call("unclaim"); } } // namespace Screeps