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 onceis_game_overreturnstrue. - 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> },
}
SpaceClickandPieceClickare clicks on the board. A piece click names the piece by its index in the state the game logic receives.- A
Commandis every other step, such as passing or naming a city. The game names it, and the client draws its button. Make one withAction::command("pass"), and match it withAction::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 withplayer(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"))
Texttakes 1 tomax_lencharacters. Give it at least one suggestion that fits, because a bot gives only suggestions.Integertakesmintomax, both included. Whenstepis set, it takes onlyminplus a multiple ofstep.command_withpanics on an input nobody can give, such asminabovemaxor a text input with no suggestions.- Read the value in
apply_actionwithaction.text()oraction.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.