static public async Task <Game> MakeGame(ServerWorker serverWorker, int idPlayer = -1, int idGame = -1) { idGame = (await serverWorker.TaskPlayGame(idPlayer: idPlayer, idGame: idGame)).IdGame; Game game = await serverWorker.TaskGetGame(idGame : idGame); game.Turns = await serverWorker.TaskGetGameTurns(idGame); return(game); }
static private async Task <bool> StartGame(ServerWorker serverWorker, Game game, Func <bool> isCancel) { GameStateEnum GameState = game.GameState; while (GameState != GameStateEnum.ACTIVE && GameState != GameStateEnum.WAIT) { if (isCancel()) { return(false); } await Task.Delay(1000); GameState = (await serverWorker.TaskPlayGame(idGame: game.IdGame)).GameState; } return(true); }