public override void OnNewGameCreated(Game game, object obj) { if (game.GameType is Campaign) { ModState.Reset(); TournamentBuilder.CreateInitialTournaments(); } }
public async Task TestCalculateRankingsAsync() { // Arrange var tournament = new TournamentBuilder().Build(); var standing = new Standing(tournament); var movies = tournament.Movies .OrderBy(m => m.Titulo); var firstHalf = movies.Take(4) .ToList(); var secondHalf = movies .Skip(4) .Take(4) .Reverse() .ToList(); var expectedScore0 = new List <string>() { "tt5164214", "tt7784604", "tt3778644" }; var expectedScore1 = new List <string>() { "tt3501632", "tt4881806" }; var expectedScore2 = new List <string>() { "tt3606756" }; var expectedScore3 = new List <string>() { "tt4154756" }; // Act var result = await standing.CalculateRankingsAsync(firstHalf, secondHalf); // Assert result.Should().BeTrue(); standing.Rankings .Where(r => expectedScore0.Contains(r.Movie.Id)) .ToList() .Should().HaveCount(expectedScore0.Count); standing.Rankings .Where(r => expectedScore1.Contains(r.Movie.Id)) .ToList() .Should().HaveCount(expectedScore1.Count); standing.Rankings .Where(r => expectedScore2.Contains(r.Movie.Id)) .ToList() .Should().HaveCount(expectedScore2.Count); standing.Rankings .Where(r => expectedScore3.Contains(r.Movie.Id)) .ToList() .Should().HaveCount(expectedScore3.Count); }
/// <summary> /// Updates an existing tournament /// </summary> /// <param name="tournament">Tournament ID (e.g. 10230) or URL (e.g. 'single_elim' for /// challonge.com/single_elim). If assigned to a subdomain, URL format must be "subdomain-tournament_url" /// (e.g. 'test-mytourney' for test.challonge.com/mytourney)</param> /// <param name="builder">The builder containing the properties to be updated</param> /// <returns>The updated tournament</returns> public async Task <Tournament> UpdateTournamentAsync(string tournament, TournamentBuilder builder) { return(await UpdateTournamentAsync(tournament, builder.Name, builder.Url, builder.TournamentType, builder.Subdomain, builder.Description, builder.OpenSignup, builder.HoldThirdPlaceMatch, builder.PointsForMatchWin, builder.PointsForMatchTie, builder.PointsForGameWin, builder.PointsForGameTie, builder.PointsForBye, builder.SwissRounds, builder.RankedBy, builder.AcceptAttachments, builder.HideForum, builder.ShowRounds, builder.IsPrivate, builder.NotifyUsersWhenMatchesOpen, builder.NotifyUsersWhenTournamentEnds, builder.SequentialPairings, builder.SignupCap, builder.StartAt, builder.CheckInDuration, builder.GrandFinalsModifier)); }
private void OnHeroesMarried(Hero firstHero, Hero secondHero, bool showNotification) { var result = TournamentBuilder.TryCreateWeddingTournament(firstHero, secondHero); if (result.Succeeded) { MBInformationManagerFacade.DisplayAsQuickBanner( $"To celebrate the wedding of {firstHero.Name} and {secondHero.Name}, local nobles have called a tournament at {result.HostSettlement.Name}"); } }
public void BuildTwoCarPlayoff() { var tournamentName = "2 Car Playoff"; var builder = new TournamentBuilder(tournamentName, @".\Races"); builder.AddGroup("2CarPlayoff", 1); var tournament = builder.Build(); Directory.CreateDirectory(Path.Combine(@"C:/Tournaments", tournamentName)); File.WriteAllText(Path.Combine(@"C:/Tournaments", tournamentName, "tournament.json"), JsonConvert.SerializeObject(tournament, Formatting.Indented)); Console.WriteLine(JsonConvert.SerializeObject(tournament, Formatting.Indented)); }
private CreatePeaceTournamentsResult TryCreatePeaceTournaments(IMBFaction factionA, IMBFaction factionB) { var factionAResults = TournamentBuilder.TryCreatePeaceTournamentForFaction(factionA); var factionBResults = TournamentBuilder.TryCreatePeaceTournamentForFaction(factionB); if (factionAResults.Failed && factionBResults.Failed) { return(CreatePeaceTournamentsResult.Failure); } return(CreatePeaceTournamentsResult.Success(factionAResults, factionBResults)); }
public void BuildThreeCarPlayoff() { var tournamentName = "Tiger Playoff"; var builder = new TournamentBuilder(tournamentName, @".\Races"); builder.AddGroup("3CarPlayoff", "Tiger Playoff", 1); var tournament = builder.Build(); Directory.CreateDirectory(Path.Combine(@"C:/Tournaments", tournamentName)); File.WriteAllText(Path.Combine(@"C:/Tournaments", tournamentName, "tournament.json"), JsonConvert.SerializeObject(tournament, Formatting.Indented)); Console.WriteLine(JsonConvert.SerializeObject(tournament, Formatting.Indented)); }
public void Build() { var tournamentName = "test-2016"; var builder = new TournamentBuilder(tournamentName, @".\Races"); builder.AddGroup("Scouts", 2, true); builder.AddGroup("Siblings", 1); builder.AddGroup("Adults", 1); var tournament = builder.Build(); Directory.CreateDirectory(Path.Combine(@"C:/Tournaments", tournamentName)); File.WriteAllText(Path.Combine(@"C:/Tournaments", tournamentName, "tournament.json"), JsonConvert.SerializeObject(tournament, Formatting.Indented)); // Console.WriteLine(JsonConvert.SerializeObject(tournament, Formatting.Indented)); }
private void TryCreateProsperityTournament() { if (!ModState.IsLotteryWinner(TournamentType.Prosperity)) { return; } var result = TournamentBuilder.TryCreateProsperityTournament(); if (result.Succeeded) { MBInformationManagerFacade.DisplayAsLogEntry($"Local nobles at {result.HostSettlement.Name} have called a tournament due to high prosperity"); } }
private void TryCreateInvitationTournament() { if (!ModState.IsLotteryWinner(TournamentType.Invitation) && MBHero.MainHero.Clan.Renown >= Settings.MaxRenownForInvitationTournaments) { return; } var result = TournamentBuilder.TryCreateInvitationTournament(); if (result.Succeeded) { MBInformationManagerFacade.DisplayAsQuickBanner("A local lord is looking for tournament contestants at " + result.HostSettlement.Name); } }
private void TryCreateHighbornTournament() { if (!ModState.IsLotteryWinner(TournamentType.Highborn)) { return; } var result = TournamentBuilder.TryCreateHighbornTournament(); if (result.Succeeded) { MBInformationManagerFacade.DisplayAsQuickBanner($"{result.Payor.Name} invites you to a Highborn tournament at {result.HostSettlement.Name}"); } }
public void Build() { var tournamentName = "2018"; var builder = new TournamentBuilder(tournamentName, @".\Races"); builder.AddGroup("Scouts", 2, true); builder.AddGroup("Siblings", 1); builder.AddGroup("Adults", 1); var tournament = builder.Build(); Directory.CreateDirectory(Path.Combine(@"C:/Tournaments", tournamentName)); File.WriteAllText(Path.Combine(@"C:/Tournaments", tournamentName, "tournament.json"), JsonConvert.SerializeObject(tournament, Formatting.Indented)); // Console.WriteLine(JsonConvert.SerializeObject(tournament, Formatting.Indented)); }
public void TestGetWinnerMatchWhitNotaDifferent() { // Arrange var expected = new MovieBuilder() .WithNota(9M) .Build(); var secondMovie = new MovieBuilder() .Build(); var tournament = new TournamentBuilder().Build(); var standing = new Standing(tournament); // Act var result = standing.GetWinnerMatch(expected, secondMovie); // Assert result.Should().BeEquivalentTo(expected); }
public async Task TestRunMatchesAsync() { // Arrange var tournament = new TournamentBuilder().Build(); var standing = new Standing(tournament); var expectedScore0 = new List <string>() { "tt5164214", "tt7784604", "tt3778644" }; var expectedScore1 = new List <string>() { "tt3501632", "tt4881806" }; var expectedScore2 = new List <string>() { "tt3606756" }; var expectedScore3 = new List <string>() { "tt4154756" }; // Act await standing.RunMatchesAsync(); // Assert standing.Rankings .Where(r => expectedScore0.Contains(r.Movie.Id)) .ToList() .Should().HaveCount(expectedScore0.Count); standing.Rankings .Where(r => expectedScore1.Contains(r.Movie.Id)) .ToList() .Should().HaveCount(expectedScore1.Count); standing.Rankings .Where(r => expectedScore2.Contains(r.Movie.Id)) .ToList() .Should().HaveCount(expectedScore2.Count); standing.Rankings .Where(r => expectedScore3.Contains(r.Movie.Id)) .ToList() .Should().HaveCount(expectedScore3.Count); }
public async Task TestCreateAsync() { // Arrange string content = File.ReadAllText($"DataTests{Path.DirectorySeparatorChar}StandingViewModel.json"); var expected = JsonConvert.DeserializeObject <StandingViewModel>(content); var tournament = new TournamentBuilder().Build(); _repositoryMock.Setup(x => x.InsertOneAsync(It.IsAny <Standing>())) .Returns(Task.CompletedTask); _mapperMock.Setup(x => x.Map <StandingViewModel>(It.IsAny <Standing>())) .Returns(expected); var service = new StandingService(_repositoryMock.Object, _mapperMock.Object); // Act var result = await service.CreateAsync(tournament); // Assert _repositoryMock.Verify(x => x.InsertOneAsync(It.IsAny <Standing>()), Times.Once); _mapperMock.Verify(x => x.Map <StandingViewModel>(It.IsAny <Standing>()), Times.Once); result.Should().BeEquivalentTo(expected); }
public void TestGenerateMatchWhitValidTournament() { // Arrange var tournament = new TournamentBuilder().Build(); var standing = new Standing(tournament); var firstMovie = tournament.Movies.First(); var lastMovie = tournament.Movies.First(); var expected = standing.GetWinnerMatch(firstMovie, lastMovie); // Act var result = standing.GenerateMatch(firstMovie, lastMovie); // Assert standing.Rankings.Count() .Should().Be(tournament.Movies.Count()); standing.Rankings .FirstOrDefault(r => r.Movie.Id == expected.Id) .Score.Should().Be(1); result.Should().BeEquivalentTo(expected); }
private void OnHostTournamentMenuConsequence(MenuCallbackArgs args) { TournamentBuilder.TryCreatePlayerInitiatedTournament(); ModState.DaysSince[TournamentType.PlayerInitiated] = 0; GameMenu.ActivateGameMenu("town_arena"); }