예제 #1
0
        private static void PreFightDetails(Celebrity c1, Celebrity c2, Arena a1)
        {
            var battleDetailsC1 = c1.Name + " with the " + c1.BladeName;

            Console.WriteLine("In the " + a1.ArenaName);
            Console.WriteLine(battleDetailsC1);
            Console.WriteLine("VS");
            var battleDetailsC2 = c2.Name + " with the " + c2.BladeName;

            Console.WriteLine(battleDetailsC2);
            Console.WriteLine("-----");
            var readyToRumble = "";

            // Needs input validation
            if (readyToRumble == "")
            {
                Console.WriteLine("Are you ready to Rumble? Enter y or n");
                readyToRumble = Console.ReadLine();
            }

            if (readyToRumble == "n")
            {
                Console.WriteLine("Too bad runty wimp, the fight goes ahead anyway");
            }
        }
예제 #2
0
        // Celebrities have a victory action selected at random
        private static string MakeVictory(Celebrity c1)
        {
            string[,] allVictoryStrings =
            {
                {
                    "having a breakdown and shaving her head.",
                    "polluting radio station airwaves with garbage music.",
                    "creating soft pornography as a music video clip.",
                    "joining ISIS as a Jihadi bride.",
                    "hunting down Christina Agullera with her blade."
                },
                {
                    "disappointing fans by being a scared weird evangelical nutter.",
                    "shaving off his beard and joining a satanic cult.",
                    "licking the American flag.",
                    "finally coming out of the closet and freeing the little boys held captive in his basement.",
                    "lynching some African Americans."
                },
                {
                    "drone striking innocent civilians, and receiving a nobel peace prize for the effort. ",
                    "giving Michelle a terrorist fist bump.",
                    "paying Billions to bankers for destroying the economy.",
                    "sending conservatives into hysteria for being black.",
                    "shooting some hoops with his opponents severed head."
                },
                {
                    "grabbing the nearest Pu&$y.",
                    "picking up the phone and colluding with Vladimir Putin.",
                    "tweeting some unhinged crap about Hillary Clinton",
                    "by just being a fat orange bastard.",
                    "heading off for his spray tan."
                }
            };

            var stringChoice = new Random();

            var stringNum = stringChoice.Next(0, 5);

            // Iterate through the arrays, match the user, select a random index as a victory message

            foreach (var i in allVictoryStrings)
            {
                var victoryAction = allVictoryStrings[c1.Id, stringNum];

                return(victoryAction);
            }

            return(null);
        }
예제 #3
0
        // Selects and returns 2 Celebrity class instances

        private static (Celebrity, Celebrity) ShowAll()
        {
            // These variables are to keep track of the user input state
            var count1      = 0;
            var count2      = 0;
            var showRecords = "";
            // make an array of instances
            var myCelebs = new Celebrity[4];

            myCelebs[0] = new Celebrity(0, "Britney Spears", 1.63, 57, 45, 25, false);

            myCelebs[1] = new ProFighter(1, "Chuck Norris", 1.83, 77.1, 70, 60, true);

            myCelebs[2] = new Celebrity(2, "Barak Obama", 1.85, 81.6, 56, 35, false);

            myCelebs[3] = new Celebrity(3, "Donald Trump", 1.90, 107, 63, 12, false);

            // User input
            // Missing validation methods
            while (count1 == 0 && count2 == 0 && showRecords == "")
            {
                Console.WriteLine("Select your first fighter by number or enter 'r' for records of previous fights.");
                // Display fighters
                foreach (var celeb in myCelebs)
                {
                    Console.WriteLine(celeb.Name + " with a " + celeb.BladeName + " Press: " + celeb.Id);
                }


                var celebString = Console.ReadLine();
                // If the user does not want to view previous fight records
                if (celebString != "r" && count1 == 0 && count2 == 0)
                {
                    var celebNum = Convert.ToInt32(celebString);
                    // Assign first choice
                    var c1 = myCelebs[celebNum];
                    // change state for the next choice

                    count1 = 1;
                    c1.ShowStats();

                    if (count1 == 1 && count2 == 0)
                    {
                        Console.WriteLine("Select your second fighter!");
                        celebString = Console.ReadLine();
                        var celebNum1 = Convert.ToInt32(celebString);
                        var c2        = myCelebs[celebNum1];
                        c2.ShowStats();
                        showRecords = "";
                        count2      = 1;
                        return(c1, c2);
                    }
                }
                var myReader = new StreamReader("fightrecords.txt");
                // Read from file
                if (celebString == "r")
                {
                    var consoleLine = " ";
                    while (consoleLine != null)
                    {
                        consoleLine = myReader.ReadLine();
                        if (consoleLine != null)
                        {
                            Console.WriteLine(consoleLine);
                        }
                        if (consoleLine == null)
                        {
                            Console.WriteLine("Press enter to return to selection!");

                            showRecords = "";
                        }
                    }

                    Console.ReadLine();
                }
                myReader.Close();
            }

            return(null, null);
        }
예제 #4
0
        // method could be broken down further
        // read comments inside
        private static void DoBattle(Celebrity c1, Celebrity c2, Arena a1)
        {
            // Check if the arena matches the celebrity, (by ID's) calculate a home advantage, added to EyeOfTheTiger, gives a little story to the battle
            if (a1.ArenaId == c1.Id)
            {
                c1.EyeOfTheTiger += 25;
                c1.FightPoints   += 25;
                Console.WriteLine(c1.Name + " Has the home advantage so their eye of the tiger increases to : " +
                                  c1.EyeOfTheTiger + "/100");
            }

            if (a1.ArenaId == c2.Id)
            {
                c2.EyeOfTheTiger += 25;
                c2.FightPoints   += 25;
                Console.WriteLine(c2.Name + " Has the home advantage so their eye of the tiger increases to : " +
                                  c2.EyeOfTheTiger + "/100");
            }


            //Logic that reduces EyeOfTheTiger of opponent if one fighter isPro
            if (c1.IsPro && !c2.IsPro)
            {
                Console.WriteLine(c2.Name + "'s eye of the tiger before the fight: " + c2.EyeOfTheTiger);
                c2.FightPoints = c2.FightPoints - c2.EyeOfTheTiger;

                c2.EyeOfTheTiger = 0;
                Console.WriteLine(c1.Name + " gives " + c2.Name + " a cold hard stare reducing " + c2.Name +
                                  "'s eye of the tiger to " + c2.EyeOfTheTiger + "/100");
            }

            if (c2.IsPro && !c1.IsPro)
            {
                Console.WriteLine(c1.Name + "'s eye of the tiger before the fight: " + c1.EyeOfTheTiger);

                c1.FightPoints = c1.FightPoints - c1.EyeOfTheTiger;

                c1.EyeOfTheTiger = 0;
                Console.WriteLine(c2.Name + " gives " + c1.Name + " a cold hard stare reducing " + c1.Name +
                                  "'s eye of the tiger to " + c1.EyeOfTheTiger + "/100");
            }

            // Prepare to write to file
            var toFile = new StreamWriter("fightrecords.txt", true);

            // Calculate winner, write the results to console and to file
            if (c1.fightPoints > c2.fightPoints)
            {
                // Example of where a new method could be inserted
                MakeVictory(c1);
                var vicMsg = MakeVictory(c1);
                var margin = c1.fightPoints - c2.fightPoints;
                Console.WriteLine(c1.Name + " Fight points: " + c1.fightPoints);
                Console.WriteLine(c2.Name + " Fight points: " + c2.fightPoints);
                Console.WriteLine(c1.Name + " Wins by : " + margin + " fight points.");
                Console.WriteLine(c1.Name + " celebrates the victory by " + vicMsg);

                DateTime now  = DateTime.Now;
                string   time = now.ToString();
                Console.WriteLine(time);
                // New method
                string[] record =
                {
                    " ",                                              c1.Name + " with a " + c1.BladeName,              "VS", c2.Name + " with a " + c2.BladeName,
                    "In " + a1.ArenaName,                             time,
                    c1.Name + " won by " + margin + " fight points.", c1.Name + " celebrated the victory by " + vicMsg,
                    " ",
                    "<----------*--*--*---------->"
                };

                foreach (var line in record)
                {
                    toFile.WriteLine(line);
                }
                toFile.Close();
            }
            else
            {
                MakeVictory(c2);
                var vicMsg = MakeVictory(c2);
                var margin = c2.fightPoints - c1.fightPoints;
                Console.WriteLine(c1.Name + " Fight points: " + c1.fightPoints);
                Console.WriteLine(c2.Name + " Fight points: " + c2.fightPoints);
                Console.WriteLine(c2.Name + " Wins by : " + margin + " fight points.");
                Console.WriteLine(c2.Name + " celebrates the victory by " + vicMsg);
                DateTime now  = DateTime.Now;
                string   time = now.ToString();
                Console.WriteLine(time);
                string[] record =
                {
                    " ",                                              c2.Name + " with a " + c2.BladeName,              "VS", c1.Name + " with a " + c1.BladeName,
                    "In " + a1.ArenaName,                             time,
                    c2.Name + " won by " + margin + " fight points.", c2.Name + " celebrated the victory by " + vicMsg,
                    " ",
                    "<----------*--*--*---------->"
                };

                foreach (var line in record)
                {
                    toFile.WriteLine(line);
                }
                toFile.Close();
            }
        }