Example #1
0
 internal void ValidaBloqueados(Bloqueados bloqueados, Usuario usuario)
 {
     if (bloqueados.ContainsKey(usuario))
     {
         throw new Exception(string.Format("Se ferrou, foi bloqueado pelo motivo: {0}", bloqueados[usuario]));
     }
 }
Example #2
0
        private ListaVotos()
        {
            Usuarios = Arquivos.Arquivos.Deserialize <Usuarios>(Consts.Consts.CadPath);
            if (Usuarios == null)
            {
                Usuarios = new Usuarios();
            }

            Votos      = new List <Voto>();
            Bloqueados = new Bloqueados();
        }
Example #3
0
        internal void Bloquear(string id, string targetId, string motivo)
        {
            new ValidadorVotacao().ValidaBloqueadosPermissao(id);

            var usuarioAlvo = Usuarios.FirstOrDefault(p => p.Id.ToString() == targetId)
                              .ExcecaoSeNull("Não achamos esse gamelão na nossa base baluda.");

            if (Bloqueados.ContainsKey(usuarioAlvo))
            {
                return;
            }
            Bloqueados.Add(usuarioAlvo, motivo);
            usuarioAlvo.Bloqueado = true;

            try
            {
                Arquivos.Arquivos.Serialize(Usuarios, Consts.Consts.CadPath);
            }
            catch
            {
                throw new Exception("Deu um erro massa que a gente sabe o que é, mas não vamos falar. Tente daqui a pouco");
            }
        }
Example #4
0
        private void GerarNosFilhos()
        {
            Nodo gerado;

            //Adjacente Norte
            if (Atual.Y - 1 >= 0)
            {
                gerado = new Nodo(Atual.X, Atual.Y - 1);
                if (!Expandidos.Contains(gerado) && !Bloqueados.Contains(gerado) && !Gerados.Contains(gerado))
                {
                    gerado.Peso = VerificarCusto(gerado, false);
                    Gerados.Add(gerado);
                    if (VerificarEstadoFinal())
                    {
                        return;
                    }
                }
            }
            //Adjacente Nordeste
            if (Atual.X < Grid.GetUpperBound(0))
            {
                if (Atual.Y - 1 >= 0)
                {
                    gerado = new Nodo(Atual.X + 1, Atual.Y - 1);
                    if (!Expandidos.Contains(gerado) && !Bloqueados.Contains(gerado) && !Gerados.Contains(gerado))
                    {
                        gerado.Peso = VerificarCusto(gerado, true);
                        Gerados.Add(gerado);
                        if (VerificarEstadoFinal())
                        {
                            return;
                        }
                    }
                }
            }
            //Adjacente Leste
            if (Atual.X < Grid.GetUpperBound(0))
            {
                gerado = new Nodo(Atual.X + 1, Atual.Y);
                if (!Expandidos.Contains(gerado) && !Bloqueados.Contains(gerado) && !Gerados.Contains(gerado))
                {
                    gerado.Peso = VerificarCusto(gerado, false);
                    Gerados.Add(gerado);
                    if (VerificarEstadoFinal())
                    {
                        return;
                    }
                }
            }
            //Adjacente Sudeste
            if (Atual.X < Grid.GetUpperBound(0))
            {
                if (Atual.Y < Grid.GetUpperBound(1))
                {
                    gerado = new Nodo(Atual.X + 1, Atual.Y + 1);
                    if (!Expandidos.Contains(gerado) && !Bloqueados.Contains(gerado) && !Gerados.Contains(gerado))
                    {
                        gerado.Peso = VerificarCusto(gerado, true);
                        Gerados.Add(gerado);
                        if (VerificarEstadoFinal())
                        {
                            return;
                        }
                    }
                }
            }
            //Adjacente Sul
            if (Atual.Y < Grid.GetUpperBound(1))
            {
                gerado = new Nodo(Atual.X, Atual.Y + 1);
                if (!Expandidos.Contains(gerado) && !Bloqueados.Contains(gerado) && !Gerados.Contains(gerado))
                {
                    gerado.Peso = VerificarCusto(gerado, false);
                    Gerados.Add(gerado);
                    if (VerificarEstadoFinal())
                    {
                        return;
                    }
                }
            }
            //Adjacente Sudoeste
            if (Atual.X - 1 >= 0)
            {
                if (Atual.Y < Grid.GetUpperBound(1))
                {
                    gerado = new Nodo(Atual.X - 1, Atual.Y + 1);
                    if (!Expandidos.Contains(gerado) && !Bloqueados.Contains(gerado) && !Gerados.Contains(gerado))
                    {
                        gerado.Peso = VerificarCusto(gerado, true);
                        Gerados.Add(gerado);
                        if (VerificarEstadoFinal())
                        {
                            return;
                        }
                    }
                }
            }
            //Adjancente Oeste
            if (Atual.X - 1 >= 0)
            {
                gerado = new Nodo(Atual.X - 1, Atual.Y);
                if (!Expandidos.Contains(gerado) && !Bloqueados.Contains(gerado) && !Gerados.Contains(gerado))
                {
                    gerado.Peso = VerificarCusto(gerado, false);
                    Gerados.Add(gerado);
                    if (VerificarEstadoFinal())
                    {
                        return;
                    }
                }
            }
            //Adjacente Noroeste
            if (Atual.X - 1 >= 0)
            {
                if (Atual.Y - 1 >= 0)
                {
                    gerado = new Nodo(Atual.X - 1, Atual.Y - 1);
                    if (!Expandidos.Contains(gerado) && !Bloqueados.Contains(gerado) && !Gerados.Contains(gerado))
                    {
                        gerado.Peso = VerificarCusto(gerado, true);
                        Gerados.Add(gerado);
                        if (VerificarEstadoFinal())
                        {
                            return;
                        }
                    }
                }
            }
        }