Apply an action
apply_action
Applies one step. Before the call, Boardweaver checks that the game offered this action to this seat, and that a command's value fits its input. Handle only the actions your offers returns.
- Return
Ok(())after the change. - Return
Err(reason)to refuse a step by a rule the offer cannot express, such as a city name another seat already took. Boardweaver discards every change the call made. - Write
reasonas a message from the game's catalogs:Err(msg!("refusal.city-taken", city = name)). The player sees it in their language. - A reason follows the rules of a label (Offers): it has no
{player}, and every seat it names must be seated. Otherwise the call panics. - Narrow the offers instead of refusing wherever you can.
- A panic is a bug. Boardweaver fails the step and records a match error (Builds, limits and errors).
Read a command's value with action.text() or action.integer(). Match a command by its name:
match action {
Action::Command { name, .. } if name == "pass" => {
table.log(msg!("log.passes"));
}
Action::PieceClick { space_id, index } => {
table.move_piece(space_id, *index, "discard");
}
_ => {}
}