Documentation

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

Every legal move for player_id now, each with its intent and label. See Offers, intents and decisions.

  • The platform calls it only for seats in active_player_ids, and never after the game is over.
  • 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 move, such as passing or naming a city. The game names it. 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 move does in words, as a message from the game's catalogs, such as "offer.pass": "Pass" (Text in the player's language). A client shows it in the player's language, such as on a command's button. Only the seat that receives the offer sees it. An offer has no label until you give it one.
  • A label is a message like a log line's (Changing the state), with the same values, but no {player}: name a seat with player(id). A label that names a seat that is not seated, or that a message's other rules refuse, panics.
  • .revealing() marks a reveal (Hidden information).
  • The same action may be offered more than once with different inputs. A move matches if it 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. It needs at least one suggestion, because bots give only suggestions.
  • Integer takes min to max, both included, and when step is set, only min plus a multiple of step.
  • command_with panics on an input nobody can give, such as min above max.
  • Read the value in apply_action with action.text() or action.integer(). The platform has already checked that it fits.

A move that needs several values is 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