public BaseResult<LogonResult> Logon(LogonRequest logon) { var validator = new LogonRequestValidator(); var results = validator.Validate(logon); if (results.IsValid) { return _gameManager.Execute(logon); } else { return BaseResult<LogonResult>.Fail(errors:results.Errors.Select(e => e.ErrorMessage)); } }
public LogonResult Execute(LogonRequest request) { // check for waiting games and log players into that var game = GetWaitingGame(); if(game != null) { game.Waiting = false; return game.LogonPlayer(request.AgentName); } else { game = GetNewGame(); game.Waiting = true; game.Start(); game.StartDemoAgent("Demo"); return game.LogonPlayer(request.AgentName); } }