コード例 #1
0
 /// <inheritdoc/>
 public void SendTrigger(Common.GameTrigger trigger)
 {
     if (this.stateMachine != null)
     {
         Console.WriteLine(string.Format("Received trigger {0}", trigger.ToString()));
         this.stateMachine.Fire(trigger);
     }
 }
コード例 #2
0
 private void ValidateTrigger(Common.GameTrigger trigger, HashSet <Common.GameTrigger> allowedTriggers, string phaseName)
 {
     if (!allowedTriggers.Contains(trigger))
     {
         throw new ArgumentException(
                   string.Format("The UI allowed the user to send the {0} trigger which is not allowed in the {1} phase.", trigger.ToString(), phaseName)
                   );
     }
 }
コード例 #3
0
        private void HandleBidOrPass(Common.GameTrigger bidTriggerType, GameLogic.PlayerPositionEventArgs e)
        {
            var potentialBid = this.currentBidAmount + 10;

            Common.GameTrigger trigger;
            if (this.IsUser(e.PlayerPosition))
            {
                trigger = this.userInterface.LetUserDoCounterBidOrPass(potentialBid);
                this.ValidateTrigger(trigger, BidOrPassTriggers, "bidding");
                if (trigger == Common.GameTrigger.BidPlaced)
                {
                    trigger = bidTriggerType; // might be bid or counterbid
                }
                this.currentStateStack.DeltaChanges.Add(new GameStateChangeInfo()
                {
                    HumanTrigger = trigger
                });
            }
            else
            {
                // TODO: Implement AI
                if (this.currentBidAmount < (150 + 20 * e.PlayerPosition))
                {
                    trigger = bidTriggerType;
                }
                else
                {
                    trigger = Common.GameTrigger.Passed;
                }
            }

            if (trigger == Common.GameTrigger.Passed)
            {
                this.userInterface.DisplayPlayerAsPassed(e.PlayerPosition);
            }
            else
            {
                this.currentBidAmount = potentialBid;
                if (!this.IsUser(e.PlayerPosition))
                {
                    this.userInterface.DisplayAIBid(e.PlayerPosition, this.currentBidAmount);
                }
            }
            this.stateBridge.TriggerSink.SendTrigger(trigger);
        }