Example #1
0
        public string[] Process(IGameMaster gameMaster)
        {
            if (gameMaster.GameEndDate > ReceiveDate || gameMaster.GameStartDate > ReceiveDate || gameMaster.IsGameFinished)
            {
                return(null);
            }
            var messages = new  string[] { gameMaster.HandlePlacePieceRequest(this)?.Serialize() };

            gameMaster.LockObject();
            try
            {
                if (gameMaster.IsGameFinished && gameMaster.State == GameMasterState.GameResolved)
                {
                    var newGameMessages = gameMaster.RestartGame();
                    messages = messages.Union(newGameMessages).ToArray();
                }
            }
            catch (Exception e)
            { }
            finally
            {
                gameMaster.UnlockOject();
            }
            return(messages);
        }