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 Constant Formatting and Parsing
define-constant-format/  parse
define-constant-format
define-constant-parse
7.4 contracts
unique-with/  c
7.5 defns
7.5.1 Level Info
level-info
number-of-levels
max-level
level/  c
max-players
num-players/  c
get-level-info
inspiration-reward
7.5.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
special-loot
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.5.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-expire-conditions
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.5.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-expire-conditions
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.5.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
expirable-conditions
conditions->string
monster-modifier-deck
monster-curse-deck
bless-deck
shuffle-modifier-deck?
better-modifier
worse-modifier
absent-from-modifier-deck
7.6 elements
size
element-pics
elements
7.7 enum-helpers
define-serializable-enum-type
7.8 icons
target
range
push
pull
move
jump
teleport
7.9 manager
7.9.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.9.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.9.3 manager/  modifier-decks
reshuffle-modifier-deck
discard
draw-modifier
draw-modifier*
do-curse-monster
do-bless-monster
do-bless-player
do-unbless-player
add-monster-modifier
remove-monster-modifier
7.9.4 manager/  db
init-dbs
init-dbs-and-foes
7.9.5 manager/  elements
element-state/  c
make-states
infuse-all
consume-all
wane-element
transition-element-state
7.9.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.9.7 manager/  round-prompts
prompt
should-do-prompt?
prompt/  c
time/  c
beginning-of
end-of
prompt->string
7.9.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.9.9 manager/  save
do-save-game
do-load-game
load-game
7.10 gui
7.10.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.10.2 gui/  counter
counter
7.10.3 gui/  elements
elements-cycler
7.10.4 gui/  font
copy-font
big-control-font
7.10.5 gui/  formula-editor
formula-editor
formula-menu-item
7.10.6 gui/  helpers
translate-to-top-coords
escape-text
define-error-text
7.10.7 gui/  level-info
level-stats
level-table
inspiration-table
7.10.8 gui/  loot
loot-picker
loot-button
loot-preview
7.10.9 gui/  manager
manager
7.10.10 gui/  markdown
markdown-text
7.10.11 gui/  mixins
make-closing-proc-mixin
make-on-close-mixin
define-close!
hide-caret/  selection
7.10.12 gui/  monster-modifier
modify-monster-deck-menu-item
favors-dialog
card-swapper
7.10.13 gui/  monsters
single-monster-picker
simple-monster-group-view
multi-monster-picker
monster-group-view
db-view
add-monster-group
7.10.14 gui/  player-info
player-input-views
player-view
7.10.15 gui/  render
current-renderer
render/  eventspace
with-closing-custodian/  eventspace
closing-custodian
closing-eventspace
close-custodian-mixin
7.10.16 gui/  rewards
player-rewards-view
7.10.17 gui/  rich-text-display
rich-text-display
7.10.17.1 Rich Text Model
newline
pict/  alt-text
newline?
scale-icon
7.10.18 gui/  round-prompts
prompts-input-view
manage-prompt-menu-item
do-round-prompt
7.10.19 gui/  server
launch-server
7.10.20 gui/  stacked-tables
stacked-tables
column
7.10.21 gui/  start
start-view
7.10.22 gui/  static-table
static-table
7.10.23 gui/  table
make-preview-rows
7.11 files
get-file/  filter
put-file/  filter
7.12 bestiary
7.13 monster-db
info-db/  c
ability-db/  c
datums->dbs
get-dbs
default-monster-db
7.14 parsers
7.14.1 parsers/  foes
parse-foes
foes/  pc
foe/  pc
spec/  pc
numbering/  pc
monster-type/  pc
foes/  p
foe/  p
7.14.2 parsers/  formula
env/  c
expr/  pc
expr/  p
parse-expr
7.14.3 parsers/  monster
parse-bestiary
bestiary/  c
monster/  p
ability-deck/  p
import-monsters/  p
bestiary/  p
bestiary-dupes
7.15 observable-operator
<@
@>
λ<@
@!
7.16 pp
7.16.1 pp/  bestiary
pretty-bestiary
7.17 qi/  list2hash
list~>hash
list->hash
7.18 qi/  utils
list-remove
7.19 server
launch-server
7.20 syntax
7.20.1 syntax/  module-reader
#%module-begin
7.20.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.13

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 Constant Formatting and Parsing🔗

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

This module provides forms for binding formatters and parsers where the mapping from constant to string and vice-versa is static.

syntax

(define-constant-format/parse
  formatter-id parser-id
  ([constant-id string] ...))

syntax

(define-constant-format formatter-id ([constant-id string] ...))

Binds formatter-id to a function accepting constants constant-id and producing the corresponding strings.

syntax

(define-constant-parse parser-id ([constant-id string] ...))

Binds parser-id to a function accepting strings and producing the corresponding constant-ids.

7.4 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.5 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.5.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.5.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.

struct

(struct special-loot (name)
    #:transparent)
  name : string?
Represents a specially named loot card. This can be used for custom cards or for the standard loot cards with special properties. These loot cards are always included in the deck when available.

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 'special)
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?)
       (not/c special-loot?))
Returns card with amounts increased by 1.

7.5.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-expire-conditions m)  monster?

  m : monster?
Remove expirable-conditions from m.

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.5.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-expire-conditions p)  player?

  p : player?
Remove expirable-conditions from p.

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

value

expirable-conditions : (setof conditions?)

The conditions that expire at end-of-next-turn.

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.

Returns the cards in monster-modifier-deck not in cards.

7.6 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.7 enum-helpers🔗

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

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

procedure

(move)  pict?

image
Provides replacements for
  • Move +N

  • Move -N

procedure

(jump)  pict?

image
Provides replacements for
  • Jump

procedure

(teleport)  pict?

image
Provides replacements for
  • Teleport

7.9 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.9.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?))
   = (@ 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.9.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.9.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.

procedure

(add-monster-modifier s)  (-> monster-modifier? any)

  s : state?

procedure

(remove-monster-modifier s)

  (-> exact-nonnegative-integer? any)
  s : state?
Handles events emitted by card-swapper. These are intended for use when the deck handed to card-swapper consists of something like this:
In particular, remove-monster-modifier translates indexes to both the modifier deck and the discard pile.

7.9.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.9.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.9.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, each herb amount, and a comma-separated list of special cards.

7.9.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.9.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.9.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.10 gui🔗

This collection provides modules for operating GUIs.

7.10.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.10.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.10.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.10.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.10.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.10.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.10.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.10.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.10.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.10.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.10.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.10.12 gui/monster-modifier🔗

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

procedure

(modify-monster-deck-menu-item @cards 
  [#:on-add on-add 
  #:on-remove on-remove] 
  #:on-shuffle on-shuffle) 
  (is-a?/c view<%>)
  @cards : (obs/c (listof monster-modifier?))
  on-add : (-> monster-modifier? any) = void
  on-remove : (-> exact-nonnegative-integer? any) = void
  on-shuffle : (-> any)
A menu-item rendering favors-dialog.

procedure

(favors-dialog @cards 
  [#:on-add on-add 
  #:on-remove on-remove] 
  #:on-shuffle on-shuffle) 
  (is-a?/c window-view<%>)
  @cards : (obs/c (listof monster-modifier?))
  on-add : (-> monster-modifier? any) = void
  on-remove : (-> exact-nonnegative-integer? any) = void
  on-shuffle : (-> any)
A dialog that wraps card-swapper and adds a Shuffle button which emits on-shuffle.

procedure

(card-swapper @cards    
  [#:on-add on-add    
  #:on-remove on-remove])  (is-a?/c view<%>)
  @cards : (obs/c (listof monster-modifier?))
  on-add : (-> monster-modifier? any) = void
  on-remove : (-> exact-nonnegative-integer? any) = void
A view that permits swapping cards in or out of @cards, a subset of monster-modifier-deck according to absent-from-modifier-deck, by clicking <= and => arrows.

When a card is added via the <= arrow, calls on-add with the card. When a card is removed via the => arrow, calls on-remove with the cards index.

7.10.13 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] 
  #:on-update arbitrary-update) 
  (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
  arbitrary-update : (-> (-> monster-group? monster-group?) any)
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.

The arbitrary-update callback is invoked with a function that computes a new monster-group?; it is intended to update @mg for more complicated events that are logically a single step.

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.10.14 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-update arbitrary-update 
  #: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
  arbitrary-update : (-> (-> player? player?) any)
  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.

The arbitrary-update callback is invoked with a function that computes a new player?; it is intended to update @player for more complicated events that are logically a single step.

7.10.15 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.10.16 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