public async Task <ActionResult <TournamentType> > PostTournamentType(TournamentType tournamentType) { _context.TournamentTypes.Add(tournamentType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTournamentType", new { id = tournamentType.TypeId }, tournamentType)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,TournamentTypeName")] TournamentType tournamentType) { if (id != tournamentType.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tournamentType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TournamentTypeExists(tournamentType.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tournamentType)); }
public async Task <List <Player> > GetPlayersWithGoals(int tournamenttypeID) { List <Player> playerList; TournamentType tournamentType = await _tournamentTypeRepository.Get(tournamenttypeID); switch (tournamentType.Format) { case TournamentFormat.WorldCup: playerList = await _playerRepository.GetWorldCupGoals(); break; case TournamentFormat.ConfederationsCup: playerList = await _playerRepository.GetConfederationsCupGoals(); break; case TournamentFormat.ConfederationTournament: playerList = await _playerRepository.GetConfederationTournamentGoals(tournamentType.ConfederationID); break; case TournamentFormat.Qualification: playerList = await _playerRepository.GetQualificationGoals(); break; default: playerList = await _playerRepository.Get(); break; } return(playerList); }
/// <summary> /// Creates a new tournament /// </summary> /// <param name="url">Url of your tournament (letters, numbers and underscores only). /// Make sure it is unique (you can leave it blank and have challonge pick a random url for you)</param> /// <param name="name">Name of the tournament</param> /// <param name="type">Type of tournament</param> /// <param name="subdomain">Subdomain to assign the tournament to (requires write access to /// the subdomain)</param> /// <param name="description">Description/instructions to be displayed above the bracket</param> /// <param name="openSignup">Have Challonge host a sign-up page (otherwise, you manually add all participants)</param> /// <param name="holdThirdPlaceMatch">Single Elimination only. Include a match between semifinal losers?</param> /// <param name="ptsForMatchWin">Swiss only: number of points gained for a match win</param> /// <param name="ptsForMatchTie">Swiss only: number of points gained for a match tie</param> /// <param name="ptsForGameWin">Swiss only: number of points gained for a game win</param> /// <param name="ptsForGameTie">Swiss only: number of points gained for a game tie</param> /// <param name="ptsForBye">Swiss only: number of points gained for a bye</param> /// <param name="swissRounds">Number of rounds</param> /// <param name="rankedBy">How the participants are ranked</param> /// <param name="acceptAttachments">Allow match attachment uploads</param> /// <param name="hideForum">Hide the forum tab on your Challonge page</param> /// <param name="showRounds">Whether or not to label each round above the bracket</param> /// <param name="isPrivate">Hide this tournament from the public browsable index and your profile</param> /// <param name="notifyUsersWhenMatchesOpen">Whether or not to email registered Challonge /// participants when matches open up for them</param> /// <param name="notifyUsersWhenTournamentsEnds">Whether or not to email registered Challonge /// participants when this tournament ends</param> /// <param name="sequentialPairings">When enabled, instead of traditional seeding rules, make /// pairings by going straight down the list of participants. First round matches are filled in top /// to bottom, then qualifying matches (if applicable).</param> /// <param name="signupCap">Maximum number of participants in the bracket. Once the cap is reached, /// new participants will be put in waiting list, and <see cref="Participant.OnWaitingList"/> will /// be set to <see langword="true"/></param> /// <param name="startAt"></param> /// <param name="checkInDuration">Length of the participant check-in window in minutes.</param> /// <param name="grandFinalsModifier">Double elimination only: how the grand finals will be played</param> /// <returns>The tournament that was created</returns> public async Task <Tournament> CreateTournamentAsync(string name, string url = null, TournamentType type = TournamentType.SingleElimination, string subdomain = null, string description = null, bool openSignup = false, bool holdThirdPlaceMatch = false, float ptsForMatchWin = 1.0f, float ptsForMatchTie = 0.5f, float ptsForGameWin = 0f, float ptsForGameTie = 0f, float ptsForBye = 1.0f, int?swissRounds = null, TournamentRankingStats rankedBy = TournamentRankingStats.MatchWins, bool acceptAttachments = false, bool hideForum = false, bool showRounds = false, bool isPrivate = false, bool notifyUsersWhenMatchesOpen = false, bool notifyUsersWhenTournamentsEnds = false, bool sequentialPairings = false, int?signupCap = null, DateTimeOffset?startAt = null, int?checkInDuration = null, TournamentGrandFinals grandFinalsModifier = TournamentGrandFinals.TwoChances) { string request = "https://api.challonge.com/v1/tournaments.json"; Dictionary <string, string> parameters = PrepareParams(name, url, type, subdomain, description, openSignup, holdThirdPlaceMatch, ptsForMatchWin, ptsForMatchTie, ptsForGameWin, ptsForGameTie, ptsForBye, swissRounds, rankedBy, acceptAttachments, hideForum, showRounds, isPrivate, notifyUsersWhenMatchesOpen, notifyUsersWhenTournamentsEnds, sequentialPairings, signupCap, startAt, checkInDuration, grandFinalsModifier); FormUrlEncodedContent content = new FormUrlEncodedContent(parameters); TournamentData tournamentData = await PostAsync <TournamentData>(_httpClient, request, content); return(tournamentData.Tournament); }
public async Task <IActionResult> PutTournamentType(int id, TournamentType tournamentType) { if (id != tournamentType.TypeId) { return(BadRequest()); } _context.Entry(tournamentType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TournamentTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public List <Player> Tournament(List <Player> players, TournamentType tournamentType, int gamePlayedGoal, GameMode gameMode) { Players = players; _gamePlayedGoal = gamePlayedGoal; _gameMode = gameMode; Stopwatch sw = new Stopwatch(); sw.Start(); Console.WriteLine("Running Gamemode:{0} TournamentType:{1} GameplayedGoal:{2}", gameMode, tournamentType, gamePlayedGoal); RunAllGames(tournamentType); Console.WriteLine(""); sw.Stop(); Console.WriteLine($"Games: {gamesPlayed} Calculation time seconds:{sw.Elapsed.TotalSeconds} Seconds per 100 games {Math.Round(sw.Elapsed.TotalSeconds * 100 / gamesPlayed,3) }"); Console.ForegroundColor = ConsoleColor.Blue; Console.Write($"Blue wins : {blueWins} "); Console.ForegroundColor = ConsoleColor.Red; Console.Write($"Red wins : {redWins} "); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine($"Ties : {ties}, did not finish : {didNotFinish}"); Console.WriteLine(); int rank = Players.Count; foreach (Player player in Players.OrderByDescending(p => p.Wins).ThenByDescending((l => l.Ties))) { Console.WriteLine("{0}: Score results Games played:{1} Wins:{2} Ties:{3} Loses:{4} Elo:{5} Args:{6}", player.AiName, player.GamesPlayed, player.Wins, player.Ties, player.Loses, Math.Round(player.EloRating, 0), player.GetArgs()); } return(Players); }
// Load tournament state from disk bool LoadTournamentState(string stateFile = "") { if (stateFile != "") { this.stateFile = stateFile; } tournamentState = new TournamentState(); if (tournamentState.LoadState(this.stateFile)) { message = "Tournament state loaded from " + this.stateFile; tournamentID = tournamentState.tournamentID; tournamentType = tournamentState.tournamentType; vesselCount = tournamentState.vesselCount; teamCount = tournamentState.teamCount; teamsPerHeat = tournamentState.teamsPerHeat; vesselsPerTeam = tournamentState.vesselsPerTeam; fullTeams = tournamentState.fullTeams; numberOfRounds = tournamentState.rounds.Count; numberOfHeats = numberOfRounds > 0 ? tournamentState.rounds[0].Count : 0; heatsRemaining = tournamentState.rounds.Select(r => r.Value.Count).Sum() - tournamentState.completed.Select(c => c.Value.Count).Sum(); } else { message = "Failed to load tournament state."; } Debug.Log("[BDATournament]: " + message); // if (BDACompetitionMode.Instance != null) // BDACompetitionMode.Instance.competitionStatus.Add(message); tournamentStatus = heatsRemaining > 0 ? TournamentStatus.Stopped : TournamentStatus.Completed; return(true); }
public void Update(TournamentType tournamentType) { var tournamentTypeModified = _mapper.Map <TournamentTypes>(tournamentType); _ctx.TournamentTypes.Attach(tournamentTypeModified); _ctx.Entry(tournamentTypeModified).State = EntityState.Modified; }
public static List <ITournamentType> GetAll() { List <ITournamentType> result = new List <ITournamentType>(); MySqlConnection dbConn = new MySqlConnection(connString); dbConn.Open(); string query = "SELECT * FROM TournamentTypes"; using (MySqlCommand cmd = new MySqlCommand(query, dbConn)) { using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { TournamentType found = new TournamentType() { TournamentTypeId = Int32.Parse(reader["tournament_type_id"].ToString()), TournamentTypeName = reader["tournament_type_name"].ToString() }; result.Add(found); } } } return(result); }
public static Tournament GetTournament(TournamentType tournamentType) { if (tournamentType == TournamentType.Worlds) { return(new WorldsTournament()); } return(new WorldsTournament()); }
/// <summary> /// Main Constructor /// </summary> public Tournament() { m_Teams = new List <Teams>(); m_Date = DateTime.Now; m_ArenaSets = new List <string>(); m_Type = TournamentType.SingleElimination; m_TeamSize = ArenaType.OneVsOne; m_Supplied = true; m_Prizes = new Dictionary <string, Item>(); }
private void LoadTournament() { _roundsLeft = _p.SavedTournament.RoundsToGo; _players = new List <TournamentPlayer>(_p.SavedTournament.Players); _matches = _p.SavedTournament.CurrentRoundMatches; _humanLibrary = _p.SavedTournament.HumanLibrary; _type = _p.SavedTournament.Type; FinishUnfinishedMatches(); }
public async Task <IActionResult> Create([Bind("Id,TournamentTypeName")] TournamentType tournamentType) { if (ModelState.IsValid) { _context.Add(tournamentType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tournamentType)); }
public void TestGetTheType_Default_ShouldReturnFifa() { string file = @"data\euro2016.toml"; string cup = @"name = ""World Cup 2016"" type = ""fifa-wouldcup"""; var t = CreateTournament(file, cup); t.Load(file); TournamentType type = t.GetTheType(); type.ShouldBe(TournamentType.FIFA_WordCup); }
public new static CreateTournamentResult Success(TournamentType tournamentType, bool hadExistingTournament, MBSettlement settlement) { var isInitialTournament = tournamentType == TournamentType.Initial; return(new CreateTournamentResult() { HadExistingTournament = hadExistingTournament, Status = ResultStatus.Success, Payor = isInitialTournament ? MBHero.Null : settlement.OwnerClan.Leader, HostSettlement = settlement }); }
public static TournamentParameters Default(string playerName, int avatarId, int playersCount, string[] boosterPacks, string tournamentPack, TournamentType type) { return(new TournamentParameters { PlayerName = playerName, PlayersCount = playersCount, BoosterPacks = boosterPacks, TournamentPack = tournamentPack, Type = type, AvatarId = avatarId }); }
public static TournamentParameters Default(string playerName, int avatarId, int playersCount, string[] boosterPacks, string tournamentPack, TournamentType type) { return new TournamentParameters { PlayerName = playerName, PlayersCount = playersCount, BoosterPacks = boosterPacks, TournamentPack = tournamentPack, Type = type, AvatarId = avatarId }; }
public async Task <IActionResult> Put([FromBody] TournamentType item) { if (item == null) { return(StatusCode(422, "Відсутні данні.")); } var result = await _tournamentTypeRepository.UpdateAsync(item); if (result.Result == OperationResult.Ok) { return(StatusCode(202, result.Value)); } return(StatusCode(422, result.Message)); }
public async Task <ActionResult <ApiResult <string> > > PostNewType(TournamentTypeVM p) { TournamentType t = new TournamentType { TournamentTypeID = p.TournamentTypeID, Name = p.Name, }; _context.TournamentTypes.Add(t); _context.SaveChanges(); return(new ApiResult <string> { IsValid = true, Result = "Tournament Type '" + t.Name + "' was successfully uploaded!" }); }
public void ChangeType(TournamentType _type) { switch (_type) { case TournamentType.Championship: Championship.gameObject.SetActive(true); //Championship.ClearMatchList(); Cup.gameObject.SetActive(false); break; case TournamentType.Cup: Championship.gameObject.SetActive(false); Cup.gameObject.SetActive(true); break; } }
public Tournament(int rounds, int secondsPerMove, string crossTableFile, string gameDataFile, EngineHelper engines, List <string> players, bool allowSelfPlay, TournamentType tournamentType) { _rounds = rounds; _secondsPerMove = secondsPerMove; _crossTableFile = crossTableFile; _gameDataFile = gameDataFile; _engines = engines; _players = players; _allowSelfPlay = allowSelfPlay; _tournamentType = tournamentType; worker = new BackgroundWorker(); worker.WorkerReportsProgress = true; worker.DoWork += Worker_DoWork; worker.RunWorkerCompleted += Worker_RunWorkerCompleted; worker.ProgressChanged += Worker_ProgressChanged; }
private void RunAllGames(TournamentType tournamentType) { if (tournamentType == TournamentType.AllvsAll) { AllvsAllTournement(); } if (tournamentType == TournamentType.Dropout) { DropoutTournement(); } if (tournamentType == TournamentType.VersusTop) { VersusTopTournement(); } }
private void ApplyHostingEffects(TournamentType type, MBSettlement settlement) { if (type == TournamentType.Initial) { return; } settlement.Prosperity += Settings.ProsperityIncrease; settlement.Town.Loyalty += Settings.LoyaltyIncrease; settlement.Town.Security += Settings.SecurityIncrease; settlement.Town.FoodStocks -= Settings.FoodStocksDecrease; if (settlement.Town.MapFaction.Leader.IsHumanPlayerCharacter && Settings.SettlementStatNotification) { MBInformationManagerFacade.DisplayAsLogEntry($"{settlement.Name}'s prosperity, loyalty and security have increased and food stocks have decreased"); } }
public async Task <List <Team> > GetTeamsWithTitles(int tournamenttypeID, int quantity) { List <Team> teamList; if (tournamenttypeID > 0) { TournamentType tournamentType = await _tournamentTypeRepository.Get(tournamenttypeID); switch (tournamentType.Format) { case TournamentFormat.WorldCup: teamList = await _teamRepository.GetWorldCupTitles(); break; case TournamentFormat.ConfederationsCup: teamList = await _teamRepository.GetConfederationsCupTitles(); break; case TournamentFormat.ConfederationTournament: teamList = await _teamRepository.GetConfederationTournamentTitles(tournamentType.ConfederationID); break; case TournamentFormat.Qualification: teamList = await _teamRepository.GetWorldCupQualifications(); break; default: teamList = await _teamRepository.Get(); break; } return(teamList); } else { teamList = await _teamRepository.GetTeamsWithTitles(quantity); return(teamList); } }
public IActionResult CreateTournament(string name, TournamentType type = TournamentType.Group) { var file = Request.Form.Files["TournamentInfo"]; using (var ms = new MemoryStream()) { file.CopyTo(ms); var content = Encoding.UTF8.GetString(ms.ToArray()); context.Tournaments.Add(new Tournament { Name = name, TournamentTree = content, Type = type }); context.SaveChanges(); return(RedirectToAction(nameof(Index))); } }
public void TestGetTheType_WhenGiven_ShouldReturnCorrectTournamentType() { string file = @"data\euro2016.toml"; string cup = @"name = ""Euro 2016 France"" type = ""uefa-euro"""; var t = CreateTournament(file, cup); t.Load(file); TournamentType type = t.GetTheType(); type.ShouldBe(TournamentType.UEFA_Euro); cup = @"name = ""World Cup 2016"" type = ""fifa-wouldcup"""; t = CreateTournament(file, cup); t.Load(file); type = t.GetTheType(); type.ShouldBe(TournamentType.FIFA_WordCup); }
public static string TournamentTypeConverter(TournamentType tournamentType) { switch (tournamentType) { case TournamentType.SingleElimination: return("single_elimination"); case TournamentType.DoubleElimination: return("double_elimination"); case TournamentType.RoundRobin: return("round_robin"); case TournamentType.Swiss: return("swiss"); } return(null); }
public async Task <IActionResult> Post([FromBody] TournamentType item) { if (item == null) { return(StatusCode(422, "Відсутні данні.")); } if (string.IsNullOrEmpty(item.Name)) { return(StatusCode(422, "Відсутня назва.")); } var result = await _tournamentTypeRepository.CreateAsync(item); if (result.Result == OperationResult.Ok) { return(StatusCode(201, result.Value)); } return(StatusCode(422, result.Message)); }
public static string ToChallongeString(this TournamentType me) { switch (me) { case TournamentType.SingleElimination: return("single elimination"); case TournamentType.DoubleElimination: return("double elimination"); case TournamentType.RoundRobin: return("round robin"); case TournamentType.Swiss: return("swiss"); } throw new ArgumentException("TournamentType is extended without TournamentTypeExtensions knowing about it."); }
public static string ToCreateString(TournamentType type) { switch (type) { case TournamentType.Single_Elimination: return("Single elimination"); case TournamentType.Double_Elimination: return("double elimination"); case TournamentType.Round_Robin: return("round robin"); case TournamentType.Swiss: return("swiss"); default: throw new NotSupportedException(); } }
private void NewTournament() { _cardRatings = LoadCardRatings(); _roundsLeft = CalculateRoundCount(); _players = CreatePlayers(); _type = _p.Type; switch (_type) { case TournamentType.Sealed: { CreateSealedDecks(); break; } case TournamentType.Draft: { CreateDraftDecks(); } break; } }
/// <summary> /// Create a new tournament. /// </summary> /// <param name="name"></param> /// <param name="type"></param> /// <param name="url"> </param> /// <param name="parameters"> </param> /// <returns></returns> public Tournament TournamentCreate(string name, TournamentType type, string url, TournamentCreateParameters parameters = null) { string apiUrl = string.Format("tournaments"); var param = new Dictionary<string, dynamic>(); if (parameters != null) { param = parameters.ToDictionary(); } if (!param.ContainsKey("tournament") || param["tournament"] == null) { param["tournament"] = new Dictionary<string, dynamic>(); } param["tournament"]["name"] = name; param["tournament"]["tournament_type"] = type.ToChallongeString(); param["tournament"]["url"] = url; var json = this.MakeJsonRequest(apiUrl, WebRequestMethods.Http.Post, param); return Deserializer.Tournament(json); }
/// <summary> /// Main Constructor /// </summary> public Tournament() { m_Teams = new List<Teams>(); m_Date = DateTime.Now; m_ArenaSets = new List<string>(); m_Type = TournamentType.SingleElimination; m_TeamSize = ArenaType.OneVsOne; m_Supplied = true; m_Prizes = new Dictionary<string,Item>(); }
private void LoadTournament() { _roundsLeft = _p.SavedTournament.RoundsToGo; _players = new List<TournamentPlayer>(_p.SavedTournament.Players); _matches = _p.SavedTournament.CurrentRoundMatches; _humanLibrary = _p.SavedTournament.HumanLibrary; _type = _p.SavedTournament.Type; FinishUnfinishedMatches(); }
public List<Tournament> GetAll(TournamentType searchType, string searchName) { var tournaments = _tournamentRepository.Table.Where(t => !t.Deleted); if (!searchType.Equals(TournamentType.All)) { tournaments = tournaments.Where(t => !t.Deleted && t.Type == searchType); } if (!string.IsNullOrEmpty(searchName)) { tournaments = tournaments.Where(t => !t.Deleted && t.Name.ToLower().Contains(searchName.Trim().ToLower())); } return tournaments.ToList(); }