public static Interaction GetInteraction(decimal amount, decimal fee) { string parm1 = amount.ToString("0.00000000").Split('.')[1]; int costTypeInt = int.Parse(parm1.Substring(0, 2)); int interactionTypInt = int.Parse(parm1.Substring(2, 2)); if (Enum.IsDefined(typeof(CostType), costTypeInt) && Enum.IsDefined(typeof(InteractionType), interactionTypInt)) { CostType costType = (CostType)costTypeInt; InteractionType interactionType = (InteractionType)interactionTypInt; int addParam1 = int.Parse(parm1.Substring(4, 4)); int addParam2 = int.Parse(fee.ToString("0.00000000").Split('.')[1].Substring(4, 4)); switch (interactionType) { case InteractionType.ADVENTURE: if (AdventureAction.TryGetAdventure(addParam1, addParam2, out AdventureAction adventure)) { return(adventure); } break; case InteractionType.LEVELING: if (LevelingAction.TryGetAdventure(addParam1, addParam2, out LevelingAction leveling)) { return(leveling); } break; } } return(new Unknown()); }
public static bool TryGetAdventure(int paramAdd1, int paramAdd2, out AdventureAction adventure) { if (Enum.IsDefined(typeof(AdventureType), int.Parse(paramAdd1.ToString("0000").Substring(0, 1))) && Enum.IsDefined(typeof(DifficultyType), int.Parse(paramAdd2.ToString("0000").Substring(0, 1)))) { adventure = new AdventureAction(paramAdd1, paramAdd2); return(true); } adventure = null; return(false); }
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()); }