示例#1
0
        public async Task SearchBattles(CommandContext context)
        {
            const int maxOpponents = 5;

            await context.RespondAsync("Buscando oponentes");

            var remainingPlayers = await DBConection.SearchMatch(context.Member);

            if (remainingPlayers == null || remainingPlayers.Count == 0)
            {
                await context.RespondAsync("No hay contrincantes!");

                return;
            }
            System.Text.StringBuilder playerBuilder = new System.Text.StringBuilder();
            playerBuilder.Append("Contricantes: ");
            int opponentCount = 1;

            foreach (var opponent in remainingPlayers)
            {
                playerBuilder.Append($" {opponent.Name}");
                opponentCount++;
                if (opponentCount == maxOpponents)
                {
                    break;
                }
            }
            await context.RespondAsync(playerBuilder.ToString());
        }
示例#2
0
        public MainWindow()
        {
            InitializeComponent();
            string server, user, pass, port, db, type;
            var    conMng = ConfigurationManager.GetSection("ConnectionManagerDatabaseServers") as System.Collections.Specialized.NameValueCollection;

            if (conMng != null)
            {
                //vezi http:/
                //blog.danskingdom.com
                //adding-and-accessing-custom-sections-in-your-c-app-config
                server = conMng["Server"].ToString();
                user   = conMng["User"].ToString();
                pass   = conMng["Password"].ToString();
                port   = conMng["Port"].ToString();
                db     = conMng["NumeDB"].ToString();
                type   = conMng["tip"].ToString();
                //Console.WriteLine(server + " " + user + " " + pass + " " + port + " " + db + " " + db);
                switch (type)
                {
                case "MySQL": con = DBFactory.getConnection(DBConection.MyDBType.MySQL); break;

                default: con = null; throw new ConnectionNotConfiguredException();
                }
                con.Open(server, user, pass, Int32.Parse(port), db);
            }
            else
            {
                throw new ConnectionNotConfiguredException();
            }
        }
示例#3
0
 /// <summary>
 /// Загрузка фаила с сервером
 /// </summary>
 public static void FileLoad()
 {
     try
     {
         string path = @"\HelaMedical\HelaMedical\File\INC.INI";
         if (!File.Exists(path))
         {
             MessageBox.Show("Файл с нахождением информации по серверу не найден!" +
                             "\nУкажите место нахождение файла");
             path = OpenFile.Open_File();
         }
         string s = File.ReadAllText(path);
         DBConection.Select(s);
     }
     catch (Exception excep)
     {
         MessageBox.Show(excep.Message);
         ExcepLog.Excep(excep);
     }
 }
示例#4
0
        public static Jucator getFromTextBox(String textBoxString, DBConection con)
        {
            if (textBoxString == "" || textBoxString.StartsWith("Jucator"))
            {
                return(null);
            }
            int  n;
            bool b  = int.TryParse(textBoxString, out n);
            bool b1 = textBoxString.All(char.IsDigit);

            if (b1)
            {
                return(con.getConcurentWithMPByID(textBoxString));
            }
            else
            {
                //prenume, nume
                int i = textBoxString.IndexOf(',');
                return(con.getJucatorByFullName(textBoxString.Substring(i + 2), textBoxString.Substring(0, i)));
            }
        }
示例#5
0
        public async Task Victoria(CommandContext context, [Description("El usuario al que le ganaste")] DiscordMember targetUser = null, [RemainingText] string resultStr = null)
        {
            var callingUser = context.Member;

            if (callingUser == targetUser)
            {
                return;
            }

            if (targetUser == null)
            {
                await context.ReplyAsync("Faltó escribir el oponente.");

                return;
            }

            if (targetUser.IsBot)
            {
                await context.ReplyAsync("No puedes reportar una victoria contra un bot!");

                return;
            }

            if (string.IsNullOrWhiteSpace(resultStr))
            {
                await context.ReplyAsync("Faltó escribir el resultado");

                return;
            }

            var messageValid = ResultService.GetResult(callingUser, targetUser, resultStr, out Result result);

            if (!messageValid)
            {
                await context.ReplyAsync($"No se escribió bien el resultado: {resultStr}. Ejemplo: 2-1");

                return;
            }

            var generalMessage = $"Resultado: \n\t{result.winner}\t{result.loser}. {result.message}";
            await targetUser.SendMessageAsync($"El usuario {callingUser.Mention} reportó una victoria {result.winner.score}-{result.loser.score} contra ti.");

            var channelName = ChannelRedirection.GetRedirectedChannel(context.Channel.Name);

            var channel = GuildService.FindTextChannel(context, channelName);
            var admins  = GuildService.FindRole(context, "admin");

            if (channel == null)
            {
                var roles    = callingUser.Roles;
                var roleText = GuildService.GetEntityNames(roles);
                generalMessage = $"{generalMessage}\nCanal: {context.Channel.Name} Roles: {roleText}";

                channelName = ChannelRedirection.TargetChannelName;
                channel     = GuildService.FindTextChannel(context, channelName);

                if (channel == null)
                {
                    await context.ReplyAsync($"{generalMessage}");

                    return;
                }
            }

            await GuildService.SendMessageToTextChannel(channel, generalMessage, admins);

            await context.ReplyAsync($"{generalMessage}");

            var hasAdmin = callingUser.Roles.Where(role => role.Name.Contains("admin")).Count() > 0;

            if (!hasAdmin)
            {
                var interaction = context.Client.GetInteractivity();

                await context.RespondAsync($"{targetUser.Mention} confirma la victoria de {callingUser.DisplayName}. Sólo escribe sí o no.");

                var response = await interaction.WaitForMessageAsync(context.WithPredicate().ToUser (targetUser).InSameChannel());

                if (response.TimedOut || response.Result.Content.Contains("no"))
                {
                    await context.RespondAsync(
                        $"{callingUser.Mention} no se ha aceptado tu victoria. Revisa si hay  un problema o contacta a un administrador.");

                    return;
                }
            }

            if (await DBConection.SetMatch(context.Guild.Id, callingUser, targetUser))
            {
                await context.RespondAsync($"Se ha reportado la victoria de {callingUser.DisplayName}");
            }
            else
            {
                await context.RespondAsync($"No hay peleas pendientes contra {targetUser.DisplayName}!");
            }
        }
示例#6
0
 public Teams(DBConection con)
 {
     conection = con;
     echipe    = new Concurenti <Echipa>();
     InitializeComponent();
 }