diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
commit | 6352e8e3196f78388b6c771073f9e03eaa612673 (patch) | |
tree | e23772f79a7fbc41bc9108951e9e136857484bf4 /source/game/StarItemRecipe.cpp | |
parent | 6741a057e5639280d85d0f88ba26f000baa58f61 (diff) |
everything everywhere
all at once
Diffstat (limited to 'source/game/StarItemRecipe.cpp')
-rw-r--r-- | source/game/StarItemRecipe.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/source/game/StarItemRecipe.cpp b/source/game/StarItemRecipe.cpp new file mode 100644 index 0000000..7295cd1 --- /dev/null +++ b/source/game/StarItemRecipe.cpp @@ -0,0 +1,46 @@ +#include "StarItemRecipe.hpp" +#include "StarRoot.hpp" +#include "StarItemDatabase.hpp" +#include "StarJsonExtra.hpp" + +namespace Star { + +Json ItemRecipe::toJson() { + JsonArray inputList; + for (auto input : inputs) + inputList.append(input.toJson()); + + return JsonObject{ + {"currencyInputs", jsonFromMap(currencyInputs)}, + {"input", inputList}, + {"output", output.toJson()}, + {"duration", duration}, + {"groups", jsonFromStringSet(groups)}, + {"collectables", jsonFromMap(collectables)}, + {"matchInputParameters", matchInputParameters} + }; +} + +bool ItemRecipe::isNull() { + return currencyInputs.size() == 0 && inputs.size() == 0 && output.isNull(); +} + +bool ItemRecipe::operator==(ItemRecipe const& rhs) const { + return std::tie(currencyInputs, inputs, output) == std::tie(rhs.currencyInputs, rhs.inputs, rhs.output); +} + +bool ItemRecipe::operator!=(ItemRecipe const& rhs) const { + return std::tie(currencyInputs, inputs, output) != std::tie(rhs.currencyInputs, rhs.inputs, rhs.output); +} + +std::ostream& operator<<(std::ostream& os, ItemRecipe const& recipe) { + os << "CurrencyInputs: " << recipe.currencyInputs << "Inputs: " << recipe.inputs << "\nOutput: " << recipe.output + << "\nDuration: " << recipe.duration << "\nGroups: " << recipe.groups; + return os; +} + +size_t hash<ItemRecipe>::operator()(ItemRecipe const& v) const { + return hashOf(v.currencyInputs.keys(), v.currencyInputs.values(), v.inputs, v.output); +} + +} |