示例#1
0
        public static bool SplitByModel(string data)
        {
            try
            {
                string temp = string.Empty;

                if (data.Split('$').Length < 4)
                {
                    MenuId = (data.Split('$'))[0].ToString();
                    UserId = (data.Split('$'))[1].ToString();
                }
                else
                {
                    MenuId   = (data.Split('$'))[0].ToString();
                    Location = (data.Split('$'))[1].ToString();
                    UserId   = (data.Split('$'))[2].ToString();
                    temp     = (data.Split('$'))[3];
                }

                if (UserId.Contains("*"))
                {
                    UserId = UserId.Replace("*", "");
                }

                GenericObject = new T();

                foreach (var prop in GenericObject.GetType().GetProperties())
                {
                    if (prop.PropertyType == typeof(string))
                    {
                        string t = temp.Split('@')[0];
                        prop.SetValue(GenericObject, t);
                        temp = temp.Remove(temp.IndexOf(t), temp.IndexOf(t) + t.Length + 1);
                    }
                    else
                    {
                        prop.SetValue(GenericObject, temp.Split('@').ToList <string>());
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                GenericObject = new T();
                return(false);
            }
        }
示例#2
0
        /// <summary>Default string content of a multiplayer game message. Displays flavor text in AI matches.</summary>
        public override string GetContent(bool showHelp = true)
        {
            if (State != State.Cancelled && UserId.Count(id => id == client.CurrentUser.Id) == 1)
            {
                if (Message == "")
                {
                    Message = Bot.Random.Choose(StartTexts);
                }
                else if (Time > 1 && Winner == Player.None && (!AllBots || Time % 2 == 0))
                {
                    Message = Bot.Random.Choose(GameTexts);
                }
                else if (Winner != Player.None)
                {
                    if (Winner != Player.Tie && UserId[Winner] == client.CurrentUser.Id)
                    {
                        Message = Bot.Random.Choose(WinTexts);
                    }
                    else
                    {
                        Message = Bot.Random.Choose(NotWinTexts);
                    }
                }

                return(Message);
            }

            if (State == State.Active)
            {
                if (UserId[0] == UserId[1] && !UserId.Contains(client.CurrentUser.Id))
                {
                    return("Feeling lonely, or just testing the bot?");
                }
                if (Time == 0 && showHelp && UserId.Length > 1 && UserId[0] != UserId[1])
                {
                    return($"{User(0).Mention} You were invited to play {GameName}.\nChoose an action below, " +
                           $"or type `{storage.GetPrefix(Channel)}cancel` if you don't want to play");
                }
            }

            return("");
        }
示例#3
0
        public string this[string columnName]
        {
            get
            {
                switch (columnName)
                {
                case "UserId":
                    if (!string.IsNullOrEmpty(UserId))
                    {
                        if (!UserId.Contains("@") && !UserId.Contains("."))
                        {
                            return("Email address is not valid");
                        }
                    }
                    break;
                }

                return(string.Empty);
            }
        }
示例#4
0
        /// <summary>Default string content of a multiplayer game message. Displays flavor text in AI matches.</summary>
        public override async ValueTask <string> GetContentAsync(bool showHelp = true)
        {
            if (State != GameState.Cancelled && UserId.Count(id => id == ShardedClient.CurrentUser.Id) == 1)
            {
                var texts = new[] { Message };

                if (Message == "")
                {
                    texts = Content.gameStartTexts;
                }
                else if (Time > 1 && Winner == Player.None)
                {
                    texts = Content.gamePlayingTexts;
                }
                else if (Winner != Player.None)
                {
                    texts = Winner != Player.Tie && UserId[Winner] == ShardedClient.CurrentUser.Id
                        ? Content.gameWinTexts
                        : Content.gameNotWinTexts;
                }

                return(Message = Program.Random.Choose(texts));
            }

            if (State == GameState.Active)
            {
                if (UserId[0] == UserId[1] && !UserId.Contains(ShardedClient.CurrentUser.Id))
                {
                    return("Feeling lonely, or just testing the bot?");
                }
                if (Time == 0 && showHelp && UserId.Length > 1 && UserId[0] != UserId[1])
                {
                    return($"{(await GetUserAsync(0)).Mention} You were invited to play {GameName}.\nChoose an action below, " +
                           $"or type `{Storage.GetPrefix(Channel)}cancel` if you don't want to play");
                }
            }

            return("");
        }