Example #1
0
        public void GenerateMethod()
        {
            string output = string.Empty;
            Random rng    = new Random();

            char[] array = { '`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\\', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '|', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', };
            int    n     = chars.Length;

            while (n > 1)
            {
                n--;
                int k     = rng.Next(n + 1);
                var value = chars[k];
                array[k] = array[n];
                array[n] = value;
                output   = new string(array);
                if (debug)
                {
                    ColorConsoleMethods.WriteLineColor(string.Format("n:{0}\nk:{1}\nvalue:{2}\noutput:{3}", n, k, value, output), ConsoleColor.DarkBlue);
                    if (debug)
                    {
                        Console.WriteLine(SwitchString);
                    }
                }
            }
            SwitchString = output;
        }
Example #2
0
 public void Ask(Player p)
 {
     while (success == false)
     {
         Utils.PrintPlayerNameWithFormattingPlusMoreText(p, this.Text);
         foreach (BWAction i in actions)
         {
             if (Console.ReadLine().ToLower() == i.alias.ToLower())
             {
                 i.Execute(p);
                 success = true;
                 break;
             }
             else
             {
                 CCM.WriteLineColor("You did not enter a valid option! options: " + GetOptionsString() + "\nPress enter to continue", ConsoleColor.Red);
                 success = false;
                 Console.ReadLine();
                 Console.Clear();
                 break;
             }
         }
     }
     success = false;
 }
Example #3
0
        public string Switch(string input)
        {
            string output = string.Empty;

            foreach (char i in input)
            {
                if (debug)
                {
                    ColorConsoleMethods.WriteLineColor(SwitchString.Length.ToString(), ConsoleColor.Green);
                }
                output += SwitchString.ToCharArray()[SwitchString.IndexOf(i)];
                if (debug)
                {
                    Console.WriteLine(output);
                }
            }
            return(output);
        }
Example #4
0
 public void Update()
 {
     if (!SuppressEliminationMessage)
     {
         if (Players.Count == 1)
         {
             if (Players[0].IsDead && BaseLoc.TeamBed.destroyed)
             {
                 Eliminated = true;
                 CCM.WriteLineMultiColor(new string[] { "------------------\n\n >", DisplayColor.ToString(), " team has been eliminated!\n\n------------------" }, new ConsoleColor[] { ConsoleColor.White, DisplayColor, ConsoleColor.White });
             }
         }
         else
         {
             CCM.WriteLineMultiColor(new string[] { "------------------\n\n >", DisplayColor.ToString(), " team has been eliminated!\n\n------------------" }, new ConsoleColor[] { ConsoleColor.White, DisplayColor, ConsoleColor.White });
             Eliminated = true;
         }
     }
 }
Example #5
0
        public List <string> Search(string input)
        {
            List <string> results     = new List <string>();
            List <string> ItemStrings = new List <string>();
            List <char>   InputUpper  = new List <char>();

            try
            {
                foreach (char i in input.ToUpper())
                {
                    if (DebugMode)
                    {
                        Console.WriteLine(i);
                    }
                    InputUpper.Add(i);
                }
                foreach (string a in items)
                {
                    ItemStrings.Add(a.ToUpper());
                    if (DebugMode)
                    {
                        Console.WriteLine(a);
                    }
                }
                foreach (string a in items)
                {
                    if (DebugMode)
                    {
                        Console.WriteLine(a);
                    }
                    string first2input = input.Length >= 2 ? InputUpper[0] + InputUpper[1].ToString() : InputUpper[0].ToString();
                    string first2a     = a[0] + a[1].ToString();
                    if (DebugMode)
                    {
                        Console.WriteLine("first2input:{1}\nfirst2a:{0}", first2a, first2input);
                    }
                    bool test = (first2a.ToUpper() == first2input.ToUpper() || first2a.ToUpper()[0] == first2input.ToUpper()[0]);
                    if (first2a.ToUpper() == first2input.ToUpper() || first2a.ToUpper()[0] == first2input.ToUpper()[0])
                    {
                        if (DebugMode && test)
                        {
                            ConsoleColor[] foo2 = { ConsoleColor.White, ConsoleColor.Green };
                            string[]       foo  = { "first2a.ToUpper() == first2input.ToUpper() || first2a.ToUpper()[0] == first2input.ToUpper()[0] = ", string.Format("{0}", test) };
                            ColorConsoleMethods.WriteLineMultiColor(foo, foo2);
                        }
                        results.Add(a);
                    }
                    else
                    {
                        if (DebugMode)
                        {
                            ConsoleColor[] foo2 = { ConsoleColor.White, ConsoleColor.Red };
                            string[]       foo  = { "first2a.ToUpper() == first2input.ToUpper() || first2a.ToUpper()[0] == first2input.ToUpper()[0] = ", string.Format("{0}", test) };
                            ColorConsoleMethods.WriteLineMultiColor(foo, foo2);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ColorConsoleMethods.WriteLineColor(e.Message, ConsoleColor.Red);
            }
            if (DebugMode)
            {
                Console.WriteLine("\n\n\nReturning results...\n\n\n");
            }
            return(results);
        }
Example #6
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Welcome to BedWars!");
            while (NumberOfPlayers <= 1 || NumberOfPlayers > 8)
            {
                try
                {
                    Console.WriteLine("How many players are playing?");
                    NumberOfPlayers = Convert.ToInt32(Console.ReadLine());
                    if (NumberOfPlayers > 8 || NumberOfPlayers == 1)
                    {
                        throw new Exception("YOU CAN ONLY HAVE UP TO 8 PLAYERS!\n YOU MUST HAVE 2 PLAYERS");
                    }
                    break;
                }
                catch (Exception e)
                {
                    CCM.WriteLineColor("An error happened! :( try again!\n" + e.Message, ConsoleColor.Red);
                    Console.ReadLine();
                    Console.Clear();
                }
            }
            for (int i = 0; i < NumberOfPlayers; i++)
            {
                Console.WriteLine("Enter a name for Player {0}:", i + 1);
                players.Add(new Player(Console.ReadLine()));
            }
retry:
            Console.WriteLine("Loading...");
            NumberOfTeams = NumberOfPlayers;
            teams.RemoveRange(0, teams.Count);
            List <int> used     = new List <int>();
            List <int> usedclrs = new List <int>();
            int        c        = 1;
            int        index    = 0;
            int        p        = 0;

            teams.Add(new Team(ConsoleColor.White));
            usedclrs.Add(0xF);
            Random rng = new Random();

            for (int i = 1; i < 8; i++)
            {
                c = rng.Next(1, 16);
                Console.WriteLine("c = {0}", c);
                foreach (int n in usedclrs)
                {
                    if (c == n || c == 0)
                    {
                        Console.WriteLine("c == n || c == 0", c);
                        while (c == n || c == 0)
                        {
                            c = new Random().Next(1, 16);
                            Console.WriteLine("c is now {0}", c);
                        }
                    }
                }
                teams.Add(new Team((ConsoleColor)c));
                usedclrs.Add(c);
            }
            for (int i = 0; i < teams.Count; i++)
            {
                p = new Random().Next(0, players.Count);
                Console.WriteLine("p = {0}", p);
                foreach (int n in used)
                {
                    if (p == n)
                    {
                        Console.WriteLine("p == n", p);
                        while (p != n)
                        {
                            p = new Random().Next(0, players.Count);
                            Console.WriteLine("p is now {0}", p);
                        }
                    }
                }
                players[p].CurrentTeam = teams[i];
                used.Add(p);
            }
                        #if DEBUG
            if (players.Count == 1)
            {
                Console.WriteLine("OH SHOOT!");
            }
            else
            {
                Console.WriteLine("# of players = " + players.Count);
            }
                        #endif
            CurrentGame = new Game(players, new MapGenorator(teams).MakeMap(teams), teams);
            try
            {
                CurrentGame.Start();
            }
            catch (Exception e)
            {
                Console.WriteLine("GAME START FAILED!!!! RETRYING!!!");
                goto retry;
            }
                        #if DEBUG
            Console.WriteLine(CurrentGame.BWMap.ToString());
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();
                        #endif
            Console.Clear();
            Console.WriteLine("Starting!");
            CurrentGame.teams = new List <Team>();
            foreach (Team t in teams)
            {
                CurrentGame.teams.Add(t);
            }
            while (CurrentGame.Running)
            {
                CurrentGame.NextTurn();
                                #if DEBUG
                Console.WriteLine("Game running? " + CurrentGame.Running);
                                #endif
                foreach (Team t in CurrentGame.teams)
                {
                    t.Update();
                    if (t.Eliminated == false)
                    {
                        continue;
                    }
                    else
                    {
                        List <Team> AliveTeams = new List <Team>();
                        foreach (Team test in CurrentGame.teams)
                        {
                            if (test.Eliminated == true)
                            {
                                continue;
                            }
                            AliveTeams.Add(test);
                        }
                        if (AliveTeams.Count == 1)
                        {
                            CCM.WriteLineColor("GAME OVER!", ConsoleColor.Red);
                        }
                    }
                }
            }
            Console.Write("Press enter to continue . . . ");
            Console.ReadLine();
        }
Example #7
0
 public static void PrintPlayerNameWithFormattingPlusMoreText(Player p, string text)
 {
     CCM.WriteLineMultiColor(new string[] { "[" + p.Name + "]", "," + text }, new ConsoleColor[] { p.CurrentTeam.DisplayColor, ConsoleColor.White });
 }