示例#1
0
    public async Task Calculate()
    {
        var client    = EPLClientFactory.createClient();
        var standings = await client.getStandings(_leagueId);

        var records = new Dictionary <int, Record>();

        foreach (var standing in standings.standings.results)
        {
            var newRecord = new Record();
            newRecord.teamName      = standing.entry_name;
            newRecord.teamId        = standing.entry;
            records[standing.entry] = newRecord;
        }

        foreach (var standing in standings.standings.results)
        {
            foreach (Standing opp in standings.standings.results)
            {
                if (standing.entry == opp.entry)
                {
                    continue;
                }

                H2hSimulator simulator = new H2hSimulator(client, standing.entry, opp.entry);
                var          rec       = await simulator.simulate();

                foreach (var teamId in rec.Keys)
                {
                    records[teamId].wins   += rec[teamId].wins;
                    records[teamId].draws  += rec[teamId].draws;
                    records[teamId].losses += rec[teamId].losses;
                }
            }
        }

        var recList = new List <Record>(records.Values.ToList());

        recList.Sort();
        int place = 1;

        foreach (var rec in recList)
        {
            Standing standing = null;
            foreach (var s in standings.standings.results)
            {
                if (s.entry == rec.teamId)
                {
                    standing = s;
                    break;
                }
            }

            var achievement = place < standing.rank ? "underachieve" : "overachieve";
            Console.WriteLine(string.Format("{0}. {1}: {2}W-{3}D-{4}L {5} {6}", place, rec.teamName, rec.wins, rec.draws, rec.losses, place - standing.rank, achievement));
            place++;
        }
    }
示例#2
0
 public H2hSimulator(EPLClient client, int team1Id, int team2Id)
 {
     if (client == null)
     {
         client = EPLClientFactory.createClient();
     }
     _client  = client;
     _team1Id = team1Id;
     _team2Id = team2Id;
 }
示例#3
0
 public PlayerProcessorV3(int start, int end)
 {
     initialize(EPLClientFactory.createHttpClient());
     _playerStart = start;
     _playerEnd   = end;
 }
 public CloudConfigUpdater(EPLClient client)
 {
     _client = client != null ? client : EPLClientFactory.createClient();
 }
示例#5
0
 public PlayerProcessorV3()
 {
     initialize(EPLClientFactory.createHttpClient());
 }