static Fighter[] FighterLoader(Move[] moves, Random rnd)
        {
            int  MAX_MOVES_KNOWN = 4;
            bool inputGood       = false;
            int  fighterCount    = 0;
            int  teamCount       = 0;

            string[] names       = { "Joe", "Rat", "Dog", "Fish", "Log", "Tim" };
            float    tempAttack  = 2;
            float    tempDefence = 2;
            float    tempSpeed   = 2;

            System.Console.Write("Enter the number of fighters: ");
            while (!int.TryParse(System.Console.ReadLine(), out fighterCount))
            {
                System.Console.WriteLine("Invalid");
            }
            Fighter[] fighters     = new Fighter[fighterCount];
            int[]     fighterMoves = new int[MAX_MOVES_KNOWN];

            while (!inputGood)
            {
                System.Console.Write("Enter the number of teams: ");
                if (int.TryParse(System.Console.ReadLine(), out teamCount))
                {
                    if (teamCount > 1)
                    {
                        inputGood = true;
                    }
                    else
                    {
                        System.Console.WriteLine("Must be greater then 1");
                    }
                }
                else
                {
                    System.Console.WriteLine("Invalid input");
                }
            }

            for (int i = 0; i < fighterCount; i++)
            {
                for (int k = 0; k < fighterMoves.Length; k++)
                {
                    fighterMoves[k] = rnd.Next(1, moves.Length);
                }
                fighters[i] = new Fighter
                {
                    name          = names[rnd.Next(0, names.Length)] + i,
                    statMaxHealth = 500,
                    statHealth    = 500,
                    statAttack    = tempAttack / rnd.Next(1, 100),
                    statDefence   = tempDefence / rnd.Next(1, 100),
                    statSpeed     = tempSpeed / rnd.Next(1, 100),
                    isAI          = true,
                    teamNum       = rnd.Next(1, teamCount + 1),
                    knownMoves    = fighterMoves
                };
            }

            /*int[] fighter0Moves = { 1, 2, 3, 0 };
             * fighters[0] = new Fighter
             * {
             *  name = "Joe",
             *  statMaxHealth = 100,
             *  statHealth = 100,
             *  statAttack = 1,
             *  statDefence = 2,
             *  statSpeed = 5,
             *  isAI = true,
             *  teamNum = 2,
             *  knownMoves = fighter0Moves
             * };*/

            return(fighters);
        }
Example #2
0
        private void UserInput(Fighter currectFighter) // This manages the user inverface for the battle.
        {
            const int MODE_SELECT_STAGE   = 1;
            const int MOVE_SELECT_STAGE   = 2;
            const int TARGET_SELECT_STAGE = 3;
            const int INFO_STAGE          = 4;
            const int DONE_STAGE          = 5;
            int       currectStage        = 1;
            bool      stageDone;
            string    userInput;
            int       convertedInput;
            bool      isUserInputDone = false;

            while (!isUserInputDone)
            {
                if (currectStage == MODE_SELECT_STAGE) // This stage is used to for the basic menu.
                {
                    Console.WriteLine("1: Fight\n2: Info\n3: PlaceHolder");
                    Console.Write("Please enter a number: ");
                    stageDone = false;
                    while (!stageDone)
                    {
                        userInput = Console.ReadLine();
                        if (int.TryParse(userInput, out convertedInput))
                        {
                            if (convertedInput == 1) // Move Stage Selected.
                            {
                                stageDone    = true;
                                currectStage = MOVE_SELECT_STAGE;
                            }
                            else if (convertedInput == 2) // Info Stage Selected.
                            {
                                stageDone    = true;
                                currectStage = INFO_STAGE;
                            }
                            else if (convertedInput == 3) // PlaceHolder Stage Selected.
                            {
                                Console.WriteLine("PlaceHolder");
                                Console.Write("Please enter another number: ");
                            }
                            else
                            {
                                Console.WriteLine("{0} is invalid", userInput);
                                Console.Write("Please enter another number: ");
                            }
                        }
                        else
                        {
                            Console.WriteLine("{0} is invalid", userInput);
                            Console.Write("Please enter another number: ");
                        }
                    }
                }
                else if (currectStage == MOVE_SELECT_STAGE) // This stage is prints all known moves and allows the user to select one.
                {
                    for (int i = 0; i < currectFighter.KnownMoves.Length; i++)
                    {
                        if (currectFighter.KnownMoves[i] != GLOBAL.NullID)
                        {
                            System.Console.WriteLine("{0}: {1}", i + 1, moves[currectFighter.KnownMoves[i]].MoveName);
                        }
                    }
                    System.Console.Write("Please select a move, or B to go back: ");
                    stageDone = false;
                    while (!stageDone)
                    {
                        userInput = System.Console.ReadLine();
                        if (userInput[0] == 'b' || userInput[0] == 'B') // Checks to see if the user wants to go back.
                        {
                            stageDone    = true;
                            currectStage = MODE_SELECT_STAGE; // Mode Stage Selected.
                        }
                        else if (int.TryParse(userInput, out convertedInput))
                        {
                            convertedInput -= 1;
                            if (convertedInput >= 0 && convertedInput < currectFighter.KnownMoves.Length && currectFighter.KnownMoves[convertedInput] != 0)
                            {
                                currectFighter.NextMove = convertedInput;
                                System.Console.WriteLine("{0} selected", moves[currectFighter.KnownMoves[currectFighter.NextMove]].MoveName);
                                stageDone = true;
                                if (moves[currectFighter.NextMoveID].IsSelfTarget)
                                {
                                    currectStage = DONE_STAGE; // Done Stage Selected.
                                }
                                else
                                {
                                    currectStage = TARGET_SELECT_STAGE; // Target Stage Selected.
                                }
                            }
                            else
                            {
                                System.Console.WriteLine("{0} is invalid", userInput);
                                System.Console.Write("Please enter another number: ");
                            }
                        }
                        else
                        {
                            System.Console.WriteLine("{0} is invalid", userInput);
                            System.Console.Write("Please enter another number: ");
                        }
                    }
                }
                else if (currectStage == TARGET_SELECT_STAGE) // This stage prints all fighter, and allows user to select one to target.
                {
                    for (int i = 0; i < fighters.Length; i++)
                    {
                        System.Console.WriteLine("{0}: {1} {2}{3}"
                                                 , i + 1
                                                 , (currectFighter.TeamID == fighters[i].TeamID) ? "Ally" : "Enemy"
                                                 , fighters[i].FighterName
                                                 , (fighters[i].StatHealthCurrect > 0) ? "" : " Dead")
                        ;
                    }
                    System.Console.Write("Please select a target or B to go back: ");
                    stageDone = false;
                    while (!stageDone)
                    {
                        userInput = System.Console.ReadLine();
                        if (userInput[0] == 'b' || userInput[0] == 'B') // Checks to see if the user wants to go back.
                        {
                            stageDone    = true;
                            currectStage = MOVE_SELECT_STAGE; // Move Stage Selected.
                        }
                        else if (int.TryParse(userInput, out convertedInput))
                        {
                            convertedInput -= 1;
                            if (convertedInput >= 0 && convertedInput < fighters.Length)
                            {
                                currectFighter.NextTarget = convertedInput;
                                System.Console.WriteLine("{0} targeted", fighters[currectFighter.NextTarget].FighterName);
                                stageDone    = true;
                                currectStage = DONE_STAGE; // Done Stage Selected.
                            }
                            else
                            {
                                System.Console.WriteLine("{0} is invalid", userInput);
                                System.Console.Write("Please enter another number: ");
                            }
                        }
                        else
                        {
                            System.Console.WriteLine("{0} is invalid", userInput);
                            System.Console.Write("Please enter another number: ");
                        }
                    }
                }
                else if (currectStage == INFO_STAGE) // This is used for debuging/user info about fighters.
                {
                    //This prints the fighters names with basic info.
                    for (int i = 0; i < fighters.Length; i++)
                    {
                        System.Console.WriteLine("{0}: {1} {2}{3}"
                                                 , i + 1
                                                 , (currectFighter.TeamID == fighters[i].TeamID) ? "Ally" : "Enemy"
                                                 , fighters[i].FighterName
                                                 , (fighters[i].StatHealthCurrect > 0) ? "" : " Dead"
                                                 );
                    }
                    System.Console.Write("Please select a target or B to go back: ");
                    stageDone = false;
                    while (!stageDone)
                    {
                        userInput = System.Console.ReadLine();
                        if (userInput[0] == 'b' || userInput[0] == 'B') // Checks to see if the user wants to go back.
                        {
                            stageDone    = true;
                            currectStage = MODE_SELECT_STAGE; // Mode Stage Selected.
                        }
                        else if (int.TryParse(userInput, out convertedInput))
                        {
                            convertedInput -= 1;
                            if (convertedInput >= 0 && convertedInput < fighters.Length)
                            {
                                Console.WriteLine("Name: {0}\nMax Health: {1}, Currecnt Health: {2}\nBase Attack: {3}, Currect Attack: {4}" +
                                                  "\nBase Defence: {5}, Currect Defence: {6}\nBase Speed: {7}, Current Speed: {8}\nPlayer Controlled: {9}, Team Number: {10}"
                                                  , fighters[convertedInput].FighterName
                                                  , fighters[convertedInput].StatHealthMax, fighters[convertedInput].StatHealthCurrect
                                                  , fighters[convertedInput].StatAttackBase, fighters[convertedInput].StatAttackBuffed
                                                  , fighters[convertedInput].StatDefenceBase, fighters[convertedInput].StatDefenceBuffed
                                                  , fighters[convertedInput].StatSpeedBase, fighters[convertedInput].StatSpeedBuffed
                                                  , !fighters[convertedInput].IsAI, fighters[convertedInput].TeamID
                                                  );
                                for (int i = 0; i < fighters[convertedInput].KnownMoves.Length; i++)
                                {
                                    Console.WriteLine("Move {0}: {1}", i + 1, moves[fighters[convertedInput].KnownMoves[i]].MoveName);
                                }
                                Console.WriteLine("Buff count: {0}", fighters[convertedInput].BuffList.Count);
                                for (int i = 0; i < fighters[convertedInput].BuffList.Count; i++)
                                {
                                    Console.WriteLine("Buff {0}: Stat: {1}, Magitude: %{2}, Duration: {3} turns left", i + 1, fighters[convertedInput].BuffList[i].ModdedStatID, fighters[convertedInput].BuffList[i].Magnitude, fighters[convertedInput].BuffList[i].Duration);
                                }
                                stageDone    = true;
                                currectStage = MODE_SELECT_STAGE;
                            }
                            else
                            {
                                System.Console.WriteLine("{0} is invalid", userInput);
                                System.Console.Write("Please enter another number: ");
                            }
                        }
                        else
                        {
                            System.Console.WriteLine("{0} is invalid", userInput);
                            System.Console.Write("Please enter another number: ");
                        }
                    }
                }
                else if (currectStage == DONE_STAGE) // This stage is used to finish the userInput, more of a placeholder for now.
                {
                    isUserInputDone = true;
                }
            }
        }
Example #3
0
        static Fighter[] FighterLoader(Move[] moves, Random rnd) // This builds the fighter array randomly for testing, based on user input.
        {
            int  MAX_MOVES_KNOWN = 4;
            bool inputGood;
            int  fighterCount    = 0;
            int  teamCount       = 0;
            int  teamInterval    = 0;
            int  realPlayerCount = 0;

            string[] names = { "Joe", "Rat", "Dog", "Fish", "Log", "Tim", "Fern", "Bob" };
            System.Console.Write("Enter the number of fighters: ");
            while (!int.TryParse(System.Console.ReadLine(), out fighterCount))
            {
                System.Console.WriteLine("Invalid");
            }
            Fighter[] fighters     = new Fighter[fighterCount];
            int[]     fighterMoves = new int[MAX_MOVES_KNOWN];
            inputGood = false;
            while (!inputGood)
            {
                System.Console.Write("Enter the number of teams: ");
                if (int.TryParse(System.Console.ReadLine(), out teamCount))
                {
                    if (teamCount > 1)
                    {
                        inputGood = true;
                    }
                    else
                    {
                        System.Console.WriteLine("Must be greater then 1");
                    }
                }
                else
                {
                    System.Console.WriteLine("Invalid input");
                }
            }
            inputGood = false;
            while (!inputGood)
            {
                System.Console.Write("Enter the Number of real players: ");
                if (int.TryParse(System.Console.ReadLine(), out realPlayerCount))
                {
                    if (teamCount >= 0)
                    {
                        inputGood = true;
                    }
                    else
                    {
                        System.Console.WriteLine("Must be greater then 1");
                    }
                }
                else
                {
                    System.Console.WriteLine("Invalid input");
                }
            }
            bool isAI;

            for (int i = 0; i < fighterCount; i++)
            {
                for (int k = 0; k < fighterMoves.Length; k++)
                {
                    fighterMoves[k] = rnd.Next(1, moves.Length);
                }
                if (i <= realPlayerCount - 1)
                {
                    isAI = false;
                }
                else
                {
                    isAI = true;
                }
                if (i == 0)
                {
                    teamInterval = 1;
                }
                else if (i == 1)
                {
                    teamInterval = 2;
                }
                else
                {
                    teamInterval = rnd.Next(1, teamCount + 1);
                }
                fighters[i] = new Fighter(names[rnd.Next(0, names.Length)] + i, 1, 0, 500, 500, rnd.Next(1, 100), rnd.Next(1, 100), rnd.Next(1, 100), isAI, teamInterval, GLOBAL.IntArrayDeepCopy(fighterMoves));
            }
            return(fighters);
        }
Example #4
0
 private void AIMoveSelecter(Fighter currectFighter) // This is used by the AI to select their next move.
 {
     // Just selects a random move for now.
     currectFighter.NextMove = this.rnd.Next(0, currectFighter.KnownMoves.Length);
 }