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> },
}
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 move, such as passing or naming a city. The game names it. 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 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 withplayer(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"))
Texttakes 1 tomax_lencharacters. It needs at least one suggestion, because bots give only suggestions.Integertakesmintomax, both included, and whenstepis set, onlyminplus a multiple ofstep.command_withpanics on an input nobody can give, such asminabovemax.- Read the value in
apply_actionwithaction.text()oraction.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.