mud_server.services.character_provisioning
Shared character provisioning service used by admin and player APIs.
- Why this module exists:
The codebase previously duplicated character creation logic across route handlers. This service centralizes deterministic name generation, DB create retries, and optional entity-state seeding so every caller follows one canonical behavior.
Attributes
Classes
Result payload for generated-character provisioning. |
Functions
Generate a replayable, non-zero seed for provisioning flows. |
|
Generate a deterministic |
|
|
Fetch an optional entity-state payload for a provisioning seed. |
|
Return |
|
Create a generated-name character with optional entity-state axis seeding. |
Module Contents
- mud_server.services.character_provisioning.logger
- class mud_server.services.character_provisioning.CharacterProvisioningResult[source]
Result payload for generated-character provisioning.
- success
True when provisioning completed and DB rows were persisted.
- reason
Stable reason key for caller-level error mapping.
- message
Human-readable status message.
- character_id
Created character id when successful.
- character_name
Created character name when successful.
- world_id
Target world id for the created character.
- seed
Deterministic provisioning seed used for name/entity generation.
- entity_state
Raw entity payload when fetched successfully.
- entity_state_error
Non-fatal warning when entity seeding fails.
- mud_server.services.character_provisioning.generate_provisioning_seed()[source]
Generate a replayable, non-zero seed for provisioning flows.
We intentionally use
secrets.randbelowrather than module-global RNG state to avoid coupling name/entity generation to gameplay randomness.
- mud_server.services.character_provisioning.fetch_generated_full_name(seed)[source]
Generate a deterministic
first lastcharacter name for provisioning.The same base seed is used for both lookups with an offset for the surname so retry attempts remain deterministic across deployments.
- mud_server.services.character_provisioning.fetch_entity_state_for_seed(seed, *, world_id=None)[source]
Fetch an optional entity-state payload for a provisioning seed.
Entity-state integration is non-fatal: character creation continues even if the upstream call fails.
- mud_server.services.character_provisioning.get_world_slot_capacity(user_id, world_id)[source]
Return
(current_count, slot_limit)for account ownership in one world.
- mud_server.services.character_provisioning.provision_generated_character_for_user(*, user_id, world_id, max_attempts=8)[source]
Create a generated-name character with optional entity-state axis seeding.
- The flow is intentionally deterministic per retry sequence:
Resolve slot capacity early and fail fast if world budget is full.
Generate
first lastnames from deterministic seeds.Retry on unique-name collisions.
Apply optional entity-state deltas as a non-fatal post-step.