Ejemplo n.º 1
0
        /// <summary>
        /// On WaitForMulligan state
        /// </summary>
        /// <returns>Seconds to be delayed before next call.</returns>
        private double OnRockMulligan()
        {
            if (this.currentAction == null)
            {
                this.ShowRockInfo("Mulligan");
                this.actionId += 1;
                // Force update sessionId when starting a new game.
                this.sessionId = Guid.NewGuid().ToString();
                var scene            = this.pegasus.SnapshotScene(this.sessionId, this.actionId);
                var mulliganedAction = this.bot.GetMulliganAction(scene);

                this.currentAction = new RockEngineAction(this.pegasus, mulliganedAction.Objects, mulliganedAction.Slot);
            }

            if (this.currentAction.IsDone())
            {
                MulliganManager.Get().GetMulliganButton().TriggerRelease();
                var scene = this.pegasus.SnapshotScene(this.sessionId, this.actionId);
                this.bot.ReportActionResult(scene);
                return(5);
            }

            this.currentAction.ApplyAll();
            return(1);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// On WaitForAction state
        /// </summary>
        /// <returns>Seconds to be delayed before next call.</returns>
        private double OnRockAction()
        {
            if (this.currentAction?.IsValid() == false)
            {
                this.currentAction = null;
            }

            if (this.currentAction?.IsDone() == true)
            {
                var scene = this.pegasus.SnapshotScene(this.sessionId, this.actionId);
                this.bot.ReportActionResult(scene);
            }

            if (this.currentAction == null || this.currentAction.IsDone())
            {
                this.actionId += 1;
                var scene      = this.pegasus.SnapshotScene(this.sessionId, this.actionId);
                var playAction = this.bot.GetPlayAction(scene);
                if (playAction.Objects != null && playAction.Objects.Count != 0)
                {
                    var rockActionContext = new RockEngineAction(this.pegasus, playAction.Objects, playAction.Slot);
                    if (rockActionContext.IsValid())
                    {
                        this.currentAction = rockActionContext;
                        this.ShowRockInfo(this.currentAction.Interpretation);
                    }
                    else
                    {
                        this.tracer.Warning("Invalid rockAction");
                        this.currentAction = null;
                        return(3);
                    }
                }
                else
                {
                    this.ShowRockInfo("Job's Done");
                    this.pegasus.DoEndTurn();
                    this.currentAction = null;
                    return(3);
                }
            }

            if (this.currentAction != null && this.currentAction.IsValid())
            {
                this.currentAction.Apply();
            }

            return(1);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// On WaitForAction state
        /// </summary>
        /// <returns>Seconds to be delayed before next call.</returns>
        private double OnRockAction()
        {
            if (EndTurnButton.Get().HasNoMorePlays())
            {
                this.ShowRockInfo("Job's Done");
                this.pegasus.DoEndTurn();
                this.currentAction = null;
                return(3);
            }

            if (this.currentAction == null || this.currentAction.IsDone() || !this.currentAction.IsValid())
            {
                var scene      = this.pegasus.SnapshotScene();
                var playAction = this.bot.GetPlayAction(scene);
                if (playAction.Objects != null && playAction.Objects.Count != 0)
                {
                    var rockActionContext = new RockEngineAction(this.pegasus, playAction.Objects, playAction.Slot);
                    if (rockActionContext.IsValid())
                    {
                        this.currentAction = rockActionContext;
                        this.ShowRockInfo(this.currentAction.Interpretation);
                    }
                    else
                    {
                        this.tracer.Warning("Invalid rockAction");
                    }
                }
                else
                {
                    this.ShowRockInfo("Job's Done");
                    this.pegasus.DoEndTurn();
                    return(3);
                }
            }

            if (this.currentAction != null && this.currentAction.IsValid())
            {
                this.currentAction.Apply();
            }

            return(1);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// On WaitForMulligan state
        /// </summary>
        /// <returns>Seconds to be delayed before next call.</returns>
        private double OnRockMulligan()
        {
            if (this.currentAction == null)
            {
                this.ShowRockInfo("Mulligan");
                var scene            = this.pegasus.SnapshotScene();
                var mulliganedAction = this.bot.GetMulliganAction(scene);

                this.currentAction = new RockEngineAction(this.pegasus, mulliganedAction.Objects, mulliganedAction.Slot);
            }

            if (this.currentAction.IsDone())
            {
                MulliganManager.Get().GetMulliganButton().TriggerRelease();
                return(5);
            }

            this.currentAction.ApplyAll();
            return(1);
        }