示例#1
0
        public async Task <ActionResult> Stats(ulong id = 0)
        {
            if (id == 0)
            {
                return(BadRequest("Invalid data, please pass steamid64"));
            }

            Dictionary <string, object> data = new Dictionary <string, object>();
            var result = await _steamService.GetUserStats(381210, id);

            if (result == null || result.Equals(default(Dictionary <string, object>)))
            {
                return(UnprocessableEntity("Unable to get player stats, maybe their profile isn't public"));
            }

            data["killerRank"] = result.ContainsKey("DBD_KillerSkulls") ?
                                 PipsToRank((uint)result["DBD_KillerSkulls"]) : 20;

            data["survivorRank"] = result.ContainsKey("DBD_CamperSkulls") ?
                                   PipsToRank((uint)result["DBD_CamperSkulls"]) : 20;

            foreach (var stat in _statsProxy)
            {
                if (result.ContainsKey(stat.Value))
                {
                    data[stat.Key] = result[stat.Value];
                }
                else
                {
                    data[stat.Key] = 0;
                }
            }

            return(Json(data));
        }