public void ParseLeague(HtmlDocument document, ref LeagueData leagueData) { //get table containing team names and team urls HtmlNode leagueTable = document.GetElementbyId(LeagueTableId); //get all the rows that contain the team links List <HtmlNode> rows = leagueTable.Descendants().Where( row => row.Attributes.Count > 0 && row.Name == "div" && row.Attributes["class"] != null && row.Attributes["class"].Value.Contains(TeamLinkClass) ).ToList <HtmlNode>(); //loop through rows and get anchors with url and team name foreach (HtmlNode row in rows) { HtmlNode anchor = row.Descendants().Where(a => a.Name == "a").FirstOrDefault <HtmlNode>(); Team team = new Team(); team.Id = leagueData.Teams.Count + 1; team.Name = anchor.InnerHtml.Replace("'", "'"); team.Url = "http://www.fleaflicker.com" + anchor.Attributes["href"].Value; leagueData.Teams.Add(team); } }
public override void Start() { Game game; int totalMatches = Players.Length - 1; Player lastWinner = null; for (int i = 0; i < totalMatches; i++) { game = new Game(Matches[i], Rules); game.Start(RoundsPerGame); game.SaveData(); History.Add(game.Data); if (lastWinner == null) { lastWinner = GetWinnerFromGame(History.Count - 1); if (_lonelyPlayerIndex != -1) { Matches.Add(new Match(lastWinner, FindPlayer(_lonelyPlayerIndex))); _lonelyPlayerIndex = -1; lastWinner = null; } } else { Matches.Add(new Match(lastWinner, GetWinnerFromGame(History.Count - 1))); lastWinner = null; } } Data = new LeagueData(Matches, History, Players); }
private void SetMockLeagues() { MockLeagues = new Mock <DbSet <League> >().SetupData(LeagueData.Data()); MockLeagues.Setup(x => x.Find(It.IsAny <object[]>())).Returns <object[]>(ids => LeagueData.Data().FirstOrDefault(d => d.LeagueId == (int)ids[0])); MockLeagues.Setup(x => x.FindAsync(It.IsAny <object[]>())).Returns <object[]>(ids => Task.FromResult(LeagueData.Data().FirstOrDefault(d => d.LeagueId == (int)ids[0]))); MockContext.Setup(x => x.Leagues).Returns(MockLeagues.Object); }
public void ParseLeague(HtmlDocument document, ref LeagueData leagueData) { //get table containing team names and team urls List <HtmlNode> leagueTables = document.DocumentNode.Descendants().Where(t => t.Name == "table" && t.Attributes["class"] != null && t.Attributes["class"].Value.Contains(LeagueTableClass)).ToList <HtmlNode>(); List <HtmlNode> rows = new List <HtmlNode>(); //get all the rows that contain the team links foreach (HtmlNode leagueTable in leagueTables) { rows.AddRange( leagueTable.Descendants().Where( row => row.Attributes.Count > 0 && row.Name == "tr" && row.Attributes["id"] != null ).ToList <HtmlNode>() ); } //loop through rows and get anchors with url and team name foreach (HtmlNode row in rows) { HtmlNode anchor = row.Descendants().Where(a => a.Name == "a").FirstOrDefault <HtmlNode>(); Team team = new Team(); team.Id = leagueData.Teams.Count + 1; team.Name = anchor.InnerHtml.Replace("'", "'"); team.Url = "http://fantasy.nfl.com" + anchor.Attributes["href"].Value.Replace("&", "&"); leagueData.Teams.Add(team); } }
internal static void UpdateLeagueRank(Player Player) { CSV.Tables.Get(Gamefile.League).Datas.ForEach(Data => { LeagueData LeagueData = (LeagueData)Data; }); }
static DB() { ActiveEvents = new ActiveEvents(); ActiveGiveaways = new ActiveGiveaways(); BackgroundInventory = new BackgroundInventory(); Cooldowns = new Cooldowns(); Events = new Database.Events(); EventLogs = new EventLogs(); EventSchedule = new EventSchedule(); GiveawayLogs = new GiveawayLogs(); Giveaways = new Giveaways(); Inventory = new Inventory(); LeagueData = new LeagueData(); Mappings = new Mappings(); ModerationLogs = new ModerationLogs(); PendingUsers = new PendingUsers(); ProfileBackgrounds = new ProfileBackgrounds(); Rewards = new Rewards(); RoleInventory = new RoleInventory(); Roles = new Roles(); Settings = new Settings(); Statistics = new Statistics(); Streamers = new Streamers(); SystemTimers = new SystemTimers(); TempRoles = new TempRoles(); Toxicity = new Toxicity(); Users = new Users(); }
public override void Deserialize(JHSNetworkReader reader) { PayLoadType = (RankingPacketType)reader.ReadByte(); if (PayLoadType == RankingPacketType.UPDATE_DATA) { int dataLenght = reader.ReadByte(); rankingData = new LeagueData[dataLenght]; for (int i = 0; i < dataLenght; i++) { rankingData[i] = new LeagueData() { PlayerName = reader.ReadString(), LeaguePoints = (int)reader.ReadPackedUInt32(), Kills = (int)reader.ReadPackedUInt32(), Deaths = (int)reader.ReadPackedUInt32() }; } LeaguePosition = reader.ReadByte(); GameCount = reader.ReadByte(); LeaguePoints = reader.ReadPackedUInt32(); CurrentLeague = (LeagueType)reader.ReadByte(); } if (PayLoadType == RankingPacketType.GAME_COUNT) { GameCount = reader.ReadByte(); } }
public Roster OptimalLineUp(LeagueData leagueData, HashSet <Player> lostPlayers) { List <Player> team = new List <Player>(Team.Players); IEnumerable <Player> lost = new List <Player>(lostPlayers); OptimalRosterMaker rosterMaker = new OptimalRosterMaker(); return(rosterMaker.GetRoster(leagueData, team, lost)); }
public Roster GetRoster(LeagueData leagueData, List <Player> team, IEnumerable <Player> lostPlayers) { Roster roster = FindOptimalRoster(leagueData, team); roster = MarkLostPlayers(roster, lostPlayers); return(roster); }
private void OnPlayerChanged(LeagueData Player) { if (Player != null && KnownPlayers.TryGetValue(Player.UserId, out RankinngOBJ obj)) { obj.Index = Player.Index; obj.League = Player.League; DbService.SubmitUpdate2Queue(obj); } }
public IActionResult PlayerSearch(string userName) { try { return(Ok(LeagueData.GetSummonerInfo(userName))); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
private void UpdateThreadTask() { AddStatusString("Loading game data..."); mLeagueData = new LeagueData(mUniverseData.SavedGames[mSavedGameIndex].PathPrefix, mUniverseData, mStartingSeason, OnFileRead, true); CreateDataTables(); AddStatusString("Finished!"); WorkCompleted(); }
public void ShowInfo(LeagueData league) { Console.WriteLine("--------------------Matches----------------------"); ShowMatches(league.Matches); Console.WriteLine(); ShowGameHistory(league.History); Console.WriteLine(); Console.WriteLine("---------------------League finished----------------------"); ShowPlayers(league.Players); Console.WriteLine(); }
public void AddFixture(LeagueData fixture) { if ( !_context.LeagueData.Any(x => x.DateTime == fixture.DateTime && x.HomeTeam == fixture.HomeTeam && x.AwayTeam == fixture.AwayTeam)) { _context.LeagueData.Add(fixture); } }
static int RunGames() { var gameRunner = new GameRunnerWithData(); var data = gameRunner.RunGame(new WaveBot(), new DynamiteBot()); var leagueData = new LeagueData("", ""); leagueData = LeagueRunner.RunLeague(new WaveBot(), new OrigWaveBot()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new WaveBotV4(), new WaveBot()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new WaveBotV5(), new WaveBot()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new WaveBot(), new WaveBotV4()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new WaveBot(), new DrawBot()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new WaveBot(), new WaveBotV3()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new WaveBot(), new WeWillRockYou()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new WaveBotV3(), new WaveBot()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new OrigWaveBot(), new WaveBot()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new OrigWaveBot(), new WaveBotV2()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new WeWillRockYou(), new WaveBot()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new ScaleBot(), new WaveBot()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new DrawBot(), new WaveBot()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new OrigWaveBot(), new ScaleBot()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new WaveBot(), new ScaleBot()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new OrigWaveBot(), new WaveBot()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new WaveBot(), new WaveBotV2()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new WaveBot(), new WaveBotV2()); Console.WriteLine(leagueData.ToString()); leagueData = LeagueRunner.RunLeague(new DrawBot(), new WaveBotV2()); Console.WriteLine(leagueData.ToString()); Console.Read(); return(1); }
private static async Task RunBattle(IBot bot1, IBot bot2) { await Task.Run(() => { Console.WriteLine("New Game"); var leagueData = new LeagueData("", ""); leagueData = LeagueRunner.RunLeague(bot1, bot2); Console.WriteLine(leagueData.ToString()); var a = 1; } ); }
public override void Start() { Game game; for (int i = 0; i < Matches.Count; i++) { game = new Game(Matches[i], Rules); game.Start(RoundsPerGame); game.SaveData(); History.Add(game.Data); } Data = new LeagueData(Matches, History, Players); }
public void _UpdatePlayer(uint PlayerId, int LeaguePoints) { if (KnownPlayers.TryGetValue(PlayerId, out RankinngOBJ player)) { player.LeaguePoints = LeaguePoints; if (leagueManager._UpdatePlayer(player.RefLeagueData)) { LeagueData updatedPlayer = leagueManager._GetPlayer(player.UserId); if (updatedPlayer != null) { player.League = updatedPlayer.League; } } DbService.SubmitUpdate2Queue(player); } }
private void FindTrades(ref List <Trade> allTrades, LeagueData leagueData, TeamPlayerPool myTeamPlayerPool, TeamPlayerPool theirTeamPlayerPool, HashSet <PlayerList> myTradePool, HashSet <PlayerList> theirTradePool) { IEnumerable <Trade> trades = from mySideOfTrade in myTradePool from theirSideOfTrade in theirTradePool select(new Trade(myTeamPlayerPool.Team.Name, theirTeamPlayerPool.Team.Name, mySideOfTrade, theirSideOfTrade)); HashSet <Trade> uniqueTrades = new HashSet <Trade>(); foreach (Trade trade in trades) { if (Math.Abs(trade.Fairness) <= 5) { uniqueTrades.Add(trade); } } //get required players and excluded players List <Player> myRequiredPlayers = myTeamPlayerPool.TradablePlayers.Where(p => p.Required).ToList <Player>(); List <Player> myExcludedPlayers = myTeamPlayerPool.TradablePlayers.Where(p => p.Excluded).ToList <Player>(); List <Player> theirRequiredPlayers = theirTeamPlayerPool.TradablePlayers.Where(p => p.Required).ToList <Player>(); List <Player> theirExcludedPlayers = theirTeamPlayerPool.TradablePlayers.Where(p => p.Excluded).ToList <Player>(); foreach (Trade trade in uniqueTrades) { //if (Math.Abs(trade.Fairness) <= 5) //{ if (trade.CalculateDifferentials(leagueData, myTeamPlayerPool, theirTeamPlayerPool) && trade.MyDifferential > 0 && trade.TheirDifferential > 0) { bool isValidTrade = HasRequiredPlayers(trade.MyPlayers, myRequiredPlayers) && HasRequiredPlayers(trade.TheirPlayers, theirRequiredPlayers) && HasExcludedPlayers(trade.MyPlayers, myExcludedPlayers) && HasExcludedPlayers(trade.TheirPlayers, theirExcludedPlayers); if (isValidTrade) { allTrades.Add(trade); } } //} } }
//Constructor. public League(bool isRandom = true, string leagueName = "", string shortName = "", int year = 1990, int month = 1, int day = 1, int teamAmount = 10, bool makeGameSchedule = true) { teams = new SerializableList <KeyValuePair <int, Team> >(); stats = new LeagueStatistics(); if (isRandom) { data = new LeagueData("Western League", "WSL", UnityEngine.Random.Range(1969, 1990), 5, 30); for (int i = 0; i < teamAmount; ++i) { teams.d.Add(new KeyValuePair <int, Team>(i, RandomTeamGenerator.CreateTeam())); } } else { data = new LeagueData(leagueName, shortName, year, month, day); } }
public void CanSaveSeasonGraph() { using var dbInstance = new LeagueDbInstance(nameof(CanSaveSeasonGraph)); var data = new LeagueData(dbInstance.NewContext()); var season = new Season() { Name = nameof(CanSaveSeasonGraph) }; var golferA = new Golfer { Id = 1, LeagueHandicap = 8 }; var golferB = new Golfer { Id = 3, LeagueHandicap = 2 }; var golferC = new Golfer { Id = 5, LeagueHandicap = 2 }; var golferD = new Golfer { Id = 7, LeagueHandicap = 2 }; var week1 = new MatchSet(DateTime.Now); season.AddWeek(week1); week1.AddResult(golferA, 44, 7, true, golferB, 36, 4, false); week1.AddResult(golferC, 44, 7, true, golferD, 36, 4, false); var week2 = new MatchSet(DateTime.Now); season.AddWeek(week2); week2.AddResult(golferA, 44, 7, true, golferD, 36, 4, false); week2.AddResult(golferB, 44, 7, true, golferC, 36, 4, false); data.Add(season, golferA, golferB, golferC, golferD); data.Commit(); var checkData = new LeagueData(dbInstance.NewContext()); var query = new SeasonDetailQuery(season.Id); var checkSeason = checkData.Execute(query); Assert.Equal(2, checkSeason.Weeks.Count); Assert.Equal(2, checkSeason.Weeks.First().Matches.Count); }
public MainWindow() { InitializeComponent(); // Init Checker Checker.AccountsChecked = new List <AccountData>(); Checker.AccountsToCheck = new List <LoginData>(); Checker.OnNewAccount += OnNewAccount; // Init Regions _regionsComboBox.ItemsSource = Enum.GetValues(typeof(Region)).Cast <Region>(); _regionsComboBox.SelectedIndex = 0; // Init Champion Data if (File.Exists("Champions.json")) { LeagueData.UpdateData("Champions.json"); } }
public void _UpdatePlayer(uint PlayerId, int TotalLeaguePoints, int TotalGamePlays, int TotalKills, int TotalDeaths) { if (KnownPlayers.TryGetValue(PlayerId, out RankinngOBJ player)) { player.LeaguePoints = TotalLeaguePoints; player.Kills = TotalKills; player.Deaths = TotalDeaths; player.GameCount = TotalGamePlays; if (leagueManager._UpdatePlayer(player.RefLeagueData)) { LeagueData updatedPlayer = leagueManager._GetPlayer(player.UserId); if (updatedPlayer != null) { player.League = updatedPlayer.League; } } DbService.SubmitUpdate2Queue(player); } }
public void CanSaveAndRetrieveSeason() { using var dbInstance = new LeagueDbInstance(nameof(CanSaveAndRetrieveSeason)); var seasonName = nameof(CanSaveAndRetrieveSeason); var data = new LeagueData(dbInstance.NewContext()); var season = new Season() { Name = seasonName }; data.Add(season); data.Commit(); var secondData = new LeagueData(dbInstance.NewContext()); var query = new SeasonDetailQuery(season.Id); var secondSeason = secondData.Execute(query); Assert.Equal(season.Id, secondSeason.Id); Assert.Equal(season.Name, secondSeason.Name); }
public List <Trade> Post(LeagueData leagueData) { //create table list to store each trade List <Trade> trades = new List <Trade>(); //create my team player pool TeamPlayerPool myTeamPlayerPool = new TeamPlayerPool(leagueData.MyTeam); //create other team list List <Team> theirTeams = new List <Team>(); if (!leagueData.UseAllTeams) { theirTeams.Add(leagueData.TheirTeam); } else { theirTeams = leagueData.Teams; theirTeams.Remove(leagueData.Teams.Where(t => t.Id == leagueData.MyTeam.Id).FirstOrDefault <Team>()); } //for each other team, find trades foreach (Team theirTeam in theirTeams) { //load team player pool for this team TeamPlayerPool otherTeamPlayerPool = new TeamPlayerPool(theirTeam); //find trades with this team FindTrades(ref trades, leagueData, myTeamPlayerPool, otherTeamPlayerPool, myTeamPlayerPool.OnePlayerTradePool, otherTeamPlayerPool.OnePlayerTradePool); //1 for 1 FindTrades(ref trades, leagueData, myTeamPlayerPool, otherTeamPlayerPool, myTeamPlayerPool.OnePlayerTradePool, otherTeamPlayerPool.TwoPlayerTradePool); //1 for 2 FindTrades(ref trades, leagueData, myTeamPlayerPool, otherTeamPlayerPool, myTeamPlayerPool.OnePlayerTradePool, otherTeamPlayerPool.ThreePlayerTradePool); //1 for 3 FindTrades(ref trades, leagueData, myTeamPlayerPool, otherTeamPlayerPool, myTeamPlayerPool.TwoPlayerTradePool, otherTeamPlayerPool.OnePlayerTradePool); //2 for 1 FindTrades(ref trades, leagueData, myTeamPlayerPool, otherTeamPlayerPool, myTeamPlayerPool.TwoPlayerTradePool, otherTeamPlayerPool.TwoPlayerTradePool); //2 for 2 FindTrades(ref trades, leagueData, myTeamPlayerPool, otherTeamPlayerPool, myTeamPlayerPool.TwoPlayerTradePool, otherTeamPlayerPool.ThreePlayerTradePool); //2 for 3 FindTrades(ref trades, leagueData, myTeamPlayerPool, otherTeamPlayerPool, myTeamPlayerPool.ThreePlayerTradePool, otherTeamPlayerPool.OnePlayerTradePool); //3 for 1 FindTrades(ref trades, leagueData, myTeamPlayerPool, otherTeamPlayerPool, myTeamPlayerPool.ThreePlayerTradePool, otherTeamPlayerPool.TwoPlayerTradePool); //3 for 2 FindTrades(ref trades, leagueData, myTeamPlayerPool, otherTeamPlayerPool, myTeamPlayerPool.ThreePlayerTradePool, otherTeamPlayerPool.ThreePlayerTradePool); //3 for 3 } return(trades.OrderByDescending(t => ((t.MyDifferential + leagueData.Fairness) * (t.TheirDifferential - leagueData.Fairness))).Distinct().ToList()); }
static ConfigLeagues() { LeagueData[] dataArray1 = new LeagueData[7]; LeagueData data = new LeagueData(); data.Id = "League001"; data.RewardChestType = ChestType.Basic001; dataArray1[0] = data; data = new LeagueData(); data.Id = "League002"; data.CrownRequirement = 100.0; data.RewardChestType = ChestType.Special001; dataArray1[1] = data; data = new LeagueData(); data.Id = "League003"; data.CrownRequirement = 3000.0; data.RewardChestType = ChestType.Special002; dataArray1[2] = data; data = new LeagueData(); data.Id = "League004"; data.CrownRequirement = 120000.0; data.RewardChestType = ChestType.Special003; dataArray1[3] = data; data = new LeagueData(); data.Id = "League005"; data.CrownRequirement = 30000000.0; data.RewardChestType = ChestType.Special004; dataArray1[4] = data; data = new LeagueData(); data.Id = "League006"; data.CrownRequirement = 7500000000; data.RewardChestType = ChestType.Special005; dataArray1[5] = data; data = new LeagueData(); data.Id = "League007"; data.CrownRequirement = 1500000000000; data.RewardChestType = ChestType.Special006; dataArray1[6] = data; Leagues = dataArray1; }
internal void AddScore(int Trophies) { this.Score += Trophies; LeagueData LeagueData = (LeagueData)CSV.Tables.Get(Gamefile.Leagues).GetDataWithInstanceID(this.League); if (LeagueData?.PlacementLimitHigh > this.Score) { for (int i = LeagueData.GetId(); i < CSV.Tables.Get(Gamefile.Leagues).Datas.Count; i++) { LeagueData Data = (LeagueData)CSV.Tables.Get(Gamefile.Leagues).Datas[i]; if (this.Score >= Data.PlacementLimitLow) { this.League = i; } else { break; } } } }
public Roster GetRoster(LeagueData leagueData, List <Player> team, IEnumerable <Player> gainedPlayers, IEnumerable <Player> lostPlayers) { if (lostPlayers != null) { foreach (Player lostPlayer in lostPlayers) { team.Remove(lostPlayer); } } if (gainedPlayers != null) { foreach (Player gainedPlayer in gainedPlayers) { team.Add(gainedPlayer); } } Roster roster = FindOptimalRoster(leagueData, team); roster = MarkGainedPlayers(roster, gainedPlayers); return(roster); }
private async void WindowLoaded(object sender, RoutedEventArgs e) { await LeagueData.Load(); }
public ActionResult CreateLeague(String leagueName) { LeagueData.addLeague(leagueName); return(Content("Form Submitted!")); }