# Monster Builder Modules

## monster_builder module

Contains definition of the monster builder window.

If run as the main script, will create and display a window allowing the user to edit, save, and export a single monster to a file.

class `monster_builder.``MonsterBuilderFrame`

  Bases: `ui_helpers.BuilderFrame`

  Main window of the application if running as a single monster builder.

  `__init__`()

    Constructor for the window. Sets up and initializes UI elements.

  `__module__` = 'monster_builder'
  `_cb_close`(event: wx._core.CloseEvent)

    Callback to handle closing the window.

    Parameters: | event – CloseEvent object containing details about the event.

  `_cb_export_rtf`(event: wx._core.CommandEvent)

    Callback handling the user wanting to export the monster to an RTF file.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_new`(event: wx._core.CommandEvent)

    Callback handling the user wanting to create a new monster.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_open`(event: wx._core.CommandEvent)

    Callback handling the user wanting to open a monster file to edit.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_resize`(event: wx._core.SizeEvent)

    Callback to handle resizing the window.

    Parameters: | event – SizeEvent object containing details about the event.

  `_cb_save`(event: wx._core.CommandEvent)

    Callback handling the user wanting to (re-)save the monster to a file.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_save_as`(event: wx._core.CommandEvent)

    Callback handling the user wanting to save the monster to a file.

    Parameters: | event – CommandEvent object containing details about the event.

  `_initialize`()

    Gives UI elements their initial values.

  `_setup_ui`()

    Sets up and places all UI elements on the window.

  `clear_status`()

    Forcibly clears the contents of the status bar and cancels any waiting status clearing timer.

  `export_to_rtf`()

    Exports the data for this monster to an RTF file.

  `new`()

    Resets all controls to default values, clears out any buildable lists or special properties.

  `open`()

    Opens a saved monster file for editing, replacing all the contents of this frame with whatever’s in the file.

  `repaint`()

    Sizes and “redraws” the window.

  `resize`()

    Handles the window being resized by telling all children to rearrange themselves.

    The monster panel’s resize() method automatically calls our repaint(), so we can omit it here.

  `set_status`(status_text: str, clear_later: bool = True)

    Sets the status bar to the given text string and sets a timer to clear the status bar later. :param status_text: The text to show on the status bar. :param clear_later: If True (the default) will set a timer to clear the status bar later, otherwise will leave the text there.

class `monster_builder.``MonsterBuilderPanel`(frame: ui_helpers.BuilderFrame, parent: wx._core.Window)

  Bases: `wx._core.Panel`

  Main panel for creating/editing a monster.

  `BLOODIED_STR` = '/ {0:d} Bloodied'
  `DEFAULT_VAL_STR` = ' ({0:d})'
  `__init__`(frame: ui_helpers.BuilderFrame, parent: wx._core.Window)

    Constructor for the window. Sets up and initializes UI elements.

    Parameters: | frame – MonsterBuilderFrame or EncounterBuilderFrame object that will hold this panel. Used to reference frame controls like the status bar. parent – The owner of this panel.

  `__module__` = 'monster_builder'
  `_attribute_changed`()

    Handles updating any components that depend on the value of an attribute when one changes.

  `_attribute_custom_check`(custom_checked: bool)

    Adjusts the UI and contents of the attribute text boxes depending on if the user (un)checked the option to enter custom attributes.

    Parameters: | custom_checked – True if the custom attributes checkbox is checked, False otherwise.

  `_cb_add_action`(event: wx._core.CommandEvent)

    Callback handling adding a new action to the action list.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_add_trait`(event: wx._core.CommandEvent)

    Callback handling adding a new trait to the trait list.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_attribute_change`(event: wx._core.CommandEvent)

    Callback handling when one of the monster’s attributes changes.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_attribute_custom`(event: wx._core.CommandEvent)

    Callback handling when the user (un)checks the option to use custom attribute scores.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_attribute_role_change`(event: wx._core.CommandEvent)

    Callback handling when the monster’s “attribute role” template changes.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_hp_change`(event: wx._core.CommandEvent)

    Callback handling when HP changes.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_level_change`(event: wx._core.CommandEvent)

    Callback handling when the monster’s level changes.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_role_change`(event: wx._core.CommandEvent)

    Callback handling when the monster’s role changes.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_role_mod_change`(event: wx._core.CommandEvent)

    Callback handling when the monster’s role mod changes.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_speed_clicked`(event: wx._core.CommandEvent)

    Callback handling when a special speed gets (un)checked. Shows/hides the speed’s labeled textbox.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_stat_change`(event: wx._core.Event)

    Callback handling when an editable stat changes.

    Parameters: | event – Various kind of event indicating what changed.

  `_initialize`()

    Gives UI elements their initial values.

  `_level_changed`()

    Handles updating any components that depend on the monster’s level for calculations.

  `_organize_traits_actions`()

    Ensures that the list of actions & traits are displayed traits first (in order), then actions (in order).

  `_role_change`(new_role: str)

    When the monster role changes, adjusts the attribute role to match and then recalculates all default stats.

    Parameters: | new_role – String name of the monster’s role.

  `_role_mod_change`(new_role_mod: str)

    When the monster’s role mod changes, recalculate default stats and check if we should show a note for any special monster roles.

    Parameters: | new_role_mod – String name of monster’s new role.

  `_setup_ui`()

    Sets up and places all UI elements on the window.

  `_update_action_ui`(action_id: int)

    Adjusts the UI for an action panel with the given ID.

    Parameters: | action_id – ID of the action panel to update.

  `_update_attribute_role`(role_label: str)

    Resets the monster’s attributes to level-appropriate defaults based on the selected role. Only change the values if the user isn’t manually entering custom attributes.

    Parameters: | role_label – The name of the attribute role that was selected.

  `_update_resist_vuln_ui`(rv_label: str)

    Adjusts the UI for a resist/vuln/immunity textbox & mods based on whether it is checked or not.

    Parameters: | rv_label – The name of the ResistVulnControls object to examine.

  `_update_speed_ui`(speed_index: int)

    Adjusts the UI for a special speed’s textbox & mods based on whether the speed is checked or not.

    Parameters: | speed_index – The index into the speeds checklist to look at.

  `_update_trait_ui`(trait_id: int)

    Adjusts the UI for a trait panel based on what kind of trait parameters are selected.

    Parameters: | trait_id – ID of the trait panel to update.

  `add_action`() → monster_ui_helpers.ActionPanel

    Adds a new action to the action list.

  `add_trait`() → monster_ui_helpers.TraitPanel

    Adds a new trait to the trait list.

  `cb_resist_vuln_clicked`(event: wx._core.CommandEvent)

    Callback handling when something in the resist/vuln/immune list gets (un)checked. Shows/hides that element’s extra controls.

    Parameters: | event – CommandEvent object containing details about the event.

  `cb_resist_vuln_radio_clicked`(event: wx._core.CommandEvent)

    Callback handling when a resistance/vulnerability type is changed. Enables/disables its textbox if it has one.

    Parameters: | event – CommandEvent object containing details about the event.

  `delete_action`(action_id: int)

    Removes an action from the action list.

    Parameters: | action_id – The ID of the action to remove.

  `delete_trait`(trait_id: int)

    Removes a trait from the trait list.

    Parameters: | trait_id – The ID of the trait to remove.

  `destroy`()

    Destroys this panel’s children, then itself.

  `initialize_stats`()

    Initializes and calculates all basic stats.

  `move_action_down`(action_id: int)

    Moves the action with the given ID down one slot on the list of actions.

    Parameters: | action_id – Integer ID of the action to move.

  `move_action_up`(action_id: int)

    Moves the action with the given ID up one slot on the list of actions.

    Parameters: | action_id – Integer ID of the action to move.

  `move_trait_down`(trait_id: int)

    Moves the trait with the given ID down one slot on the list of traits.

    Parameters: | trait_id – Integer ID of the trait to move.

  `move_trait_up`(trait_id: int)

    Moves the trait with the given ID up one slot on the list of traits.

    Parameters: | trait_id – Integer ID of the trait to move.

  `recalculate`()

    Recalculates all “suggested value” stats based on user-input fields.

  `repaint`()

    Sizes and “redraws” the panel. Also calls up to the containing frame’s repaint() so it can adjust if this panel’s size changes as a result of the Layout() and Fit() calls.

  `reset`()

    Resets all controls to default values, clears out any buildable lists or special properties.

  `resize`()

    Calls Layout() for everything and then Fit() to ensure everything has the correct UI size.

  `save`() → int

    Saves the data of the current monster to a file. Uses the last file saved to, or asks the user for a file name if no file has been specified yet.

    Returns: | 1 if the file saved successfully, 0 if it was canceled, -1 if it failed.

  `save_as`(filename: str = '') → int

    Saves the data of the current monster to a file. Prompts the user for a file name to save to if filename is blank.

    Returns: | 1 if the file saved successfully, 0 if it was cancelled, -1 if it failed.

  `set_inputs_to_calc_vals`()

    Sets all user input fields to the calculated “default” values for them based on current monster stats.

  `set_label_vals`()

    Sets the “suggested” values and other hints in labels based on current calculated values.

  `update_ui`()

    Updates all UI fields after a monster gets loaded.

`monster_builder.``main`(argv)

  Main function to run the program as a single monster editor.

  Parameters: | argv – Command-line args as sys.argv would provide.

## monster_ui_helpers module

Contains helper data, functions, and classes for Monster Builder UI creation & management.

class `monster_ui_helpers.``ActionPanel`(container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window, id: int = -1, pos: wx._core.Point = wx.Point(-1, -1), size: wx._core.Size = wx.Size(-1, -1), style: int = 524288)

  Bases: `wx._core.Panel`

  Container class for the controls needed to display an editable action.

  `__init__`(container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window, id: int = -1, pos: wx._core.Point = wx.Point(-1, -1), size: wx._core.Size = wx.Size(-1, -1), style: int = 524288)

    Creates a new set of action controls in a panel. Panel’s wx name is always “ActionPanel:X” where X is the action ID.

    Parameters: | container – MonsterBuilderPanel object that will hold the panel. parent – The owner of the new action panel. id – Integer ID of the panel for wx. pos – Position of the panel. size – Size of the panel. style – Style flags for the panel.

  `__module__` = 'monster_ui_helpers'
  `_cb_change_frequency`(event: wx._core.CommandEvent)

    Callback handling when the allowed frequency of an action changes (e.g., At-Will to Encounter).

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_delete_action`(event: wx._core.CommandEvent)

    Callback handling removing an action from the action list.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_move_down`(event: wx._core.CommandEvent)

    Callback handling moving an action down in the order.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_move_up`(event: wx._core.CommandEvent)

    Callback handling moving an action up in the order.

    Parameters: | event – CommandEvent object containing details about the event.

  `destroy`()

    Destroys all controls belonging to a action, presumably as part of removing a action from the list.

  `get_keywords`() → list

    Returns a list of the names of all checked keywords. Gives sources first, then damages, then types.

  `next_action_id` = 0
  `set_id`(new_id: int)

    Change the ID of this action, cascading to all the component controls.

    Parameters: | new_id – Integer ID to change to.

  `update_ui`()

    Adjusts the UI for the action panel.

class `monster_ui_helpers.``KeywordControls`(container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window, parent_type: str, parent_id: int)

  Bases: `wx._core.BoxSizer`

  Specialized BoxSizer holding controls to select keywords for traits & actions.

  `__init__`(container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window, parent_type: str, parent_id: int)

    Creates a set of multi-select dropdowns to attach keywords to the given trait/action. :param container: MonsterBuilderPanel the controls will be part of. :param parent: ActionPanel or TraitPanel containing the controls. :param parent_type: “Action” or “Trait”, used to name the controls. :param parent_id: The ID of the trait or action, will become part of the name of these controls.

  `__module__` = 'monster_ui_helpers'
  `set_id`(new_id: int)

    Change the ID of these controls to match a new ID of their parent panel.

    Parameters: | new_id – Integer ID to change to.

class `monster_ui_helpers.``ResistVulnControls`(container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window, label: str, value: str = '', has_rv=False, orient: int = 4)

  Bases: `wx._core.BoxSizer`

  Specialized BoxSizer containing the controls needed to display options for a resistance/vulnerability/immunity.

  `__init__`(container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window, label: str, value: str = '', has_rv=False, orient: int = 4)

    Creates a new set of resistance/vulnerability/immunity controls in a sizer. All controls get the wx naming convention “[R/V/I Name]:[Control]”, where [R/V/I Name] is the name of the resistance/vulnerability/immunity item, and [Control] is what the control represents.

    Parameters: | container – MonsterBuilderPanel object that will hold the sizer. Used to reference callbacks. parent – The owner of the new controls. label – The label text prefacing the controls. value – The initial value in the resist/vuln text box. has_rv – If True, this can be a resistance/vulnerability. If False, it can only be an immunity. orient – The orientation of the sizer.

  `__module__` = 'monster_ui_helpers'
  `clear`()

    Selects the resist radio button if available (immune otherwise) and clears the text box.

  `get_int_value`()

    Returns the integer-cast contents of the value textbox, or 0 if its contents aren’t an integer.

  `get_rvi_type`()

    Returns “r”, “v”, or “i” based on which radio button is currently selected (resistance, vulnerability, or immunity).

  `get_value`()

    Returns the string contents of the value textbox.

  `hide`()

    Hides all child controls except the main checkbox.

  `repaint`()

    Adjusts the display of the child controls based on what’s selected.

  `show`()

    Shows all child controls.

class `monster_ui_helpers.``SenseControls`(label: str, has_value: bool, container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window)

  Bases: `wx._core.BoxSizer`

  Specialized BoxSizer holding the controls needed to display a sense with optional range.

  `__init__`(label: str, has_value: bool, container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window)

    Creates a new set of sense controls in a sizer.

    Parameters: | label – What to label the “does(n’t) have” checkbox. has_value – Whether or not to include an editable range textbox. container – MonsterBuilderPanel object that will hold the controls. parent – The owner of the new sense controls.

  `__module__` = 'monster_ui_helpers'
  `_cb_sense_clicked`(event)

    Callback handling when a sense gets (un)checked. Enables/disables the sense’s textbox if it has one.

    Parameters: | event – CommandEvent object containing details about the event.

  `update_ui`()

    Adjusts the UI for a sense based on whether it’s checked or not.

class `monster_ui_helpers.``SkillControls`(container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window, sizer: wx._core.FlexGridSizer, label: str)

  Bases: `object`

  Container class holding the controls needed to display options for a skill.

  `__dict__` = mappingproxy({'__module__': 'monster_ui_helpers', '__doc__': '\n Container class holding the controls needed to display options for a skill.\n ', '__init__': <function SkillControls.__init__>, 'cb_custom_clicked': <function SkillControls.cb_custom_clicked>, 'cb_trained_clicked': <function SkillControls.cb_trained_clicked>, 'get_value': <function SkillControls.get_value>, 'get_int_value': <function SkillControls.get_int_value>, 'is_custom': <function SkillControls.is_custom>, 'is_included': <function SkillControls.is_included>, 'is_trained': <function SkillControls.is_trained>, 'set_label_value': <function SkillControls.set_label_value>, 'recalculate': <function SkillControls.recalculate>, 'reset_value': <function SkillControls.reset_value>, 'update_ui': <function SkillControls.update_ui>, 'reset': <function SkillControls.reset>, '__dict__': <attribute '__dict__' of 'SkillControls' objects>, '__weakref__': <attribute '__weakref__' of 'SkillControls' objects>})
  `__init__`(container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window, sizer: wx._core.FlexGridSizer, label: str)

    Creates a new set of controls for a skill as a new row of a FlexGridSizer. All controls get the wx naming convention “[Skill Name]:[Control]”, where [Skill Name] is the name of the skill, and [Control] is what the control represents.

    Parameters: | container – MonsterBuilderPanel object that will hold the sizer. Used to reference callbacks. parent – The owner of the new controls. sizer – The FlexGridSizer to add a row of controls to. label – The label text prefacing the controls.

  `__module__` = 'monster_ui_helpers'
  `__weakref__`

    list of weak references to the object (if defined)

  `cb_custom_clicked`(event: wx._core.CommandEvent)

    Callback handling when the user (un)checks the option to use a custom skill value.

    Parameters: | event – CommandEvent object containing details about the event.

  `cb_trained_clicked`(event: wx._core.CommandEvent)

    Callback handling when the user (un)checks the option to consider a skill (un)trained.

    Parameters: | event – CommandEvent object containing details about the event.

  `get_int_value`() → int

    Returns the value in the skill text box as an integer.

  `get_value`() → str

    Returns the string contents of the skill value text box.

  `is_custom`() → bool

    Returns True if the user is allowed to enter a custom skill value or False if it’s clamped to the “recommended” value.

  `is_included`() → bool

    Returns True if the skill should be listed on the exported monster card, False if it should not be listed.

  `is_trained`() → bool

    Returns True if this skill is considered trained, False otherwise.

  `recalculate`()

    Recalculates the suggested skill value based on current monster stats. Also updates the skill label with the suggested value.

  `reset`()

    Clears all checkboxes and resets the current value.

  `reset_value`()

    Resets the value in the textbox to the “default” value based on the monster’s stats.

  `set_label_value`()

    Updates the suggested value for the skill to the current calculated value.

  `update_ui`()

    Adjusts the display of the controls based on what’s selected.

class `monster_ui_helpers.``SkillsPanel`(container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window, label: str = 'Skills')

  Bases: `wx._core.Panel`

  Specialized Panel containing & managing controls to display options for monster skills.

  Access controls for each skill by doing something like this.skills[“SkillName”].

  `__init__`(container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window, label: str = 'Skills')

    Creates the controls to display a list of editable skill values.

    Parameters: | container – MonsterBuilderPanel object that will hold this panel. Used to reference callbacks and other controls. parent – The owner of this panel. label – The name to show for the panel’s box.

  `__module__` = 'monster_ui_helpers'
  `_cb_perception_change`(event)

    Callback handling when the user changes the monster’s Perception value.

    Parameters: | event – CommandEvent object containing details about the event.

  `_perception_changed`()

    Handles updating helper UI fields when the monster’s Perception changes.

  `get`(skill) → str

    Retrieves the current value for the given skill.

    Parameters: | skill – String name of skill.
    Returns: | Value from the textbox of that skill.

  `get_int`(skill) → int

    Retrieves the current value for the given skill.

    Parameters: | skill – String name of skill.
    Returns: | Integer value from the textbox of that skill.

  `recalculate`()

    Recalculates all skills’ suggested values.

  `reset`()

    Resets all skills to their default states.

  `reset_values`()

    Resets the value in each skill’s text box to the current suggested value.

  `set_label_values`()

    Updates all skills’ labels to show the current suggested value for them.

  `update`()

    Updates the display of all skills, presumably after something like a monster being loaded from file.

class `monster_ui_helpers.``TraitPanel`(container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window, id: int = -1, pos: wx._core.Point = wx.Point(-1, -1), size: wx._core.Size = wx.Size(-1, -1), style: int = 524288)

  Bases: `wx._core.Panel`

  Container class for the controls needed to display an editable trait.

  `__init__`(container: monster_builder.MonsterBuilderPanel, parent: wx._core.Window, id: int = -1, pos: wx._core.Point = wx.Point(-1, -1), size: wx._core.Size = wx.Size(-1, -1), style: int = 524288)

    Creates a new set of trait controls in a panel. Panel’s wx name is always “TraitPanel:X” where X is the trait ID.

    Parameters: | container – MonsterBuilderPanel object that will hold the panel. parent – The owner of the new trait panel. id – Integer ID of the panel for wx. pos – Position of the panel. size – Size of the panel. style – Style flags for the panel.

  `__module__` = 'monster_ui_helpers'
  `_cb_change_trait_type`(event)

    Callback handling when the type of a trait changes. Disables or enables the range of the trait depending on if its a property or aura, respectively.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_delete_trait`(event)

    Callback handling removing a trait from the trait list.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_move_down`(event: wx._core.CommandEvent)

    Callback handling moving a trait down in the order.

    Parameters: | event – CommandEvent object containing details about the event.

  `_cb_move_up`(event: wx._core.CommandEvent)

    Callback handling moving a trait up in the order.

    Parameters: | event – CommandEvent object containing details about the event.

  `destroy`()

    Destroys all controls belonging to a trait, presumably as part of removing a trait from the list.

  `get_keywords`()

    Returns a list of the names of all checked keywords. Gives sources first, then damages, then types.

  `next_trait_id` = 0
  `set_id`(new_id: int)

    Change the ID of this trait, cascading to all the component controls.

    Parameters: | new_id – Integer ID to change to.

  `update_ui`()

    Adjusts the UI for a trait panel based on what kind of trait parameters are selected.