Exemplo n.º 1
0
        public static bool TryGetInteraction(int paramAdd1, int paramAdd2, out SpecialAction special)
        {
            if (Enum.IsDefined(typeof(SpecialType), int.Parse(paramAdd1.ToString("0000").Substring(0, 2))) &&
                Enum.IsDefined(typeof(SpecialSubType), int.Parse(paramAdd1.ToString("0000").Substring(2, 2))))
            {
                special = new SpecialAction(paramAdd1, paramAdd2);
                return(true);
            }

            special = null;
            return(false);
        }
Exemplo n.º 2
0
        public static Interaction GetInteraction(decimal amount, decimal fee)
        {
            var param1 = ((int)(amount * 100000000 % 100000000)).ToString("00000000");
            //var param1 = amount.ToString("0.00000000").Split('.')[1];
            var costTypeInt = int.Parse(param1.Substring(0, 2));
            //var costTypeInt = (int) (amount * 100 % 100);
            var interactionTypInt = int.Parse(param1.Substring(2, 2));

            //var interactionTypInt = (int) (amount * 10000 % 10000) % (costTypeInt * 100);

            if (Enum.IsDefined(typeof(CostType), costTypeInt) &&
                Enum.IsDefined(typeof(InteractionType), interactionTypInt))
            {
                var interactionType = (InteractionType)interactionTypInt;
                var addParam1       = int.Parse(param1.Substring(4, 4));

                var feeString = ((int)(fee * 100000000 % 100000000)).ToString("00000000");
                var addParam2 = int.Parse(feeString.Substring(4, 4));
                //var addParam2 = int.Parse(fee.ToString("0.00000000").Split('.')[1].Substring(4, 4));

                switch (interactionType)
                {
                case InteractionType.Adventure:
                    if (AdventureAction.TryGetInteraction(addParam1, addParam2, out AdventureAction adventure))
                    {
                        return(adventure);
                    }

                    break;

                case InteractionType.Leveling:
                    if (LevelingAction.TryGetInteraction(addParam1, addParam2, out LevelingAction leveling))
                    {
                        return(leveling);
                    }

                    break;

                case InteractionType.Special:
                    if (SpecialAction.TryGetInteraction(addParam1, addParam2, out SpecialAction special))
                    {
                        return(special);
                    }

                    break;
                }
            }

            return(new Unknown());
        }