Registry / Framework

framework · v0.1.2
Game Rounds
Advance a fixed-length round counter through scoring, disputes and finalization.
Use Game Rounds
use vendor::game_rounds::game_rounds;
Run the example
nest demo game_rounds@0.1.2
blyxc native-run game_rounds-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::game_rounds::game_rounds;
fn main() {
let arguments = cli_args();
if args_len(arguments) > 0 {
if args_len(arguments) % 2 != 0 {
stderr_line("Expected event and value pairs");
process_exit(2);
}
let mut live = game_rounds_start();
let mut i = 0;
while i < args_len(arguments) {
let input = args_at(arguments, i + 1);
if !text_is_number(input) {
stderr_line("Expected a whole numeric event value");
process_exit(2);
}
live = game_rounds_step(live, args_at(arguments, i), text_number(input));
let command = game_rounds_command(live);
println!(command);
if command == "reject" { process_exit(1); }
i += 2;
}
return;
}
let mut state = game_rounds_start();
state = game_rounds_step(state, "rounds", 2.0);
println!(game_rounds_command(state));
state = game_rounds_step(state, "score", 0.0);
println!(game_rounds_command(state));
state = game_rounds_step(state, "challenge", 0.0);
println!(game_rounds_command(state));
state = game_rounds_step(state, "score", 0.0);
println!(game_rounds_command(state));
state = game_rounds_step(state, "accept", 0.0);
println!(game_rounds_command(state));
state = game_rounds_step(state, "score", 0.0);
println!(game_rounds_command(state));
state = game_rounds_step(state, "accept", 0.0);
println!(game_rounds_command(state));
}
Expected output
start_round
confirm_score
replay_round
confirm_score
next_round
confirm_score
close_series
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.2 | Download ZIP · Browse files | 34b90f8503 | ba53634f7e0da395716bbf4d232747389ee01bdedb90402b9b29b2a7e184eece |
| 0.1.1 | Download ZIP · Browse files | af44976d1c | 831733c4d9a006c322b03b6f6589c63dda63b13d3951878a311bb22494770ff9 |
| 0.1.0 | Download ZIP · Browse files | 6349f23784 | 50d8b7fc06b836b78fcdd9856b2e2edb4907e1ae9c04021b37d09ebb100ef64d |