private static void AddToDictionary(string unparsedWrestlerString)
        {
            string key = UsefulActions.GetDataFromUnparsedFile(unparsedWrestlerString, "Name: ");

            WrestlerData wrestlerData = new WrestlerData(unparsedWrestlerString);

            if (allWrestlers.ContainsKey(key))
            {
                throw new Exception("The wrestler '" + key + "' already exists.");
            }
            allWrestlers.Add(key, wrestlerData);
        }
Ejemplo n.º 2
0
        private static void AddToDictionary(string unparsedMoveString)
        {
            string textFromFile = UsefulActions.GetDataFromUnparsedFile(unparsedMoveString, "ID: ");
            ushort moveID       = ushort.Parse(textFromFile);

            //Remove the ID from the string
            MoveData newMove = new MoveData(unparsedMoveString);

            if (allMoves.ContainsKey(moveID))
            {
                throw new Exception("The ID: " + moveID + " already exists.");
            }
            allMoves.Add(moveID, newMove);
        }
Ejemplo n.º 3
0
        public readonly float lowerMoveTime, upperMoveTime;         //length of time it takes to perform the move

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

            name = textFromFile;

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Description: ");
            description  = textFromFile;

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Stamina Cost: ");
            switch (textFromFile.ToUpper())
            {
            case "VERY LOW":
                staminaCost = StaminaCost.VERY_LOW;
                break;

            case "LOW":
                staminaCost = StaminaCost.LOW;
                break;

            case "NORMAL":
                staminaCost = StaminaCost.NORMAL;
                break;

            case "HIGH":
                staminaCost = StaminaCost.HIGH;
                break;

            case "VERY HIGH":
                staminaCost = StaminaCost.VERY_HIGH;
                break;
            }

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Offence Type: ");
            switch (textFromFile.ToUpper())
            {
            case "GRAPPLE":
                offenceType = OffenceType.GRAPPLE;
                break;

            case "STRIKE":
                offenceType = OffenceType.STRIKE;
                break;

            case "DIVE":
                offenceType = OffenceType.FLYING;
                break;

            case "RUNNING":
                offenceType = OffenceType.RUNNING;
                break;
            }

            textFromFile     = UsefulActions.GetDataFromUnparsedFile(textToParse, "Required Position: ");
            requiredPosition = StringToPosition(textFromFile);

            textFromFile             = UsefulActions.GetDataFromUnparsedFile(textToParse, "Required Opponent Position: ");
            requiredOpponentPosition = StringToPosition(textFromFile);

            textFromFile     = UsefulActions.GetDataFromUnparsedFile(textToParse, "Finished Position: ");
            finishedPosition = StringToPosition(textFromFile);

            textFromFile     = UsefulActions.GetDataFromUnparsedFile(textToParse, "Reversal Position: ");
            reversalPosition = StringToPosition(textFromFile);

            textFromFile = UsefulActions.GetDataFromUnparsedFile(textToParse, "Damaged Body Parts: ");
            string[] bodyParts = textFromFile.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
            damagedBodyParts = new BodyPart[bodyParts.Length];
            for (byte i = 0; i < bodyParts.Length; i++)
            {
                switch (bodyParts [i].ToUpper())
                {
                case "HEAD":
                    damagedBodyParts [i] = BodyPart.HEAD;
                    break;

                case "TORSO":
                    damagedBodyParts [i] = BodyPart.TORSO;
                    break;

                case "ARMS":
                    damagedBodyParts [i] = BodyPart.ARMS;
                    break;

                case "LEGS":
                    damagedBodyParts [i] = BodyPart.LEGS;
                    break;

                default:
                    throw new Exception("Not a valid body part.");
                }
            }

            textFromFile  = UsefulActions.GetDataFromUnparsedFile(textToParse, "Lower Move Time: ");
            lowerMoveTime = float.Parse(textFromFile);

            textFromFile  = UsefulActions.GetDataFromUnparsedFile(textToParse, "Upper Move Time: ");
            upperMoveTime = float.Parse(textFromFile);
        }
Ejemplo n.º 4
0
        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);
            }
        }