Exemplo n.º 1
0
        private async void SaveResultsButton_Clicked()
        {
            int sum = Player1Input + Player2Input + Player3Input + Player4Input + Player5Input + Player6Input;

            if (CurrentGame.Equals("Queens"))
            {
                if (sum == 4)
                {
                    Continue = true;
                    if (Players.Count == 4)
                    {
                        Players[0].Score = Player1Input * QueensScore;
                        Players[1].Score = Player2Input * QueensScore;
                        Players[2].Score = Player3Input * QueensScore;
                        Players[3].Score = Player4Input * QueensScore;

                        EventAggregator.GetEvent <ScoreSentEvent>().Publish(Players);
                    }
                    else if (Players.Count == 5)
                    {
                        Players[0].Score = Player1Input * QueensScore;
                        Players[1].Score = Player2Input * QueensScore;
                        Players[2].Score = Player3Input * QueensScore;
                        Players[3].Score = Player4Input * QueensScore;
                        Players[4].Score = Player5Input * QueensScore;

                        EventAggregator.GetEvent <ScoreSentEvent5Players>().Publish(Players);
                    }
                    else
                    {
                        Players[0].Score = Player1Input * QueensScore;
                        Players[1].Score = Player2Input * QueensScore;
                        Players[2].Score = Player3Input * QueensScore;
                        Players[3].Score = Player4Input * QueensScore;
                        Players[4].Score = Player5Input * QueensScore;
                        Players[5].Score = Player6Input * QueensScore;

                        EventAggregator.GetEvent <ScoreSentEvent6Players>().Publish(Players);
                    }
                }
                else
                {
                    await DialogService.DisplayAlertAsync("", "Queens game should have 4 queens", "OK");
                }
            }
            else if (CurrentGame.Equals("Diamonds"))
            {
                if (Players.Count == 4)
                {
                    if (sum == 8)
                    {
                        Continue = true;

                        Players[0].Score = Player1Input * DiamondsScore;
                        Players[1].Score = Player2Input * DiamondsScore;
                        Players[2].Score = Player3Input * DiamondsScore;
                        Players[3].Score = Player4Input * DiamondsScore;

                        EventAggregator.GetEvent <ScoreSentEvent>().Publish(Players);
                    }
                    else
                    {
                        await DialogService.DisplayAlertAsync("", "Diamonds game should have 8 diamonds", "OK");
                    }
                }
                else if (Players.Count == 5)
                {
                    if (sum == 10)
                    {
                        Continue = true;

                        Players[0].Score = Player1Input * DiamondsScore;
                        Players[1].Score = Player2Input * DiamondsScore;
                        Players[2].Score = Player3Input * DiamondsScore;
                        Players[3].Score = Player4Input * DiamondsScore;
                        Players[4].Score = Player5Input * DiamondsScore;

                        EventAggregator.GetEvent <ScoreSentEvent5Players>().Publish(Players);
                    }
                    else
                    {
                        await DialogService.DisplayAlertAsync("", "Diamonds game should have 10 diamonds", "OK");
                    }
                }
                else
                {
                    if (sum == 12)
                    {
                        Continue = true;

                        Players[0].Score = Player1Input * DiamondsScore;
                        Players[1].Score = Player2Input * DiamondsScore;
                        Players[2].Score = Player3Input * DiamondsScore;
                        Players[3].Score = Player4Input * DiamondsScore;
                        Players[4].Score = Player5Input * DiamondsScore;
                        Players[5].Score = Player6Input * DiamondsScore;

                        EventAggregator.GetEvent <ScoreSentEvent6Players>().Publish(Players);
                    }
                    else
                    {
                        await DialogService.DisplayAlertAsync("", "Diamonds game should have 12 diamonds", "OK");
                    }
                }
            }
            else if (CurrentGame.Equals("Whist"))
            {
                if (sum == 8)
                {
                    Continue = true;
                    if (Players.Count == 4)
                    {
                        Players[0].Score = Player1Input * WhistScore;
                        Players[1].Score = Player2Input * WhistScore;
                        Players[2].Score = Player3Input * WhistScore;
                        Players[3].Score = Player4Input * WhistScore;

                        EventAggregator.GetEvent <ScoreSentEvent>().Publish(Players);
                    }
                    else if (Players.Count == 5)
                    {
                        Players[0].Score = Player1Input * WhistScore;
                        Players[1].Score = Player2Input * WhistScore;
                        Players[2].Score = Player3Input * WhistScore;
                        Players[3].Score = Player4Input * WhistScore;
                        Players[4].Score = Player5Input * WhistScore;

                        EventAggregator.GetEvent <ScoreSentEvent5Players>().Publish(Players);
                    }
                    else
                    {
                        Players[0].Score = Player1Input * WhistScore;
                        Players[1].Score = Player2Input * WhistScore;
                        Players[2].Score = Player3Input * WhistScore;
                        Players[3].Score = Player4Input * WhistScore;
                        Players[4].Score = Player5Input * WhistScore;
                        Players[5].Score = Player6Input * WhistScore;

                        EventAggregator.GetEvent <ScoreSentEvent6Players>().Publish(Players);
                    }
                }
                else
                {
                    await DialogService.DisplayAlertAsync("", "Whist game should have 8 hands", "OK");
                }
            }
            else if (CurrentGame.Equals("Levate"))
            {
                if (sum == 8)
                {
                    Continue = true;
                    if (Players.Count == 4)
                    {
                        Players[0].Score = Player1Input * LevateScore;
                        Players[1].Score = Player2Input * LevateScore;
                        Players[2].Score = Player3Input * LevateScore;
                        Players[3].Score = Player4Input * LevateScore;

                        EventAggregator.GetEvent <ScoreSentEvent>().Publish(Players);
                    }
                    else if (Players.Count == 5)
                    {
                        Players[0].Score = Player1Input * LevateScore;
                        Players[1].Score = Player2Input * LevateScore;
                        Players[2].Score = Player3Input * LevateScore;
                        Players[3].Score = Player4Input * LevateScore;
                        Players[4].Score = Player5Input * LevateScore;

                        EventAggregator.GetEvent <ScoreSentEvent5Players>().Publish(Players);
                    }
                    else
                    {
                        Players[0].Score = Player1Input * LevateScore;
                        Players[1].Score = Player2Input * LevateScore;
                        Players[2].Score = Player3Input * LevateScore;
                        Players[3].Score = Player4Input * LevateScore;
                        Players[4].Score = Player5Input * LevateScore;
                        Players[5].Score = Player6Input * LevateScore;

                        EventAggregator.GetEvent <ScoreSentEvent6Players>().Publish(Players);
                    }
                }
                else
                {
                    await DialogService.DisplayAlertAsync("", "Levate game should have 8 hands", "OK");
                }
            }
        }
Exemplo n.º 2
0
        private async void SaveResultsButton_Clicked()
        {
            bool sum = Player1Input || Player2Input || Player3Input || Player4Input || Player5Input || Player6Input;

            if (CurrentGame.Equals("King"))
            {
                if (sum)
                {
                    Continue = true;

                    if (Players.Count == 4)
                    {
                        if (Player1Input)
                        {
                            Players[0].Score = KingScore;
                        }
                        else if (Player2Input)
                        {
                            Players[1].Score = KingScore;
                        }
                        else if (Player3Input)
                        {
                            Players[2].Score = KingScore;
                        }
                        else if (Player4Input)
                        {
                            Players[3].Score = KingScore;
                        }

                        EventAggregator.GetEvent <ScoreSentEvent>().Publish(Players);
                    }
                    else if (Players.Count == 5)
                    {
                        if (Player1Input)
                        {
                            Players[0].Score = KingScore;
                        }
                        else if (Player2Input)
                        {
                            Players[1].Score = KingScore;
                        }
                        else if (Player3Input)
                        {
                            Players[2].Score = KingScore;
                        }
                        else if (Player4Input)
                        {
                            Players[3].Score = KingScore;
                        }
                        else if (Player5Input)
                        {
                            Players[4].Score = KingScore;
                        }

                        EventAggregator.GetEvent <ScoreSentEvent5Players>().Publish(Players);
                    }
                    else
                    {
                        if (Player1Input)
                        {
                            Players[0].Score = KingScore;
                        }
                        else if (Player2Input)
                        {
                            Players[1].Score = KingScore;
                        }
                        else if (Player3Input)
                        {
                            Players[2].Score = KingScore;
                        }
                        else if (Player4Input)
                        {
                            Players[3].Score = KingScore;
                        }
                        else if (Player5Input)
                        {
                            Players[4].Score = KingScore;
                        }
                        else if (Player6Input)
                        {
                            Players[5].Score = KingScore;
                        }

                        EventAggregator.GetEvent <ScoreSentEvent6Players>().Publish(Players);
                    }
                }
                else
                {
                    await DialogService.DisplayAlertAsync("", "Select one player for the King Of Hearts game", "OK");
                }
            }
            else if (CurrentGame.Equals("Ten"))
            {
                if (sum)
                {
                    Continue = true;

                    if (Players.Count == 4)
                    {
                        if (Player1Input)
                        {
                            Players[0].Score = TenScore;
                        }
                        else if (Player2Input)
                        {
                            Players[1].Score = TenScore;
                        }
                        else if (Player3Input)
                        {
                            Players[2].Score = TenScore;
                        }
                        else if (Player4Input)
                        {
                            Players[3].Score = TenScore;
                        }

                        EventAggregator.GetEvent <ScoreSentEvent>().Publish(Players);
                    }
                    else if (Players.Count == 5)
                    {
                        if (Player1Input)
                        {
                            Players[0].Score = TenScore;
                        }
                        else if (Player2Input)
                        {
                            Players[1].Score = TenScore;
                        }
                        else if (Player3Input)
                        {
                            Players[2].Score = TenScore;
                        }
                        else if (Player4Input)
                        {
                            Players[3].Score = TenScore;
                        }
                        else if (Player5Input)
                        {
                            Players[4].Score = TenScore;
                        }

                        EventAggregator.GetEvent <ScoreSentEvent5Players>().Publish(Players);
                    }
                    else
                    {
                        if (Player1Input)
                        {
                            Players[0].Score = TenScore;
                        }
                        else if (Player2Input)
                        {
                            Players[1].Score = TenScore;
                        }
                        else if (Player3Input)
                        {
                            Players[2].Score = TenScore;
                        }
                        else if (Player4Input)
                        {
                            Players[3].Score = TenScore;
                        }
                        else if (Player5Input)
                        {
                            Players[4].Score = TenScore;
                        }
                        else if (Player6Input)
                        {
                            Players[5].Score = TenScore;
                        }

                        EventAggregator.GetEvent <ScoreSentEvent6Players>().Publish(Players);
                    }
                }
                else
                {
                    await DialogService.DisplayAlertAsync("", "Select one player for the Ten Of Clubs game", "OK");
                }
            }
        }