Exemplo n.º 1
0
        public static Character.Iactor CreateCharacter(CharacterEnums.CharacterType characterType, int MobTypeID = 0)
        {
            Character.Iactor character = null;

            switch (characterType)
            {
            case CharacterType.NPC:
                if (MobTypeID != 0)
                {
                    character = CreateNPCCharacter(MobTypeID);
                }
                else
                {
                    character = CreateNPCCharacterHusk();
                }
                break;

            case CharacterType.PLAYER:
                character = new Character.Character();
                break;

            default: character = null;
                break;
            }

            return(character);
        }
Exemplo n.º 2
0
        public double ParseAndCalculateCheck(Character.Iactor player, string calculation)
        {
            Expression expression = new Expression(ReplaceStringWithNumber(player, calculation));
            double     result     = 0;

            try {
                result = (double)expression.Evaluate();
            }
            catch (Exception) {
            }

            return(result);
        }
Exemplo n.º 3
0
        public object GetTarget(string type)
        {
            User.User        user      = new User.User();
            Character.Iactor character = CharacterFactory.Factory.CreateCharacter(CharacterEnums.CharacterType.PLAYER);
            user.Player = character;
            object o = null;

            if (string.Equals(type, "Character", StringComparison.CurrentCultureIgnoreCase))
            {
                o = character;
            }
            else
            {
                o = user;
            }

            return(o);
        }
Exemplo n.º 4
0
        /// <summary>
        /// For this method to work correctly the Attribute names **MUST** be separated by a space at the start and end.
        /// (Dexterity+Cunning) will not work it needs to be ( Dexterity + Cunning ) any other math symbols and numbers do not require
        /// spaces.
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        private string ReplaceStringWithNumber(Character.Iactor player, string calculation)
        {
            //would like to make this a bit more generic so if new attributes are inserted we don't have to change this method
            //I think easiest way is to have the expression be separated by spaces, but just so it works with anything let's get rid of
            //any mathematical signs and then we should just have the name of the attributes we want.
            string temp = calculation;

            string[] operators = new string[] { "+", "-", "/", "*", "(", ")", "[", "]", "{", "}", "^", "SQRT", "POW", "." };
            foreach (string operand in operators)
            {
                temp = temp.Replace(operand, " ");
            }

            //need to get rid of repeats and empty spaces
            string[] attributeList = temp.Split(' ');

            temp = calculation;

            foreach (string attributeName in attributeList)
            {
                if (!string.IsNullOrEmpty(attributeName))
                {
                    if (player.GetAttributes().ContainsKey(attributeName))
                    {
                        temp = temp.Replace(attributeName, player.GetAttributeValue("attributeName").ToString());
                    }
                    else if (player.GetSubAttributes().ContainsKey(attributeName))
                    {
                        temp = temp.Replace(attributeName, player.GetSubAttributes()[attributeName].ToString());
                    }
                    else if (attributeName.Contains("Rank"))
                    {
                        temp = temp.Replace(attributeName, player.GetAttributeRank(attributeName.Substring(0, attributeName.Length - 4)).ToString());
                    }
                }
            }

            return(temp);
        }
Exemplo n.º 5
0
 public double ParseAndCalculateCheck(Character.Iactor player, string calculation)
 {
     return(1.0d);
 }