TakeTreasure
Empty a treasure cache or a pile of dropped goods into the party's packs (one turn).
Full documentation: TakeTreasure. Wire type: take_treasure.
Legal session modes: exploring
JSON Schema
{
"description": "Empty a treasure cache or a pile of dropped goods into the party's packs (one turn).\n\nThe party must be exploring a dungeon (see\n`EnterDungeon`). `feature_id` is the id\nof an authored cache or a cache the engine generated, or the literal `\"pile\"` for goods\ndropped on the party's cell.\n\nBy default the goods spread across the living members:\n\n- Each item goes to a member whose class can use it, so the fighter takes the plate mail\n and the magic-user takes the arcane scroll.\n- Gems and jewellery divide by worth.\n- Coins divide evenly, one denomination at a time.\n\nA member who carries more than their maximum load can't move, and then the party can't\nmove either. So the session never gives a member more than their maximum load. The maximum\nload is a weight of 1,600 coins. Under detailed encumbrance, a member who wears gauntlets of\nogre power can carry 2,600. The party moves at its slowest member's rate, so a heavy load on\none member slows everyone.\n\nName `recipient_id` to have one member take all the goods instead, up to their maximum\nload. Whatever the carriers can't carry stays in the pile on the cell. The party can\nlighten its load and come back for it. To change who carries what afterwards, use\n`GiveItems`.\n\nUnder the immediate XP timing, the treasure's XP divides evenly among the living\nmembers, however the goods end up split, as the OSE SRD's rule for treasure XP says.\n\nThe named recipient, or the first living member in marching order when nobody is named,\nreaches into the cache. A cache whose trap hasn't been removed gets its chance to spring\non that member first.\n\nModes:\n `exploring`\n\nRejections:\n - `session.command.wrong_mode` - the session is not exploring a dungeon.\n - `session.command.no_living_members` - nobody is left alive to carry anything.\n - `session.command.unknown_member` - `recipient_id` matches no party member.\n - `session.command.member_incapacitated` - the recipient can't act.\n - `exploration.feature.unknown` - no cache by that id is on this cell, or there's\n no pile on it.\n - `exploration.feature.emptied` - the cache has already been emptied.\n\nEvents:\n When the cache has a trap that hasn't been removed or sprung, its spring check comes\n first: a `DetectionRolledEvent`, a\n `TrapEvent`, and the trap's resolution\n when it springs. Then comes one\n `ItemAcquiredEvent` for each member\n who took something, in marching order, listing their goods and coin value with\n `origin` `\"treasure\"`. An\n `ItemsLeftBehindEvent` follows\n when the party couldn't carry it all. Under the immediate XP timing, an\n `XpAwardedEvent` follows for each living member.\n One turn passes. A trap that kills the whole party leaves the cache full, and only\n the turn passes.\n\nExamples:\n ```python\n from osrlib.core.alignment import Alignment\n from osrlib.core.character import CHARACTER_CREATION_STREAM, create_character\n from osrlib.core.events import Visibility\n from osrlib.core.items import Coins\n from osrlib.core.rng import RngStreams\n from osrlib.core.ruleset import Ruleset\n from osrlib.crawl.adventure import Adventure, TownSpec\n from osrlib.crawl.commands import EnterDungeon, TakeTreasure\n from osrlib.crawl.dungeon import DungeonSpec, FeatureSpec, LevelSpec\n from osrlib.crawl.party import Party\n from osrlib.crawl.session import GameSession\n from osrlib.messages import format_message\n\n stream = RngStreams(master_seed=7).get(CHARACTER_CREATION_STREAM)\n hero = create_character(\n name=\"Hild\", class_id=\"fighter\", alignment=Alignment.LAWFUL, ruleset=Ruleset(), stream=stream\n ).character\n chest = FeatureSpec(id=\"chest\", kind=\"treasure_cache\", cell=(0, 0), coins=Coins(gp=50), item_ids=(\"rope\",))\n level = LevelSpec(number=1, width=1, height=1, entrance=(0, 0), features=(chest,))\n crypt = DungeonSpec(id=\"crypt\", name=\"The Old Crypt\", levels=(level,))\n adventure = Adventure(name=\"A First Delve\", town=TownSpec(name=\"Threshold\"), dungeons=(crypt,))\n session = GameSession.new(Party(members=[hero]), adventure, seed=7)\n session.execute(EnterDungeon(dungeon_id=\"crypt\"))\n\n result = session.execute(TakeTreasure(feature_id=\"chest\"))\n print([format_message(event) for event in result.events if event.visibility is Visibility.PLAYER])\n # ['character-0001 acquires rope and 50 gp in coin.']\n\n # The chest is empty now, so a second try is refused.\n print(session.execute(TakeTreasure(feature_id=\"chest\")).rejections[0].code)\n # exploration.feature.emptied\n ```",
"properties": {
"command_type": {
"const": "take_treasure",
"default": "take_treasure",
"title": "Command Type",
"type": "string",
"description": "The name that identifies the command class in serialized data. Each command class fixes\nit to a distinct snake_case string, like `\"move_party\"` or `\"open_door\"`, and constructing\nthe class sets it, so you never pass it yourself.\n`parse_command` and the\n`AnyCommand` union use it to rebuild the right class\nfrom a serialized mapping. A class's value never changes between releases."
},
"source": {
"anyOf": [
{
"minLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Source",
"description": "Who or what issued the command on whose behalf: an authored trigger or quest id, or the\nname of one of your game's systems. The engine never reads it, so a command with a\n`source` does exactly what the same command without one does. The session logs and\nreplays it with the command, so the log alone shows why something happened. Leave it\n`None` when there's nothing to record. An empty string fails validation when the command\nis constructed."
},
"feature_id": {
"title": "Feature Id",
"type": "string",
"description": "What to empty. Name an authored cache by its\n`FeatureSpec.id`. Name a cache the engine generated\nby the\n`HoardGeneratedEvent.cache_ref` the\nsession emitted when it generated the cache. The literal `\"pile\"` means the goods dropped\non the party's cell, which\n`PlayerView.piles` lists by cell reference. The session\nrefuses a cache that's already emptied with `exploration.feature.emptied`."
},
"recipient_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Recipient Id",
"description": "One member to take all the goods, by\n`MemberView.id`, or `None` to spread it across the\nliving members. The named member fills their pack up to their maximum load, and the rest\nstays on the cell. Name a recipient to keep a specific item with a specific member. The\nnamed member is also the one who reaches into the cache, so a trap that hasn't been\nremoved springs on them. If that trap leaves them unable to act, the goods spread across\nthe living members instead."
}
},
"required": [
"feature_id"
],
"title": "TakeTreasure",
"type": "object"
}