Example #1
0
 public PlayerViewModel()
 {
     HandCollection = new AsyncObservableCollection<HandViewModel>();
     HandViewModel NewHand = new HandViewModel(0, 0, 1, 1);
     HandCollection.Add(NewHand);
     ActivePlayer = false;
     PlayerPlaceHolder = @"/BlackJackSL;component/Images/Player" + PlayerId + "PlaceHolder.png";
     SetPlayerPositions();
     IsInPlay();
     Commands.InsuranceCommand.CanExecute += (sender, e) => e.CanExecute = ActiveInsurance;
     Commands.InsuranceCommand.Executed += InsuranceCommand_OnExecuted;
 }
Example #2
0
 public void SetActiveHand(HandViewModel hand)
 {
     foreach (var player in ServiceLocator.Get<PlayerCollectionViewModel>().PlayerCollection)
     {
         foreach (var h in player.HandCollection)
         {
             h.ActiveHand = false;
         }
     }
     //if (HandCollection.Where(p => p.ActiveHand).Any())
     //    HandCollection.Where(p => p.ActiveHand).First().ActiveHand = false;
     hand.ActiveHand = true;
 }
Example #3
0
 private void BetCommand_OnExecuted(object sender, ExecutedEventArgs e)
 {
     //ServiceLocator.Get<PlayerCollectionViewModel>().CanAddPlayer = false;
     if (gameFinished)
     {
         dealer.ClearDealer();
         foreach (var player in players.Where(p => p.PlayerName == ServiceLocator.Get<LoginViewModel>().Nickname))
         {
             ServiceLocator.Get<ClientComms>().ClearPlayers();
             player.ClearPlayer();
             betting = false;
             dealing = false;
             dealt = false;
             playing = false;
             dealerPlaying = false;
             gameFinished = false;
         }
     }
     betting = true;
     double betAmount = 0;
     switch (e.Command.Name)
     {
         case "Bet10Command":
             betAmount = 10.00;
             break;
         case "Bet20Command":
             betAmount = 20.00;
             break;
         case "Bet50Command":
             betAmount = 50.00;
             break;
         case "Bet100Command":
             betAmount = 100.00;
             break;
     }
     PlayerViewModel activePlayer = players.Where(p => p.ActivePlayer).First();
     if (activePlayer.HandCollection.Count == 0)
     {
         HandViewModel NewHand = new HandViewModel(0, 0, 1, 1);
         activePlayer.HandCollection.Add(NewHand);
     }
     activePlayer.HandCollection[0].HandPot += betAmount;
     OverallPlayerBank -= betAmount;
     playSound.SetSource(Application.GetResourceStream(new Uri("/BlackJackSL;component/Sounds/betchip.mp3", UriKind.RelativeOrAbsolute)).Stream);
     activePlayer.HandCollection[0].AddChip(betAmount);
     ServiceLocator.Get<ClientComms>().AddPlayerChips(activePlayer.PlayerId, betAmount);
     CanDoneBetting = true;
 }
Example #4
0
        public void ClearPlayer()
        {
            //foreach (var hand in HandCollection)
            //{
            //    hand.IsSplitLeft = false;
            //    hand.ActiveHand = false;
            //    hand.CardCollection.Clear();
            //    hand.HandTotal = 0;
            //    hand.HandPot = 0;
            //}

            if (!PlayerInPlay)
                PlayerInPlay = true;
            HandCollection.Clear();
            HandViewModel NewHand = new HandViewModel(0, 0, 1, 1);
            HandCollection.Add(NewHand);
        }
Example #5
0
 public void SplitChips(HandViewModel hand)
 {
     foreach (var chip in hand.ChipCollection)
     {
         AddChip(chip.ChipValue);
         Thread.Sleep(20);
     }
     Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             HandPot = hand.HandPot;
         });
 }