Example #1
0
        public GetBet(GameServant g, UI_Sketch ui)
        {
            InitializeComponent();
            this.Title += String.Format(" ({0} available)", g.PlayerFunds.Substring(7));
            t = new System.Timers.Timer(100);
            t.Elapsed += t_Elapsed;
            game = g;
            if (ui != null) {
                ui.csDealerNormal.Cards.Clear();
                ui.csPlayerNormal.Cards.Clear();
                ui.csPlayerSplit.Cards.Clear();
                ui.btnNormalHit.IsEnabled = false;
                ui.btnNormalStand.IsEnabled = false;
                ui.paint();
                ui.Visibility = System.Windows.Visibility.Visible;
            }
            if (Application.Current != null) {
                Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new Action(delegate {
                }));
            }
            this.ShowDialog();

            Binding bind = new Binding("IsNormalActive");
            bind.Source = game;
            ui.btnNormalHit.SetBinding(Button.IsEnabledProperty, bind);
            ui.btnNormalStand.SetBinding(Button.IsEnabledProperty, bind);

            txtBet.Focus();
            //t.Start();
        }
Example #2
0
        internal void NewRound(UI_Sketch ui = null)
        {
            l("New Round", false);
            _playerHand.PutCardsBack();

            _dealerHand.DiscardAll();
            NotifyAll();
            _displayHole = false;
            ActiveHand = ActiveHandPotentials.Normal;

            if (PlayerHand.Cash < MIN_BET) {
                l("Cash is less than MIN_BET", false);
                throw new IllegalMoveException("I can't do that, Dave.");
            }
            l("Retrieving bet", false);
            var b = new GetBet(this, ui);
            l("Making bet", false);
            PlayerHand.makeBet(b.Bet);
            b.Close();

            l("Player draws 2 cards", false);
            _playerHand.Draw(2);

            l("Dealer draws 2 cards", false);
            _dealerHand.Draw(2);
            NotifyAll();
            l("Cards drawn");

            if (_playerHand.IsBlackjack) {
                l("Player drew Blackjack");
                throw new BlackjackException();
            }

            NotifyAll();
        }