Beispiel #1
0
        public void Rapport(Spelare p1, Spelare p2, int ScorePlayer1Game1, int ScorePlayer2Game1, int ScorePlayer1Game2, int ScorePlayer2Game2)
        {
            player1 = p1;
            player2 = p2;

            //Game 1
            scorePlayer1Game1 = ScorePlayer1Game1;
            scorePlayer2Game1 = ScorePlayer2Game1;

            //Game 2
            scorePlayer1Game2 = ScorePlayer1Game2;
            scorePlayer2Game2 = ScorePlayer2Game2;

            CalculateWin();
        }
Beispiel #2
0
        //Hämta information från excel
        public List <Spelare> importPlayers()
        {
            List <Spelare> temp = new List <Spelare>();

            using (var package = new ExcelPackage(file))
            {
                var cells = package.Workbook.Worksheets["Ranking"].Cells["C7:C19"].Value.ToString();

                var query1 = (from cell in package.Workbook.Worksheets["Ranking"].Cells["C7:C80"]
                              where cell.Value != null
                              select cell.Value);
                int i = 1;
                foreach (var p in query1)
                {
                    Spelare newSpelare = new Spelare(p.ToString(), i);
                    temp.Add(newSpelare);
                    i++;
                }
            }

            return(temp);
        }
Beispiel #3
0
        //Uppdatera poäng
        public void updateScore(Spelare Player1, Spelare Player2, int resultat1Spelare1Match1, int resultatSpelare2Match1, int resultatSpelare1Match2, int resultatSpelare2Match2)
        {
            int     round        = 1;
            Spelare player1      = Player1;
            int     rankSpelare1 = Player1.rank;
            Spelare player2      = Player2;
            int     rankSpelare2 = Player2.rank;

            int p1Row;
            int p2Row;

            if (player1.rank > 3)
            {
                rankSpelare1 = player1.rank - (3 * (player1.division - 1));
            }
            if (player2.rank > 3)
            {
                rankSpelare2 = player2.rank - (3 * (player2.division - 1));
            }

            using (var package = new ExcelPackage(file))
            {
                p1Row = (from cell in package.Workbook.Worksheets["S30" + round].Cells["A11:A57"]
                         where cell.Text == player1.name.Trim()
                         select cell.Start.Row).First();
                p2Row = (from cell in package.Workbook.Worksheets["S30" + round].Cells["A11:A57"]
                         where cell.Text == player2.name.Trim()
                         select cell.Start.Row).First();

                if (rankSpelare1 == 1)
                {
                    if (rankSpelare2 == 2)
                    {
                        //spelare 1
                        package.Workbook.Worksheets["S30" + round].Cells["E" + p1Row].Value       = resultat1Spelare1Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["G" + p1Row].Value       = resultatSpelare2Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["E" + (p1Row + 1)].Value = resultatSpelare1Match2;
                        package.Workbook.Worksheets["S30" + round].Cells["G" + (p1Row + 1)].Value = resultatSpelare2Match2;

                        package.Workbook.Worksheets["S30" + round].Cells["N" + p1Row].Value = player1.matchWon;
                        package.Workbook.Worksheets["S30" + round].Cells["O" + p1Row].Value = player1.gameWon;
                        package.Workbook.Worksheets["S30" + round].Cells["P" + p1Row].Value = player1.pointDifference;
                        package.Workbook.Worksheets["S30" + round].Cells["Q" + p1Row].Value = player1.rank;


                        //Spelare2
                        package.Workbook.Worksheets["S30" + round].Cells["B" + p2Row].Value       = resultatSpelare2Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["D" + p2Row].Value       = resultat1Spelare1Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["B" + (p2Row + 1)].Value = resultatSpelare2Match2;
                        package.Workbook.Worksheets["S30" + round].Cells["D" + (p2Row + 1)].Value = resultatSpelare1Match2;

                        package.Workbook.Worksheets["S30" + round].Cells["N" + p2Row].Value = player2.matchWon;
                        package.Workbook.Worksheets["S30" + round].Cells["O" + p2Row].Value = player2.gameWon;
                        package.Workbook.Worksheets["S30" + round].Cells["P" + p2Row].Value = player2.pointDifference;
                        package.Workbook.Worksheets["S30" + round].Cells["Q" + p2Row].Value = player2.rank;
                    }
                    else if (rankSpelare2 == 3)
                    {
                        //spelare 1
                        package.Workbook.Worksheets["S30" + round].Cells["H" + p1Row].Value       = resultat1Spelare1Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["J" + p1Row].Value       = resultatSpelare2Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["H" + (p1Row + 1)].Value = resultatSpelare1Match2;
                        package.Workbook.Worksheets["S30" + round].Cells["J" + (p1Row + 1)].Value = resultatSpelare2Match2;

                        package.Workbook.Worksheets["S30" + round].Cells["N" + p1Row].Value = player1.matchWon;
                        package.Workbook.Worksheets["S30" + round].Cells["O" + p1Row].Value = player1.gameWon;
                        package.Workbook.Worksheets["S30" + round].Cells["P" + p1Row].Value = player1.pointDifference;
                        package.Workbook.Worksheets["S30" + round].Cells["Q" + p1Row].Value = player1.rank;

                        //spelare 2
                        package.Workbook.Worksheets["S30" + round].Cells["B" + p2Row].Value       = resultatSpelare2Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["D" + p2Row].Value       = resultat1Spelare1Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["B" + (p2Row + 1)].Value = resultatSpelare2Match2;
                        package.Workbook.Worksheets["S30" + round].Cells["D" + (p2Row + 1)].Value = resultatSpelare1Match2;

                        package.Workbook.Worksheets["S30" + round].Cells["N" + p2Row].Value = player2.matchWon;
                        package.Workbook.Worksheets["S30" + round].Cells["O" + p2Row].Value = player2.gameWon;
                        package.Workbook.Worksheets["S30" + round].Cells["P" + p2Row].Value = player2.pointDifference;
                        package.Workbook.Worksheets["S30" + round].Cells["Q" + p2Row].Value = player2.rank;
                    }
                    package.Save();
                }
                else if (rankSpelare1 == 2)
                {
                    if (rankSpelare2 == 1)
                    {
                        //Spelare 1
                        package.Workbook.Worksheets["S30" + round].Cells["B" + p1Row].Value       = resultat1Spelare1Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["D" + p1Row].Value       = resultatSpelare2Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["B" + (p1Row + 1)].Value = resultatSpelare1Match2;
                        package.Workbook.Worksheets["S30" + round].Cells["D" + (p1Row + 1)].Value = resultatSpelare2Match2;

                        package.Workbook.Worksheets["S30" + round].Cells["N" + p1Row].Value = player1.matchWon;
                        package.Workbook.Worksheets["S30" + round].Cells["O" + p1Row].Value = player1.gameWon;
                        package.Workbook.Worksheets["S30" + round].Cells["P" + p1Row].Value = player1.pointDifference;
                        package.Workbook.Worksheets["S30" + round].Cells["Q" + p1Row].Value = player1.rank;

                        //Spelare 2
                        package.Workbook.Worksheets["S30" + round].Cells["E" + p2Row].Value       = resultatSpelare2Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["G" + p2Row].Value       = resultat1Spelare1Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["E" + (p2Row + 1)].Value = resultatSpelare2Match2;
                        package.Workbook.Worksheets["S30" + round].Cells["G" + (p2Row + 1)].Value = resultatSpelare1Match2;

                        package.Workbook.Worksheets["S30" + round].Cells["N" + p2Row].Value = player2.matchWon;
                        package.Workbook.Worksheets["S30" + round].Cells["O" + p2Row].Value = player2.gameWon;
                        package.Workbook.Worksheets["S30" + round].Cells["P" + p2Row].Value = player2.pointDifference;
                        package.Workbook.Worksheets["S30" + round].Cells["Q" + p2Row].Value = player2.rank;
                    }
                    else if (rankSpelare2 == 3)
                    {
                        //Spelare 1
                        package.Workbook.Worksheets["S30" + round].Cells["H" + p1Row].Value       = resultat1Spelare1Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["J" + p1Row].Value       = resultatSpelare2Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["H" + (p1Row + 1)].Value = resultatSpelare1Match2;
                        package.Workbook.Worksheets["S30" + round].Cells["J" + (p1Row + 1)].Value = resultatSpelare2Match2;

                        package.Workbook.Worksheets["S30" + round].Cells["N" + p1Row].Value = player1.matchWon;
                        package.Workbook.Worksheets["S30" + round].Cells["O" + p1Row].Value = player1.gameWon;
                        package.Workbook.Worksheets["S30" + round].Cells["P" + p1Row].Value = player1.pointDifference;
                        package.Workbook.Worksheets["S30" + round].Cells["Q" + p1Row].Value = player1.rank;

                        //spelare 2
                        package.Workbook.Worksheets["S30" + round].Cells["E" + p2Row].Value       = resultatSpelare2Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["G" + p2Row].Value       = resultat1Spelare1Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["E" + (p2Row + 1)].Value = resultatSpelare2Match2;
                        package.Workbook.Worksheets["S30" + round].Cells["G" + (p2Row + 1)].Value = resultatSpelare1Match2;

                        package.Workbook.Worksheets["S30" + round].Cells["N" + p2Row].Value = player2.matchWon;
                        package.Workbook.Worksheets["S30" + round].Cells["O" + p2Row].Value = player2.gameWon;
                        package.Workbook.Worksheets["S30" + round].Cells["P" + p2Row].Value = player2.pointDifference;
                        package.Workbook.Worksheets["S30" + round].Cells["Q" + p2Row].Value = player2.rank;
                    }
                    package.Save();
                }
                else if (rankSpelare1 == 3)
                {
                    if (rankSpelare2 == 1)
                    {
                        //Spelare 1
                        package.Workbook.Worksheets["S30" + round].Cells["B" + p1Row].Value       = resultat1Spelare1Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["D" + p1Row].Value       = resultatSpelare2Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["B" + (p1Row + 1)].Value = resultatSpelare1Match2;
                        package.Workbook.Worksheets["S30" + round].Cells["D" + (p1Row + 1)].Value = resultatSpelare2Match2;

                        package.Workbook.Worksheets["S30" + round].Cells["N" + p1Row].Value = player1.matchWon;
                        package.Workbook.Worksheets["S30" + round].Cells["O" + p1Row].Value = player1.gameWon;
                        package.Workbook.Worksheets["S30" + round].Cells["P" + p1Row].Value = player1.pointDifference;
                        package.Workbook.Worksheets["S30" + round].Cells["Q" + p1Row].Value = player1.rank;

                        //spelare 2
                        package.Workbook.Worksheets["S30" + round].Cells["H" + p2Row].Value       = resultatSpelare2Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["J" + p2Row].Value       = resultat1Spelare1Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["H" + (p2Row + 1)].Value = resultatSpelare2Match2;
                        package.Workbook.Worksheets["S30" + round].Cells["J" + (p2Row + 1)].Value = resultatSpelare1Match2;

                        package.Workbook.Worksheets["S30" + round].Cells["N" + p2Row].Value = player2.matchWon;
                        package.Workbook.Worksheets["S30" + round].Cells["O" + p2Row].Value = player2.gameWon;
                        package.Workbook.Worksheets["S30" + round].Cells["P" + p2Row].Value = player2.pointDifference;
                        package.Workbook.Worksheets["S30" + round].Cells["Q" + p2Row].Value = player2.rank;
                    }
                    else if (rankSpelare2 == 2)
                    {
                        //Spelare 1
                        package.Workbook.Worksheets["S30" + round].Cells["E" + p1Row].Value       = resultat1Spelare1Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["G" + p1Row].Value       = resultatSpelare2Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["E" + (p1Row + 1)].Value = resultatSpelare1Match2;
                        package.Workbook.Worksheets["S30" + round].Cells["G" + (p1Row + 1)].Value = resultatSpelare2Match2;

                        package.Workbook.Worksheets["S30" + round].Cells["N" + p1Row].Value = player1.matchWon;
                        package.Workbook.Worksheets["S30" + round].Cells["O" + p1Row].Value = player1.gameWon;
                        package.Workbook.Worksheets["S30" + round].Cells["P" + p1Row].Value = player1.pointDifference;
                        package.Workbook.Worksheets["S30" + round].Cells["Q" + p1Row].Value = player1.rank;

                        //Spelare 2
                        package.Workbook.Worksheets["S30" + round].Cells["H" + p2Row].Value       = resultatSpelare2Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["J" + p2Row].Value       = resultat1Spelare1Match1;
                        package.Workbook.Worksheets["S30" + round].Cells["H" + (p2Row + 1)].Value = resultatSpelare2Match2;
                        package.Workbook.Worksheets["S30" + round].Cells["J" + (p2Row + 1)].Value = resultatSpelare1Match2;

                        package.Workbook.Worksheets["S30" + round].Cells["N" + p2Row].Value = player2.matchWon;
                        package.Workbook.Worksheets["S30" + round].Cells["O" + p2Row].Value = player2.gameWon;
                        package.Workbook.Worksheets["S30" + round].Cells["P" + p2Row].Value = player2.pointDifference;
                        package.Workbook.Worksheets["S30" + round].Cells["Q" + p2Row].Value = player2.rank;
                    }
                    package.Save();
                }
            }
        }