Skip to content

MoraleCheckedEvent

A side's nerve tested, and whether it held.

Full documentation: MoraleCheckedEvent. Wire type: morale_checked.

Default visibility: referee

Message codes: combat.morale.broke, combat.morale.exempt, combat.morale.held

JSON Schema

{
  "$defs": {
    "Visibility": {
      "description": "Who is allowed to see an event.\n\nEvery event has one of these two values, and the split exists because B/X keeps some rolls behind the\nreferee's screen. Filter a log on it before you show anything to a player, or call\n`GameSession.view`, which builds the player's and the referee's\nviews for you. A narrator playing referee reads both.\n\nThe values are the lowercase strings and they serialize into every event, so a renamed value is a\n`schema_version` bump.\n\nExamples:\n    ```python\n    from osrlib.core.events import DamageDealtEvent, HitPointsReportedEvent, Visibility\n\n    log = [\n        DamageDealtEvent(target_id=\"monster-0001\", amount=5),\n        HitPointsReportedEvent(target_id=\"monster-0001\", current_hp=2, max_hp=7),\n    ]\n    shown = [event.code for event in log if event.visibility is Visibility.PLAYER]\n    assert shown == [\"combat.damage.dealt\"]  # the goblin's remaining hit points stay hidden\n    ```",
      "enum": [
        "player",
        "referee"
      ],
      "title": "Visibility",
      "type": "string"
    }
  },
  "description": "A side's nerve tested, and whether it held.\n\n`check_morale` emits one of these when a fight gives a side reason to\nreconsider. A broken side flees or surrenders, and acting on that is the caller's job.\n\nSome morale scores never roll. A score of 2 or less never fights and a score of 12 or more never checks,\nand both report `combat.morale.exempt` with no roll. Read `held` to tell them apart, as on any other code:\nat 2 or less the side is already broken, and at 12 or more it holds.",
  "properties": {
    "code": {
      "title": "Code",
      "type": "string",
      "description": "What happened, as two or more lowercase segments separated by dots and namespaced by subsystem, like\n`combat.attack.hit`. This is what you branch on and what\n`format_message` looks up. Anything else raises a validation error."
    },
    "visibility": {
      "$ref": "#/$defs/Visibility",
      "default": "referee",
      "description": "Referee visibility: the players find out a side has broken by watching it run."
    },
    "event_type": {
      "const": "morale_checked",
      "default": "morale_checked",
      "title": "Event Type",
      "type": "string",
      "description": "The wire name for this event type."
    },
    "subject": {
      "title": "Subject",
      "type": "string",
      "description": "Whose morale was checked, by the side key the caller passed in."
    },
    "score": {
      "title": "Score",
      "type": "integer",
      "description": "The side's morale score. Anything from 3 to 11 rolls. A score of 2 or less exempts the side and leaves it\nbroken, and 12 or more exempts it and leaves it holding."
    },
    "roll": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Roll",
      "description": "The 2d6 total, before modifiers. `None` when the score exempted the side from rolling."
    },
    "modifier": {
      "default": 0,
      "title": "Modifier",
      "type": "integer",
      "description": "The situational adjustment applied, which B/X caps at plus or minus 2."
    },
    "held": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Held",
      "description": "Whether the side keeps fighting, on every code: a rolled check's verdict, `True` for a score of\n12 or more, and `False` for a score of 2 or less.\n`check_morale` sets it on every event it emits, so render the\noutcome from this field rather than from the code and the score together. It is `None` on an event\nloaded from a save written before the field existed, because no migration fills it in."
    }
  },
  "required": [
    "code",
    "subject",
    "score"
  ],
  "title": "MoraleCheckedEvent",
  "type": "object"
}