示例#1
0
        //----------------------Hauptfunktion welche das Spiel berechnet------------------------------
        public Winner BattleHandler()
        {
            while (GameContinue()) //Ist das Spiel vorbei?
            {
                Round();           //Wenn nein-->Eine Runde wird gespielt
            }

            DeterminWinner();  //Wenn ja-->Wer hat gewonnen?



            //Nochmal ein Log Eintrag wer gewonnen hat und addieren bzw abziehen der Punkte
            Log.Add("Game Over");
            if (betterfighter == Winner.FirstPlayer)
            {
                Log.Add("\n#####  " + UserOne + " has won the game and receives 3 points #####\n");
                Database.updatePlayerPoints(UserOne, 3, true);

                if (Database.selectPlayerJustPoints(UserTwo) - 5 > 0)
                {
                    Database.updatePlayerPoints(UserTwo, 5, false);
                    Log.Add("\n#####  " + UserTwo + " has lost the game and loses 5 points #####\n");
                }
                else
                {
                    Log.Add("\n#####  " + UserTwo + " has lost the game but can not drop deeper than 0 points #####\n");
                }
            }
            else if (betterfighter == Winner.SekondPlayer)
            {
                Log.Add("\n#####  " + UserTwo + " has won the game and receives 3 points #####\n");
                Database.updatePlayerPoints(UserTwo, 3, true);

                if (Database.selectPlayerJustPoints(UserOne) - 5 > 0)
                {
                    Database.updatePlayerPoints(UserOne, 5, false);
                    Log.Add("\n#####  " + UserOne + " has lost and loses 5 points #####\n");
                }
                else
                {
                    Log.Add("\n#####  " + UserOne + " has lost but can not drop deeper than to 0 points #####\n");
                }
            }
            else
            {
                Log.Add("#####  draw  #####");
            }


            //Ausgabe des Logs

            /*foreach (var sentence in Log)
             * {
             *  Console.WriteLine(sentence);
             * }*/

            return(betterfighter); //Sieger rausgeben
        }