コード例 #1
0
        private static bool ParseListCategories(IrcMessageData data)
        {
            var split = data.Message.Split(new [] { ' ' }, 2);

            if (split.Length != 2)
            {
                Console.WriteLine("Invalid arguments for command");
                return(false);
            }
            Games.Game game = Games.GameList.FirstOrDefault(x => x.GameNames.Any(y => y.ToLower() == (split.ElementAtOrDefault(1) ?? string.Empty).ToLower()));
            if (game == null)
            {
                Connection.SendToChat("Game not found");
                return(false);
            }
            Connection.SendToChat(string.Join(" , ", (from i in game.Categories orderby i select i).ToList()));
            return(true);
        }
コード例 #2
0
        private static bool ParseBuyRun(IrcMessageData data)
        {
            decimal pointCost = 100;

            var split = data.Message.Split(new[] { ' ' }, 3);

            if (split.Length != 3)
            {
                Console.WriteLine("Invalid !buyrun command");
                return(false);
            }
            string gameName = split.ElementAtOrDefault(1) ?? string.Empty;

            Games.Game game = Games.GameList.FirstOrDefault(x => x.GameNames.Any(y => y.ToLower() == gameName.ToLower()));
            if (game == null)
            {
                Connection.SendToChat("Game not found");
                return(false);
            }
            if (game.Categories.Any(x => x.ToLower() == split.ElementAtOrDefault(2).ToLower()))
            {
                decimal points = 0;
                int     exp    = 0;
                UserManager.GetUserInfo(data.Nick, out exp, out points);
                if (points >= pointCost)
                {
                    Connection.SendToChat(string.Format("User {0} has bought a run! Game: {1} Category: {2}", data.Nick,
                                                        split.ElementAtOrDefault(1), split.ElementAtOrDefault(2)));
                    UserManager.UpdateUser(data.Nick, 0, -pointCost);
                    return(true);
                }
                else
                {
                    Connection.SendToChat("Not enough fasts!");
                    return(false);
                }
            }
            else
            {
                Connection.SendToChat("Category not found");
            }
            return(false);
        }