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 contracts
unique-with/  c
7.4 defns
7.4.1 Level Info
level-info
number-of-levels
max-level
level/  c
max-players
num-players/  c
get-level-info
inspiration-reward
7.4.2 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
material-amount*
herb
loot-card?
loot-type/  c
card->type
format-loot-card
max-money-cards
max-material-cards
max-herb-cards
max-random-item-cards
money-deck
material-decks
herb-decks
standard-loot-deck
apply-sticker
7.4.3 Monster Cards
monster-stats
monster-info
monster-ability
monster-number/  c
monster
monster-group
monster-stats-max-hp*
monster-stats-attack*
monster-stats-bonuses-string
monster-stats-effects-string
monster-stats-immunities-string
monster-ability-name->text
monster-ability-initiative->text
monster-ability-ability->rich-text
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
monster-group-change-max-HP
7.4.4 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.4.5 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
conditions->string
monster-modifier-deck
monster-curse-deck
bless-deck
shuffle-modifier-deck?
better-modifier
worse-modifier
7.5 elements
size
element-pics
elements
7.6 enum-helpers
make-property-maker-that-displays-as-constant-names
define-serializable-enum-type
7.7 icons
target
range
push
pull
7.8 manager
7.8.1 manager/  state
creature
monster-group*
creature-is-mg*?
state
make-state
state-@env
state-@info-db
state-@ability-db
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
single-monster-event/  c
add-monster-event/  c
remove-monster-event/  c
add-or-remove-monster-group
draw-new-card-mid-round-if-needed
initiative-public?
add-prompt
remove-prompt
7.8.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.8.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.8.4 manager/  db
init-dbs
init-dbs-and-foes
7.8.5 manager/  elements
element-state/  c
make-states
infuse-all
consume-all
wane-element
transition-element-state
7.8.6 manager/  loot
update-loot-deck-and-num-loot-cards
build-loot-deck
build-loot-deck!
give-player-loot
place-loot-on-bottom
player->rewards
7.8.7 manager/  round-prompts
prompt
should-do-prompt?
prompt/  c
time/  c
beginning-of
end-of
prompt->string
7.8.8 manager/  transition
transition/  c
to-start
to-input-player-info
to-build-loot-deck
to-add-prompts
to-choose-monster-db
to-choose-monsters-or-play
to-choose-monsters
to-play
next-round
draw-abilities
7.8.9 manager/  save
do-save-game
do-load-game
load-game
7.9 gui
7.9.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.9.2 gui/  counter
counter
7.9.3 gui/  elements
elements-cycler
7.9.4 gui/  font
copy-font
big-control-font
7.9.5 gui/  formula-editor
formula-editor
formula-menu-item
7.9.6 gui/  helpers
translate-to-top-coords
escape-text
define-error-text
7.9.7 gui/  level-info
level-stats
level-table
inspiration-table
7.9.8 gui/  loot
loot-picker
loot-button
loot-preview
7.9.9 gui/  manager
manager
7.9.10 gui/  markdown
markdown-text
7.9.11 gui/  mixins
make-closing-proc-mixin
make-on-close-mixin
define-close!
hide-caret/  selection
7.9.12 gui/  monsters
single-monster-picker
simple-monster-group-view
multi-monster-picker
monster-group-view
db-view
add-monster-group
7.9.13 gui/  player-info
player-input-views
player-view
7.9.14 gui/  render
current-renderer
render/  eventspace
with-closing-custodian/  eventspace
closing-custodian
closing-eventspace
close-custodian-mixin
7.9.15 gui/  rewards
player-rewards-view
7.9.16 gui/  rich-text-display
rich-text-display
7.9.16.1 Rich Text Model
newline
pict/  alt-text
newline?
scale-icon
7.9.17 gui/  round-prompts
prompts-input-view
manage-prompt-menu-item
do-round-prompt
7.9.18 gui/  server
launch-server
7.9.19 gui/  stacked-tables
stacked-tables
column
7.9.20 gui/  start
start-view
7.9.21 gui/  static-table
static-table
7.9.22 gui/  table
make-preview-rows
7.10 files
get-file/  filter
put-file/  filter
7.11 bestiary
7.12 monster-db
info-db/  c
ability-db/  c
datums->dbs
get-dbs
default-monster-db
7.13 parsers
7.13.1 parsers/  foes
parse-foes
foes/  pc
foe/  pc
spec/  pc
numbering/  pc
monster-type/  pc
foes/  p
foe/  p
7.13.2 parsers/  formula
env/  c
expr/  pc
expr/  p
parse-expr
7.13.3 parsers/  monster
parse-bestiary
bestiary/  c
monster/  p
ability-deck/  p
import-monsters/  p
bestiary/  p
bestiary-dupes
7.14 observable-operator
<@
@>
λ<@
@!
7.15 pp
7.15.1 pp/  bestiary
pretty-bestiary
7.16 qi/  list2hash
list~>hash
list->hash
7.17 qi/  utils
list-remove
7.18 server
launch-server
7.19 syntax
7.19.1 syntax/  module-reader
#%module-begin
7.19.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.12

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 contracts🔗

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

procedure

(unique-with/c key c)  contract?

  key : (-> any/c any/c)
  c : flat-contract?
The contract (unique-with/c key c) requires of a value v that the result of (map key v) is a (listof c) with no duplicates.

7.4 defns🔗

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

This module reprovides everything from frosthaven-manager/defns/level, frosthaven-manager/defns/loot, frosthaven-manager/defns/monsters, frosthaven-manager/defns/players, and frosthaven-manager/defns/scenario.

7.4.1 Level Info🔗

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

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.4.2 Loot Deck🔗

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

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.

procedure

(material-amount* m n)  natural-number/c

  m : material?
  n : num-players/c
Calculates the amount a material loot card m is worth for the number of players n.

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?.

value

loot-type/c : flat-contract?

 = (or/c 'money material-kind? herb-kind? 'random-item)
This contract recognizes the type of a loot card.

procedure

(card->type c)  loot-type/c

  c : loot-card?
Convert a loot card to its type.

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.

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

procedure

(apply-sticker card)  loot-card?

  card : (and/c loot-card? (not/c random-item?))
Returns card with amounts increased by 1.

7.4.3 Monster Cards🔗

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

struct

(struct monster-stats (max-hp
    move
    attack
    bonuses
    effects
    immunities)
    #:prefab)
  max-hp : (or/c positive-integer? string?)
  move : (or/c #f 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.

Returns a single string containing all the bonuses, effects, or immunities.

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->rich-text ability-text 
  ability-card 
  mg 
  env) 
  (listof (or/c string? pict? pict/alt-text? newline?))
  ability-text : string?
  ability-card : monster-ability?
  mg : monster-group?
  env : env/c
Format a single monster ability from an ability card as a rich text sequence, compatible with rich-text-display.

  • an extra `(aoe-pict ,aoe-pict) means the ability had an area of effect specified by the pict.

}

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 monster-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.

procedure

(monster-group-change-max-HP mg f env)  monster-group?

  mg : monster-group?
  f : (-> (or/c 'normal 'elite) natural-number/c number?)
  env : env/c
Updates a monster-group’s maximum HP value in all statistics by applying a procedure.

7.4.4 Players🔗

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

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.4.5 Scenario🔗

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

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.

procedure

(conditions->string cs)  string?

  cs : (listof condition?)
Converts a set of conditions to a string.

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.5 elements🔗

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

The size of the element pictures.

struct

(struct element-pics (name infused waning unfused consume)
    #:transparent)
  name : string?
  infused : pict?
  waning : pict?
  unfused : pict?
  consume : 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.6 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.

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.7 icons🔗

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

This module provides various icons that are spliced into ability card texts. All replacements are case insensitive; any numbers or other accompanying text are preserved. The signifier N denotes where a number is expected.

procedure

(target)  pict?

image
Provides replacements for
  • Target N

  • Target all

  • +N target(s)

procedure

(range)  pict?

image
Provides replacements for
  • Range N

procedure

(push)  pict?

image
Provides replacements for
  • Push N

procedure

(pull)  pict?

image
Provides replacements for
  • Pull N

7.8 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, frosthaven-manager/manager/elements, frosthaven-manager/manager/loot, frosthaven-manager/manager/round-prompts, frosthaven-manager/manager/transition, and frosthaven-manager/manager/save.

7.8.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.

procedure

(creature-is-mg*? c)  any/c

  c : creature?
True iff c holds a monster-group*.

struct

(struct state (@mode
    @level
    @num-players
    @creatures
    @type->number-of-cards
    @loot-deck
    @num-loot-cards
    @elements
    @in-draw?
    @round
    @monster-modifier-deck
    @monster-discard
    @player-blesses
    @curses
    @blesses
    @modifier
    @monster-prev-discard
    @bestiary-path
    @ability-decks
    @prompts
    @type->deck))
  @mode : symbol?
  @level : (obs/c level/c)
  @num-players : (obs/c num-players/c)
  @creatures : (obs/c (listof creature?))
  @type->number-of-cards : (obs/c (hash/c loot-type/c 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?))
  @bestiary-path : (obs/c (or/c #f path-string?))
  @ability-decks : (obs/c (hash/c string? ability-decks?))
  @prompts : (obs/c (listof prompt/c))
  @type->deck : (maybe-obs/c (hash/c loot-type/c (listof loot-card?)))
All of the "global" manager state.

procedure

(make-state [@mode    
  @level    
  @num-players    
  @creatures    
  @type->number-of-cards    
  @loot-deck    
  @num-loot-cards    
  @elements    
  @in-draw?    
  @round    
  @monster-modifier-deck    
  @monster-discard    
  @player-blesses    
  @curses    
  @blesses    
  @modifier    
  @monster-prev-discard    
  @bestiary-path    
  @ability-decks    
  @prompts    
  @type->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)
  @type->number-of-cards : (maybe-obs/c (hash/c loot-type/c 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)
  @bestiary-path : (maybe-obs/c (or/c #f path-string?)) = (@ #f)
  @ability-decks : (maybe-obs/c (hash/c string? ability-decks?))
   = (@ (hash))
  @prompts : (maybe-obs/c (listof prompt/c)) = (@ empty)
  @type->deck : (maybe-obs/c (hash/c loot-type/c (listof loot-card?)))
   = (@ standard-loot-deck)
Create an initial state.

procedure

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

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

procedure

(state-@info-db s)  (obs/c info-db/c)

  s : state?

procedure

(state-@ability-db s)  (obs/c ability-db/c)

  s : state?
Derive corresponding databases from state-@bestiary-path. The databases are empty if the path is not present.

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.

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

(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.

procedure

(add-prompt s)  (-> prompt/c any)

  s : state?
Add a prompt to s.

procedure

((remove-prompt s) i p)  any

  s : state?
  i : natural-number/c
  p : prompt/c
Remove a prompt p from s by index i. If the prompt at index i is not p, no prompts are removed.

7.8.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. The value of (ability-decks-current ad) is silently discarded; if it is a monster-ability?, it is effectively lost.

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

Updates each deck via f, which is called with the monster set and deck.

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

7.8.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.8.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.8.5 manager/elements🔗

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

value

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

A contract recognizing valid element 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.8.6 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) loot-type/c) any)
  s : state?
Update the loot deck based on the loot-picker event.

procedure

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

The mapping type->number-of-cards maps a loot card type to a number of loot cards of that type. The mapping type->deck specifies which deck cards of that type should be drawn from.

This function assumes, but does not check, that for all types t the number of cards for that type (hash-ref type->number-of-cards t) is less than or equal to the number of loot cards in that type’s deck (length (hash-ref type->deck t)).

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.

procedure

(player->rewards p num-players level)  (listof string?)

  p : player?
  num-players : num-players/c
  level : level/c
Each string is a reward for player p except the first, which is the player’s name. The values are an indicator if the player got the random item, the player’s XP, gold, each material amount, and each herb amount.

7.8.7 manager/round-prompts🔗

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

This module provides facilities for manipulating round prompt values.

syntax

(prompt [time rule] ...)

 
rule = m-expr
  | even
  | odd
  | every n-expr starting-at start-expr
 
  time : time/c
  m-expr : natural-number/c
  n-expr : natural-number/c
  start-expr : natural-number/c
Notation for describing round prompt values. The result of a prompt expression is a list of prompt/c values.

Each round prompt value is denoted by a time and rule.
  • A rule consisting of m-expr means to prompt at round m-expr.

  • A rule consisting of even means to prompt at every even round.

  • A rule consisting of odd means to prompt at every odd round.

  • A rule consisting of every n-expr starting-at start-expr means to prompt at every n-exprth round, starting at the start-exprth round.

procedure

(should-do-prompt? t current-round prompts)  any/c

  t : time/c
  current-round : natural-number/c
  prompts : (listof prompt/c)
Returns true iff at time t and round current-round the round prompt rules in prompts determine that a prompt should happen.

A serializable round prompt value. A round prompt value expresses rules both for which round(s) to prompt in and when.

Times for round prompts representing the beginning of the round and the end of the round.

procedure

(prompt->string p)  string?

  p : prompt/c
A textual description of a round prompt value meant for human use.

7.8.8 manager/transition🔗

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

value

transition/c : contract? = (-> state? (-> any))

A transition function consumes a state? and produces a thunk typically used as the action for a button.

A series of transition functions.

7.8.9 manager/save🔗

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

procedure

(do-save-game s)  any

  s : state?
Prompts the user to save the game to a file of their choice.

procedure

(do-load-game s)  any

  s : state?
Prompts the user to load the game from a file of their choice.

procedure

((load-game s) p)  any

  s : state?
  p : path-string?
Load a game from p.

7.9 gui🔗

This collection provides modules for operating GUIs.

7.9.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.9.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.9.3 gui/elements🔗

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

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.

7.9.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.

value

big-control-font : (is-a?/c font%)

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

7.9.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.9.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.

procedure

(escape-text s)  string?

  s : string?
Escapes s for use in text; only needed when s is derived from user input.

syntax

(define-error-text @error-text-id with-error-text-id)

Binds @error-text-id to an observable string and with-error-text-id to a form accepting arbitrarily many expressions. The form resets @error-text-id evaluates all of its body expressions and returns the result of the last one; if any raise an exception, instead, the exception’s error message is stored in @error-text-id and returned from the form.

7.9.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.9.8 gui/loot🔗

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

procedure

(loot-picker @type->cards    
  @type->deck    
  [#:on-card on-card    
  #:on-deck on-deck])  (is-a?/c view<%>)
  @type->cards : (obs/c (hash/c loot-type/c natural-number/c))
  @type->deck : (obs/c (hash/c loot-type/c (listof loot-card?)))
  on-card : (-> (list/c (or/c 'add 'remove) loot-type/c) any)
   = void
  on-deck : (-> (hash/c loot-type/c (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 type of cards from which one card should be added or removed. The callback on-deck is invoked with a mapping from loot types to decks that should be used to interpret what decks to draw cards from. See build-loot-deck.

This picker allows loading new decks of loot cards and stickering cards on the fly with + 1 stickers. It does not allow removing such stickers; reset the deck to start over.

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.9.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.9.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.9.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.

mixin

hide-caret/selection : (class? . -> . class?)

  argument extends/implements: text%
  result implements: text%
Augments the text editor to hide the caret but still permit and show selections.

7.9.12 gui/monsters🔗

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

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 
  #:on-max-hp on-max-hp]) 
  (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/c) any) = void
  on-move-ability-card : (-> any) = void
  on-max-hp : (-> (-> (or/c 'normal 'elite) natural-number/c number?) 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.

  • on-max-hp is invoked when adjusting all maximum HP of the group. The given procedure computes new maximum HP values as for monster-group-change-max-HP.

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.9.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.9.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 renderer?) = #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.9.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.9.16 gui/rich-text-display🔗

 (require frosthaven-manager/gui/rich-text-display)
  package: frosthaven-manager

This module provides a view-based rich text display, suitable for certain replacements of text.

procedure

(rich-text-display @content    
  [#:font @font    
  #:min-size @min-size    
  #:stretch @stretch    
  #:margin @margin    
  #:inset @inset    
  #:style style])  (is-a?/c view<%>)
  @content : 
(maybe-obs/c (listof (or/c string?
                           pict?
                           pict/alt-text?
                           newline?)))
  @font : (maybe-obs/c (is-a?/c font%)) = normal-control-font
  @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)
Displays @content via a text%. Keyword arguments except @font control the text%. The @font controls the font at which text is displayed and to which pictures are scaled.

Contents are selectable and copyable with the usual keyboard shortcuts, and can also be selected with mouse. Contents are automatically reflowed.

7.9.16.1 Rich Text Model🔗

 (require (submod frosthaven-manager/gui/rich-text-display model))

value

newline : newline?

When used with rich-text-display, forces a hard newline.

struct

(struct pict/alt-text (p alt-text))

  p : pict?
  alt-text : string?
When used with rich-text-display, displays a pict?. Copying the pict copies the alt-text instead.

procedure

(newline? x)  boolean?

  x : any/c
A predicate that recognizes the newline value.

procedure

(scale-icon p)  pict?

  p : pict?
Produces a scaled pict suitable for an icon size. Note that this does not take a font object for scaling, so the size may not be correct when providing fonts to rich-text-display.

7.9.17 gui/round-prompts🔗

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

This module contains GUI utilities for frosthaven-manager/manager/round-prompts.

procedure

(prompts-input-view @prompts    
  [#:on-add on-add    
  #:on-remove on-remove])  (is-a?/c view<%>)
  @prompts : (obs/c (listof prompt/c))
  on-add : (-> prompt/c any) = void
  on-remove : (-> natural-number/c prompt/c any) = void
Views and constructs a list of round prompt values. The on-add event is emitted when a round prompt is added, and on-remove when a round prompt is removed. The on-remove event signals both the index of the round prompt and the prompt value to be removed.

procedure

(manage-prompt-menu-item @prompts 
  [#:on-add on-add 
  #:on-remove on-remove]) 
  (is-a?/c view<%>)
  @prompts : (obs/c (listof prompt/c))
  on-add : (-> prompt/c any) = void
  on-remove : (-> natural-number/c prompt/c any) = void
Renders a dialog for managing round prompts in the same style as prompts-input-view.

procedure

(do-round-prompt t round)  any

  t : time/c
  round : natural-number/c
Renders a dialog prompting players to check the rules based on the timing of the current round.

7.9.18 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.9.19 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.9.20 gui/start🔗

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

procedure

(start-view @level    
  @num-players/c    
  [#:on-level on-level    
  #:on-player on-player])  (is-a?/c view<%>)
  @level : (obs/c level/c)
  @num-players/c : (obs/c num-players/c)
  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.

The observables control the initially selected values.

7.9.21 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.9.22 gui/table🔗

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

procedure

(make-preview-rows xs 
  n 
  #:reveal reveal 
  #:hide hide) 
  (vectorof (vectorof string?))
  xs : list?
  n : (or/c 'all natural-number/c)
  reveal : (-> any/c (vectorof string?))
  hide : (-> any/c (vectorof string?))
Separates xs into n revealed rows and otherwise hidden rows. Rows are generated by applying the corresponding functions to elements of xs.

If n is 'all or greater than the length of xs, all elements are considered revealed.

Rows correspond to the notion of rows or entries in table.

7.10 files🔗

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

procedure

(get-file/filter message filter)  (or/c path? #f)

  message : label-string?
  filter : (list/c string? string?)
Returns get-file with message and filter. Additionally permits an "Any" filter. The Windows extensions is provided from (second filter).

procedure

(put-file/filter message    
  filter    
  [directory    
  file])  (or/c path? #f)
  message : label-string?
  filter : (list/c string? string?)
  directory : path-string? = #f
  file : path-string? = #f
Returns put-file with message and filter. Additionally permits an "Any" filter. The Windows extensions is provided from (second filter).

7.11 bestiary🔗

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

7.12 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.13 parsers🔗

This collection contains parsers that support various #langs.

7.13.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.13.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.13.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.14 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 and everything from qi via frosthaven-manager/curlique.

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.

7.15 pp🔗

This collection holds pretty printers based on pretty-expressive.

7.15.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.16 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.17 qi/utils🔗

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

procedure

(list-remove xs i)  
list? any/c
  xs : list?
  i : natural-number/c
Returns a new list consisting of all elements of xs excepth the ith, and the ith value. If i is out of bounds, raises an exception.

7.18 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.19 syntax🔗

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

7.19.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 read-syntax; the second is the same input port as for read and read-syntax with line-counting enabled. Then it must accept a keyword option #:syntax?, whose value is a boolean indicating whether or not to produce a syntax object.

Examples of valid parsers include parse-foes and parse-bestiary.

7.19.2 syntax/monsters🔗

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

syntax

(make-dbs (provide info-db-id ability-db-id)
          (import import-mod-path ...)
          (info monster-info ...)
          (ability (monster-ability ...) ...))
 
  monster-info : monster-info?
  monster-ability : monster-ability?
Binds and provides info-db-id and ability-db-id to info-db/c and ability-db/c values, respectively, by importing all the monster information from each import-mod-path and merging it with the provided monster-info and monster-ability.

Each import-mod-path is expected to provide the same info-db-id and ability-db-id.

The provide keyword in the provide specification is recognized by binding and must be the same as the one from racket/base. The import, info, and ability keywords are recognized by datum identity.

procedure

(syntaxes->bestiary-parts syntaxes)

  (list/c (listof syntax?) (listof syntax?) (listof syntax?) (listof syntax?))
  syntaxes : (listof syntax?)
Separates the input syntaxes into 4 categories: imports whose datum matches (list/c 'import string?), monster information matching monster-info?, ability decks matching (listof monster-ability?), and foes matching foe/pc.

procedure

(imports->dbs import-paths)

  
(listof info-db/c) (listof ability-db/c)
  import-paths : (listof string?)
Produces all the monster information databases, one for each import in import-paths, using get-dbs.

procedure

(check-monsters-have-abilities imported-info-dbs    
  imported-ability-dbs    
  infos    
  actions)  boolean?
  imported-info-dbs : (listof info-db/c)
  imported-ability-dbs : (listof ability-db/c)
  infos : (listof monster-info?)
  actions : (listof monster-ability?)
True iff the set names among all the given imported-info-dbs and infos is a subset of those among all the given imported-ability-dbs and actions.

procedure

(check-monsters-have-abilities-message imported-info-dbs 
  imported-ability-dbs 
  infos 
  actions) 
  string?
  imported-info-dbs : (listof info-db/c)
  imported-ability-dbs : (listof ability-db/c)
  infos : (listof monster-info?)
  actions : (listof monster-ability?)
An error message for when check-monsters-have-abilities fails.

procedure

(check-foes-have-monsters imported-info-dbs    
  infos    
  foes)  boolean?
  imported-info-dbs : (listof info-db/c)
  infos : (listof monster-info?)
  foes : (listof foe/pc)
True iff the foe names among all the given foes is a subset of the monster names among all the given imported-info-dbs and infos.

procedure

(check-foes-have-monsters-message imported-info-dbs    
  infos    
  foes)  string?
  imported-info-dbs : (listof info-db/c)
  infos : (listof monster-info?)
  foes : (listof foe/pc)
An error message for when check-foes-have-monsters fails.