private void LoginCommand_OnExecuted(object sender, ExecutedEventArgs e) { if(string.IsNullOrEmpty(Nickname)) { LoginText = "Name Cannot Be Empty"; } else { ServiceLocator.Get<ClientComms>().GameConnect(); ServiceLocator.Get<ClientComms>().ChatConnect(Nickname); } }
private void AddPlayerCommand_OnExecuted(object sender, ExecutedEventArgs e) { string name = ServiceLocator.Get<LoginViewModel>().Nickname; switch (e.Command.Name) { case "AddPlayer1Command" : if (AddPlayer1ButtonContent == "Join") { AddPlayer(1, name); AddPlayer1ButtonContent = "Remove"; ServiceLocator.Get<ClientComms>().AddPlayerToGame(1); } else { RemovePlayer(1, name); AddPlayer1ButtonContent = "Join"; ServiceLocator.Get<ClientComms>().RemovePlayerFromGame(1); } break; case "AddPlayer2Command" : if (AddPlayer2ButtonContent == "Join") { AddPlayer(2, name); AddPlayer2ButtonContent = "Remove"; ServiceLocator.Get<ClientComms>().AddPlayerToGame(2); } else { RemovePlayer(2, name); AddPlayer2ButtonContent = "Join"; ServiceLocator.Get<ClientComms>().RemovePlayerFromGame(2); } break; case "AddPlayer3Command": if (AddPlayer3ButtonContent == "Join") { AddPlayer(3, name); AddPlayer3ButtonContent = "Remove"; ServiceLocator.Get<ClientComms>().AddPlayerToGame(3); } else { RemovePlayer(3, name); AddPlayer3ButtonContent = "Join"; ServiceLocator.Get<ClientComms>().RemovePlayerFromGame(3); } break; case "AddPlayer4Command": if (AddPlayer4ButtonContent == "Join") { AddPlayer(4, name); AddPlayer4ButtonContent = "Remove"; ServiceLocator.Get<ClientComms>().AddPlayerToGame(4); } else { RemovePlayer(4, name); AddPlayer4ButtonContent = "Join"; ServiceLocator.Get<ClientComms>().RemovePlayerFromGame(4); } break; case "AddPlayer5Command": if (AddPlayer5ButtonContent == "Join") { AddPlayer(5, name); AddPlayer5ButtonContent = "Remove"; ServiceLocator.Get<ClientComms>().AddPlayerToGame(5); } else { RemovePlayer(5, name); AddPlayer5ButtonContent = "Join"; ServiceLocator.Get<ClientComms>().RemovePlayerFromGame(5); } break; } }
private void StandCommand_OnExecuted(object sender, ExecutedEventArgs e) { StopTimer(); ServiceLocator.Get<ClientComms>().Stand(players.Where(p => p.ActivePlayer).First().PlayerId); Stand(); }
private void InsuranceCommand_OnExecuted(object sender, ExecutedEventArgs e) { ActiveInsurance = false; }
private void SplitCommand_OnExecuted(object sender, ExecutedEventArgs e) { StopTimer(); PlayerViewModel player = players.Where(p => p.ActivePlayer).First(); HandViewModel hand = player.HandCollection.Where(h => h.ActiveHand).First(); ServiceLocator.Get<ClientComms>().Split(player.PlayerId, hand.HandId); Split(); }
private void DoneBetting_OnExecuted(object sender, ExecutedEventArgs e) { //ServiceLocator.Get<PlayerCollectionViewModel>().CanAddPlayer = false; CanDoneBetting = false; List<PlayerViewModel> myPlayers = ServiceLocator.Get<PlayerCollectionViewModel>().PlayerCollection.Where( p => p.PlayerName == ServiceLocator.Get<LoginViewModel>().Nickname).ToList(); if (myPlayers.IndexOf(myPlayers.Where(p => p.ActivePlayer).First()) == myPlayers.Count - 1) { dealing = true; ServiceLocator.Get<ClientComms>().DealCards(); //Deal(); } ServiceLocator.Get<PlayerCollectionViewModel>().SetNextActivePlayer(); }
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; }
private void SendMessageCommand_OnExecuted(object sender, ExecutedEventArgs e) { ServiceLocator.Get<ClientComms>().Send(); }
/// <summary> /// Executes the command /// </summary> /// <param name="parameter">The parameter.</param> public virtual void Execute(object parameter) { if (this.RaiseCanExecute(parameter)) { if (this.Executed != null) { ExecutedEventArgs e = new ExecutedEventArgs(this, parameter); this.Executed(this, e); } } }