示例#1
0
        public bool ProcessAction(ActionBase action)
        {
            if (GameStage == null)
            {
                return(false);
            }
            if (!CheckAndSetBusy())
            {
                return(false);
            }

            try {
                var validPlayerActions = GetValidActionIdList(action.PlayerInfo.PlayerId);
                if (!validPlayerActions.Contains(action.GetActionId()))
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                Log.Error($"Exception in GetValidActionIdList of ProcessAction: {e.Message}", e);
                throw;
            }

            RunBusyAction(() =>
            {
                try {
                    GameStage.ProcessAction(action);
                }
                catch (Exception e)
                {
                    Log.Error($"Exception in ProcessAction: {e}", e);
                    throw;
                }
                try {
                    UpdatePlayers();
                }
                catch (Exception e)
                {
                    Log.Error($"Exception in UpdatePlayers: {e.Message}", e);
                    throw;
                }
            });
            return(true);
        }