Skip to main content

Module mart

Module mart 

Source
Expand description

Mart / shop interaction state machine — the UI-level counterpart of the buy / sell money-and-inventory drivers.

MartState owns only the interaction flow of a shop: the Buy/Sell/Quit top menu, item-list cursors, quantity selection, the Yes/No confirmation sub-phase, and result display. It knows nothing about prices, money, or bag capacity — those are supplied by the game through the MartBackend callback trait, so every game keeps its own pricing rules, currency semantics, and inventory quirks (per-slot caps, overflow spill, unsellable key items, …).

MartDriver is a ready-made backend that routes transactions through the engine’s buy / sell drivers and a ShopProvider; games with special bag semantics implement MartBackend directly instead.

Input uses the engine-wide MenuInput; sound cues are reported as MartSound values the game maps to its own audio ids.

Structs§

MartDriver
Ready-made MartBackend that routes transactions through the engine’s buy / sell drivers and a ShopProvider.
MartState
Complete mart interaction state machine.
MartStock
The list of items a shop stocks, in display order.

Enums§

BuyMenuState
Phases inside the Buy flow.
BuyResult
Outcome of a buy attempt, reported by MartBackend::commit_buy.
ConfirmChoice
Yes/No choice used inside the confirmation sub-phase.
MartPhase
Actual state machine phase (read via MartState::phase).
MartSound
Sound cues the mart layer can request.
MartTopChoice
Top-menu cursor position.
MartUpdate
Returned by MartState::update_frame to signal the caller.
SellMenuState
Phases inside the Sell flow.
SellResult
Outcome of a sell attempt, reported by MartBackend::commit_sell.

Traits§

MartBackend
Price / capacity / transaction callbacks the game supplies to MartState. The state machine owns navigation; the backend owns all money and bag semantics.