Exemple #1
0
        private void AddToDictionary(Dictionary <PositionLayout, List <MoveData> > myDictionary, PositionLayout requiredPosition, ushort moveID)
        {
            MoveData        move  = MoveDictionary.GetMove(moveID);
            List <MoveData> moves = null;

            if (myDictionary.ContainsKey(requiredPosition))
            {
                moves = myDictionary [requiredPosition];
                moves.Add(move);                  //We're adding to a reference, so we do not have to readd the list to the dictionary
                return;
            }

            moves = new List <MoveData> ();
            moves.Add(move);
            myDictionary.Add(requiredPosition, moves);
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            UsefulActions.InitialiseRandom();
            MoveDictionary.Initialise();
            WrestlerDictionary.Initialise();

            Console.WriteLine("Welcome to my Wrestling Simulator!");
            Console.WriteLine("Currently you can only do pin-fall only matches which require at least 2 wrestlers (can do multi-man matches).");
            Console.WriteLine("\nHere's the list of all available wrestlers:");
            WrestlerDictionary.ListAllWrestlers();
            Console.WriteLine("\nList all wrestlers you wish to add into the match, then type START when you're done.");

            List <Wrestler> wrestlersInMatch = new List <Wrestler> ();
            string          userInput        = "";

            while (!userInput.Equals("START"))
            {
                userInput = Console.ReadLine();
                WrestlerData wrestlerDetails = WrestlerDictionary.GetWrestler(userInput);
                if (wrestlerDetails == null)
                {
                    Console.WriteLine("The wrestler: '{0}' does not exist.", userInput);
                    continue;
                }
                Wrestler wrestler = new Wrestler(wrestlerDetails);
                wrestlersInMatch.Add(wrestler);

                Console.WriteLine("{0} has been added.", userInput);
            }

            /*Wrestler wrestlerA = new Wrestler (WrestlerDictionary.GetWrestler ("Bob Dylan"));
             * Wrestler wrestlerB = new Wrestler (WrestlerDictionary.GetWrestler ("Jake Matthews"));
             * Wrestler wrestlerC = new Wrestler (WrestlerDictionary.GetWrestler ("Michael Lopez"));
             * Wrestler[] wrestlerList = new Wrestler[] { wrestlerA, wrestlerB, wrestlerC };*/

            Match.instance = new NormalMatch(wrestlersInMatch.ToArray());
            Match.instance.ProcessMatch();

            Console.WriteLine("The program will end after you press enter.");
            Console.ReadLine();
        }
        public WrestlerData(string textToParse)
        {
            /*string textToParse = File.ReadAllText (filePath);
             * if (textToParse.Length == 0)
             *      throw new Exception ("File with path '" + filePath + "' is empty.");*/

            string textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Name: ");

            name = textFromFile;

            textFromFile   = UsefulActions.GetDataFromUnparsedFile(textToParse, "Wrestling Style: ");
            wrestlingStyle = GetWrestlingStyle(textFromFile);

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Weight: ");
            weight       = ushort.Parse(textFromFile);

            textFromFile    = UsefulActions.GetDataFromUnparsedFile(textToParse, "Grapple Strength: ");
            grappleStrength = float.Parse(textFromFile);

            textFromFile     = UsefulActions.GetDataFromUnparsedFile(textToParse, "Striking Strength: ");
            strikingStrength = float.Parse(textFromFile);

            textFromFile    = UsefulActions.GetDataFromUnparsedFile(textToParse, "Running Strength: ");
            runningStrength = float.Parse(textFromFile);

            textFromFile   = UsefulActions.GetDataFromUnparsedFile(textToParse, "Diving Strength: ");
            divingStrength = float.Parse(textFromFile);

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Heart: ");
            heart        = float.Parse(textFromFile);

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Health: ");
            health       = float.Parse(textFromFile);

            textFromFile   = UsefulActions.GetDataFromUnparsedFile(textToParse, "Health Recovery: ");
            healthRecovery = float.Parse(textFromFile);

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Stamina: ");
            stamina      = float.Parse(textFromFile);

            textFromFile    = UsefulActions.GetDataFromUnparsedFile(textToParse, "Stamina Recovery: ");
            staminaRecovery = float.Parse(textFromFile);

            textFromFile   = UsefulActions.GetDataFromUnparsedFile(textToParse, "Head Resistance: ");
            headResistance = float.Parse(textFromFile);

            textFromFile    = UsefulActions.GetDataFromUnparsedFile(textToParse, "Torso Resistance: ");
            torsoResistance = float.Parse(textFromFile);

            textFromFile  = UsefulActions.GetDataFromUnparsedFile(textToParse, "Arms Resistance: ");
            armResistance = float.Parse(textFromFile);

            textFromFile  = UsefulActions.GetDataFromUnparsedFile(textToParse, "Legs Resistance: ");
            legResistance = float.Parse(textFromFile);

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Technique: ");
            technique    = float.Parse(textFromFile);

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Speed: ");
            speed        = float.Parse(textFromFile);

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Block: ");
            block        = float.Parse(textFromFile);

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Counter: ");
            counter      = float.Parse(textFromFile);

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Submission: ");
            submission   = float.Parse(textFromFile);

            myMoves = new MoveList();

            //Add moves to the moves list
            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Finishers: ");
            while (textFromFile.Length > 1)
            {
                int indexOfComma   = textFromFile.IndexOf(',');
                int indexOfIDStart = indexOfComma + 2;
                int indexOfEnd     = textFromFile.IndexOf(']');

                string specialMoveName = textFromFile.Substring(1, indexOfComma - 1);
                string moveIDText      = textFromFile.Substring(indexOfIDStart, indexOfEnd - indexOfIDStart);

                ushort   moveID       = ushort.Parse(moveIDText);
                MoveData originalMove = MoveDictionary.GetMove(moveID);

                PositionLayout requiredPosition = new PositionLayout(originalMove.requiredPosition, originalMove.requiredOpponentPosition);
                myMoves.AddToFinishers(requiredPosition, moveID, specialMoveName);
                textFromFile = textFromFile.Remove(0, indexOfEnd + 1);
                if (textFromFile.Length != 0)
                {
                    textFromFile = textFromFile.Remove(0, 2);
                }
            }

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Signatures: ");
            while (textFromFile.Length > 1)
            {
                int indexOfComma   = textFromFile.IndexOf(',');
                int indexOfIDStart = indexOfComma + 2;
                int indexOfEnd     = textFromFile.IndexOf(']');

                string specialMoveName = textFromFile.Substring(1, indexOfComma - 1);
                string moveIDText      = textFromFile.Substring(indexOfIDStart, indexOfEnd - indexOfIDStart);

                ushort   moveID       = ushort.Parse(moveIDText);
                MoveData originalMove = MoveDictionary.GetMove(moveID);

                PositionLayout requiredPosition = new PositionLayout(originalMove.requiredPosition, originalMove.requiredOpponentPosition);
                myMoves.AddToSignatures(requiredPosition, moveID, specialMoveName);
                textFromFile = textFromFile.Remove(0, indexOfEnd + 1);
                if (textFromFile.Length != 0)
                {
                    textFromFile = textFromFile.Remove(0, 2);
                }
            }

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Favourite Moves: ");
            while (textFromFile.Length > 1)
            {
                int indexOfComma = textFromFile.IndexOf(',');
                if (indexOfComma == -1)
                {
                    indexOfComma = textFromFile.Length - 1;
                }

                string   moveIDText   = textFromFile.Substring(0, indexOfComma);
                ushort   moveID       = ushort.Parse(moveIDText);
                MoveData originalMove = MoveDictionary.GetMove(moveID);

                PositionLayout requiredPosition = new PositionLayout(originalMove.requiredPosition, originalMove.requiredOpponentPosition);
                myMoves.AddToFavouriteMoves(requiredPosition, moveID);
                if (indexOfComma + 2 > textFromFile.Length)
                {
                    break;
                }
                textFromFile = textFromFile.Remove(0, indexOfComma + 2);
            }

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Normal Moves: ");
            while (textFromFile.Length > 1)
            {
                int indexOfComma = textFromFile.IndexOf(',');
                if (indexOfComma == -1)
                {
                    indexOfComma = textFromFile.Length - 1;
                }

                string moveIDText = textFromFile.Substring(0, indexOfComma);

                ushort   moveID       = ushort.Parse(moveIDText);
                MoveData originalMove = MoveDictionary.GetMove(moveID);

                PositionLayout requiredPosition = new PositionLayout(originalMove.requiredPosition, originalMove.requiredOpponentPosition);
                myMoves.AddToMoves(requiredPosition, moveID);
                if (indexOfComma + 2 > textFromFile.Length)
                {
                    break;
                }
                textFromFile = textFromFile.Remove(0, indexOfComma + 2);
            }
        }