示例#1
0
        public List <LocalizedUnit> UnitListForPlayers(IEnumerable <string> codes)
        {
            try
            {
                List <LocalizedUnit> localizedUnits;
                List <UnitWithStat>  PlayerOne;
                List <UnitWithStat>  PlayerTwo;

                var helper = Authenticate();

                localizedUnits = GetLocalizedUnits();

                var codesToRequest = new List <string>(codes);

                var players = Task.Run(() =>
                {
                    GetPlayerOneAndTwoFromHelp(codesToRequest);
                });

                List <List <UnitWithStat> > playerOneandTwo = GetPlayerOneAndTwo(codesToRequest);

                PlayerOne = playerOneandTwo[0];
                PlayerTwo = playerOneandTwo[1];

                var filteredPlayerUnits = PlayerOne.Where(x => PlayerTwo.Any(y => y.DefId == x.DefId));

                var filteredUnits = localizedUnits.Where(x => filteredPlayerUnits.Any(y => y.DefId == x.BaseId));

                return(filteredUnits.ToList());
            }
            catch (Exception ex)
            {
                _logger.LogCritical(LoggingEvents.UnitListForPlayers, ex, "UnitListForPlayers Exception");
                return(new List <LocalizedUnit>());
            }
        }