public RoundDisplay(TournamentMatch match) { AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; InternalChildren = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Direction = FillDirection.Vertical, Children = new Drawable[] { new DrawableTournamentHeaderText(false) { Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, }, new TournamentSpriteText { Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, Text = match.Round.Value?.Name.Value ?? "Unknown Round", Font = OsuFont.Torus.With(size: 26, weight: FontWeight.SemiBold) }, } } }; }
public DrawableMatchTeam(TournamentTeam team, TournamentMatch match, bool losers) : base(team) { this.match = match; this.losers = losers; Size = new Vector2(185, 40); Masking = true; CornerRadius = 5; Flag.Scale = new Vector2(1f); Flag.Anchor = Flag.Origin = Anchor.CentreLeft; AcronymText.Anchor = AcronymText.Origin = Anchor.CentreLeft; AcronymText.Padding = new MarginPadding { Left = 35 }; AcronymText.Font = OsuFont.GetFont(size: 24); if (match != null) { isWinner = () => match.Winner == Team; completed.BindTo(match.Completed); if (team != null) { score.BindTo(team == match.Team1.Value ? match.Team1Score : match.Team2Score); } } }
public void CompleteBetting(TournamentMatch lastMatch) { if (activeBets != null) { double totalBet = activeBets.Values.Sum(v => v.bet); var allWonBets = activeBets .Where(kv => lastMatch.Winners.Contains(lastMatch.Teams.ElementAt(kv.Value.team).Participants.First())) .Select(kv => ( hero: kv.Key, bet: kv.Value.bet )) .ToList(); double winningTotalBet = allWonBets.Sum(v => v.bet); foreach ((var hero, int bet) in allWonBets.OrderByDescending(b => b.bet)) { int winnings = (int)(totalBet * bet / winningTotalBet); int newGold = BLTAdoptAHeroCampaignBehavior.Current.ChangeHeroGold(hero, winnings); Log.LogFeedResponse(hero.FirstName.ToString(), $"WON BET {Naming.Inc}{winnings}{Naming.Gold}{Naming.To}{newGold}{Naming.Gold}"); } activeBets = null; } TournamentHub.UpdateBets(); }
public RoundDisplay(TournamentMatch match) { InternalChildren = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 10), Children = new Drawable[] { new TournamentSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Colour = OsuColour.Gray(0.33f), Text = match.Round.Value?.Name.Value ?? "Unknown Round", Font = OsuFont.Torus.With(size: 26, weight: FontWeight.Light) }, } } }; }
public static void RunTournamentMatch() { // Create a new tournament match var match = new TournamentMatch(BotSetupType.RandomBot, BotSetupType.RandomBot, 10, BudgetType.Time, 5000); match.RunMatch(); }
public DrawableMatchTeam(TournamentTeam team, TournamentMatch match, bool losers) : base(team) { this.match = match; this.losers = losers; Size = new Vector2(150, 40); Flag.Scale = new Vector2(0.54f); Flag.Anchor = Flag.Origin = Anchor.CentreLeft; AcronymText.Anchor = AcronymText.Origin = Anchor.CentreLeft; AcronymText.Padding = new MarginPadding { Left = 50 }; AcronymText.Font = OsuFont.Torus.With(size: 22, weight: FontWeight.Bold); if (match != null) { isWinner = () => match.Winner == Team; completed.BindTo(match.Completed); if (team != null) { score.BindTo(team == match.Team1.Value ? match.Team1Score : match.Team2Score); } } }
bool IsRoundAlreadyStarted() { short count = 0; int round = 0; foreach (DataRow item in table.Rows) { TournamentMatch tournamentMatch = new TournamentMatch(Cxt.Instance, item); if (tournamentMatch.TournamentMatchStatusE == TournamentMatchStatusE.InProgress) { if (tournamentMatch.Round != round) { if (count > 1) { break; } round = tournamentMatch.Round; count++; } } } if (count > 1) { MessageForm.Error(Msg.GetMsg(MsgE.ErrorTournamentNextRoundStarted, "")); //RsPanel.ShowMessage(Msg.GetMsg(MsgE.ErrorTournamentMultipleRounds), true); return(false); } else { return(true); } }
private static bool Prefix(TournamentFightMissionController __instance, TournamentMatch match, bool isLastRound) { TournamentXPandedMatchBehavior._match = match; TournamentXPandedMatchBehavior.firstKiller = null; TournamentXPandedMatchBehavior.achievements = new Dictionary <TournamentParticipant, ParticipantAchievements>(); foreach (var p in match.Participants) { TournamentXPandedMatchBehavior.achievements.Add(p, new ParticipantAchievements()); } return(true); }
static void Postfix(TournamentMatch __instance) { var tournamentMatch = (MBTournamentMatch)__instance; if (Settings.VeryHardTournaments && tournamentMatch.IsPlayerParticipating()) { CampaignOptions.CombatAIDifficulty = CampaignModel.NonTournamentDifficulty; } ModState.TournamentRecords.Remove(tournamentMatch.HostSettlement); }
protected override void LoadComplete() { base.LoadComplete(); TournamentMatch match = CreateSampleMatch(); Ladder.Rounds.Add(match.Round.Value); Ladder.Matches.Add(match); Ladder.Teams.Add(match.Team1.Value); Ladder.Teams.Add(match.Team2.Value); Ladder.CurrentMatch.Value = match; }
private void load(TournamentStorage storage) { Ladder.Ruleset.Value ??= rulesetStore.AvailableRulesets.First(); match = CreateSampleMatch(); Ladder.Rounds.Add(match.Round.Value); Ladder.Matches.Add(match); Ladder.Teams.Add(match.Team1.Value); Ladder.Teams.Add(match.Team2.Value); Ruleset.BindTo(Ladder.Ruleset); Dependencies.CacheAs(new StableInfo(storage)); }
private void load() { var match = new TournamentMatch(); match.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "USA"); match.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "JPN"); match.Round.Value = Ladder.Rounds.FirstOrDefault(g => g.Name.Value == "Finals"); ladder.CurrentMatch.Value = match; Add(new TeamWinScreen { FillMode = FillMode.Fit, FillAspectRatio = 16 / 9f }); }
public JoinVisualiser(Container <DrawableTournamentMatch> matchesContainer, TournamentMatch source, bool losers, Action complete) { this.matchesContainer = matchesContainer; RelativeSizeAxes = Axes.Both; Source = source; this.losers = losers; this.complete = complete; if (losers) { Source.LosersProgression.Value = null; } else { Source.Progression.Value = null; } }
public RoundDisplay(TournamentMatch match) { var col = OsuColour.Gray(0.33f); InternalChildren = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 10), Children = new Drawable[] { new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Colour = col, Text = "COMING UP NEXT", Spacing = new Vector2(2, 0), Font = OsuFont.GetFont(size: 15, weight: FontWeight.Black) }, new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Colour = col, Text = match.Round.Value?.Name.Value ?? "Unknown Round", Spacing = new Vector2(10, 0), Font = OsuFont.GetFont(size: 50, weight: FontWeight.Light) }, new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Colour = col, Text = match.Date.Value.ToUniversalTime().ToString("dd MMMM HH:mm UTC"), Font = OsuFont.GetFont(size: 20) }, } } }; }
public RoundDisplay(TournamentMatch match) { var col = OsuColour.Gray(0.33f); InternalChildren = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 10), Children = new Drawable[] { new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Colour = col, Text = "WINNER", Font = TournamentFont.GetFont(TournamentTypeface.Aquatico, 20, FontWeight.Regular), }, new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Colour = col, Text = match.Round.Value?.Name.Value ?? "Unknown Round", Font = TournamentFont.GetFont(TournamentTypeface.Aquatico, 50, FontWeight.Light), Spacing = new Vector2(10, 0), }, new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Colour = col, Text = match.Date.Value.ToUniversalTime().ToString("MM dd HH:mm UTC+8"), Font = TournamentFont.GetFont(TournamentTypeface.Aquatico, 20, FontWeight.Light), }, } } }; }
private void tsRestartMatchSetup_Click(object sender, EventArgs e) { if (dgvMatches.RowCount <= 0) { return; } if (this.Tournament == null) { return; } if (this.Tournament.TournamentID == 0) { return; } if (this.Tournament.TournamentStatusIDE != TournamentStatusE.InProgress) { return; } int senderUserID = 0; int receiverUserID = 0; bool IsRestartTournamentDirector = false; TournamentMatch tm = GetOpponentAndChallenger(ref IsRestartTournamentDirector); if (tm != null) { senderUserID = Ap.CurrentUserID; receiverUserID = tm.OpponentUserID(Ap.CurrentUserID); if (Ap.Game != null) { Ap.Game.Pause(); } if (receiverUserID > 0 && tm.TournamentMatchID > 0) { DialogResult dr = SetupMatch.Show(this.ParentForm, 0, tm.TournamentMatchID, senderUserID, receiverUserID, 0, 0, 0, 0, IsRestartTournamentDirector); } } }
private void ViewGame(DataGridViewRow row) { //if (Ap.IsGameInProgress) //{ // return; //} if (filterTable.Rows.Count == 0) { return; } TournamentMatch tm = null; DataRow dr = filterTable.Rows[row.Index]; tm = new TournamentMatch(Ap.Cxt, dr); if (tm.WhiteUserID == Ap.CurrentUserID || tm.BlackUserID == Ap.CurrentUserID) { if (tm.TournamentMatchStatusE == TournamentMatchStatusE.InProgress) { return; } } int gameID = SocketClient.GetGameIDByTournamentMatchID(this.SelectedID); if (gameID <= 0) { MessageForm.Show(this.ParentForm, MsgE.InfoGameNotFoundForTournamentMatch); } else { if (Ap.CurrentUser.UserStatusIDE == UserStatusE.Blank || Ap.CurrentUser.UserStatusIDE == UserStatusE.Engine || Ap.CurrentUser.UserStatusIDE == UserStatusE.Centaur) { SocketClient.AddAudience(gameID); InfinityChess.WinForms.MainOnline.ShowMainOnline(gameID); } } }
public ScheduleMatch(TournamentMatch match, bool showTimestamp = true) : base(match) { Flow.Direction = FillDirection.Horizontal; Scale = new Vector2(0.8f); CurrentMatchSelectionBox.Scale = new Vector2(1.02f, 1.15f); bool conditional = match is ConditionalTournamentMatch; if (conditional) { Colour = OsuColour.Gray(0.5f); } if (showTimestamp) { AddInternal(new DrawableDate(Match.Date.Value) { Anchor = Anchor.TopRight, Origin = Anchor.TopLeft, Colour = OsuColour.Gray(0.7f), Alpha = conditional ? 0.6f : 1, Font = OsuFont.Torus, Margin = new MarginPadding { Horizontal = 10, Vertical = 5 }, }); AddInternal(new TournamentSpriteText { Anchor = Anchor.BottomRight, Origin = Anchor.BottomLeft, Colour = OsuColour.Gray(0.7f), Alpha = conditional ? 0.6f : 1, Margin = new MarginPadding { Horizontal = 10, Vertical = 5 }, Text = match.Date.Value.ToUniversalTime().ToString("HH:mm UTC") + (conditional ? " (conditional)" : "") }); } }
private TournamentMatch GetCurrentPlayerInProgressMatch() { DataTable dt = (DataTable)dgvMatches.DataSource; if (dt == null) { return(null); } DataRow[] rows = dt.Select(String.Format("TournamentMatchStatusID=2 AND (WhiteUserID={0} OR BlackUserID={1})", Ap.CurrentUserID, Ap.CurrentUserID)); if (rows.Length == 0) { return(null); } TournamentMatch tm = new TournamentMatch(Ap.Cxt, rows[0]); return(tm); }
public RoundDisplay(TournamentMatch match) { AutoSizeAxes = Axes.Both; InternalChildren = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Children = new Drawable[] { new DrawableTournamentTitleText(), new TournamentSpriteText { Text = match.Round.Value?.Name.Value ?? "Unknown Round", Font = OsuFont.Torus.With(size: 26, weight: FontWeight.SemiBold) }, } } }; }
private TournamentMatch GetOpponentAndChallenger(ref bool IsRestartTournamentDirector) { DataTable dt = (DataTable)dgvMatches.DataSource; if (dt == null) { return(null); } DataRow[] rows = dt.Select(String.Format("TournamentMatchStatusID=2 AND (WhiteUserID={0} OR BlackUserID={1})", Ap.CurrentUserID, Ap.CurrentUserID)); IsRestartTournamentDirector = false; if (rows.Length == 0) { string matchId = GetTournamentMatchID().ToString(); if (matchId == "0") { return(null); } rows = dt.Select(String.Format("TournamentMatchStatusID=2 AND (TournamentMatchID={0})", matchId)); IsRestartTournamentDirector = true; } else if (IsTournamentDirector) { IsRestartTournamentDirector = true; } if (rows.Count() > 0) { TournamentMatch tm = new TournamentMatch(Ap.Cxt, rows[0]); return(tm); } else { MessageForm.Error(this.ParentForm, MsgE.ErrorTournamentMatchNotInprogress); return(null); } }
public ScheduleMatch(TournamentMatch match, bool showTimestamp = true) : base(match) { Flow.Direction = FillDirection.Horizontal; bool conditional = match is ConditionalTournamentMatch; if (conditional) { Colour = OsuColour.Gray(0.5f); } if (showTimestamp) { AddInternal(new DrawableDate(Match.Date.Value) { Anchor = Anchor.TopRight, Origin = Anchor.TopLeft, Colour = Color4.Black, Alpha = conditional ? 0.6f : 1, Margin = new MarginPadding { Horizontal = 10, Vertical = 5 }, }); AddInternal(new OsuSpriteText { Anchor = Anchor.BottomRight, Origin = Anchor.BottomLeft, Colour = Color4.Black, Alpha = conditional ? 0.6f : 1, Margin = new MarginPadding { Horizontal = 10, Vertical = 5 }, Text = match.Date.Value.ToLocalTime().ToString("HH:mm UTC") + (conditional ? " (如果有)" : "") }); } }
public void Remove(TournamentMatch match) { MatchesContainer.FirstOrDefault(p => p.Match == match)?.Remove(); }
public void BeginJoin(TournamentMatch match, bool losers) { ScrollContent.Add(new JoinVisualiser(MatchesContainer, match, losers, UpdateLayout)); }
public DrawableTournamentMatch(TournamentMatch match, bool editor = false) { Match = match; this.editor = editor; AutoSizeAxes = Axes.Both; Margin = new MarginPadding(5); InternalChildren = new[] { selectionBox = new Container { Scale = new Vector2(1.1f), RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, Alpha = 0, Colour = Color4.YellowGreen, Child = new Box { RelativeSizeAxes = Axes.Both } }, CurrentMatchSelectionBox = new Container { Scale = new Vector2(1.05f, 1.1f), RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, Alpha = 0, Colour = Color4.White, Child = new Box { RelativeSizeAxes = Axes.Both } }, Flow = new FillFlowContainer <DrawableMatchTeam> { AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Spacing = new Vector2(2) } }; boundReference(match.Team1).BindValueChanged(_ => updateTeams()); boundReference(match.Team2).BindValueChanged(_ => updateTeams()); boundReference(match.Team1Score).BindValueChanged(_ => updateWinConditions()); boundReference(match.Team2Score).BindValueChanged(_ => updateWinConditions()); boundReference(match.Round).BindValueChanged(_ => { updateWinConditions(); Changed?.Invoke(); }); boundReference(match.Completed).BindValueChanged(_ => updateProgression()); boundReference(match.Progression).BindValueChanged(_ => updateProgression()); boundReference(match.LosersProgression).BindValueChanged(_ => updateProgression()); boundReference(match.Losers).BindValueChanged(_ => { updateTeams(); Changed?.Invoke(); }); boundReference(match.Current).BindValueChanged(_ => updateCurrentMatch(), true); boundReference(match.Position).BindValueChanged(pos => { if (!IsDragged) { Position = new Vector2(pos.NewValue.X, pos.NewValue.Y); } Changed?.Invoke(); }, true); updateTeams(); }
/// <summary> /// Creates a new instance of the MatchLockChangedEventArgs object. /// </summary> /// <param name="locked">If true, the Match scores have been locked and should be considered finalized.</param> /// <param name="match">The relevant TournamentMatch object that raised this event.</param> public MatchLockChangedEventArgs(bool locked, TournamentMatch match) { Locked = locked; Match = match; }
static bool Prefix(ref List <TournamentParticipant> ____participants, TournamentParticipant participant, bool firstTime, TournamentMatch __instance) { if (!__instance.IsPlayerParticipating()) { return(true); } var teams = __instance.Teams.CastList <MBTournamentTeam>(); var playerTeam = GetPlayerTeamFrom(teams); var nonPlayerTeams = teams; nonPlayerTeams.Remove(playerTeam); MBTournamentParticipant wrappedParticipant = participant; ____participants.Add(participant); if (playerTeam.IsParticipantRequired() && (participant.IsPlayer || participant.IsPlayerCompanion() || participant.IsMarriedToPlayer() || participant.IsPlayerTroop())) { playerTeam.AddParticipant(participant); return(false); } if ((firstTime && participant.TryPlaceInNewOrSameTeam(teams.CastList <TournamentTeam>())) || participant.TryPlaceInAnyTeam(teams.CastList <TournamentTeam>())) { return(false); } return(false); }
public TestSceneDrawableTournamentMatch() { Container <DrawableTournamentMatch> level1; Container <DrawableTournamentMatch> level2; var match1 = new TournamentMatch( new TournamentTeam { FlagName = { Value = "AU" }, FullName = { Value = "Australia" }, }, new TournamentTeam { FlagName = { Value = "JP" }, FullName = { Value = "Japan" }, Acronym = { Value = "JPN" } }) { Team1Score = { Value = 4 }, Team2Score = { Value = 1 }, }; var match2 = new TournamentMatch( new TournamentTeam { FlagName = { Value = "RO" }, FullName = { Value = "Romania" }, } ); Child = new FillFlowContainer { RelativeSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Children = new Drawable[] { level1 = new FillFlowContainer <DrawableTournamentMatch> { AutoSizeAxes = Axes.X, Direction = FillDirection.Vertical, Children = new[] { new DrawableTournamentMatch(match1), new DrawableTournamentMatch(match2), new DrawableTournamentMatch(new TournamentMatch()), } }, level2 = new FillFlowContainer <DrawableTournamentMatch> { AutoSizeAxes = Axes.X, Direction = FillDirection.Vertical, Margin = new MarginPadding(20), Children = new[] { new DrawableTournamentMatch(new TournamentMatch()), new DrawableTournamentMatch(new TournamentMatch()) } } } }; level1.Children[0].Match.Progression.Value = level2.Children[0].Match; level1.Children[1].Match.Progression.Value = level2.Children[0].Match; AddRepeatStep("change scores", () => match1.Team2Score.Value++, 4); AddStep("add new team", () => match2.Team2.Value = new TournamentTeam { FlagName = { Value = "PT" }, FullName = { Value = "Portugal" } }); AddStep("Add progression", () => level1.Children[2].Match.Progression.Value = level2.Children[1].Match); AddStep("start match", () => match2.StartMatch()); AddRepeatStep("change scores", () => match2.Team1Score.Value++, 10); AddStep("start submatch", () => level2.Children[0].Match.StartMatch()); AddRepeatStep("change scores", () => level2.Children[0].Match.Team1Score.Value++, 5); AddRepeatStep("change scores", () => level2.Children[0].Match.Team2Score.Value++, 4); }
/// <summary> /// Creates a new instance of the ctlTournamentMatch control. /// </summary> /// <param name="match">The TournamentMatch object containing the relevant data for this matchup.</param> /// <param name="matchNumber">The match number, for display purposes.</param> public ctlTournamentMatch(TournamentMatch match, int matchNumber) { InitializeComponent(); ThisMatch = match; lblMatch.Text = "Match #" + matchNumber.ToString(); Tournament tournament = Config.Settings.GetTournament(ThisMatch.TournamentName); PlayerRecord player1 = Config.Settings.GetPlayer(ThisMatch.Players[0]); lblPlayer1.Text = player1.Name; MatchResult currentResult1 = tournament.GetPlayerResults(player1.ID); switch (tournament.Format) { case EventFormat.Victory: lblRecord1.Text = "Record: " + currentResult1.VictoryPoints.ToString() + " VP/" + currentResult1.TournamentPoints.ToString() + " TP/" + (currentResult1.Differential > 0 ? "+" : "") + currentResult1.Differential.ToString() + " DIFF"; break; case EventFormat.Disparity: lblRecord1.Text = "Record: " + (currentResult1.Differential > 0 ? "+" : "") + currentResult1.Differential.ToString() + " DIFF/" + currentResult1.VictoryPoints.ToString() + " VP/" + currentResult1.TournamentPoints.ToString() + " TP"; break; case EventFormat.Domination: lblRecord1.Text = "Record: " + currentResult1.TournamentPoints.ToString() + " TP/" + (currentResult1.Differential > 0 ? "+" : "") + currentResult1.Differential.ToString() + " DIFF/" + currentResult1.VictoryPoints.ToString() + " VP"; break; } if (match.Results.ContainsKey(match.Players[0])) if (match.Results[match.Players[0]].Forfeited) txtVP1.Text = "F"; else if (match.Results[match.Players[0]].Bye) txtVP1.Text = "B"; else txtVP1.Text = match.Results[match.Players[0]].VictoryPoints.ToString(); // Detect a Bye round automatically. if (match.Players.Count == 1) { IsForcedBye = true; lblPlayer2.Text = "BYE ROUND"; txtVP1.Text = "B"; lblRecord2.Text = ""; LockScores(); } else { IsForcedBye = false; PlayerRecord player2 = Config.Settings.GetPlayer(ThisMatch.Players[1]); lblPlayer2.Text = player2.Name; MatchResult currentResult2 = tournament.GetPlayerResults(player2.ID); switch (tournament.Format) { case EventFormat.Victory: lblRecord2.Text = "Record: " + currentResult2.VictoryPoints + " VP/" + currentResult2.TournamentPoints + " TP/" + (currentResult2.Differential > 0 ? "+" : "") + currentResult2.Differential + " DIFF"; break; case EventFormat.Disparity: lblRecord2.Text = "Record: " + (currentResult2.Differential > 0 ? "+" : "") + currentResult2.Differential + " DIFF/" + currentResult2.VictoryPoints + " VP/" + currentResult2.TournamentPoints + " TP"; break; case EventFormat.Domination: lblRecord2.Text = "Record: " + currentResult2.TournamentPoints + " TP/" + (currentResult2.Differential > 0 ? "+" : "") + currentResult2.Differential + " DIFF/" + currentResult2.VictoryPoints + " VP"; break; } if (match.Results.ContainsKey(match.Players[1])) if (match.Results[match.Players[1]].Forfeited) txtVP2.Text = "F"; else if (match.Results[match.Players[1]].Bye) txtVP2.Text = "B"; else txtVP2.Text = match.Results[match.Players[1]].VictoryPoints.ToString(); } }
public void SkipMatch(TournamentMatch match) { }
private void btnAddPlayer_Click(object sender, EventArgs e) { var tournament = Config.Settings.GetTournament(TournamentName); using (var playerSelect = new FrmAddPlayer(tournament.Players)) { if (playerSelect.ShowDialog() == DialogResult.OK) { var reopenRoundForm = false; if (RoundForm != null) { RoundForm.Close(); reopenRoundForm = true; } var id = playerSelect.SelectedID; var faction = playerSelect.SelectedFaction; tournament.AddPlayer(id, faction); int currentRound = Config.Settings.GetTournament(TournamentName).Rounds.Count; if (currentRound > 0) { if (tournament.Players.Count%2 == 1) { var byeMatch = new TournamentMatch(TournamentName); byeMatch.Players.Add(id); byeMatch.Crews.Add(id, new PlayerCrew()); var byeResult = new MatchResult(id) {Bye = true}; byeMatch.Results.Add(id, byeResult); if (!Config.Settings.GetTournament(TournamentName).Rounds[currentRound - 1].Completed) Config.Settings.GetTournament(TournamentName).Rounds[currentRound - 1].Matches.Add( byeMatch); } else { foreach ( var match in Config.Settings.GetTournament(TournamentName).Rounds[currentRound - 1]. Matches.Where(match => match.ByeRound)) { if (!Config.Settings.GetTournament(TournamentName).Rounds[currentRound - 1].Completed) { match.Results.Clear(); match.Players.Add(id); match.Crews.Add(id, new PlayerCrew()); break; } } } } Config.Settings.SaveEvents(); FillPlayers(); UpdateScores(); if (reopenRoundForm) btnRound_Click(sender, e); } } }
public void StartMatch(TournamentMatch match, bool isLastRound) { }
public void AddMatch(Tournament tournament, Match match) { var tournamentMatch = new TournamentMatch(tournament, match); _tournamentMatchRepository.Insert(tournamentMatch); }
public int createTournament(CreateTournament tournament) { Tournament tourToCreate = new Tournament(); var allTeams = dataManager.getAllTeams(); foreach (var team in allTeams) { if (tournament.TeamNames.Contains(team.Name)) { tourToCreate.Teams.Add(team); } } tourToCreate.Name = tournament.Name; tourToCreate.hostPlayerID = tournament.hostPlayerID; var tournamentId = dataManager.CreateTournament(tourToCreate.hostPlayerID, tourToCreate.Name, tourToCreate.Teams[0], tournament.Description, tournament.TournamentSizeTeams); for (int i = 0; i < tournament.TournamentSizeTeams - 1; i++) { TournamentMatch tmpMatch = new TournamentMatch(); tmpMatch.tournamentId = tournamentId; tourToCreate.Matches.Add(tmpMatch); } double numberOfRounds = System.Math.Sqrt(tournament.TournamentSizeTeams); var RealRounds = Math.Ceiling(numberOfRounds); var filledRound = 1; List <TournamentMatch> matchesToSet = new List <TournamentMatch>(); double matchesLeft = tourToCreate.Matches.Count / 2.0; matchesToSet = tourToCreate.Matches.GetRange(0, Convert.ToInt32(Math.Ceiling(matchesLeft))); int matchCount = 0; while (filledRound != RealRounds + 1) { setTournamentGameRound(filledRound, matchesToSet); matchCount += matchesToSet.Count; filledRound++; matchesLeft = matchesLeft / 2; if (matchesLeft > 0.5) { matchesToSet = tourToCreate.Matches.GetRange(matchCount, Convert.ToInt32(Math.Ceiling(matchesLeft))); } } int nofrg = tourToCreate.Matches.Where(o => o.TournamentRound == 1).Count(); int j = 0; for (int i = 0; i < tourToCreate.Teams.Count; i++) { tourToCreate.Matches[j].teamOne = tourToCreate.Teams[i]; if (tourToCreate.Teams.Count > i + 1) { tourToCreate.Matches[j].teamTwo = tourToCreate.Teams[i + 1]; } i++; j++; } foreach (var match in tourToCreate.Matches) { if (match.teamOne == null || match.teamOne.Name == "") { match.teamOne = new Team(); match.teamOne.Name = "Unknown"; } if (match.teamTwo == null || match.teamTwo.Name == "") { match.teamTwo = new Team(); match.teamTwo.Name = "Unknown"; } dataManager.createTournamentGame(match); } if (tournamentId > 0) { foreach (var team in tourToCreate.Teams) { dataManager.AddTeamToTournament(team.Id, tournamentId); } return(tournamentId); } else { return(0); } }