Game logic

v3 · Preview

Framework v3 is an opt-in preview available to everyone. New games use the stable framework by default.

Offer actions

offers

Returns every offer player_id may take now, each with its intent and label. See Offers, intents and decisions.

  • Boardweaver calls it only for seats in active_player_ids, and never once is_game_over returns true.
  • It also runs on the seat's view, where hidden parts are missing (Hidden information).
  • Return an empty list when the seat has nothing to do.

Actions

pub enum Action {
    SpaceClick { space_id: String },
    PieceClick { space_id: String, index: usize },
    Command { name: String, value: Option<InputValue> },
}
  • SpaceClick and PieceClick are clicks on the board. A piece click names the piece by its index in the state the game logic receives.
  • A Command is every other step, such as passing or naming a city. The game names it, and the client draws its button. Make one with Action::command("pass"), and match it with Action::Command { name, .. }.

Offers

Offer::new(Action::command("pass"), Intent::Confirm).label(msg!("offer.pass"))
  • .label(message) says what the step does, as a message from the game's catalogs, such as "offer.pass": "Pass" (Text in the player's language). The client shows it in the player's language, such as on a command's button. Only the seat that receives the offer sees it. Give every offer a label: an offer has none until you set one.
  • A label is a message like a log line's (Changing the state), with the same values. It has no {player}: name a seat with player(id). A label that names a seat that is not seated panics, as does one that breaks another message limit (Builds, limits and errors).
  • .revealing() marks a reveal (Hidden information).
  • You may offer the same action more than once with different inputs. A step matches when its value fits any of them.

Command inputs

A command may ask for one value:

Offer::command_with(
    "name-city",
    Input::Text { max_len: 24, suggestions: vec!["Aldmoor".into(), "Brennick".into()] },
    Intent::Choice,
)
.label(msg!("offer.name-city"))

Offer::command_with(
    "bid",
    Input::Integer { min: 0, max: coins, step: Some(5) },
    Intent::Confirm,
)
.label(msg!("offer.bid"))
  • Text takes 1 to max_len characters. Give it at least one suggestion that fits, because a bot gives only suggestions.
  • Integer takes min to max, both included. When step is set, it takes only min plus a multiple of step.
  • command_with panics on an input nobody can give, such as min above max or a text input with no suggestions.
  • Read the value in apply_action with action.text() or action.integer(). Boardweaver has already checked that it fits.

Split a step that needs several values into several steps, one value each, so each step can narrow the next. "Give 3 wood to Ana" is three steps: a Choice of Ana, a Choice of wood, then a Confirm of the amount, whose max is the wood the seat holds.

Need a hand with this?

Join our Discord