Skip to main content

Module use_driver

Module use_driver 

Source
Expand description

Generic item-effect application + bag/shop buy-sell flow (P0e).

This module owns only the control flow of using, buying, and selling items. It is 100% game-agnostic: it never decides what an item effect actually does. The engine routes; the game decides.

  • UsageContext / ItemUseResult are neutral engine types.
  • ItemProvider::apply_effect is an opaque dispatch hook: the game implements what healing / status-cure / PP-restore / vitamins / battle items / catch / etc. actually do. The engine never inspects the effect.
  • use_item is the shared driver for field and battle use: it validates ownership and the usage context (ItemProvider::usable_in), dispatches to apply_effect, then consumes one unit from the Inventory iff the result says so. One place so field & battle share it.
  • buy / sell perform pure money/inventory bookkeeping; prices and the sell rate come from ShopProvider (Gen-1 quirks stay game-side).

Structs§

ShopReceipt
Summary of a completed shop transaction.

Enums§

ItemUseResult
Neutral result of an item-use attempt, returned by ItemProvider::apply_effect and propagated by use_item.
ShopError
Error from a shop transaction. Nothing is mutated when an error is returned.
UsageContext
Where / whether an item may be used. A neutral engine enum — no game specifics. Returned by ItemProvider::usable_in and passed into ItemProvider::apply_effect / use_item as the active context.

Functions§

buy
Buy quantity units of item at the shop’s ShopProvider::buy_price.
sell
Sell quantity units of item for the shop’s ShopProvider::sell_price.
use_item
Engine driver for using an item from the bag, shared by field and battle.