๐งพ 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
๐กCurOpResultUtilonly 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
InvOpCodeto choose phrasing - Appends the optional
Messagefield 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
๐ Related¶
- Abstractions โ
InvOpResult,InvOpCodesemantics - Extensions โ sugar helpers built on result-first APIs