From 66dbbe0efe8799ecdd8d9211bb1c33168314b1e2 Mon Sep 17 00:00:00 2001 From: ThePerkinrex Date: Tue, 12 Oct 2021 13:30:28 +0200 Subject: [PATCH] Initial game_finished addition --- README.md | 4 ++-- server/src/games/run.rs | 1 + server/src/games/run/functions.rs | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8482848..082f816 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ fn setup(data) { // Required return data; } -// turn_end(data, player) -> [data, next_player] +// turn_end(data, player) -> [data, next_player, has_finished] fn turn_end(data, player) { // Required print("Turn for " + player + " ending"); if data.fw { @@ -73,7 +73,7 @@ fn turn_end(data, player) { // Required }else{ player.sub(1); } - return [data, player]; + return [data, player, false]; } // turn_start(data, player) -> data diff --git a/server/src/games/run.rs b/server/src/games/run.rs index 18e15c9..529aa15 100644 --- a/server/src/games/run.rs +++ b/server/src/games/run.rs @@ -139,6 +139,7 @@ impl RunningGame { let mut arr = self.functions.turn_end(data, self.current_player).unwrap(); self.save_data(&arr[0]).unwrap(); self.current_player = arr.remove(1).cast(); + let has_finished: bool = arr.remove(1).cast(); self.turn_start(); } diff --git a/server/src/games/run/functions.rs b/server/src/games/run/functions.rs index a9c85e6..4aba2e6 100644 --- a/server/src/games/run/functions.rs +++ b/server/src/games/run/functions.rs @@ -54,7 +54,6 @@ impl Functions { pub fn turn_end(&self, d: Dynamic, p: Player) -> RhaiResult { self.engine .call_fn(&mut Scope::new(), &self.ast, "turn_end", (d, p)) - // TODO Check if the game has ended (With variable in the scope) } pub fn on_click(