Beispiel #1
0
        public List <PlayerReport> GetBestPlayers(string count)
        {
            int quantity = 0;

            try
            {
                quantity = CheckCount(count);
            }
            catch (Exception exc)
            {
                if (exc.Message == "Count is less or equal zero")
                {
                    return(new List <PlayerReport>());
                }
                else
                {
                    Program.log.Error(exc, "An error occured for HTTP GET GetBestPlayers");
                    throw exc;
                }
            }
            try
            {
                using (var database = new LiteDatabase(Program.databasePath))
                {
                    var matchesCollection = database.GetCollection <Match>("matches");
                    matchesCollection.EnsureIndex(x => x.Scoreboard.Select(y => y.Name));
                    return(PlayerReport.GetBestPlayers(matchesCollection, quantity));
                }
            }
            catch (Exception exc)
            {
                Program.log.Error(exc, "An error occured for HTTP GET GetBestPlayers");
                throw exc;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Get all players and their asscociated tags
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public object Get(PlayerReport request)
        {
            //todo: better query that will scale
            var players    = Db.Select <Player>().ToList();
            var playertags = Db.Select <PlayerTag>().ToList();
            var tags       = Db.Select <Tag>().ToDictionary(x => x.Id, y => y);

            var reports = players.Select(x => new PlayerReport()
            {
                Player = x,
                Tags   = new List <PlayerTagReport>()
            }).ToList();

            foreach (var r in reports)
            {
                var pts = playertags.Where(x => x.PlayerId == r.Player.Id).Select(y => new PlayerTagReport()
                {
                    PlayerTag = y,
                    Tag       = tags[y.TagId]
                }).ToList();

                r.Tags.AddRange(pts);
            }

            return(reports);
        }
Beispiel #3
0
        static public void Main()
        {
            GameState level1 = new GameState();

            level1.AddPlayer(new Player("zeroeth"));
            level1.AddPlayer(new Player("haiiro"));
            level1.AddPlayer(new Player("takeshi"));

            PlayerReport.about(level1);
        }
Beispiel #4
0
        public Player(PlayerInput input, IManager manager, byte clientId, Coordinate curPoint, Coordinate halfDefault)
        {
            this._input      = input;
            this._clientId   = clientId;
            this._manager    = manager;
            this._match      = manager.Match;
            this._propCore   = new PropertyCore(this);
            this._status     = new PlayerStatus(this, curPoint, halfDefault);
            this._report     = new PlayerReport(input, clientId);
            _report.ClientId = clientId;
            _report.Position = input.Position;
            _report.Name     = input.FamilyName;

            #region ISkill
            this.boostCore   = new BoostCore(this._match);
            this.buffCore    = new BuffCore(this._match);
            this.specBuffCoe = new SpecBuffCore();
            #endregion

            #region Buff
            int last    = _match.RoundPerMinute * 90;
            int point   = 0;
            int percent = 0;
            if (null != input.PropList)
            {
                foreach (var item in input.PropList)
                {
                    if (null == item.BuffId)
                    {
                        continue;
                    }
                    point   = (int)(item.Point * 100);
                    percent = (int)(item.Percent * 10000);
                    this.AddBuff(_manager.CreatePropBuff(last, point, percent, item.BuffId));
                }
            }
            if (null != input.BoostList)
            {
                foreach (var item in input.BoostList)
                {
                    if (null == item.BuffId)
                    {
                        continue;
                    }
                    point   = (int)(item.Point * 100);
                    percent = (int)(item.Percent * 10000);
                    this.AddBoost(_manager.CreateBoostBuff(item.BoostType, last, point, percent, item.BuffId));
                }
            }
            #endregion
        }
Beispiel #5
0
        internal Task <PlayerReport> GetPlayerStats()
        {
            var ps = from games in Store.Games
                     select new PlayerStat {
                GameId = games.Id, GameName = games.Name, PlayerCount = games.Players.Count
            };

            PlayerReport playerReport = new PlayerReport
            {
                Timestamp = DateTime.UtcNow,
                Stats     = ps.ToArray()
            };

            return(Task.FromResult(playerReport));
        }