Skip to content

๐Ÿงพ Results Helpers

(Inventory/Extensions/Results)

Utility helpers for turning result-first operation codes into short, readable UI/debug strings.

๐ŸŸข Always safe to call
๐ŸŸข Pure formatting โ€” never mutates state
๐ŸŸก CurOpResultUtil only appears when the Currency module is present
๐Ÿ”ด Not a replacement for real error handling โ€” just text helpers


Purpose

Inventory operations return a standard result structure:

public readonly struct InvOpResult
{
    public bool Success;
    public InvOpCode Code;
    public string Message;
}

These helpers convert that into human-friendly text suitable for:

  • Debug logs
  • HUD toasts
  • Quick prototype UI
  • Teachable and demo panels

They do not influence control flow or gameplay logic.


๐Ÿ“˜ InvOpResultUtil

Extension methods for Inventory result formatting.

Example

var res = svc.MergeThenSwap(player, "Backpack", 0, 1);
Debug.Log(res.ToUserMessage("Move"));

Example Output

Move succeeded.
Move failed โ€“ not enough space.
Move blocked โ€“ no authority.
Move failed โ€“ item not found.
Move partially succeeded.

Behaviour

  • Uses InvOpCode to choose phrasing
  • Appends the optional Message field if provided
  • Never throws; always returns a string
  • Tone is consistent across RevFramework systems

๐Ÿ’ฐ CurOpResultUtil

(only available when REV_CURRENCY_PRESENT is defined)

Provides the same formatting helpers for Currency operations:

var buy = currencyService.TrySpend(player, cost);
Debug.Log(buy.ToUserMessage("Purchase"));

Possible Outputs

Purchase succeeded.
Purchase failed โ€“ insufficient funds.
Purchase failed โ€“ no space.
Purchase blocked โ€“ no authority.

Notes

  • Compiles only when the Currency module is present
  • Lives in the Inventory namespace for convenience
  • Mirrors the tone and behaviour of InvOpResultUtil

๐Ÿ” When to Use These Helpers

Good fits:

  • UI toast notifications
  • Debug or logging output
  • Editor tools and panels
  • Prototype gameplay
  • Teachable/demo scenes

Avoid using them:

  • As core game logic
  • For branching decisions (use InvOpResult.Success / Code)
  • In networking or authoritative flows

  • Abstractions โ†’ InvOpResult, InvOpCode semantics
  • Extensions โ†’ sugar helpers built on result-first APIs