reward_resolver.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include "../account/account_state.h"
  3. #include "../build_data/rewards/definition.h"
  4. #include "../unlocks/definition.h"
  5. namespace sunrise::state::rewards {
  6. /** One item a resolved reward grants, with the socket overrides its row carries. */
  7. struct Grant {
  8. std::uint16_t itemIndex{build_data::rewards::kAbsent};
  9. std::int32_t quantity{};
  10. std::array<build_data::rewards::SocketOverride, build_data::rewards::kSocketsPerItem> sockets{};
  11. std::size_t socketCount{};
  12. };
  13. /** Every grant one resolution produces, in draw order. */
  14. struct Result {
  15. std::array<Grant, build_data::rewards::kGrantCapacity> grants{};
  16. std::size_t count{};
  17. };
  18. /** The seed belongs to the prepared server transaction, so validation repeats the same draw. */
  19. struct Context {
  20. const unlocks::Table& unlocks;
  21. CharacterClass characterClass{};
  22. std::uint64_t seed{};
  23. /** Optional refusal reason; points to a static diagnostic label. */
  24. const char** refusal{};
  25. };
  26. /** Evaluates one bound condition; an empty condition is always eligible. */
  27. [[nodiscard]] bool eligible(std::span<const build_data::rewards::Instruction> instructions,
  28. const Context& context,
  29. bool& result) noexcept;
  30. /** How one resolution ended; ineligible means the saved unlocks left nothing to draw. */
  31. enum class Resolution : std::uint8_t { resolved, ineligible, refused };
  32. /** Plans an acquisition without changing State; retains wrappers opened separately. */
  33. [[nodiscard]] Resolution resolve(const Context& context,
  34. std::uint16_t itemIndex,
  35. std::uint32_t quantity,
  36. Result& result) noexcept;
  37. } // namespace sunrise::state::rewards