Beispiel #1
0
        public OracleRoller(OracleService oracleService, GameName game, Random rnd = null)
        {
            OracleService = oracleService;
            Game          = game;

            RollerRandom = rnd ?? BotRandom.Instance;
        }
Beispiel #2
0
        internal static OracleRoller RebuildRoller(OracleService oracleService, EmbedBuilder embed)
        {
            var roller = new OracleRoller(oracleService, Utilities.GetGameContainedInString(embed.Author.Name));

            foreach (var field in embed.Fields)
            {
                var titleElementsRegex = Regex.Match(field.Name, @" ?(.*)\[(\d+)\]");
                var sourceTable        = oracleService.OracleList.Find(oracle => oracle.Name == titleElementsRegex.Groups[1].Value.Trim());

                var oracleResult = oracleService.OracleList.Find(tbl => tbl.Name == sourceTable.Name)?.Oracles?.Find(oracle => oracle.Description == field.Value.ToString()) ?? null;

                if (!Int32.TryParse(titleElementsRegex.Groups[2].Value, out int tempRoll))
                {
                    continue;
                }

                roller.RollResultList.Add(new RollResult
                {
                    ParentTable  = sourceTable,
                    Result       = oracleResult,
                    ShouldInline = field.IsInline,
                    Roll         = tempRoll
                });
            }

            return(roller);
        }