Exemple #1
0
        /// <summary>
        /// Generate a play action for current scene.
        /// </summary>
        /// <param name="scene">The scene.</param>
        /// <returns>The cards to be played.</returns>
        public RockAction GetPlayAction(RockScene scene)
        {
            this.tracer.Verbose(RockJsonSerializer.Serialize(scene));

            try
            {
                if (string.IsNullOrEmpty(this.configuration.BotEndpoint))
                {
                    var robot  = new Bot.RockBot();
                    var action = robot.GetPlayAction(scene);
                    this.tracer.Verbose(RockJsonSerializer.Serialize(action));
                    return(action);
                }
                else
                {
                    var apiClient = new RockApiClient();
                    var action    = apiClient.Post <RockAction>($"{this.configuration.BotEndpoint}{RockConstants.DefaultBotPlayRelativePath}", scene);
                    this.tracer.Verbose(RockJsonSerializer.Serialize(action));
                    return(action);
                }
            }
            catch (Exception e)
            {
                this.tracer.Error($"Unexpected Exception from Bot: {e}");
                return(RockAction.Create());
            }
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RockTracer" /> class.
 /// </summary>
 /// <param name="configuration">The RockConfiguration.</param>
 public RockTracer(RockConfiguration configuration)
 {
     this.configuration = configuration;
     this.webApiClient  = new RockApiClient();
 }