Ejemplo n.º 1
0
        private static void RunServer([NotNull] IEnumerable <string> args)
        {
            var staticContentPath    = GetStaticContentDir();
            var settings             = GetSettingsFile(args);
            var httpListenerPrefix   = settings.HttpListenerPrefix;
            var warriorProgramParser = new WarriorParser();
            var playersRepo          = new PlayersRepo(new DirectoryInfo("../players"), warriorProgramParser);
            var gamesRepo            = new CachingGamesRepo(new GamesRepo(new DirectoryInfo("../games")));
            var sessionManager       = new SessionManager("../sessions");
            var gameServer           = new GameServer();
            var debuggerManager      = new DebuggerManager(gameServer);
            var battleRunner         = new BattleRunner();
            var countdownProvider    = new CountdownProvider(settings.ContestStartTimestamp, TimeSpan.FromHours(settings.ContestDurationInHours));
            var arenaState           = new ArenaState(playersRepo, gamesRepo, countdownProvider, settings.GodModeSecret, settings.GodAccessOnly, settings.SubmitIsAllowed, settings.EnableDeepNavigation);
            var tournamentRunner     = new TournamentRunner(arenaState, battleRunner, settings.BattlesPerPair);
            var httpServer           = new GameHttpServer(httpListenerPrefix, arenaState, sessionManager, debuggerManager, tournamentRunner, staticContentPath);

            Runtime.SetStopHandler(() =>
            {
                log.InfoFormat("Stopping...");
                httpServer.Stop();
                tournamentRunner.Stop();
            });
            tournamentRunner.Start();
            httpServer.Run();
            log.InfoFormat("Listening on: {0}", httpListenerPrefix);
            if (!settings.ProductionMode)
            {
                Process.Start(httpServer.DefaultUrl);
            }
            httpServer.WaitForTermination();
            tournamentRunner.WaitForTermination();
            log.InfoFormat("Stopped");
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            PlayersRepo playerRepo = new PlayersRepo();
            TeamsRepo   teamRepo   = new TeamsRepo();

            var playTeam = new Tuple <IEnumerable <SelectListItem>, IEnumerable <SelectListItem>, IEnumerable <SelectListItem> >(playerRepo.GetAllPlayersNames(), playerRepo.GetAllPlayerTypes(), teamRepo.GetAllTeamNames());

            return(View(playTeam));
        }
Ejemplo n.º 3
0
        public EmailProcessing(FetchAllUnseenPop3Client client, PlayersRepo playersRepo, AnswersRepo answersRepo,
		                       TagsRepo tagsRepo, Replier replier)
        {
            this.client = client;
            this.playersRepo = playersRepo;
            this.answersRepo = answersRepo;
            this.tagsRepo = tagsRepo;
            this.replier = replier;
        }
Ejemplo n.º 4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            var dialogResult = MessageBox.Show("Czy napewno usunąć zaznaczony rekord?", "Pytanie", MessageBoxButtons.YesNo,
                                               MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes)
            {
                PlayersRepo playersRepo = new PlayersRepo();
                var         player      = (Player)lsbPlayers.SelectedItem;
                playersRepo.DeletePlayer(player.Id);
            }
            RefreshData();
        }
Ejemplo n.º 5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Player player = new Player
            {
                Imie     = txtImieNew.Text,
                Nazwisko = txtNazwiskoNew.Text,
                Kraj     = txtKrajNew.Text,
                DataUr   = dateTimePicker2.Value,
                Wzrost   = Convert.ToInt32(txtWzrostNew.Text),
                Waga     = Convert.ToInt32(txtWagaNew.Text)
            };

            PlayersRepo playersRepo = new PlayersRepo();

            playersRepo.AddPlayer(player);
            RefreshData();
        }
Ejemplo n.º 6
0
 private GameResult GetResults(TagInfo tag, PlayersRepo playersRepo, Dictionary<string, PlayerAnswers> playerAnswers)
 {
     IDictionary<string, int> wordStats = playerAnswers.SelectMany(ans => ans.Value.Answers).CountStatistics(word => word);
     return
         new GameResult
             {
                 Results = playerAnswers.Keys.Select(
                     k => new PlayerResult
                          	{
                          		Player = playersRepo.Find(k),
                                 WordsScores =
                          			playerAnswers[k].Answers.Select(ans => Tuple.Create(ans, wordStats[ans])).ToArray(),
                                 Score = playerAnswers[k].Answers.Sum(ans => wordStats[ans])
                          	}
                     ).OrderByDescending(p => p.Score).ToArray(),
                 Tag = tag,
                 WordsScores =
                     wordStats.OrderByDescending(kv => kv.Value).Select(kv => Tuple.Create(kv.Key, kv.Value)).ToArray()
             };
 }
Ejemplo n.º 7
0
        public void GetPlayers()
        {
            var players = new PlayersRepo().GetPlayers();

            Assert.IsTrue(players.Count > 0);
        }
Ejemplo n.º 8
0
        private void RefreshData()
        {
            PlayersRepo playersRepo = new PlayersRepo();

            Filter filter = new Filter();

            filter.Imie     = txtImie.Text;
            filter.Nazwisko = txtNazwisko.Text;
            filter.Kraj     = txtKraj.Text;
            if (string.IsNullOrWhiteSpace(txtWzrostOd.Text))
            {
                filter.WzrostOd = null;
            }
            else
            {
                filter.WzrostOd = Convert.ToInt32(txtWzrostOd.Text);
            }

            if (string.IsNullOrWhiteSpace(txtWzrostDo.Text))
            {
                filter.WzrostDo = null;
            }
            else
            {
                filter.WzrostDo = Convert.ToInt32(txtWzrostDo.Text);
            }

            if (string.IsNullOrWhiteSpace(txtWagaOd.Text))
            {
                filter.WagaOd = null;
            }
            else
            {
                filter.WagaOd = Convert.ToInt32(txtWagaOd.Text);
            }

            if (string.IsNullOrWhiteSpace(txtWagaDo.Text))
            {
                filter.WagaDo = null;
            }
            else
            {
                filter.WagaDo = Convert.ToInt32(txtWagaDo.Text);
            }

            if (checkBoxDataOd.Checked)
            {
                filter.DataUrOd = datDataUrOd.Value;
            }
            else
            {
                filter.DataUrOd = null;
            }

            if (checkBoxDataDo.Checked)
            {
                filter.DataUrDo = datDataUrDo.Value;
            }
            else
            {
                filter.DataUrDo = null;
            }

            lsbPlayers.DataSource    = playersRepo.GetPlayers(filter);
            lsbPlayers.DisplayMember = "ImieNazwiskoKraj";
        }
Ejemplo n.º 9
0
 public PlayerProvider()
 {
     Repo = new PlayersRepo();
 }
Ejemplo n.º 10
0
 public void Test()
 {
     using (var playersRepo = new PlayersRepo("players"))
     using (var answersRepo = new AnswersRepo("answers"))
     using (var tagsRepo = new TagsRepo("tags"))
     {
         File.WriteAllText("index.html",
                           Razor.Parse(File.ReadAllText("index.cshtml"),
                                       new GameLogic().Calculate(playersRepo, answersRepo, tagsRepo)
                           	));
     }
     Process.Start("index.html");
 }
Ejemplo n.º 11
0
 public GameResult[] Calculate(PlayersRepo playersRepo, AnswersRepo answersRepo, TagsRepo tagsRepo)
 {
     return
         tagsRepo.Tags.Select(
             tag => GetResults(tag, playersRepo, answersRepo.GetFor(tag.Tag))).OrderByDescending(res => res.Tag.Finish).ToArray();
 }