public void EndGame() { var state = GameLayer?.GetState(); if (state == null) { return; } var ended = state.Turn >= state.MaxTurns; if (ended) { // Automatic ending } else { // Ends a game prematurely // This is not needed to end a game that has been completed by playing all turns. GameLayer.EndGame(state.GameId); _logger.LogInformation("Game ended prematurely"); // Sleep again to make sure the API and Database has ended the game Thread.Sleep(5000); _logger.LogInformation("Finished sleeping after signaled Api that the game has ended"); } }
public static void Main(string[] args) { Helper.INIT(); try { GameLayer.EndGame(); } catch (Exception e) { } var gameId = GameLayer.NewGame(Map); Console.WriteLine($"Starting game: {GameLayer.GetState().GameId}"); GameLayer.StartGame(gameId); var state = GameLayer.GetState(); while (GameLayer.GetState().Turn < GameLayer.GetState().MaxTurns) { //Console.WriteLine(GameLayer.GetState().CurrentTemp); NewTakeTurn(); //take_turn(gameId); foreach (var message in GameLayer.GetState().Messages) { Console.WriteLine(message); } foreach (var error in GameLayer.GetState().Errors) { Console.WriteLine("Error: " + error); } } Console.WriteLine($"Done with game: {GameLayer.GetState().GameId}"); Console.WriteLine(GameLayer.GetScore(gameId).FinalScore); }