On this page:
7.1 aoe
7.2 aoe-images
hex-size
r
S
X
O
M
border-size
spec-sym?
spec?
spec->shape
syntaxes-can-be-spec?
syntaxes->spec
string->spec
7.3 defns
no-duplicates?
unique/  c
unique-with/  c
vector-update!
7.3.1 Level Info
level-info
number-of-levels
max-level
level/  c
max-players
num-players/  c
get-level-info
inspiration-reward
7.3.2 Players
player
make-player
player-update-name
player-act-on-hp
player-act-on-max-hp
player-act-on-xp
player-add-condition
player-remove-condition
player-condition-handler
player-afflicted-by?
player-dead?
player-at-max-health?
player-set-initiative
player-clear-initiative
player-add-loot
player->hp-text
player-conditions*
summon
summon-update-name
summon-act-on-hp
summon-act-on-max-hp
summon-add-condition
summon-remove-condition
summon-condition-handler
summon-afflicted-by?
summon-dead?
summon-at-max-health?
summon->hp-text
summon-conditions*
player-summon
update-player-summon
player-kill-summon
7.3.3 Loot Deck
material-kind?
lumber
metal
hide
material-kinds
herb-kind?
arrowvine
axenut
corpsecap
flamefruit
rockroot
snowthistle
herb-kinds
random-item?
random-item
money
material
herb
loot-card?
format-loot-card
max-money-cards
max-material-cards
max-herb-cards
max-random-item-cards
money-deck
material-decks
herb-decks
7.3.4 Scenario
element?
fire
ice
air
earth
light
dark
monster-modifier?
zero
minus1
plus1
minus2
plus2
null
crit
curse
bless
condition?
regenerate
ward
invisible
strengthen
wound
brittle
bane
poison
immobilize
disarm
impair
stun
muddle
discriminator:  condition
selector:  condition
initiative?
conditions
monster-modifier-deck
monster-curse-deck
bless-deck
shuffle-modifier-deck?
better-modifier
worse-modifier
7.3.5 Monster Cards
monster-stats
monster-info
monster-ability
monster-number/  c
monster
monster-group
monster-stats-max-hp*
monster-stats-attack*
monster-ability-name->text
monster-ability-initiative->text
monster-ability-ability->text
monster-ability-ability->extras
make-monster
make-monster-group
get-monster-stats
monster-at-max-health?
monster-dead?
monster-update-condition
monster-update-hp
monster-group-update-num
monster-group-remove
monster-group-add
monster-group-first-monster
monster->hp-text
swap-monster-group-elites
swap-monster-elite
7.4 elements
size
element-pics
elements
7.5 enum-helpers
make-property-maker-that-displays-as-constant-names
compose-property-makers
define-serializable-enum-type
7.6 manager
7.6.1 manager/  state
creature
monster-group*
state
make-state
state-@env
serialize-state
deserialize-state
copy-state
make-undo
undo!
undoable?
make-player-creature
update-players
update-monster-groups
update-all-players
update-all-monster-groups
update-player-name
update-player-max-hp
creature-initiative
add-or-remove-monster-group
draw-new-card-mid-round-if-needed
initiative-public?
7.6.2 manager/  ability-decks
ability-decks
ability-decks-draw-next
ability-decks-discard-and-maybe-shuffle
update-ability-decks
move-top-draw-to-bottom
7.6.3 manager/  modifier-decks
reshuffle-modifier-deck
discard
draw-modifier
draw-modifier*
do-curse-monster
do-bless-monster
do-bless-player
do-unbless-player
7.6.4 manager/  db
init-dbs
init-dbs-and-foes
7.6.5 manager/  loot
update-loot-deck-and-num-loot-cards
update-stickers-per-deck
build-loot-deck
build-loot-deck!
give-player-loot
place-loot-on-bottom
7.7 gui
7.7.1 gui/  common-menu
about-menu-item
issue-menu-item
feature-menu-item
contribute-menu-item
send-feedback-menu-item
how-to-play-menu-item
launch-server-menu-item
do-about
7.7.2 gui/  counter
counter
7.7.3 gui/  elements
element-state/  c
elements-cycler
make-states
infuse-all
consume-all
wane-element
transition-element-state
7.7.4 gui/  font
copy-font
big-control-font
7.7.5 gui/  formula-editor
formula-editor
formula-menu-item
7.7.6 gui/  helpers
translate-to-top-coords
7.7.7 gui/  level-info
level-stats
level-table
inspiration-table
7.7.8 gui/  loot
loot-picker
loot-button
loot-preview
7.7.9 gui/  manager
manager
7.7.10 gui/  markdown
markdown-text
7.7.11 gui/  mixins
make-closing-proc-mixin
make-on-close-mixin
define-close!
7.7.12 gui/  monsters
single-monster-event/  c
add-monster-event/  c
remove-monster-event/  c
single-monster-picker
simple-monster-group-view
multi-monster-picker
monster-group-view
db-view
add-monster-group
7.7.13 gui/  player-info
player-input-views
player-view
7.7.14 gui/  render
current-renderer
render/  eventspace
with-closing-custodian/  eventspace
closing-custodian
closing-eventspace
close-custodian-mixin
7.7.15 gui/  rewards
player-rewards-view
7.7.16 gui/  server
launch-server
7.7.17 gui/  stacked-tables
stacked-tables
column
7.7.18 gui/  start
start-view
7.7.19 gui/  static-table
static-table
7.8 bestiary
7.9 monster-db
info-db/  c
ability-db/  c
datums->dbs
get-dbs
default-monster-db
7.10 parsers
7.10.1 parsers/  foes
parse-foes
foes/  pc
foe/  pc
spec/  pc
numbering/  pc
monster-type/  pc
foes/  p
foe/  p
7.10.2 parsers/  formula
env/  c
expr/  pc
expr/  p
parse-expr
7.10.3 parsers/  monster
parse-bestiary
bestiary/  c
monster/  p
ability-deck/  p
import-monsters/  p
bestiary/  p
bestiary-dupes
7.11 observable-operator
<@
@>
λ<@
@!
@~>
<~@
7.12 pp
7.12.1 pp/  bestiary
pretty-bestiary
7.13 qi
7.13.1 qi/  list2hash
list~>hash
list->hash
7.14 server
launch-server
7.15 syntax
7.15.1 syntax/  module-reader
#%module-begin
7.15.2 syntax/  monsters
make-dbs
syntaxes->bestiary-parts
imports->dbs
check-monsters-have-abilities
check-monsters-have-abilities-message
check-foes-have-monsters
check-foes-have-monsters-message
8.10

7 Developer Reference

None of these APIs should be considered stable enough for use in projects other than Frosthaven Manager. They should be considered stable enough for use in Frosthaven Manager. Changes to an internally-used API should be made with care and compelling reason.

7.1 aoe

This module implements the Area-of-Effect (AoE) language. See Programming a Scenario and frosthaven-manager/aoe for more information.

7.2 aoe-images

 (require frosthaven-manager/aoe-images)
  package: frosthaven-manager

This module provides procedures for constructing area-of-effect diagrams.

parameter

(hex-size)  natural-number/c

(hex-size size)  void?
  size : natural-number/c
 = 30
The size of the hexes built from this module.

procedure

(r)  (and/c positive? number?)

Returns the amount by which odd rows need shifted to align with even rows in a hex-grid (based on hex-size).

procedure

(S)  pict?

procedure

(X)  pict?

procedure

(O)  pict?

procedure

(M)  pict?

Hexes for an area-of-effect diagram: respectively, spacers, attacks, allies, and the initiating figure.

procedure

(border-size max-row max-col)  (and/c positive? number?)

  max-row : natural-number/c
  max-col : natural-number/c
Returns the side-length of a square rectangle which would encompass an area-of-effect diagram of max-row rows and max-col columns in a hex-grid, if the diagram were centered and superimposed on the rectangle à la cc-superimpose.

value

spec-sym? : flat-contract? = (or/c 's 'x 'o 'm 'g)

value

spec? : flat-contract?

 = 
(listof (list/c exact-positive-integer?
                boolean?
                (listof (list/c spec-sym? natural-number/c))))

procedure

(spec->shape s)  pict?

  s : spec?
Convert an AoE spec to a shape. The spec contains a list of rows; each row contains a line number, a flag indicating this line should be offset relative to the lines above and below it (which are not necessarily in the spec), and a list of column specifiers, pairing symbols with columns in sorted order.

The symbols represent the corresponding shapes, with 'g a ghost hex.

Convert a list of syntax objects to a spec?.

procedure

(string->spec s)  spec?

  s : string?
Uses syntaxes->spec on syntax read from s by read-syntax to produce an AoE spec. Fails if the resulting syntaxes cannot be a spec, as defined by syntaxes-can-be-spec?.

7.3 defns

 (require frosthaven-manager/defns)
  package: frosthaven-manager

In this section, subsections represented subsections of the module, indicated by comments.

procedure

(no-duplicates? xs)  boolean?

  xs : (listof any/c)

procedure

(unique/c c)  contract?

  c : flat-contract?

procedure

(unique-with/c key c)  contract?

  key : (-> any/c any/c)
  c : flat-contract?
Utility procedures and contracts for verifying uniqueness. The predicate no-duplicates? is true if-and-only-if the input xs has no duplicates. The contract unique/c requires that a value be a (listof c) and have no duplicates. The contract unique-with/c requires of a value v that the result of (map key v) is a (unique/c c).

procedure

(vector-update! v pos f)  void?

  v : (and/c vector? (not/c immutable?))
  pos : natural-number/c
  f : (-> any/c any/c)
Like list-update for mutable vectors. Equivalent to setting vpos to f of vpos.

7.3.1 Level Info

struct

(struct level-info (monster-level
    gold
    trap-damage
    hazardous-terrain
    exp)
    #:transparent)
  monster-level : natural-number/c
  gold : natural-number/c
  trap-damage : natural-number/c
  hazardous-terrain : natural-number/c
  exp : natural-number/c
An instance of level-info exposes characteristics of the level, such as the monster level, value of gold, damage caused by traps and hazardous terrain, and end-of-scenario experience.

A constant representing the number of possible levels, as opposed to what the levels are.

A constant representing the maximum level. The minimum level is 0.

A contract recognizing valid level numbers, used for both the scenario level and monster levels.

A constant representing the maximum number of players.

A contract recognizing a valid number of players.

procedure

(get-level-info level)  level-info?

  level : level/c
Returns the level-info for the given level number.

procedure

(inspiration-reward num-players)  natural-number/c

  num-players : num-players/c
Returns the amount of inspiration rewarded for completing a scenario based on how many players participated in the scenario.

7.3.2 Players

struct

(struct player (name
    max-hp
    current-hp
    xp
    conditions
    initiative
    loot
    summons)
    #:transparent)
  name : string?
  max-hp : positive-integer?
  current-hp : natural-number/c
  xp : natural-number/c
  conditions : (listof condition?)
  initiative : initiative?
  loot : (listof loot-card?)
  summons : (listof summon?)
A player captures everything about a player that Frosthaven Manager needs.

You will not usually need the player constructor: use the smart constructor make-player instead.

Serializable.

procedure

(make-player name max-hp)  player?

  name : string?
  max-hp : positive-integer?
Creates a player with name and max-hp.

procedure

((player-update-name new-name) p)  player?

  new-name : string?
  p : player?
Transforms p to have player-name equal to new-name.

procedure

((player-act-on-hp f) p)  player?

  f : (-> natural-number/c number?)
  p : player?
Transforms (player-current-hp p) by f. If the result is not positive? the update is ignored.

procedure

((player-act-on-max-hp f) p)  player?

  f : (-> natural-number/c number?)
  p : player?
Similarly to player-act-on-hp, transforms (player-max-hp p) by f. If the result is not positive? the update is ignored.

procedure

((player-act-on-xp f) p)  player?

  f : (-> natural-number/c number?)
  p : player?
Similarly to player-act-on-hp, transforms (player-xp p) by f. If the result is not natural? the update is ignored.

procedure

((player-add-condition c) p)  player?

  c : condition?
  p : player?

procedure

((player-remove-condition c) p)  player?

  c : condition?
  p : player?
Transforms (player-conditions p) by adding or removing condition c.

procedure

((player-condition-handler c?) p)  player?

  c? : (list/c condition? boolean?)
  p : player?
Dispatches to player-add-condition or player-remove-condition based on (second c?): #true means player-add-condition. The condition to be added or removed is (first c?).

procedure

((player-afflicted-by? c) p)  boolean?

  c : condition?
  p : player?
True if-and-only-if (player-conditions c) includes c.

procedure

(player-dead? p)  boolean?

  p : player?
True if-and-only-if (player-current-hp p) is zero?.

In practice, player HP does not currently fall below 1. This may be a bug.

procedure

(player-at-max-health? p)  boolean?

  p : player?
True if-and-only-if (player-current-hp p) is (player-max-hp p).

procedure

(player-set-initiative p i)  player?

  p : player?
  i : initiative?

procedure

(player-clear-initiative p)  player?

  p : player?
Transforms (player-initiative p) by setting it to i or clearing it to 0.

procedure

((player-add-loot card) p)  player?

  card : loot-card?
  p : player?
Transforms (player-loot p) by adding card.

procedure

(player->hp-text p)  string?

  p : player?
Formats the string "HP: current/max" for the player p.

procedure

(player-conditions* p)  (listof condition?)

  p : player?
Same as (player-conditions p) but sorted.

struct

(struct summon (name max-hp current-hp conditions)
    #:transparent)
  name : string?
  max-hp : positive-integer?
  current-hp : natural-number/c
  conditions : (listof condition?)
A player summon. Serializable.

procedure

((summon-update-name new-name) s)  summon?

  new-name : string?
  s : summon?
Transforms s to have summon-name equal to new-name.

procedure

((summon-act-on-hp f) s)  summon?

  f : (-> natural-number/c number?)
  s : summon?
Transforms (summon-current-hp s) by f. If the result is not positive? the update is ignored.

procedure

((summon-act-on-max-hp f) s)  summon?

  f : (-> natural-number/c number?)
  s : summon?
Similarly to summon-act-on-hp, transforms (summon-max-hp s) by f. If the result is not positive? the update is ignored.

procedure

((summon-add-condition c) s)  summon?

  c : condition?
  s : summon?

procedure

((summon-remove-condition c) s)  summon?

  c : condition?
  s : summon?
Transforms (summon-conditions s) by adding or removing condition c.

procedure

((summon-condition-handler c?) s)  summon?

  c? : (list/c condition? boolean?)
  s : summon?
Dispatches to summon-add-condition or summon-remove-condition based on (second c?): #true means summon-add-condition. The condition to be added or removed is (first c?).

procedure

((summon-afflicted-by? c) s)  boolean?

  c : condition?
  s : summon?
True if-and-only-if (summon-conditions c) includes c.

procedure

(summon-dead? s)  boolean?

  s : summon?
True if-and-only-if (summon-current-hp s) is zero?.

In practice, summon HP does not currently fall below 1. This may be a bug.

procedure

(summon-at-max-health? s)  boolean?

  s : summon?
True if-and-only-if (summon-current-hp s) is (summon-max-hp s).

procedure

(summon->hp-text s)  string?

  s : summon?
Formats the string "HP: current/max" for the summon s.

procedure

(summon-conditions* s)  (listof condition?)

  s : summon?
Same as (summon-conditions s) but sorted.

procedure

(player-summon p name max-hp)  player?

  p : player?
  name : string?
  max-hp : positive-integer?
Adds a summon to p.

procedure

((update-player-summon i f) p)  player?

  i : natural-number/c
  f : (-> summon? summon?)
  p : player?
Update the ith summon via f.

procedure

((player-kill-summon i) p)  player?

  i : natural-number/c
  p : player?
Kill the ith summon.

7.3.3 Loot Deck

Represents materials for loot cards.

Serializable.

Represents herbs for loot cards.

Serializable.

Represents the random-item loot card.

Serializable.

struct

(struct money (amount)
    #:transparent)
  amount : natural-number/c
Represents a loot card worth 1 to 3 gold, but may have +1 stickers.

Serializable.

struct

(struct material (name amount)
    #:transparent)
  name : material-kind?
  amount : (apply list/c (build-list (sub1 max-players) (const natural-number/c)))
Represents a loot card for a material; the amount varies by number of players. May have +1 stickers.

Serializable.

struct

(struct herb (name amount)
    #:transparent)
  name : herb-kind?
  amount : natural-number/c
Represents a loot card worth 1 name herb, but may have +1 stickers.

Serializable.

This predicate recognizes valid loot cards. It is also a valid contract?.

procedure

((format-loot-card n) card)  string?

  n : num-players/c
  card : loot-card?
Formats a loot card for display.

Constants designating the maximum number of certain kinds of cards.

Decks of loot cards from which you draw to make the loot deck.

Current values are the standard loot cards. Modifications via stickers are not yet supported.

7.3.4 Scenario

value

element? : predicate/c

value

fire : element?

value

ice : element?

value

air : element?

value

earth : element?

value

light : element?

value

dark : element?

The elements.

Serializable.

Monster modifier cards.

Serializable.

The condition? predicate recognizes all valid conditions, which are listed here.

Serializable.

procedure

(discriminator:condition c)  integer?

  c : condition?

procedure

(selector:condition i)  condition?

  i : integer?
Enum discriminator and enum selector for condition? values. Both contract error when the argument is outside the appropriate domain.

procedure

(initiative? v)  boolean?

  v : any/c
A predicate recognizing valid initiative values.

All the conditions together.

A full deck of 20 monster modifier cards.

Full decks of 10 monster curse and bless cards.

procedure

(shuffle-modifier-deck? deck)  boolean?

  deck : (listof monster-modifier?)
True if-and-only-if deck contains a null or crit.

procedure

(better-modifier a b)  monster-modifier?

  a : monster-modifier?
  b : monster-modifier?

procedure

(worse-modifier a b)  monster-modifier?

  a : monster-modifier?
  b : monster-modifier?
Returns the better or worse of the two modifier cards.

7.3.5 Monster Cards

struct

(struct monster-stats (max-hp
    move
    attack
    bonuses
    effects
    immunities)
    #:prefab)
  max-hp : (or/c positive-integer? string?)
  move : natural-number/c
  attack : (or/c natural-number/c string?)
  bonuses : (listof string?)
  effects : (listof string?)
  immunities : (listof string?)
The monster statistic representation, usually used with pre-fabs.

struct

(struct monster-info (set-name name normal-stats elite-stats)
    #:prefab)
  set-name : string?
  name : string?
  normal-stats : (apply list/c (build-list number-of-levels (const monster-stats?)))
  elite-stats : (apply list/c (build-list number-of-levels (const monster-stats?)))
The monster information representation, often for reading pre-fab structs.

struct

(struct monster-ability (set-name
    name
    initiative
    abilities
    shuffle?
    location)
    #:prefab)
  set-name : string?
  name : string?
  initiative : initiative?
  abilities : (listof string?)
  shuffle? : boolean?
  location : (or/c #f path?)
The monster ability representation, often for reading pre-fab structs.

Note that pre-fab syntax does not permit path? objects.

A contract that recognizes valid monster numbers.

struct

(struct monster (number elite? current-hp conditions)
    #:transparent)
  number : monster-number/c
  elite? : boolean?
  current-hp : natural-number/c
  conditions : (listof condition?)
A monster captures the individual status of a monster, but not its game statistics. Those are listed in its parent monster-group.

Prefer the smart constructor make-monster.

Serializable.

struct

(struct monster-group (set-name
    name
    level
    normal-stats
    elite-stats
    monsters)
    #:transparent)
  set-name : string?
  name : string?
  level : level/c
  normal-stats : monster-stats?
  elite-stats : monster-stats?
  monsters : (listof monster?)
A monster-group describes a group of monsters and their stats.

Prefer the smart constructor make-monster-group and the update functions, which maintain an invariant of monsters sorted by eliteness and number.

Serializable.

procedure

(monster-stats-max-hp* stats env)  positive-integer?

  stats : monster-stats?
  env : env/c
Calculates the maximum HP value of stats, which may be a formula.

procedure

(monster-stats-attack* stats env)  positive-integer?

  stats : monster-stats?
  env : env/c
Calculates the attack value of stats, which may be a formula.

procedure

(monster-ability-name->text ability)  string?

  ability : (or/c #f monster-ability?)
Returns a string suitable for display to indicate the name of a possibly-absent monster ability.

procedure

(monster-ability-initiative->text ability)  string?

  ability : (or/c #f monster-ability?)
Returns a string suitable for display to indicate the initiative of a possibly-absent monster ability.

procedure

((monster-ability-ability->text ability)    
  mg    
  env)  string?
  ability : string?
  mg : monster-group?
  env : env/c
Formats a single ability on a monster ability card, as from monster-ability-abilities, by replacing keywords like “Attack +1” with calculated text and values.

procedure

(monster-ability-ability->extras ability-card 
  ability-text) 
  (listof (or/c (list/c 'aoe-pict pict?)))
  ability-card : (or/c #f monster-ability?)
  ability-text : string?
Returns a list of “extras” for rendering a specific ability-text from a monster-ability. The meaning of each extra spec is as follows:

procedure

(make-monster info level number elite? env)  monster?

  info : monster-info?
  level : level/c
  number : monster-number/c
  elite? : boolean?
  env : env/c
Populates the resulting monster based on the statistics from info and elite?. Formulas are calculated using env.

procedure

(make-monster-group info    
  level    
  num+elite?s    
  env)  monster-group?
  info : monster-info?
  level : level/c
  num+elite?s : 
(and/c (listof (cons/c monster-number/c boolean?))
       (unique-with/c car any/c))
  env : env/c
Creates a monter-group at level level based on the statistics from info.

The num+elite?s parameter provides a mapping from (unique) monster numbers to their elite status. Only monster numbers in the mapping are added to the monster-group.

Formulas are calculated using env.

procedure

(get-monster-stats mg m)  monster-stats?

  mg : monster-group?
  m : monster?
Retrieves the corresponding monster-group-normal-stats or monster-group-elite-stats based on (monster-elite? m). The monster m is assumed to be part of the group mg.

procedure

(monster-at-max-health? m s env)  boolean?

  m : monster?
  s : monster-stats?
  env : env/c
True if-and-only-if (monster-current-hp m) is (monster-stats-max-hp* s env). The stats s are assumed to correlate to the monster m.

procedure

(monster-dead? m)  boolean?

  m : monster?
True if-and-only-if (monster-current-hp m) is 0.

procedure

((monster-update-condition c on?) m)  monster?

  c : condition?
  on? : boolean?
  m : monster?
Transforms (monster-conditions m) by adding the condition c if on? or removing it otherwise.

procedure

((monster-update-hp f) m)  monster?

  f : (-> number? number?)
  m : monster?
Transforms (monster-current-hp m) by f. If the result is not positive? the update is ignored.

procedure

((monster-group-update-num n f) mg)  monster-group?

  n : monster-number/c
  f : (-> monster? monster?)
  mg : monster-group?
Transforms (monster-group-monsters mg) by transforming the monster numbered n by f.

procedure

((monster-group-remove n) mg)  monster-group?

  n : monster-number/c
  mg : monster-group?
Removes the monster numbered n from (monster-group-monsters mg).

procedure

((monster-group-add n elite? env) mg)  monster-group?

  n : monster-number/c
  elite? : boolean?
  env : env/c
  mg : monster-group?
Adds the monster numbered n to (monster-group-monsters mg). It is elite if-and-only-if elite? is #true.

procedure

(monster-group-first-monster mg)  (or/c #f monster-number/c)

  mg : monster-group?
The number of the first monster in the monster group mg, or #false if there are no such monsters.

procedure

(monster->hp-text m ms env)  string?

  m : monster?
  ms : monster-stats
  env : env/c
Formats the string "HP: current/max" for the monster m.

The same monster group, but with all elite monsters normal and vice-versa.

procedure

(swap-monster-elite m)  monster?

  m : monster?
The same monster, but normal instead of elite and vice-versa.

7.4 elements

 (require frosthaven-manager/elements)
  package: frosthaven-manager

The size of the element pictures.

struct

(struct element-pics (name infused waning unfused)
    #:transparent)
  name : string?
  infused : pict?
  waning : pict?
  unfused : pict?
A container for a named set of element pictures.

procedure

(elements)  (listof element-pics?)

Returns all of the elements bundled together. This module also provides bindings from the names of the elemnts to procedures returning element-pics values, but they are not documented here. See Elements Tracker for the various element names and pictures.

7.5 enum-helpers

 (require frosthaven-manager/enum-helpers)
  package: frosthaven-manager

This helper adjusts enum types so that the display string is the same as the constant name as in define-enum-type.

Creates a property maker suitable for define-enum-type that combines each p.

syntax

(define-serializable-enum-type id (constant-id ...) enum-option ...)

 
enum-option = #:omit-root-binding
  | #:descriptor-name descriptor-id
  | #:predicate-name predicate-id
  | #:discriminator-name discriminator-id
  | #:selector-name selector-id
  | #:property-maker prop-maker-expr
  | #:inspector inspector-expr
 
  prop-maker-expr : 
(-> uninitialized-enum-descriptor?
    (listof (cons/c struct-type-property? any/c)))
  inspector-expr : inspector?
Exactly like define-enum-type, but with the addition of prop:serializable via a deserialize-info named deserialize-info:id.

7.6 manager

 (require frosthaven-manager/manager)
  package: frosthaven-manager

This module reprovides all the bindings from frosthaven-manager/manager/state, frosthaven-manager/manager/ability-decks, frosthaven-manager/manager/modifier-decks, frosthaven-manager/manager/db, and frosthaven-manager/manager/loot.

7.6.1 manager/state

 (require frosthaven-manager/manager/state)
  package: frosthaven-manager

This module provides facilities for manipulating manager-level state.

struct

(struct creature (id v)
    #:transparent)
  id : any/c
  v : (or/c player? monster-group*?)
A creature is displayed in the central area of the Frosthaven Manager GUI, as described in Creature List. Therefore a creature-v can be either a player or a monster-group*.

A creature is identified by its unique creature-id.

Serializable.

struct

(struct monster-group* (active mg)
    #:transparent)
  active : (or/c #f monster-number/c)
  mg : monster-group?
A monster-group* wraps a monster-group with a possibly active monster-number/c, which identifies the monster currently displayed in Monster Group Controls.

Serializable.

struct

(struct state (@mode
    @level
    @num-players
    @creatures
    @cards-per-deck
    @loot-deck
    @num-loot-cards
    @elements
    @in-draw?
    @round
    @monster-modifier-deck
    @monster-discard
    @player-blesses
    @curses
    @blesses
    @modifier
    @monster-prev-discard
    @info-db
    @ability-db
    @ability-decks
    @stickers-per-loot-deck))
  @mode : symbol?
  @level : (obs/c level/c)
  @num-players : (obs/c num-players/c)
  @creatures : (obs/c (listof creature?))
  @cards-per-deck : (obs/c (hash/c (listof loot-card?) natural-number/c))
  @loot-deck : (obs/c (listof loot-card?))
  @num-loot-cards : (obs/c natural-number/c)
  @elements : (listof (obs/c element-state/c))
  @in-draw? : (obs/c boolean?)
  @round : (obs/c natural-number/c)
  @monster-modifier-deck : (obs/c (listof monster-modifier?))
  @monster-discard : (obs/c (listof monster-modifier?))
  @player-blesses : (obs/c (listof monster-modifier?))
  @curses : (obs/c (listof monster-modifier?))
  @blesses : (obs/c (listof monster-modifier?))
  @modifier : (obs/c (or/c #f monster-modifier?))
  @monster-prev-discard : (obs/c (or/c #f monster-modifier?))
  @info-db : (obs/c info-db/c)
  @ability-db : (obs/c ability-db/c)
  @ability-decks : (obs/c (hash/c string? ability-decks?))
  @stickers-per-loot-deck : (obs/c (hash/c (listof loot-card?) natural-number/c))
All of the "global" manager state.

procedure

(make-state [@mode    
  @level    
  @num-players    
  @creatures    
  @cards-per-deck    
  @loot-deck    
  @num-loot-cards    
  @elements    
  @in-draw?    
  @round    
  @monster-modifier-deck    
  @monster-discard    
  @player-blesses    
  @curses    
  @blesses    
  @modifier    
  @monster-prev-discard    
  @info-db    
  @ability-db    
  @ability-decks    
  @stickers-per-loot-deck])  state?
  @mode : (maybe-obs/c symbol?) = (@ 'start)
  @level : (maybe-obs/c level/c) = (@ 0)
  @num-players : (maybe-obs/c num-players/c) = (@ 2)
  @creatures : (maybe-obs/c (listof creature?)) = (@ empty)
  @cards-per-deck : (maybe-obs/c (hash/c (listof loot-card?) natural-number/c))
   = (@ (hash))
  @loot-deck : (maybe-obs/c (listof loot-card?)) = (@ empty)
  @num-loot-cards : (maybe-obs/c natural-number/c) = (@ 0)
  @elements : (listof (maybe-obs/c element-state/c))
   = (make-states '(fire ice air earth light dark))
  @in-draw? : (maybe-obs/c boolean?) = (@ #f)
  @round : (maybe-obs/c natural-number/c) = (@ 1)
  @monster-modifier-deck : (maybe-obs/c (listof monster-modifier?))
   = (@ (shuffle monster-modifier-deck))
  @monster-discard : (maybe-obs/c (listof monster-modifier?))
   = (@ empty)
  @player-blesses : (maybe-obs/c (listof monster-modifier?))
   = (@ empty)
  @curses : (maybe-obs/c (listof monster-modifier?))
   = (@ monster-curse-deck)
  @blesses : (maybe-obs/c (listof monster-modifier?))
   = (@ bless-deck)
  @modifier : (maybe-obs/c (or/c #f monster-modifier?)) = (@ #f)
  @monster-prev-discard : (maybe-obs/c (or/c #f monster-modifier?))
   = (@ #f)
  @info-db : (maybe-obs/c info-db/c) = (@ (hash))
  @ability-db : (maybe-obs/c ability-db/c) = (@ (hash))
  @ability-decks : (maybe-obs/c (hash/c string? ability-decks?))
   = (@ (hash))
  @stickers-per-loot-deck : (maybe-obs/c (hash/c (listof loot-card?) natural-number/c))
   = (@ (hash))
Create an initial state.

procedure

(state-@env s)  (obs/c env/c)

  s : state?
Derives a formula environment observable from pieces of s.

procedure

(serialize-state s out)  any

  s : state?
  out : output-port?

procedure

(deserialize-state in)  state?

  in : input-port?
Procedures to serialize and deserialize a state? value.

procedure

(copy-state from to)  any

  from : state?
  to : state?
Copies the state from from to to by updating the internal observables. This makes it possible to update an existing state? with the values from a deserialized state?.

procedure

(make-undo s)  obs?

  s : state?

procedure

(undo! s @undo)  any

  s : state?
  @undo : obs?

procedure

(undoable? undo)  any/c

  undo : list?
Undo procedures. To create an observable undo state that tracks s, use (make-undo s). Then, when undoable? is true of the observable undo state, use (undo! s @undo) to actually trigger change.

Warning: sometimes multiple undos are necessary to be coherent. Not all state changes are recorded.

procedure

(make-player-creature i)  creature?

  i : any/c
Make a creature with creature-id i and creature-v a player?.

procedure

(update-players creatures k f)  (listof creature?)

  creatures : (listof creature?)
  k : any/c
  f : (-> player? player?)

procedure

(update-monster-groups creatures k f [fn])  (listof creature?)

  creatures : (listof creature?)
  k : any/c
  f : (-> monster-group? monster-group?)
  fn : (-> (or/c #f monster-number/c) monster-group? (or/c #f monster-number/c))
   = (flow 1>)
Updates player or monster-group k in creatures via f. When updating a monster-group, fn can update the monster-group*-active number.

procedure

(update-all-players creatures f)  (listof creature?)

  creatures : (listof creature?)
  f : (-> player? player?)

procedure

(update-all-monster-groups creatures f)  (listof creature?)

  creatures : (listof creature?)
  f : (-> monster-group? monster-group?)
Updates all players or monster-groups in creatures via f.

procedure

((update-player-name s) k name)  any

  s : state?
  k : any/c
  name : string?

procedure

((update-player-max-hp s) k f)  any

  s : state?
  k : any/c
  f : (-> natural-number/c natural-number/c)
Updates player ks name to name or max health via f.

procedure

(creature-initiative ads)

  (-> creature? (or/c +inf.0 initiative?))
  ads : (hash/c string? ability-decks?)
Calculates a creature’s initiative.

procedure

(add-or-remove-monster-group s)

  
(-> (or/c add-monster-event/c
          remove-monster-event/c)
    any)
  s : state?
Adds or removes a monster group based on the received event.

procedure

(draw-new-card-mid-round-if-needed s set)  any

  s : state?
  set : string?
If it is mid-round per state-@in-draw? and the ability deck for set does not have a card per ability-decks-current, draw a card for set.

It is the caller’s responsibility to verify that a monster has been added and needs to potentially trigger a new card.

procedure

(initiative-public? in-draw?)  boolean?

  in-draw? : boolean?
True if, according to in-draw?, initiative values should be publicly revealed.

7.6.2 manager/ability-decks

 (require frosthaven-manager/manager/ability-decks)
  package: frosthaven-manager

struct

(struct ability-decks (current draw discard)
    #:transparent)
  current : (or/c #f monster-ability?)
  draw : (listof monster-ability?)
  discard : (listof monster-ability?)
Monster ability deck, with currently active card, draw pile, and discard pile.

Serializable.

Draws a card from the ability deck.

Discards the active card and shuffles the ability deck if necessary.

Updates each deck via f.

Moves the top card of the draw pile to its bottom.

7.6.3 manager/modifier-decks

 (require frosthaven-manager/manager/modifier-decks)
  package: frosthaven-manager

This module provides facilities for manipulating the modifier deck.

procedure

(reshuffle-modifier-deck s)  any

  s : state?
Reshuffle the monster modifier deck.

procedure

(discard s card)  any

  s : state?
  card : monster-modifier?
Discard a card to the appropriate pile.

procedure

(draw-modifier s)  (-> any)

  s : state?
Draws and discards a single modifier card.

procedure

(draw-modifier* s keep)  (-> any)

  s : state?
  keep : (-> monster-modifier? monster-modifier? monster-modifier?)
Draws two modifier cards and discards them with the kept card on top.

procedure

(do-curse-monster s)  (-> any)

  s : state?

procedure

(do-bless-monster s)  (-> any)

  s : state?

procedure

(do-bless-player s)  (-> any)

  s : state?

procedure

(do-unbless-player s)  (-> any)

  s : state?
Add a curse or bless to the appropriate deck.

7.6.4 manager/db

 (require frosthaven-manager/manager/db)
  package: frosthaven-manager

This module provides facilities for manipulating the active monster databases.

procedure

(init-dbs db s)  any

  db : path-string?
  s : state?
Initialize the active monster databases.

procedure

(init-dbs-and-foes db s)  any

  db : path-string?
  s : state?
Initialize the active monster databases, exactly as init-dbs. Additionally, initialize the foes from db if it provides a foes specification. This manipulates (state-@creatures s); see also add-or-remove-monster-group and frosthaven-manager/foes.

7.6.5 manager/loot

 (require frosthaven-manager/manager/loot)
  package: frosthaven-manager

This module provides facilities for manipulating the loot deck.

procedure

(update-loot-deck-and-num-loot-cards s)

  (-> (list/c (or/c 'add 'remove) (listof loot-card?)) any)
  s : state?
Update the loot deck based on the loot-picker event.

procedure

((update-stickers-per-deck s) evt)  any

  s : state?
  evt : (list/c (or/c 'add 'remove) (listof loot-card?))
Updates (state-@stickers-per-loot-deck s) based on the event evt as described in loot-picker by updating the count of stickers per deck.

procedure

(build-loot-deck cards-per-loot-deck    
  stickers-per-loot-deck)  (listof loot-card?)
  cards-per-loot-deck : (hash/c (listof loot-card?) natural-number/c)
  stickers-per-loot-deck : (hash/c (listof loot-card?) natural-number/c)
Converts a count of cards per deck into an shuffled deck of loot cards. This can be considered the interpreter for a language whose values are like those produced by loot-picker and update-stickers-per-deck; namely, mappings from decks to number of cards.

procedure

(build-loot-deck! s)  any

  s : state?
Updates s by applying build-loot-deck.

procedure

((give-player-loot s) k)  any

  s : state?
  k : any/c
Give player k the top loot card.

procedure

(place-loot-on-bottom s)  any

  s : state?
Rotate the top loot card to the bottom of the deck.

7.7 gui

The following sections describe modules under frosthaven-manager/gui.

7.7.1 gui/common-menu

 (require frosthaven-manager/gui/common-menu)
  package: frosthaven-manager

Menu items for Frosthaven Manager.

procedure

(do-about)  renderer?

Renders an About window, as in about-menu-item. Useful with application-about-handler.

7.7.2 gui/counter

 (require frosthaven-manager/gui/counter)
  package: frosthaven-manager

procedure

(counter @label up down)  (is-a?/c view<%>)

  @label : (maybe-obs/c string?)
  up : (-> any)
  down : (-> any)
A GUI component for a counter with a label and up and down callbacks.

7.7.3 gui/elements

 (require frosthaven-manager/gui/elements)
  package: frosthaven-manager

value

element-state/c : contract? = (or/c 'unfused 'infused 'waning)

A contract recognizing valid element states.

procedure

(elements-cycler @states es [panel])  (is-a?/c view<%>)

  @states : (listof (obs/c element-state/c))
  es : (listof element-pics?)
  panel : (unconstrained-domain-> (is-a?/c view<%>)) = hpanel
Returns a GUI view displaying the element-pics. Each element of es is controlled by the corresponding element of @states.

procedure

(make-states es)  (listof (obs/c element-state/c))

  es : (listof any/c)
Builds an equally-sized list of element states to control es in elements-cycler.

procedure

(infuse-all es)  any

  es : (listof (obs/c element-state/c))

procedure

(consume-all es)  any

  es : (listof (obs/c element-state/c))
Set all element states es to 'infused or 'unfused, respectively.

procedure

(wane-element state)  element-state/c

  state : element-state/c
Returns the new element state after waning for one cycle.

procedure

(transition-element-state state)  element-state/c

  state : element-state/c
Returns the new element state after cycling once, with unfused wrapping around to infused.

7.7.4 gui/font

 (require frosthaven-manager/gui/font)
  package: frosthaven-manager

This module provides helpers for manipulating font objects, as in font%.

procedure

(copy-font f 
  [#:size size 
  #:face face 
  #:family family 
  #:style style 
  #:weight weight 
  #:underlined? underlined? 
  #:smoothing smoothing 
  #:size-in-pixels? size-in-pixels? 
  #:hinting hinting 
  #:feature-settings feature-settings 
  #:font-list font-list]) 
  (is-a?/c font%)
  f : (is-a?/c font%)
  size : (real-in 0.0 1024.0)
   = (send f get-size size-in-pixels?)
  face : (or/c string? #f) = (send f get-face)
  family : (or/c 'default 'decorative 'roman 'script 'swiss 'modern 'symbol 'system)
   = (send f get-family)
  style : (or/c 'normal 'italic 'slant) = (send f get-style)
  weight : font-weight/c = (send f get-weight)
  underlined? : any/c = (send f get-underlined)
  smoothing : (or/c 'default 'partly-smoothed 'smoothed 'unsmoothed)
   = (send f get-smoothing)
  size-in-pixels? : any/c = (send f get-size-in-pixels)
  hinting : (or/c 'aligned 'unaligned) = (send f get-hinting)
  feature-settings : font-feature-settings/c
   = (send f get-feature-settings)
  font-list : (or/c (is-a?/c font-list%) #f)
   = (current-font-list)
Copy all the features of font f to a brand new font object. Supply modified values via the keyword arguments.

A font bigger than normal-control-font and italic, but otherwise the same.

7.7.5 gui/formula-editor

 (require frosthaven-manager/gui/formula-editor)
  package: frosthaven-manager

This module provides GUI objects for interactive formula editing.

procedure

(formula-editor @env)  (is-a?/c view<%>)

  @env : env/c
A window containing an interactive formula editor.

procedure

(formula-menu-item @env)  (is-a?/c view<%>)

  @env : env/c
A menu item that displays an interactive formula editor.

7.7.6 gui/helpers

 (require frosthaven-manager/gui/helpers)
  package: frosthaven-manager

procedure

(translate-to-top-coords this top x y)

  
position-integer? position-integer?
  this : (is-a?/c area<%>)
  top : (is-a?/c area<%>)
  x : position-integer?
  y : position-integer?
Returns translated x and y coordinates relative to top, assuming they were originally relative to this.

7.7.7 gui/level-info

 (require frosthaven-manager/gui/level-info)
  package: frosthaven-manager

procedure

(level-stats @level @num-players)  (is-a?/c view<%>)

  @level : (obs/c level/c)
  @num-players : (obs/c num-players/c)
A GUI view that displays the level-info corresponding to @level and @num-players.

procedure

(level-table @level)  (is-a?/c view<%>)

  @level : (obs/c level/c)
A GUI view of a button that shows a table of level-info values for each level. The current @level starts selected.

procedure

(inspiration-table @num-players)  (is-a?/c view<%>)

  @num-players : (obs/c num-players/c)
A GUI view of a button that shows a table of inspiration rewards for each possible number of players. The current @num-players starts selected.

7.7.8 gui/loot

 (require frosthaven-manager/gui/loot)
  package: frosthaven-manager

procedure

(loot-picker [#:on-card on-card    
  #:on-sticker on-sticker])  (is-a?/c view<%>)
  on-card : (-> (list/c (or/c 'add 'remove) (listof loot-card?)) any)
   = void
  on-sticker : (-> (list/c (or/c 'add 'remove) (listof loot-card?)) any)
   = void
A GUI view to build a loot deck by including certain loot cards. The callback on-card is invoked with an "event" that specifies a deck of cards from which one card should be added or removed. Similarly for on-sticker to add stickers to decks.

procedure

(loot-button @loot-deck    
  @num-loot-cards    
  @num-players    
  @players    
  [#:on-player on-player    
  #:on-top on-top    
  #:on-bottom on-bottom])  (is-a?/c view<%>)
  @loot-deck : (obs/c (listof loot-card?))
  @num-loot-cards : (obs/c natural-number/c)
  @num-players : (obs/c num-players/c)
  @players : (obs/c (listof (cons/c player? any/c)))
  on-player : (-> any/c any) = void
  on-top : (-> any) = void
  on-bottom : (-> any) = void
A GUI view of a button that, when clicked, shows a view to assign the top loot card from @loot-deck to one of @players via buttons. The callback on-player is invoked with the ID (cdr) of the player from @players whose button is clicked to assign loot; it can be used to, e.g., assign the loot card. After on-player is invoked, the view is closed.

Additionally, buttons for the top and bottom of the deck trigger the on-top and on-bottom callbacks, which then also close the view.

See Scenario Information and Loot for how loot-button functions in Frosthaven Manager.

procedure

(loot-preview @loot-deck @num-players)  (is-a?/c view<%>)

  @loot-deck : (obs/c (listof loot-card?))
  @num-players : (obs/c num-players/c)
A button that, when clicked, shows a loot deck previewer.

7.7.9 gui/manager

 (require frosthaven-manager/gui/manager)
  package: frosthaven-manager

This module’s main function is to run the Frosthaven Manager. It provides only a single binding:

procedure

(manager s)  (is-a?/c window-view<%>)

  s : state?
A view for the Frosthaven Manager. Render with render/eventspace.

7.7.10 gui/markdown

 (require frosthaven-manager/gui/markdown)
  package: frosthaven-manager

procedure

(markdown-text @content    
  [#:min-size min-size    
  #:stretch stretch    
  #:margin margin    
  #:inset inset    
  #:style style])  (is-a?/c view<%>)
  @content : (maybe-obs/c (or/c string? path?))
  min-size : (maybe-obs/c size/c) = '(#f #f)
  stretch : (maybe-obs/c stretch/c) = '(#t #t)
  margin : (maybe-obs/c margin/c) = '(0 0)
  inset : (maybe-obs/c margin/c) = '(5 5)
  style : 
(listof (one-of/c 'no-border 'control-border 'combo
                  'no-hscroll 'no-vscroll
                  'hide-hscroll 'hide-vscroll
                  'auto-vscroll 'auto-hscroll
                  'resize-corner 'deleted 'transparent))
   = '(no-hscroll)
A GUI view rendering the markdown in @content, which is either a string of Markdown or a path to a file containing Markdown. The view updates when @content does—note that in the string case this means the Markdown content has changed, but in the path case this means the path has changed, not the contents of the file at the path!

The following Markdown features are supported:
  • Paragraphs;

  • HTML comments;

  • Hyperlinks;

  • Blockquotes;

  • Unordered and ordered lists;

  • Horizontal rules;

  • Bold, italic, and code styles;

  • and six levels of headings.

The following xexpr?s are supported recursively in the parsed Markdown; these map to the Markdown features above:
  • Any string

  • Any expression tagged !HTML-COMMENT, the tag for HTML comments

  • Any expression tagged a

  • Any expression tagged blockquote

  • Any expression tagged ul

  • Any expression tagged ol

  • Any expression tagged li

  • Any expression tagged hr

  • Any expression tagged p

  • Any expression tagged strong

  • Any expression tagged em

  • Any expression tagged code

  • Any expression tagged h1

  • Any expression tagged h2

  • Any expression tagged h3

  • Any expression tagged h4

  • Any expression tagged h5

  • Any expression tagged h6

Any other tag found in the parsed Markdown is a runtime error.

Note that Markdown technically requires 4 spaces or a single tab as leading indent for nesting lists and other blocks; while many Markdown implementations (such as those used on GitHub) are more lenient, the implementation backing markdown-text is stricter on this point.

7.7.11 gui/mixins

 (require frosthaven-manager/gui/mixins)
  package: frosthaven-manager

procedure

(make-closing-proc-mixin out)

  (make-mixin-contract top-level-window<%>)
  out : (-> (-> any) any)
Produces a mixin that calls out on instantiation with a procedure that closes the window. Many uses of out are to store a local binding to this "close" procedure.

procedure

(make-on-close-mixin proc)

  (make-mixin-contract top-level-window<%>)
  proc : (-> any)
Produces a mixin that augments on-close to call proc.

syntax

(define-close! close!-id set-close-mixin-id)

If the mixin set-close-mixin-id is applied to a top-level-window<%> then close!-id is a nullary procedure that closes it.

7.7.12 gui/monsters

 (require frosthaven-manager/gui/monsters)
  package: frosthaven-manager

value

single-monster-event/c : contract?

 = 
(or/c
  (list/c 'set 'from string? 'to string?)
  (list/c 'monster 'from monster-info? 'to monster-info?)
  (list/c 'include? monster-number/c 'to boolean?)
  (list/c 'elite? monster-number/c 'to boolean?)
  (list/c 'level level/c))

value

add-monster-event/c : contract? = (list/c 'add monster-group?)

value

remove-monster-event/c : contract?

 = (list/c 'remove monster-group?)
Contracts for events used in callbacks to monster GUI views. Best used with match.

procedure

(single-monster-picker info-db 
  @initial-level 
  [#:on-change on-change 
  #:unavailable unavailable]) 
  (is-a?/c view<%>)
  info-db : info-db/c
  @initial-level : (obs/c level/c)
  on-change : (-> single-monster-event/c any) = void
  unavailable : (set/c string?) = empty
A GUI view used to build a monster group by choosing the set, name, and included monsters (along with their elite status and level). The available choices come from info-db less unavailable (a set of monster names). The callback on-change is invoked each time changes are made. The default monster level is specified by @initial-level.

procedure

(simple-monster-group-view @mg)  (is-a?/c view<%>)

  @mg : (obs/c monster-group?)
A GUI view of a monster group showing a table of monsters and some other information about the group.

procedure

(multi-monster-picker info-db 
  @initial-level 
  @env 
  [#:on-change on-change]) 
  (is-a?/c view<%>)
  info-db : info-db/c
  @initial-level : (obs/c level/c)
  @env : (obs/c env/c)
  on-change : 
(-> (or/c add-monster-event/c
          remove-monster-event/c)
    any)
 = void
A GUI view used to choose the monsters in a scenario: it composes single-monster-picker in order to allow selection and removal of entire groups. The callback on-change is invoked to notify of the addition or removal of a group. Other parameters are used as in single-monster-picker.

procedure

(monster-group-view 
  @mg 
  @ability-deck 
  @monster-num 
  @env 
  [#:on-select on-select 
  #:on-condition on-condition 
  #:on-hp on-hp 
  #:on-kill on-kill 
  #:on-new on-new 
  #:on-swap on-swap 
  #:on-move-ability-card on-move-ability-card]) 
  (is-a?/c view<%>)
  @mg : (obs/c monster-group?)
  @ability-deck : (obs/c ability-decks?)
  @monster-num : (obs/c (or/c #f monster-number/c))
  @env : (obs/c env/c)
  on-select : (-> (or/c #f monster-number/c) any) = void
  on-condition : (-> monster-number/c condition? boolean? any)
   = void
  on-hp : (-> monster-number/c (-> number? number?) any) = void
  on-kill : (-> monster-number/c any) = void
  on-new : (-> monster-number/c boolean? any) = void
  on-swap : (-> (or/c 'all monster-number?) any) = void
  on-move-ability-card : (-> any) = void
A GUI view used to display an entire monster group. See Monster Group Controls. An ability is displayed if an ability card is present in @ability-deck. The @monster-num determines the currently selected monster in the detailed portion of the view.

The callbacks function as follows:
  • on-select is given a new monster number when one is selected in the detailed view, or #false if there are none.

  • on-condition is given a monster number, condition, and either #true or #false to indiciate whether the condition should be applied or removed.

  • on-hp is given a monster number and a procedure to update the monsters monster-current-hp.

  • on-kill is invoked with a monster number when that monster is killed.

  • on-new is invoked with a monster number and #true if the monster is elite or #false otherwise for a newly added monster.

  • on-swap is invoked with 'all if all monsters should be swapped by swap-monster-group-elites, or with a monster number if only that monster should be swapped by swap-monster-elite.

  • on-move-ability-card is invoked when the top of the ability draw pile should be moved to the bottom using the ability deck previewer.

procedure

(db-view @info-db    
  @ability-db    
  @monster-groups)  (is-a?/c view<%>)
  @info-db : (obs/c info-db/c)
  @ability-db : (obs/c ability-db/c)
  @monster-groups : (obs/c (listof monster-group?))
A GUI view to display the hierarchical monster database, separated by monster-info and monster-ability.

Any pre-set monster groups will also be shown.

procedure

(add-monster-group @info-db    
  @initial-level    
  @monster-names    
  @env    
  [#:on-group on-group])  any
  @info-db : (obs/c info-db/c)
  @initial-level : (obs/c level/c)
  @monster-names : (obs/c (set/c string? #:cmp 'dont-care #:kind 'dont-care))
  @env : (obs/c env/c)
  on-group : (-> monster-group? any) = void
Renders a dialog to add a monster group by invoking the callback on-group if one is selected. The value of @initial-level is used for the initial level of the group, which can be adjusted in the dialog. Similarly, @monster-names specifies which names are not available for the new group.

Originally an internal part of the implementation of multi-monster-picker until it had uses in the main playing view.

7.7.13 gui/player-info

 (require frosthaven-manager/gui/player-info)
  package: frosthaven-manager

procedure

(player-input-views @num-players    
  [#:on-name on-name    
  #:on-hp on-hp    
  #:names names    
  #:hps hps])  (is-a?/c view<%>)
  @num-players : (obs/c natural-number/c)
  on-name : (-> natural-number/c string? any) = void
  on-hp : (-> natural-number/c (-> number? number?) any) = void
  names : (or/c #f (listof string?)) = #f
  hps : (or/c #f (listof positive-integer?)) = #f
A GUI view to enter player names and max HP. The number of entry slots is determined by @num-players. The callbacks on-name and on-hp are invoked with a player number and a name or a procedure to modify player-max-hp. Default names and max HP values can be specified via names and hps.

procedure

(player-view @player 
  [#:on-condition on-condition 
  #:on-hp on-hp 
  #:on-xp on-xp 
  #:on-initiative on-initiative] 
  #:on-summon add-summon 
  #:on-summon-hp update-summon-hp 
  #:on-summon-condition update-summon-condition 
  #:kill-summon kill-summon) 
  (is-a?/c view<%>)
  @player : (obs/c player?)
  on-condition : (-> (list/c condition? boolean?) any) = void
  on-hp : (-> (-> number? number?) any) = void
  on-xp : (-> (-> number? number?) any) = void
  on-initiative : (-> number? any) = void
  add-summon : (-> string? positive-integer? any)
  update-summon-hp : (-> natural-number/c (-> number? number?) any)
  update-summon-condition : (-> natural-number/c (list/c condition? boolean?) any)
  kill-summon : (-> natural-number/c any)
A GUI view of a single player. See Player Controls. The callback on-condition is given an condition and value that determines whether the condition should be applied (#true) or removed (#false). The callbacks on-hp and on-xp are given procedures to modify player-current-hp and player-xp, respectively. The callback on-initiative is given a new initiative for player-initiative. The number of players is used to format the player’s loot appropriately.

The summon callbacks are given the summon number, a list index, to indicate which summon to update. Adding a summon is done by name and max HP.

7.7.14 gui/render

 (require frosthaven-manager/gui/render)
  package: frosthaven-manager

parameter

(current-renderer)  (or/c #f renderer?)

(current-renderer r)  void?
  r : (or/c #f renderer?)
 = #f
A parameter for the current renderer. This can be set so that sub-views can access the top-level renderer. Note that it is not re-entrant, in the sense that to make it effective one must render an application by
(define root (render ...))
(current-renderer root)
Any other application running in the same thread cannot use current-renderer or it will interfere with the previous application. This also holds more generally of sub-views rendered on-the-fly. See render/eventspace to avoid this.

This will not affect multiple applications built and run separately that use this library, since they’re in separate processes completely.

procedure

(render/eventspace tree    
  [#:parent parent    
  #:eventspace es])  renderer?
  tree : (is-a?/c view<%>)
  parent : (or/c #f render?) = #f
  es : eventspace? = (current-eventspace)
Renders (as in render) tree with parent parent in the eventspace es, then queues a high-priority callback in the handler-thread for es to set current-renderer to the resulting renderer, which is returned.

Pass a new eventspace created with make-eventspace to separate the rendered tree and corresponding current-renderer from other applications.

This can be used to group windows in an application together, but note that subsequent calls with the same es will override that eventspace’s handler thread’s current-renderer.

For a short-lived window that should tear down the eventspace on closure, combine with with-closing-custodian/eventspace.

Evaluates the body expressions e ... with the following special variables available:
For example, the following produces either #t or #f depending on whether window A or window B was closed first. Note also the use of render/eventspace to set current-renderer correctly.
(require racket/gui/easy)
(define main-es (make-eventspace))
(render/eventspace #:eventspace main-es (window #:title "A" (text "A")))
(define aux-es
  (with-closing-custodian/eventspace
    (render/eventspace
      #:eventspace closing-eventspace
      (window #:mixin close-custodian-mixin
              #:title "B"
              (text "B")))
    closing-eventspace))
 
(sync main-es) ;; wait until window A is closed
(eventspace-shutdown? aux-es) ;; true if window B was closed first

7.7.15 gui/rewards

 (require frosthaven-manager/gui/rewards)
  package: frosthaven-manager

This module contains views for end-of-scenario rewards.

procedure

(player-rewards-view @num-players    
  @level    
  @players    
  [#:mixin mix])  (is-a?/c view<%>)
  @num-players : (obs/c num-players/c)
  @level : (obs/c level/c)
  @players : (obs/c (listof player?))
  mix : (make-mixin-contract top-level-window<%>) = values
Produces a window for displaying a players rewards, such as loot, gold, and XP. The selected player’s loot cards are also displayed. The mixin mix is applied to the window.

7.7.16 gui/server

 (require frosthaven-manager/gui/server)
  package: frosthaven-manager

procedure

(launch-server s)  renderer?

  s : state?
Renders a window in a new closing eventspace with server information, and launches a server. See with-closing-custodian/eventspace and server:launch-server.

7.7.17 gui/stacked-tables

 (require frosthaven-manager/gui/stacked-tables)
  package: frosthaven-manager

procedure

(stacked-tables [#:topleft? topleft?    
  #:panel panel]    
  @data    
  final-view    
  column1    
  column-spec ...)  (is-a?/c view<%>)
  topleft? : boolean? = #t
  panel : (-> (is-a?/c view<%>) ... (is-a?/c view<%>)) = hpanel
  @data : (obs/c (vectorof any/c))
  final-view : (-> (obs/c (or/c #f any/c)) (is-a?/c view<%>))
  column1 : column?
  column-spec : column?
A view of @data using stacked tables. The tables are horizontal, left-to-right by default. Supplying vpanel for panel makes the stack vertical. When topleft? is true, the first table is on the left or top of the stack. Otherwise it is on the right or bottom, reversing the order of subsequent tables.

The stack of tables is determined by column1 and each column-spec. The first is always column1.

Starting with @data and column1, a table is added to the stack. The table’s title is given by column-title. The labels for the items in the table come from applying column-entry->label to the values in the data. When a value is selected, the data for the next table and column-spec is produced by column-entry->next on the selection. This value is automatically wrapped in vector as needed.

This process continues, adding tables to the stack whose data depends on previous data and selections, until the final table and column-spec are added. The final selection, which is not automatically vectorized, is given to final-view. The resulting view is also added to the stack.

The intermediate data produced by column-entry->next is automatically emptied when no value is selected previously. In contrast, final-view needs to handle the case that no data has yet been selected. A common pattern is to compute a default value:
(stacked-tables
  @data
  (λ (@x?) ... (@~> @x? (or _ default)) ...)
  ...)

struct

(struct column (title entry->label entry->next))

  title : string?
  entry->label : (-> any/c string?)
  entry->next : (-> any/c (or/c any/c (vectorof any/c)))
A column specification for stacked-tables, which explains how the specification is used.

A note about column-entry->next: you almost certainly want to return a vector for all but (possibly) the last column. Intermediate columns likely have multiple choices. As a convenience, when there is only one, you may omit the vector. For the final column, you likely want to omit the vector unless the selected data is one: the data here is the final selection, of which there should probably be one.

7.7.18 gui/start

 (require frosthaven-manager/gui/start)
  package: frosthaven-manager

procedure

(start-view [#:on-level on-level    
  #:on-player on-player])  (is-a?/c view<%>)
  on-level : (-> level/c any) = void
  on-player : (-> num-players/c any) = void
A GUI view for the start screen of Frosthaven Manager. The callbacks are invoked with the level and number of players for each update to those values.

7.7.19 gui/static-table

 (require frosthaven-manager/gui/static-table)
  package: frosthaven-manager

procedure

(static-table columns    
  num-rows    
  entry->columns    
  [#:index->entry index->entry    
  #:entry->value entry->value    
  #:selection @selection    
  #:widths widths])  (is-a?/c view<%>)
  columns : (listof label-string?)
  num-rows : natural-number/c
  entry->columns : (listof (-> any/c any/c))
  index->entry : (-> natural-number/c natural-number/c) = values
  entry->value : (-> natural-number/c any/c) = values
  @selection : 
(maybe-obs/c
  (or/c #f
        exact-nonnegative-integer?
        (listof exact-nonnegative-integer?)))
   = #f
  widths : 
(maybe-obs/c
  (or/c #f
        (listof
          (or/c (list/c exact-nonnegative-integer?
                        dimension-integer?)
                (list/c exact-nonnegative-integer?
                        dimension-integer?
                        dimension-integer?
                        dimension-integer?)))))
   = #f
A GUI view for static tables. The columns are labelled by columns, and there are exactly num-rows rows. Each row is indexed by a natural number i from 0 to (sub1 num-rows); (entry->value (index->entry i)) computes a value v on which the functions in entry->columns are called to compute the values of the columns for that row. Each row is labelled with the entry (index->entry i).

Summarizing: each row is indexed by a natural number in the range [0,num-rows). An entry is computed by index->entry. A value is computed from the entry by entry->value. From this value, functions in entry->columns compute the elements of the row.

The selection is determined by @selection as with table.

The column widths are calculated automatically based on columns, or are provided as widths.

7.8 bestiary

This module implements the bestiary language. See Programming a Scenario and frosthaven-manager/bestiary for more information.

7.9 monster-db

 (require frosthaven-manager/monster-db)
  package: frosthaven-manager

See Programming a Scenario for more information on custom monster databases.

Contracts recognizing monster databases of monster-info and monster-ability values.

procedure

(datums->dbs xs)  
info-db/c ability-db/c
  xs : (listof any/c)
Filters the monster-info and monster-ability values out of xs and produces monster databases.

procedure

(get-dbs db-file)  
info-db/c ability-db/c
  db-file : path-string?
Reads db-file and produces the monster databases.

The demo, default monster database included with Frosthaven Manager.

7.10 parsers

7.10.1 parsers/foes

 (require frosthaven-manager/parsers/foes)
  package: frosthaven-manager

This module contains parsers for #lang frosthaven-manager/foes. See Programming a Scenario for more details.

procedure

(parse-foes src in #:syntax? syn?)  (or/c syntax? foes/pc)

  src : any/c
  in : input-port?
  syn? : any/c
The result is syntax? with source src if syn? is true, and the datum it contains matches foes/pc.

value

foes/pc : flat-contract?

 = (listof (or/c (list/c 'import string?) monster-info? (listof monster-ability?) foe/pc))

value

foe/pc : flat-contract?

 = (list/c string? string? numbering/pc (listof spec/pc))

value

spec/pc : flat-contract?

 = (hash/c num-players/c monster-type/pc #:immutable #t)

value

numbering/pc : flat-contract? = (or/c "ordered" "random" #f)

value

monster-type/pc : flat-contract?

 = (or/c "absent" "normal" "elite")
Contracts for foes values.

Textual parsers for parts of the foes language.

7.10.2 parsers/formula

 (require frosthaven-manager/parsers/formula)
  package: frosthaven-manager

This module contains parsers for arithmetic formulas over addition, subtraction, multiplication, division, rounding, and a limited set of variables. The parse result is a function from an environment of variables to a number.

value

env/c : flat-contract?

 = (hash/c (or/c "L" "C") number? #:flat? #t)

value

expr/pc : contract? = (-> env/c number?)

Contracts for the parse results of formulas.

Textual parser for formulas.

procedure

(parse-expr in)  expr/pc

  in : string?
Parses a string as a formula or fails.

7.10.3 parsers/monster

 (require frosthaven-manager/parsers/monster)
  package: frosthaven-manager

This module contains parsers for #lang frosthaven-manager/bestiary. See Programming a Scenario for more details.

procedure

(parse-bestiary src in #:syntax? syn?)

  (or/c syntax? bestiary/c)
  src : any/c
  in : input-port?
  syn? : any/c
The result is syntax? with source src if syn? is true, and the datum it contains matches bestiary/c.

value

bestiary/c : flat-contract?

 = 
(listof (or/c (list/c 'import string?)
              monster-info?
              (listof monster-ability?)))
A contract for bestiary values.

Textual parsers for parts of the bestiary language.

procedure

(bestiary-dupes xs)  
(or/c #f (listof string?))
(or/c #f (listof string?))
  xs : (listof any/c)
Returns duplicate monster names from bestiaries and ability decks in xs. The first value is based on any monster-infos and the second on monster-ability decks.

7.11 observable-operator

 (require frosthaven-manager/observable-operator)
  package: frosthaven-manager

In addition to the shorthands below, this module exports define/obs, @, :=, and λ:= from racket/gui/easy/operator.

procedure

(<@ @o f)  any/c

  @o : obs?
  f : (-> any/c any/c)
An alias for obs-update!.

procedure

(@> @o f)  obs?

  @o : obs?
  f : (-> any/c any/c)
An alias for obs-map.

procedure

(λ<@ @o f)  (-> any/c)

  @o : obs?
  f : (-> any/c any/c)
An alias for λ<~.

procedure

(@! @o)  any/c

  @o : obs?
An alias for obs-peek.

syntax

(@~> @o flo)

 
  @o : obs?
An alias for obs-map that wraps flo in flow.

syntax

(<~@ @o flo)

 
  @o : obs?
An alias for obs-update! that wraps flo in flow.

7.12 pp

This collection holds pretty printers based on pretty-expressive.

7.12.1 pp/bestiary

 (require frosthaven-manager/pp/bestiary)
  package: frosthaven-manager

This module pretty-prints bestiary files. It can be run as a program with

racket -l- frosthaven-manager/pp/bestiary

to format standard in or a provided file to standard out. Use --help for more options.

procedure

(pretty-bestiary bestiary    
  [#:lang-line? lang-line?])  pretty:doc?
  bestiary : bestiary/c
  lang-line? : any/c = #t
Creates a document for pretty printing from the results of a parsed bestiary. The document starts with a #lang line preceding the result if lang-line? is not #f.

7.13 qi

 (require frosthaven-manager/qi)
  package: frosthaven-manager

This modules provides everything from qi in addition to the bindings from frosthaven-manager/qi/list2hash.

7.13.1 qi/list2hash

 (require frosthaven-manager/qi/list2hash)
  package: frosthaven-manager

syntax

(list~>hash maybe->key maybe->value)

 
maybe->key = 
  | #:->key ->key-flo
     
maybe->value = 
  | #:->value ->value-flo
This Qi form transforms the input value (a list) into a hash, where each element of the list is mapped into a key via ->key-flo and a value via ->value-flo. It uses list->hash as implementation.

procedure

(list->hash xs    
  [#:->key ->key    
  #:->value ->value])  hash?
  xs : list?
  ->key : (-> any/c any/c) = identity
  ->value : (-> any/c any/c) = identity
Transforms xs to a hash by mapping each element into a key via ->key and a value via ->value.

7.14 server

 (require frosthaven-manager/server)
  package: frosthaven-manager

procedure

(launch-server s send-event)  
string? (-> any)
  s : state?
  send-event : procedure?
Launches the actual web server for s. The callback protocol for send-event is not yet formalized and very unstable.

Returns the server address (on a best-guess basis) and a stop procedure that stops the server when called.

7.15 syntax

The modules in this collection provide helpers for macros, syntax, and languages.

7.15.1 syntax/module-reader

 (require frosthaven-manager/syntax/module-reader)
  package: frosthaven-manager

This expander language wraps syntax/module-reader by assuming a specific reading protocol.

This module does not have a reader of its own, so should be used with module or #lang s-exp.

syntax

(#%module-begin expander-mod-path
 [parser-id from parser-mod-path])
The following example demonstrates the entire grammer of the expander language:
#lang s-exp frosthaven-manager/syntax/module-reader
frosthaven-manager/foes
[parse-foes from frosthaven-manager/parsers/foes]

Or with module:
#lang racket
(module reader frosthaven-manager/syntax/module-reader
  frosthaven-manager/foes
  [parse-foes from frosthaven-manager/parsers/foes])

The semantics are as follows. The resulting module satisfies the language reader extension protocol from Reading via an Extension via syntax/module-reader with a few specifications. The expander-mod-path is used as in syntax/module-reader to determine the module-path for the initial bindings of modules produced by the reader. The parser-id, which must be provided by parser-mod-path, is assumed to parse the whole body as with the #:whole-body-readers? keyword for syntax/module-reader. In addition, it should support the following protocol: the parser accepts 2 positional arguments. The first is the same name-value as