Fixed game api methods

This commit is contained in:
AlphaCodingPilot 2022-12-31 17:30:24 +01:00
commit 67a256ebaf
2 changed files with 55 additions and 69 deletions

View file

@ -1,69 +0,0 @@
use std::arch::asm;
struct Game;
enum MoveData {}
struct Options;
type PlayerIndex = u32;
struct LogSliceOptions {
player: Option<PlayerIndex>,
start: u32,
end: Option<u32>,
}
struct LogData;
// Game API methods, see https://docs.boardgamers.space/guide/engine-api.html#required-methods
#[export_name = "init"]
pub async extern fn init(players: u32, expansions: Vec<str>, options: Options, seed: String, creator: Option<PlayerIndex>) -> Game {
return Game{}
}
#[export_name = "move"]
pub extern fn execute_move(mut game: Game, move_data: MoveData, player: PlayerIndex) -> Game {
return game;
}
#[export_name = "ended"]
pub extern fn ended(game: Game) -> bool {
return false;
}
#[export_name = "scores"]
pub extern fn scores(game: Game) -> Vec<u32> {
return Vec::new();
}
#[export_name = "dropPlayer"]
pub async extern fn dropPlayer(mut game: Game, player: PlayerIndex) -> Game {
return game;
}
#[export_name = "currentPlayer"]
pub async extern fn currentPlayer(game: Game) -> Option<PlayerIndex> {
return Option::None;
}
#[export_name = "logLength"]
pub async extern fn logLength(game: Game) -> u32 {
return 0;
}
#[export_name = "logSlice"]
pub async extern fn logSlice(game: Game, options: LogSliceOptions) -> LogData {
return LogData;
}

55
server/src/game_api.rs Normal file
View file

@ -0,0 +1,55 @@
pub struct GameData;
pub struct Move;
pub struct GameOptions;
pub struct LogSliceOptions {
player: Option<usize>,
start: u32,
end: Option<u32>,
}
pub struct LogData;
// Game API methods, see https://docs.boardgamers.space/guide/engine-api.html#required-methods
#[export_name = "init"]
pub async extern fn init(players: u32, expansions: Vec<String>, options: GameOptions, seed: String, creator: Option<usize>) -> GameData {
todo!()
}
#[export_name = "move"]
pub extern fn execute_move(game: GameData, move_data: Move, player: usize) -> GameData {
todo!()
}
#[export_name = "ended"]
pub extern fn ended(game: GameData) -> bool {
todo!()
}
#[export_name = "scores"]
pub extern fn scores(game: GameData) -> Vec<u32> {
todo!()
}
#[export_name = "dropPlayer"]
pub async extern fn drop_player(game: GameData, player: usize) -> GameData {
todo!()
}
#[export_name = "currentPlayer"]
pub async extern fn current_player(game: GameData) -> Option<usize> {
todo!()
}
#[export_name = "logLength"]
pub async extern fn log_length(game: GameData) -> u32 {
todo!()
}
#[export_name = "logSlice"]
pub async extern fn log_slice(game: GameData, options: LogSliceOptions) -> LogData {
todo!()
}