/// <summary> /// Writes the data of the provided <see cref="ITournament"/> to the <see cref="StringBuilder"/> /// </summary> /// <param name="tournament">The <see cref="ITournament"/> whose data is to be written</param> /// <returns>A <see cref="StringBuilder"/> containing string representation of the provided tournament</returns> private StringBuilder WriteTournamentData(ITournament tournament) { Guard.Argument(tournament, nameof(tournament)).NotNull(); var builder = new StringBuilder(); AddEntityData(tournament, builder); var sport = _taskProcessor.GetTaskResult(tournament.GetSportAsync()); var category = _taskProcessor.GetTaskResult(tournament.GetCategoryAsync()); var currentSeasonInfo = _taskProcessor.GetTaskResult(tournament.GetCurrentSeasonAsync()); var tournamentCoverage = _taskProcessor.GetTaskResult(tournament.GetTournamentCoverage()); var seasons = _taskProcessor.GetTaskResult(tournament.GetSeasonsAsync()); var seasonsIds = seasons == null ? "null" : string.Join(",", seasons.Select(s => s.Id)); var currentSeasonStr = string.Empty; if (currentSeasonInfo != null) { currentSeasonStr = $"[{WriteCurrentSeasonInfoData(currentSeasonInfo)}]"; } builder.Append(" Sport=").Append(sport) .Append(" Category=").Append(category) .Append(" CurrentSeasonInfo=").Append(currentSeasonStr) .Append(" TournamentCoverage=").Append(tournamentCoverage?.LiveCoverage) .Append(" Seasons=[").Append(seasonsIds).Append("]"); return(builder); }
public ITournament rebuildTournament(ITournament savedTournament) { var tournament = TournamentTypeHelper.ConvertTournamentType(savedTournament); tournament.RebuildTournament(); return(tournament); }
public TournamentViewUI(ITournament inTourney, bool fullAccess = true) { InitializeComponent(); source = ApplicationController.getProvider(); tournamentController = ApplicationController.getTournamentController(); tournament = inTourney; //Add all the rounds to the Rounds view populateRoundList(); //Set tournament Name tournamentNameLbl.Content = tournament.TournamentName; //Results Button var activeRound = tournament.Rounds.Where(x => x.RoundNum == tournament.ActiveRound).First(); var isActiveRoundValid = tournamentController.validateActiveRound(tournament); if (!isActiveRoundValid) { resultsBtn.Visibility = Visibility.Visible; } matchupGrid.IsEnabled = fullAccess; finalizeRoundBtn.IsEnabled = fullAccess; populateMatchupListBox(0); initialization = false; }
public IndexPageModule(ITournament tournament, ISubmittedBets bets, IResults actual) { Get["/"] = _ => { return(View["frontpage.sshtml", new IndexPageViewModel(tournament, bets, actual)]); }; }
public static void SaveFinishedTournamendToDB(ITournament tournament, String username) { TournamentDL tdl = new TournamentDL(); tdl.UpdateTournament(new TournamentPers(tournament.Name, username, tournament.GameMode.ToString(), tournament.AmountSets, tournament.AmountGoalsperSet, tournament.IsRanked, true)); }
private void FinalizeRoundBtn_Click(object sender, RoutedEventArgs e) { //Confirm that all matchups in active round are complete //Build matchups for next round var activeRound = tournament.Rounds.Where(x => x.RoundNum == tournament.ActiveRound).First(); var isRoundComplete = tournamentController.validateRoundCompletion(activeRound); if (!isRoundComplete) { lblFinalized.Content = "Active round not finished"; return; //Error Message somewhere } var isActiveRoundValid = tournamentController.validateActiveRound(tournament); if (isActiveRoundValid) { tournament = tournamentController.advanceRound(tournament); source.saveActiveRound(tournament); lblFinalized.Content = "Round finalized"; } else { lblFinalized.Content = "Tournament is over"; resultsBtn.Visibility = Visibility.Visible; } }
public static TournamentDto FromTournament(ITournament tournament) { if (tournament == null) { return(null); } TournamentDto result = new TournamentDto() { ID = tournament.ID, Name = tournament.Name, NumLanes = tournament.NumLanes, TrackLengthInches = tournament.TrackLengthInches, State = tournament.State.ToString(), CurrentRace = tournament.CurrentRace }; foreach (ICar car in tournament.Cars) { result.Cars.Add(CarDto.FromCar(car)); } foreach (IRace race in tournament.Races) { result.Races.Add(RaceDto.FromRace(race)); } return(result); }
void CacheTournament(ITournament tournament) { if (!cachedTournaments.ContainsKey(tournament.FileName)) { cachedTournaments.Add(tournament.FileName, tournament); } }
public ITournament reSeedTournament(ITournament tournament) { var matchups = tournament.Rounds.SelectMany(x => x.Matchups).ToList(); foreach (var entry in tournament.TournamentEntries) { var wins = 0; var losses = 0; var entryMatchupEntries = matchups.SelectMany(y => y.MatchupEntries).Where(z => z.TheTeam.TeamId == entry.TeamId); foreach (var matchupEntry in entryMatchupEntries) { var matchup = matchups.Where(x => x.MatchupId == matchupEntry.MatchupId).First(); var entryScore = matchup.MatchupEntries.Where(x => x.TheTeam.TeamId == entry.TeamId).First().Score; var opponentScore = matchup.MatchupEntries.Where(x => x.TheTeam.TeamId != entry.TeamId).First().Score; if (entryScore > opponentScore) { wins++; } else { losses++; } } if (losses == 0) { entry.Seed = 1; } else { entry.Seed = calculateWinPercentage(wins, losses); } } return(tournament); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ITournament trt) { trt.AddTeam(new RemTeam("SUPER TEAM")); trt.AddTeam(new RemTeam("mango team")); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapBlazorHub(); endpoints.MapFallbackToPage("/_Host"); }); }
private void TournamentDelete_Click(object sender, RoutedEventArgs e) { string path = (string)((Button)sender).Tag; try { Directory.Delete(path, true); } catch (IOException ev) { SetNotification(ev.Message); } catch (Exception ev) { SetNotification(ev.Message); } TournamentTemporary tour = new TournamentTemporary(path); if (CurrentTournament != null && tour.getNameFromPath() == CurrentTournament.Name) { CurrentTournament = null; TournamentLoad_Click(null, e); } MenuTournament_Load_Click(sender, e); }
public void InitializeSportEntities() { var watch = Stopwatch.StartNew(); if (SportEntityFactory == null) { Init(); } var time = watch.Elapsed.TotalMilliseconds; Debug.WriteLine($"Init time: {time}"); Competition = SportEntityFactory.BuildSportEvent <ICompetition>(TestData.EventId, URN.Parse("sr:sport:3"), TestData.Cultures3, TestData.ThrowingStrategy); Debug.WriteLine($"Competition time: {watch.Elapsed.TotalMilliseconds - time}"); time = watch.Elapsed.TotalMilliseconds; Sport = SportEntityFactory.BuildSportAsync(TestData.SportId, TestData.Cultures3, TestData.ThrowingStrategy).Result; Debug.WriteLine($"Sport time: {watch.Elapsed.TotalMilliseconds - time}"); time = watch.Elapsed.TotalMilliseconds; Sports = SportEntityFactory.BuildSportsAsync(TestData.Cultures3, TestData.ThrowingStrategy).Result?.ToList(); Debug.WriteLine($"Sports time: {watch.Elapsed.TotalMilliseconds - time}"); time = watch.Elapsed.TotalMilliseconds; Tournament = SportEntityFactory.BuildSportEvent <ITournament>(TestData.TournamentId, TestData.SportId, TestData.Cultures3, TestData.ThrowingStrategy); Debug.WriteLine($"Tournament time: {watch.Elapsed.TotalMilliseconds - time}"); time = watch.Elapsed.TotalMilliseconds; Season = SportEntityFactory.BuildSportEvent <ISeason>(TestData.SeasonId, TestData.SportId, TestData.Cultures3, TestData.ThrowingStrategy); Debug.WriteLine($"Season time: {watch.Elapsed.TotalMilliseconds - time}"); }
public static void SaveRankingsToDB(ITournament tournament) { if (!tournament.IsRanked) { throw new Exception("Das Turnier ist nicht gerankt. Daher darf auch kein Ranking gespeichert werden"); } int maxSiegeAnzahl = 0; Team siegerTeam = null; foreach (Team t in tournament.Ranking.Keys) { int anzahlSiege = tournament.Ranking[t]; if (anzahlSiege > maxSiegeAnzahl) { siegerTeam = t; maxSiegeAnzahl = anzahlSiege; } foreach (ICompetitor c in t.SpielerListe) { RankingDL rdl = new RankingDL(); rdl.CreateRanking(new RankingPers(tournament.Name, c.CompetitorID, anzahlSiege, false)); } } foreach (ICompetitor c in siegerTeam.SpielerListe) { RankingDL rdl = new RankingDL(); rdl.SetWinner(tournament.Name, c.CompetitorID); } }
public TournamentViewModel(ITournament tournament) { _tournament = tournament; TournamentManager.TournamentUpdated += TournamentManager_TournamentUpdated; _views.Add(new TournamentViewViewModel("Home", new HomeControl { DataContext = new HomeControlViewModel(_tournament.ID) })); _views.Add(new TournamentViewViewModel("Cars", new CarsControl { DataContext = new CarsControlViewModel(_tournament.ID) })); _views.Add(new TournamentViewViewModel("Lineup", new LineupControl { DataContext = new LineupControlViewModel(_tournament.ID) })); _views.Add(new TournamentViewViewModel("Results", new ResultsControl { DataContext = new ResultsControlViewModel(_tournament.ID) })); }
public void AddStatus(ITournament stage, IStageStatus status) { if (!Status.ContainsKey(stage)) { Status[stage] = new List <IStageStatus>(); } Status[stage].Add(status); }
public static void TournamentObject(ITournament t, string name = null) { IsNameAndObject(name, t, "Tournament"); var path = Path(name); SerializeObject(path, "tournament.json", t); }
public IndexPageViewModel(ITournament t, ISubmittedBets sb, IResults actual) { _tournament = t; CreateGroups(); CreateBetterlist(sb.GetBetters(), sb, actual); MarkWinnerIfFinished(actual); TimeStamp = actual.GetTimeStamp(); }
public bool IsAllMakeAddon { get; private set; } // все поставили аддоны public RebuyAddonGame(ITournament tour) : base(tour) { _addonChips = tour.AddonChips; AddonCost = tour.AddonCost; AddonAvailable = 1; if (tour.CommissionType == 0) AddonCost -= AddonCost*(tour.Commission/100); }
public ITournament advanceRound(ITournament tournament) { var convertedTournament = TournamentTypeHelper.ConvertTournamentType(tournament); var lastRound = convertedTournament.Rounds.Max(x => x.RoundNum); convertedTournament.AdvanceRound(); return(convertedTournament); }
private void TournamentManager_TournamentUpdated(TournamentUpdatedEventArgs e) { if (e.Tournament.ID == this.Tournament.ID) { _tournament = e.Tournament; OnPropertyChanged(nameof(this.Name)); } }
public IndexPageViewModel(ITournament t, ISubmittedBets sb, IResultCollection rc) { _tournament = t; CreateGroups(); CreateBetterlist(sb.GetBetters(), sb, rc); EvaluateTrends(); MarkWinnerIfFinished(rc.Current); TimeStamp = rc.Current.GetTimeStamp(); }
void ITournamentsList.AddTournament(ITournament tournament) { if (tournament != null) { _tournaments.Add(tournament); TournamentAdded?.Invoke(tournament); TournamentListChanged?.Invoke(); } }
public static void NotifyParticipants(IMatchup matchup, ITournament tournament) { List <IMatchupEntry> matchupEntries = matchup.MatchupEntries; string firstTeamName = tournament.Teams.Find(x => x.TeamId == matchupEntries[0].TheTeam.TeamId).TeamName; string secondTeamName = tournament.Teams.Find(x => x.TeamId == matchupEntries[1].TheTeam.TeamId).TeamName; var finals = tournament.Rounds.Max(x => x.RoundNum) == tournament.ActiveRound;; Email(matchupEntries[0], firstTeamName, secondTeamName, tournament.TournamentName, tournament.ActiveRound, finals); Email(matchupEntries[1], secondTeamName, firstTeamName, tournament.TournamentName, tournament.ActiveRound, finals); }
public GroupController(IUnitOfWork uow, IGroup group, ITournament tournament, ISportType sporttype, IPartInGroup partingroup, IParticipant participant, ICountry country) { _uow = uow; _Group = group; _Tournament = tournament; _SportType = sporttype; _partInGroup = partingroup; _participant = participant; _Country = country; }
public BetterPageModule(ITournament tournament, ISubmittedBets bets, IResultCollection rc) { Get["/{better}"] = _ => { // disable once ConvertToLambdaExpression return(View["betterpage.sshtml", new BetterPageViewModel(tournament, bets.GetSingleBet(_.better), rc.Current)]); }; }
public static void SaveTournamentToFinalizedFolder(ITournament tournament) { if (tournament == null) { return; } string filename = Path.Combine(Path.Combine(Settings.DataStorageFolder, "Finalized"), tournament.Filename); Engine.SaveTournamentToFile(tournament, filename); }
public bool validateActiveRound(ITournament tournament) { var lastround = tournament.Rounds.Max(x => x.RoundNum); if (tournament.ActiveRound == lastround) { return(false); } return(true); }
public static Tournament CreateTournament(ITournament challonge) { return(new Tournament { ID = challonge.TournamentID, ChallongeIDWithSubdomain = challonge.TournamentSubdomainID, ShortName = challonge.URL, Name = challonge.Name, FullLink = challonge.FullLink }); }
// ребаи, аддоны: цены на них фишки public RebuyGame(ITournament tour) : base(tour) { RebuyAvailable = tour.RebuyAvailable; RebuyUnlimited = tour.IsRebuyUnlimited; RebuyCost = tour.RebuyCost; // проверяем случай наличия комисии (уменьшаем цены) if (tour.CommissionType == 0) RebuyCost -= RebuyCost*(tour.Commission/100); RebuyChips = tour.RebuyChips; }
public ITournament saveActiveRound(ITournament entry) { TournamentTable.Update(entry, dbConn); entry.Rounds.ForEach(x => x.TournamentId = entry.TournamentId); var activeRound = entry.Rounds.Where(x => x.RoundNum == entry.ActiveRound).First(); activeRound.Matchups.ForEach(x => x.RoundId = activeRound.RoundId); CreateRoundLinks(activeRound, entry.TournamentEntries); return(entry); }
public static ITournamentApplication ConvertTournamentType(ITournament tournament) { switch (tournament.TournamentTypeId) { case 1: return(ConvertToSingleElimination(tournament)); case 2: return(ConvertToSwiss(tournament)); default: return(null); } }
public EventCoOrdinator( ITournamentPersistence tournamentPersistence, IOutgoingPlayerChannelFactory channelFactory, IApplicationConfiguration applicationConfiguration, IActionScheduler actionScheduler) { Tournament = tournamentPersistence.LoadTournament(); _channelFactory = channelFactory; _applicationConfiguration = applicationConfiguration; _actionScheduler = actionScheduler; }
private void WriteTournamentToDB(ITournament table) { Tournament t = dbMgr.InsertTournament(table.GetTournament()); foreach (Player p in table.GetPlayers()) { TournamentResult res = table.GetResult(p); res.Event = t; dbMgr.InsertResult(res); int newRate = EloTable.GetNewRate(p.GetRate(table.GetGameType()), table.GetAverageRate(p), table.GetMaxPoints(p), table.GetResult(p).Points); Player tp = p.Clone(); tp.SetRate(table.GetGameType(), newRate); tp.SetUpdateDate(t.Type, t.EndOn); dbMgr.UpdatePlayer(tp); } foreach (Game g in table.GetGames()) { g.Tournament = t; dbMgr.InsertGame(g); } ReloadPlayersAndView(); }
public FrezoutGame(ITournament tour) { _disPrizes = new DistributionPrizesGame(); _settings = new Settings(); Players = new ObservableCollection<PlayerGame>(); FrezoutGameMain = this; _isSound = _settings.SoundSetting; IsPause = true; Name = tour.Name; Type = tour.TypeToString; AllChips = tour.BuyInChips*tour.Players; BuyInCost = tour.BuyInCost; StartStack = tour.StartStack; // начальный стек _buyInChips = tour.BuyInChips; if (tour.Commission != 0) // проверяем случай наличия комисии (уменьшаем цену на бай-ин) BuyInCost -= BuyInCost*(tour.Commission/100); /* заполняем времена продолжительности: игры, уровня, времени до след. перерыва, ребай-периода */ //_levelSeconds = 2; //_breakDurationSeconds = 2 * 3; //_breakInSeconds = _levelSeconds * 0; //_lateRegistration = 2; // selectTour.LateRegistration; _levelSeconds = tour.LevelDuration*Sixty; _breakDurationSeconds = tour.BreakDuration*Sixty; _breakInSeconds = _levelSeconds*tour.BreakFrequency; _lateRegistration = tour.LateRegistration; // если==0 - послед. рег отсутствует _gameSeconds = tour.GameDuration*Sixty; _isGameUnlimited = tour.IsGameUnlimited; LateRegistrationDec = _levelSeconds*_lateRegistration; // делаем их копии с целью изменения в таймере LevelDec = _levelSeconds; BreakDec = _breakInSeconds; //если==0 - перерывы отсутствуют GameInc = _gameSeconds; IsBreakExist = _breakInSeconds != 0; IsLateRegExist = _lateRegistration != 0; // за 30/60 секунд до окончания - звуковое уведомление if (_levelDec >= 600 && _levelDec < 1800) // 10-30 минут { _secondEndLevel = 30; _isSoundEndLevel = true; } else if (_levelDec >= 1800) // больше 30 минут { _secondEndLevel = 60; _isSoundEndLevel = true; } /* инициализируем игроков и блайнды */ AddPlayers(tour.GetPlayersOfTour()); Blinds = new GameBlindCollection(MyDataContextBase.Blinds.Where(x => x.BlindTour == tour)); CalcChips(); /* Таймеры игры и уровня */ _timerGame = new DispatcherTimer {Interval = _interval}; _timerGame.Tick += timerGame_Tick; _timerLevel = new DispatcherTimer {Interval = _interval}; _timerLevel.Tick += timerLevel_Tick; }
public int InputsAll { get; private set; } // число входов всех игроков public ReentryGame(ITournament tour) : base(tour) { }
protected DurationViewModel() { SelectTour = (ITournament) _navigationService.GetLastNavigationData(); }