public void UpdateAvailableTournamentsList() { if (availableTournamentsList == null) { availableTournamentsList = new List <TournamentInfo>(); //TournamentInfo tournamentInfo = (Resources.Load("Templates/Tournaments/TutorialTournament") as TournamentInfoWrapper).tournamentInfo; //availableTournamentsList.Add(tournamentInfo); } else { availableTournamentsList.Clear(); } TournamentInfo tournamentInfo1 = (Resources.Load("Templates/Tournaments/TutorialTournament") as TournamentInfoWrapper).tournamentInfo; availableTournamentsList.Add(tournamentInfo1); TournamentInfo tournamentInfo2 = (Resources.Load("Templates/Tournaments/Sectionals") as TournamentInfoWrapper).tournamentInfo; availableTournamentsList.Add(tournamentInfo2); TournamentInfo tournamentInfo3 = (Resources.Load("Templates/Tournaments/Regionals") as TournamentInfoWrapper).tournamentInfo; availableTournamentsList.Add(tournamentInfo3); TournamentInfo tournamentInfo4 = (Resources.Load("Templates/Tournaments/CombatTournamentA") as TournamentInfoWrapper).tournamentInfo; availableTournamentsList.Add(tournamentInfo4); }
public async Task <IActionResult> AddTeamToTournamentAsync(string tournamentId, Participant <Team> addTeam) { if (await Session.GetCurrentUser() == null) { return(Unauthorized()); } var tournament = (await TournamentInfo.GetAllTournamentsAsync()).FirstOrDefault(t => t.Id == tournamentId || t.Slug == tournamentId || t.ToornamentId == tournamentId); if (tournament.Teams.Any(i => i.Id == addTeam.Item.Id)) { return(Ok()); } Toornament.Participant team = new Toornament.Participant { Identifier = addTeam.Item.Id, Name = addTeam.Item.Name }; if (!string.IsNullOrEmpty(tournament?.ToornamentId)) { try { team = await Toornament.Organizer.AddParticipantAsync(tournament.ToornamentId, team); } catch { var parts = await Toornament.Organizer.GetParticipantsAsync(tournament.ToornamentId); team = parts.FirstOrDefault(p => p.Identifier == addTeam.Item.Id); } } var participant = new Participant <Team> { Item = addTeam.Item, Information = addTeam.Information, ToornamentId = team?.Id }; return(Ok(await TournamentInfo.AddTeamToTournamentAsync(tournamentId, participant))); }
public void Initialize(TeamsConfig teamsConfig, TournamentInfo tournamentInfo) { Debug.Log("TournamentManager Initialize"); currentTournamentInfo = tournamentInfo; // Load Competitors, // Create Match Schedule // Process Tournament Info: tournamentInfo.PrepareTournament(teamsConfig.playersList[0].agentGenomeList[0]); gameManager.prestige -= tournamentInfo.entranceFee; // Set up Exhibition Instance: if (tournamentInstance == null) { GameObject tournamentInstanceGO = new GameObject("TournamentInstance"); tournamentInstance = tournamentInstanceGO.AddComponent <EvaluationInstance>(); tournamentInstance.transform.position = new Vector3(0f, 0f, 0f); tournamentInstance.visible = true; tournamentInstance.isExhibition = true; } else { tournamentInstance.gameObject.SetActive(true); } }
public void EnterTournamentMode(TournamentInfo tournamentInfo) { // Set up TournamentManager with info tournamentManager.Initialize(trainerRef.teamsConfig, tournamentInfo); // Set up UI: ChangeState(GameState.Tournament); //mainMenuRef.panelTournament.GetComponent<TournamentUI>().Initialize(tournamentInfo); }
private void SaveToHtml(string html_filename) { string pic_filename = Path.Combine(Path.GetDirectoryName(html_filename), Path.GetFileNameWithoutExtension(html_filename) + ".jpg"); if (!Globals.Tournaments.ContainsKey(FCompetition.Info.TournamentId)) { DatabaseManager.CurrentDb.ReadTournamentList(Globals.Tournaments); } TournamentInfo tInfo = Globals.Tournaments[FCompetition.Info.TournamentId].Info; string tDate = tInfo.DateBegin.ToString("dd.MM.yyyy") + " - " + tInfo.DateEnd.ToString("dd.MM.yyyy"); string tPlace = tInfo.Place; string tName = tInfo.Name; string cName = FCompetition.Info.Name; string cDate = FCompetition.Info.Date.ToString("dd.MM.yyyy"); string title = String.Format("{0}. {1}. {2} - {3}", tDate, tPlace, tName, cName); HtmlGenerator html = new HtmlGenerator(); html.Title = title; StringBuilder body = new StringBuilder(); body.AppendLine(html.TagString("h1", tDate + " - " + tPlace)); body.AppendLine(html.TagString("h1", tName)); body.AppendLine(html.TagString("h2", cName)); // Список участников body.AppendLine(html.TagString("h3", Localizator.Dictionary.GetString("PLAYER_IN_COMPETITION", ":"))); body.AppendLine(html.TagString("p", lvCompetitionPlayers.ToHtmlTableString())); // Сетка турнира if (FCompetition.Info.Status != CompetitionInfo.CompetitionState.RegistrationAndSeeding) { Bitmap bmp = pnlCompetition.GetPicture(new SolidBrush(Color.White)); PictureSaver.SavePicture(bmp, pic_filename, ImageFormat.Png); string fn = Path.GetFileName(pic_filename); string img = String.Format("<img src='{0}' alt=''/>", fn); body.AppendLine(html.TagString("h3", Localizator.Dictionary.GetString("COMPETITION_MATCHES", " :"))); body.AppendLine(html.TagString("p", img)); } // Результаты if (FCompetition.Info.Status == CompetitionInfo.CompetitionState.Finished) { body.AppendLine(html.TagString("h3", Localizator.Dictionary.GetString("COMPETITION_RESULTS", " :"))); body.AppendLine(html.TagString("p", lvPlayerPlace.ToHtmlTableString())); } // Изменение рейтинга #if FEDITION if (FCompetition.Info.Status == CompetitionInfo.CompetitionState.Finished && FCompetition.Info.ChangesRating) { body.AppendLine(html.TagString("h3", Localizator.Dictionary.GetString("RATING_CHANGES", " :"))); body.AppendLine(html.TagString("p", lvRatingAfter.ToHtmlTableString())); } #endif html.Body = body.ToString(); html.SaveTo(html_filename); }
public async Task <IActionResult> GetTournamentsAsync() { if (await Session.GetCurrentUser() == null) { return(Unauthorized()); } return(Ok(await TournamentInfo.GetAllTournamentsAsync())); // return Ok(await Toornament.Organizer.GetTournamentsAsync()); }
private void OnAfterJoinRoom(JoinRoomEvent e) { if (e.RoomId == currentShow.info.roomId && e.ZoneId == currentShow.info.zoneId) { GameManager.Instance.currentTournamentInfo = currentShow.info; TournamentInfo info = GameManager.Instance.currentTournamentInfo; GameManager.LoadScene(ESceneName.Tournament); } }
public async Task <IActionResult> GetAdminInfoAsync(string tournamentId) { User player = await Session.GetCurrentUser(); if (player == null) { return(Unauthorized()); } return(Ok(await TournamentInfo.GetAdminInfoAsync(player, tournamentId))); }
public TournamentInstance(TournamentInfo tournamentInfo, GameLogic.Player player) { this.OutgoingLogQueue = new List <TournamentLogEvent>(); this.HeroStats = new GameLogic.HeroStats(); this.Resources = new Dictionary <string, double>(); this.Upgrades = new TournamentUpgrades(); this.LastAdventurePanelSubTabIdx = -1; this.TournamentId = tournamentInfo.Id; this.Player = player; this.CurrentState = State.PENDING_JOIN_CONFIRMATION; }
private void OpenTournament(object sender, System.Windows.Input.MouseButtonEventArgs e) { Console.WriteLine("Opening Tournament..."); ListViewItem lv = sender as ListViewItem; TournamentInfo tInfo = lv.Content as TournamentInfo; ActiveTournamentID = tInfo.UID; RequestTournament(tInfo.UID); }
public async Task <IActionResult> GetTournamentsAsync(string tournamentId) { if (await Session.GetCurrentUser() == null) { return(Unauthorized()); } var tournaments = await TournamentInfo.GetAllTournamentsAsync(); var tournament = tournaments.FirstOrDefault(t => t.Id == tournamentId || t.Slug == tournamentId || t.ToornamentId == tournamentId); return(Ok(tournament)); }
/*public void EnterTournamentSelectScreen() { * Debug.Log("EnterTournamentSelect()"); * * // Pause Evaluations * Pause(); * // Switch UI panel from trainer to Tournaments * * // Display upcoming tournaments, with some eligible, some on cooldown, and some locked * * * } * public void ExitTournamentSelectScreen() { * // Switch UI panel back to trainerUI * // resume paused evaluations * TogglePlayPause(); // UGLY!! assumes it was paused during tournament select screen! * }*/ public void EnterTournament(TournamentInfo tournamentInfo) { Debug.Log("TrainingManager.EnterTournament"); // Clean up current training, evalManager etc. - reset this generation isTraining = false; evaluationManager.ClearCurrentTraining(); // Bring up Tournament Summary Page: name, type, opponent, etc. // Pass everything to TournamentManager? gameManager.EnterTournamentMode(tournamentInfo); //trainingMenuRef.mainMenuRef.EnterTournamentMode(tournamentInfo); }
private void okButton_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tournamentCodeTextbox.Text)) { MessageBox.Show("Tournament Code cannot be empty string!"); return; } if (string.IsNullOrWhiteSpace(descriptionTextbox.Text)) { MessageBox.Show("Description cannot be empty string!"); return; } if (string.IsNullOrWhiteSpace(tournamentLevelCombobox.Text)) { MessageBox.Show("Tournament Level cannot be empty string!"); return; } this.loginPanel.Enabled = false; this.loadingPicture.Enabled = true; this.loadingPicture.Visible = true; this.loadingPicture.BringToFront(); this.Refresh(); TournamentInfo tournamentInfo = new TournamentInfo(); tournamentInfo.tournament_code = tournamentCodeTextbox.Text; tournamentInfo.description = descriptionTextbox.Text; tournamentInfo.tournament_level_code = tournamentLevelCodes[tournamentLevelCombobox.SelectedIndex]; string json_result = m_mm.addTournament(tournamentInfo); Dictionary <string, string> result = Utilities.convertJsonOutput(json_result); bool errorStatus = Convert.ToBoolean(result["error"]); if (errorStatus) { Utilities.showErrorMessage(result["message"]); /*if (result["message"].Contains("Session cannot be validated!")) * { * Utilities.showErrorMessage(result["message"]); * } * else Utilities.showErrorMessage("Error when trying to add tournament because : " + result["content"]);*/ } else { MessageBox.Show(result["content"], "Add Tournament Success"); this.DialogResult = DialogResult.OK; this.Close(); } this.loadingPicture.Visible = false; this.loginPanel.Enabled = true; }
public async Task <IActionResult> GetEligbleTeamsAsync(string tournamentId) { User player = await Session.GetCurrentUser(); if (player == null) { return(Unauthorized()); } if (tournamentId == "null") { return(Ok(false)); } return(Ok(await TournamentInfo.GetEligibleTeamsAsync(tournamentId, player.Id))); }
void CheckWinner(TournamentInfo info) { Debug.Log("Check winner..."); if (string.IsNullOrEmpty(info.userNameWin)) { tournamentDetail.SetActive(true); tournamentWinner.SetActive(false); } else { tournamentDetail.SetActive(false); tournamentWinner.SetActive(true); tournamentWinner.GetComponent <TournamentWinner>().SetData(info.award, info.userNameWin, info.avatarWinner); } }
public void SetData(TournamentInfo info) { this.idTournament = info.tournamentId; lblName.text = info.tournamentName; lblDecription.text = info.decription; lblCost.text = Utility.Convert.Chip(info.costRegistration); lblCondition.text = info.consdition; lblEndRegistration.text = info.endDate; this.remainTime = (float)info.remainStartTime; if (info.isRegister) { NGUITools.SetActive(lblTournamentStatus.gameObject, true); lblTournamentStatus.text = "(Đã đăng ký)"; } else { lblTournamentStatus.gameObject.SetActive(false); //if (info.remainStartTime<=0) //{ // if (info.remainStartTime==-1) // { // NGUITools.SetActive(lblTournamentStatus.gameObject, true); // lblTournamentStatus.text = "Đã kết thúc"; // } // else // { // NGUITools.SetActive(lblTournamentStatus.gameObject, true); // lblTournamentStatus.text = "Đang diễn ra"; // } //} //else //{ // NGUITools.SetActive(lblTournamentStatus.gameObject, false); //} } //lblStatus.text=info.st lblNumberUser.text = info.numPlayersRegister + "/" + info.maxPlayers; new AvatarCacheOrDownload(info.awardLink, delegate(Texture awardtexture) { if (awardtexture != null) { imgAward.mainTexture = awardtexture; imgAward.SetDimensions(128, 128); } } ); CountDownTime(); }
public bool AddTournament(TournamentInfo tourInfo, Competition[] competitions) { Tournament tournament = new Tournament(); tournament.Info.DateBegin = tourInfo.DateBegin; tournament.Info.DateEnd = tourInfo.DateEnd; tournament.Info.Id = tourInfo.Id; tournament.Info.Name = tourInfo.Name; tournament.Info.Place = tourInfo.Place; for (int i = 0; i < competitions.Length; i++) { tournament.Competitions.Add(i, competitions[i]); } Tournaments.Add(tournament); return(true); }
/*public void ClickFirstTournament() { * panelTournamentPrompt.SetActive(true); * * buttonEnterTournament.interactable = false; * buttonEnterTournament.GetComponentInChildren<Text>().text = "Enter Tournament $10"; * * // Set selected TournamentInfo * selectedTournamentTemplateName = "TutorialTournament"; * }*/ public void ClickEnterTournament() { string competitorName = inputFieldCompetitorName.text; Debug.Log("ClickEnterTournament() name:" + competitorName); // Grab from Template! //TournamentInfo firstTourneyInfo = new TournamentInfo(trainingMenuRef.gameManager.trainerRef.teamsConfig); // Error check for incorrect/non-existant filename... eventually //TournamentInfo tournamentInfo = (Resources.Load("Templates/Tournaments/" + selectedTournamentTemplateName) as TournamentInfoWrapper).tournamentInfo; TournamentInfo tournamentInfo = trainingMenuRef.gameManager.availableTournamentsList[selectedTournamentIndex]; // fill in stats trainingMenuRef.gameManager.cameraEnabled = false; trainingMenuRef.gameManager.trainerRef.EnterTournament(tournamentInfo); }
private TournamentInfo IsTournamentActive(List <TournamentInfo> allSearchJoinable) { foreach (var tournamentInfo in allSearchJoinable) { var currentTournament = GetTournamentInfo(tournamentInfo.tag); if (currentTournament != null && currentTournament.currentPlayers < currentTournament.maxPlayers && currentTournament.status.ToLower() == "inprogress") { { TournamentInfo.SetRealStartDate(new List <TournamentInfo> { currentTournament }); return(currentTournament); } } } return(null); }
public void Exit() { if (playerWon) { gameManager.prestige += currentTournamentInfo.reward; } tournamentInstance.gameObject.SetActive(false); isPlaying = false; isSimulating = false; inbetweenMatches = true; tournamentFinished = false; resultsProcessed = false; playerWon = false; currentRoundNum = 0; currentMatchNum = 0; currentMatchup = null; currentTournamentInfo = null; //tournamentUI.TournamentEndScreen(); }
void Awake() { this.tournamentInfo = GameManager.Instance.currentTournamentInfo; CUIHandle.AddClick(btnRegister, OnRegister); CUIHandle.AddClick(btnBack, OnClickBack); GameManager.Server.EventPluginMessageOnProcess += OnProcessPluginMessage; GameManager.Server.EventJoinRoom += OnAfterJoinRoom; if (GameManager.CurrentScene == ESceneName.Tournament) { HeaderMenu.Instance.OnClickButtonBackCallBack = delegate() { WaitingView.Show("Đang thoát"); GameManager.Instance.currentTournamentInfo = null; GameManager.Server.DoJoinRoom(GameManager.Instance.currentRoomGiaiDau.zoneId, GameManager.Instance.currentRoomGiaiDau.roomId); }; } GameManager.Instance.displayTournamentMenu = true; HeaderMenu.Instance.ReDraw(); }
private void OnProcessPluginMessage(string command, string action, EsObject paremeters) { if (command == Fields.RESPONSE.COMMAND_TOURNAMENT) { EsObject[] esObject = paremeters.getEsObjectArray("tournaments"); for (int i = 0; i < esObject.Length; i++) { TournamentInfo info = new TournamentInfo(esObject[i]); GameObject obj = NGUITools.AddChild(gridTournament.gameObject, tournamentItemPrefab); obj.name = "Tournament" + info.tournamentId; TournamentItem item = obj.GetComponent <TournamentItem>(); item.UpdateInfo(info); tournamentItems.Add(item); } gridTournament.Reposition(); gridTournament.GetComponent <UICenterOnChild>().Recenter(); WaitingView.Instance.Close(); } if (command == "updateTournament") { if (paremeters.variableExists("tournamentId")) { int id = paremeters.getInteger("tournamentId"); TournamentItem item = this.tournamentItems.Find(x => x.info.tournamentId == id); if (item != null) { if (paremeters.variableExists("zoneId")) { item.info.zoneId = paremeters.getInteger("zoneId"); } if (paremeters.variableExists("roomId")) { item.info.roomId = paremeters.getInteger("roomId"); } } } NGUITools.SetActive(btnShow.gameObject, currentShow.info.roomId >= 0); } }
public void UpdateInfo(TournamentInfo _info) { this.info = _info; lblAward.text = info.award; lblTime.text = info.startDate + " - " + info.endDate; lblTitle.text = info.tournamentName; if (string.IsNullOrEmpty(info.userNameWin)) { avatarObject.SetActive(false); lblTime.gameObject.SetActive(true); lblAward.gameObject.SetActive(true); } else { avatarObject.SetActive(true); lblTime.gameObject.SetActive(false); lblAward.gameObject.SetActive(false); DownloadAvatar(); } InitCountDownTime(); }
public async Task <IActionResult> AddPlayerToTournamentAsync(string tournamentId, Participant <Player> addPlayer) { var user = await Session.GetCurrentUser(); if (user == null) { return(Unauthorized()); } var tournament = (await TournamentInfo.GetAllTournamentsAsync()).FirstOrDefault(t => t.Id == tournamentId || t.Slug == tournamentId || t.ToornamentId == tournamentId); Toornament.Participant player = new Toornament.Participant { Identifier = addPlayer.Item.Id, Name = addPlayer.Item.Name }; if (!string.IsNullOrEmpty(tournament?.ToornamentId)) { player = await Toornament.Organizer.AddParticipantAsync(tournament.ToornamentId, player); } var participant = new Participant <Player> { Item = addPlayer.Item, Information = addPlayer.Information, ToornamentId = player.Id }; return(Ok(await TournamentInfo.AddPlayerToTournamentAsync(tournamentId, participant))); }
IEnumerator _LoadScene(ESceneName scene) { if (GameManager.Setting.AllowLockScreen) { //dont allow sleep all sences Screen.sleepTimeout = SleepTimeout.NeverSleep; //if (scene == ESceneName.Gameplay) // Screen.sleepTimeout = SleepTimeout.NeverSleep; //else if (Screen.sleepTimeout != SleepTimeout.SystemSetting) // Screen.sleepTimeout = SleepTimeout.SystemSetting; } _oldScene = _currentScene; _currentScene = scene; Debug.LogWarning("Loading Scene: " + scene.ToString()); //AsyncOperation async = Application.LoadLevelAsync(scene.ToString()); Application.LoadLevel(scene.ToString()); yield return(new WaitForFixedUpdate()); if (scene == ESceneName.LoginScreen) { GameObject.Destroy(HeaderMenu.Instance.gameObject); } if (scene == ESceneName.GameplayChan || scene == ESceneName.LoginScreen) { GPChatView.listMessage.Clear(); BroadcastView.Destroy(); } HeaderMenu.Instance.isClickedBtnBack = false; System.GC.Collect(); PlaySameDevice.ClearCache(); TournamentInfo item = GameManager.Instance.currentTournamentInfo; }
internal static void ScheduleGames(TournamentInfo tournamentInfo) { //check arguments that are needed if (tournamentInfo == null) throw new ArgumentNullException("tournamentInfo"); if (tournamentInfo.TournamentId == Guid.Empty) throw new ArgumentNullException("TorunamentId"); if (tournamentInfo.OrganisationId == Guid.Empty) throw new ArgumentNullException("OrganisationId"); if (tournamentInfo.StartDate == new DateTime()) throw new ArgumentException("Incorrect tournament start date"); //set up helpers. //need current culture. CultureManager cultManager = new CultureManager(tournamentInfo.OrganisationId); PlayerManager playerManager = new PlayerManager(); playerManager.AlgoType = tournamentInfo.PairAlgo; playerManager.MatchType = tournamentInfo.MatchType; DateTime startDate = tournamentInfo.StartDate; IEnumerable<PlayersEntity> playerPairs = playerManager.BuildPairs( tournamentInfo.TournamentId); int i = 0; int numberOfGamesPerDay = 3; DateTime dts = startDate; List<Matchup> scheds = new List<Matchup>(); //schedule 3 games per day within 15 min intervals IEnumerator<DateTime> dayEnumerator = cultManager.GetNextBusinessDay(startDate).GetEnumerator(); foreach (PlayersEntity matches in playerPairs) { if ((i % numberOfGamesPerDay) == 0) { dayEnumerator.MoveNext(); dts = dayEnumerator.Current; dts = new DateTime(dts.Year, dts.Month, dts.Day, tournamentInfo.TimeWindowStart, 0, 0); } DateTime dte = dts.AddMinutes(15); //insert here scheds.Add(new Matchup() { TournamentId = tournamentInfo.TournamentId, PlayerAId = matches.PlayerAId, PlayerA = matches.PlayerAName, PlayerBId = matches.PlayerBId, PlayerB = matches.PlayerBName, Start = dts, End = dts.AddMinutes(15) // i need end date, otherwise i cant insert. }); dts = dte; i++; } using (TournaDataContext db = new TournaDataContext()) { //db.TournamentMatchups.DeleteAllOnSubmit(db.TournamentMatchups.Where(x => x.TournamentId == tournamentInfo.TournamentId)); //db.TournamentMatchups.InsertAllOnSubmit(scheds); //db.SubmitChanges(); } }
public CmdJoinTournament(Player player, TournamentInfo tournamentInfo) { this.m_player = player; this.m_tournamentInfo = tournamentInfo; }
public StartUp(DbContextOptions <MMdb> mmdb) { _mmdb = mmdb; _db = new MMdb(_mmdb); foreach (string cmdr in DSdata.s_races) { MMraces.TryAdd(cmdr, new MMplayerNG(cmdr)); } /** * using (var db = new MMdb(_mmdb)) * { * foreach (var ent in db.MMdbPlayers) * db.MMdbPlayers.Remove(ent); * foreach (var ent in db.MMdbRatings) * db.MMdbRatings.Remove(ent); * foreach (var ent in db.MMdbRaceRatings) * db.MMdbRaceRatings.Remove(ent); * * db.SaveChanges(); * } **/ // /** using (var db = new MMdb(_mmdb)) { foreach (var ent in db.MMdbPlayers) { MMplayers[ent.Name] = new MMplayerNG(ent); } foreach (var ent in db.MMdbRaces) { MMraces[ent.Name] = new MMplayerNG(ent); } foreach (var ent in db.MMdbRatings.OrderBy(o => o.Games)) { if (MMplayers.ContainsKey(ent.MMdbPlayer.Name)) { if (MMplayers[ent.MMdbPlayer.Name].AuthName == ent.MMdbPlayer.AuthName) { MMplayers[ent.MMdbPlayer.Name].Rating[ent.Lobby].Add(new MMPlRating(ent)); } } } foreach (var ent in db.MMdbRaceRatings.OrderBy(o => o.Games)) { if (MMraces.ContainsKey(ent.MMdbRace.Name)) { MMraces[ent.MMdbRace.Name].Rating[ent.Lobby].Add(new MMPlRating(ent)); } } } // **/ foreach (string name in MMplayers.Keys) { if (MMplayers[name].AuthName != null && MMplayers[name].AuthName != "") { Players.Add(MMplayers[name].Name); Auth.Add(MMplayers[name].AuthName, MMplayers[name].Name); } } if (!File.Exists(Program.myJson_file)) { File.Create(Program.myJson_file).Dispose(); } foreach (var line in File.ReadAllLines(Program.myJson_file)) { dsreplay rep = null; try { rep = JsonSerializer.Deserialize <dsreplay>(line); } catch { } if (rep != null) { //rep.Init(); repHash.Add(rep.HASH); if (!replays.ContainsKey(rep.ID)) { replays[rep.ID] = new List <dsreplay>(); } replays[rep.ID].Add(rep); } } if (!File.Exists(Program.myReplays_file)) { File.Create(Program.myReplays_file).Dispose(); } foreach (var line in File.ReadAllLines(Program.myReplays_file)) { dsreplay rep = null; try { rep = JsonSerializer.Deserialize <dsreplay>(line); } catch { } if (rep != null) { MyReplays.Add(rep); } } string exedir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Exedir = exedir; foreach (var file in Directory.EnumerateFiles(Program.replaydir)) { string dest = exedir + "/replays/" + Path.GetFileName(file); if (!File.Exists(dest)) { File.Copy(file, dest); } } foreach (var file in Directory.EnumerateFiles(Program.myreplaydir)) { string dest = exedir + "/replays/" + Path.GetFileName(file); if (!File.Exists(dest)) { File.Copy(file, dest); } } foreach (var dir in Directory.EnumerateDirectories(Program.workdir + "/tournaments")) { string tourny = Path.GetFileName(dir); if (File.Exists(dir + "/treplays.json")) { TournamentReplays.Add(tourny, new List <dsreplay>()); foreach (var line in File.ReadAllLines(dir + "/treplays.json")) { dsreplay rep = null; try { rep = JsonSerializer.Deserialize <dsreplay>(line); } catch { } if (rep != null) { TournamentReplays[tourny].Add(rep); } } if (!Directory.Exists(Exedir + "/treplays/" + tourny)) { Directory.CreateDirectory(Exedir + "/treplays/" + tourny); } foreach (var file in Directory.EnumerateFiles(dir + "/replays")) { string dest = Exedir + "/treplays/" + tourny + "/" + Path.GetFileName(file); if (!File.Exists(dest)) { File.Copy(file, dest); } } } if (File.Exists(dir + "/info.json")) { TournamentInfo t = JsonSerializer.Deserialize <TournamentInfo>(File.ReadAllText(dir + "/info.json")); TournamentInfo[tourny] = t; } } foreach (var file in Directory.EnumerateFiles(Program.commentdir)) { GameComment com = JsonSerializer.Deserialize <GameComment>(File.ReadAllText(file)); if (com != null) { GameComments[com.RepId] = com; } } // ladder init //LadderInit(); }
public TournamentSection GetTournaments() { TournamentSection result = new TournamentSection(); var opened = GetOpenedTournaments(); if (opened != null && opened.Any()) { result.All.AddRange(opened.Where(s => s.status.ToLower() != "ended")); } var known = GetKnownTournaments(); var allKnown = new List <TournamentInfo>(); if (known != null && known.Any()) { // result.All.AddRange(known.Where(s => s.status.ToLower() != "ended")); allKnown = known.Where(s => (s.maxPlayers > s.currentPlayers && s.status.ToLower() != "ended")).ToList(); } // var allOpened = opened.Where(s => (s.maxCapacity>s.playerCount && s.status.ToLower() != "ended")); result.All.Sort(); var allSearchJoinable = result.All.Where(s => s.maxPlayers > s.currentPlayers).ToList(); allSearchJoinable.Sort(); List <TournamentInfo> realCheckedJoinable = new List <TournamentInfo>(); foreach (var tournamentInfo in allSearchJoinable) { GetTournamentInfo(tournamentInfo.tag); if (tournamentInfo.currentPlayers < tournamentInfo.maxPlayers) { realCheckedJoinable.Add(tournamentInfo); break; } } // var promotionTournaments = allSearchJoinable.Skip(0).Take(6).ToList(); var promotionTournaments = allSearchJoinable.Skip(0).Take(6).ToList(); promotionTournaments.Sort(); TournamentInfo.SetRealStartDate(promotionTournaments); int count = 1; result.TournamentPromotion = new List <TournamentPromotion>(); var promotion = new TournamentPromotion(); foreach (var promotionTournament in allSearchJoinable) { if (count == 1) { promotion.Title = "Open"; result.TournamentPromotion.Add(promotion); promotion.TournamentLeft = promotionTournament; } if (count == 2) { promotion.TournamentMiddle = promotionTournament; } if (count == 3) { promotion.TournamentRight = promotionTournament; } if (count == 4) { promotion = new TournamentPromotion { Title = "Highest Players Capacity" }; result.TournamentPromotion.Add(promotion); promotion.TournamentLeft = promotionTournament; } if (count == 5) { promotion.TournamentMiddle = promotionTournament; } if (count == 6) { promotion.TournamentRight = promotionTournament; } count++; } result.All.AddRange(allKnown); return(result); }
public static string GetTournamentInfo(string token, dynamic data, bool isActive) { long userID = GetIDfromToken(token); if (userID == -1) { return("-1"); } using var conSelect = new NpgsqlConnection(ConnectionString); conSelect.Open(); string sqlSelect = $"SELECT DISTINCT tournamentID FROM SEB_History WHERE userid = {userID}"; using var cmdSelect = new NpgsqlCommand(sqlSelect, conSelect); using var reader = cmdSelect.ExecuteReader(); var TournamentInfoList = new List <TournamentInfo>(); while (reader.Read()) { int tempTournamentID = reader.GetInt32(reader.GetOrdinal("tournamentID")); using var conSelect2 = new NpgsqlConnection(ConnectionString); conSelect2.Open(); string sqlSelect2 = $"SELECT username, SUM(count) as count, SUM(duration) as duration FROM SEB_History INNER JOIN SEB_Users ON SEB_History.userID = SEB_Users.userID WHERE tournamentID = {tempTournamentID} GROUP BY username"; using var cmdSelect2 = new NpgsqlCommand(sqlSelect2, conSelect2); using var reader2 = cmdSelect2.ExecuteReader(); var TournamentEntryList = new List <TournamentEntry>(); while (reader2.Read()) { string tempUsername = reader2.GetString(reader2.GetOrdinal("username")); int tempCount = reader2.GetInt32(reader2.GetOrdinal("count")); int tempDuration = reader2.GetInt32(reader2.GetOrdinal("duration")); var tempObject = new TournamentEntry(tempUsername, tempCount, tempDuration); TournamentEntryList.Add(tempObject); } var tempObject2 = new TournamentInfo(TournamentEntryList, false, tempTournamentID); TournamentInfoList.Add(tempObject2); conSelect2.Close(); } conSelect.Close(); if (isActive) { TournamentInfoList.LastOrDefault().isActive = true; } return(JsonConvert.SerializeObject(TournamentInfoList)); }
public Tournament(string user, TournamentInfo info) : base(user) { try { Message = GetMessageName(); TournamentData = new NotifierTournament(info); } catch (Exception ex) { Log.Exception("API", ex); } }
private static TournamentInfo GetTournamentStartDate(Guid tournamentId) { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["StrongerOrgString"].ConnectionString)) { SqlCommand command = new SqlCommand("TournamentInfo", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@TournamentId", SqlDbType.UniqueIdentifier).Value = tournamentId; conn.Open(); SqlDataReader reader = command.ExecuteReader(); TournamentInfo tournamentInfo = new TournamentInfo(); while (reader.Read()) { tournamentInfo.TimeWindowStart = reader.GetInt32(8); tournamentInfo.TimeWindowEnd = reader.GetInt32(9); tournamentInfo.StartDate = reader.GetDateTime(14); } return tournamentInfo; } }
//internal static void ScheduleGames(Guid orgId, Guid tournaId) //{ // //Get tourna startDate // DateTime startDate = new DateTime(); // using (TournaDataContext db = new TournaDataContext()) // { // startDate = db.Tournaments.Where(x => x.Id == tournaId) // .Select(y => y.StartDate) // .FirstOrDefault() ?? new DateTime(); // } // ScheduleGames(orgId, tournaId, startDate); //} internal static void ScheduleGames(Guid orgId, Guid tournaId, DateTime startDate, PairsMatchType matchType, PairsAlgorithmType pairAlgo) { TournamentInfo info = new TournamentInfo() { TournamentId = tournaId, OrganisationId = orgId, StartDate = startDate, MatchType = matchType, PairAlgo = pairAlgo }; ScheduleGames(info); }
public void TestInitialize() { this.tournament = new TournamentInfo(TournamentId, "TournamentTest"); this.game = new Game(GameId, "GameTest", this.tournament); this.player = new Player(PlayerId, "John", 30); }
public NotifierTournament(TournamentInfo info) { ID = info.TournamentID; Style = info.Style; Format = info.Format; NextEventTime = info.NextRoundTime.ToString(); if (info.Players != null) foreach (TournamentPlayerInfo player in info.Players) Players.Add(new NotifierTournamentPlayer(player)); if (info.Games != null) foreach (TournamentGameInfo game in info.Games) Games.Add(new NotifierTournamentGame(game, info.Players)); }