using System;
using System.Collections.Generic;
using System.Text;

namespace OnlineUserPool.Model
{
    public class MapRecordRanking
    {
        public int UserId { get; set; }

        public string RecordFileName { get; set; }

        public int RouteId { get; set; }

        public int Ticks { get; set; }

        public Guid Id { get; set; }

        public string[] record { get; set; }

        public string WxHeadImg { get; set; }

        public string NickName { get; set; }

        /// <summary>
        /// 总点位数据
        /// </summary>
        public int Count
        {
            get
            {
                return this.record.Length;
            }
        }

        private int _BeginIndex;

        /// <summary>
        /// 当前位置
        /// </summary>
        public int CurrentIndex
        {
            get
            {
                if (_BeginIndex != 0)
                {
                    _BeginIndex++;
                    if (End)
                    {
                        return this.Count - 1;
                    }
                    return this._BeginIndex;
                }
                else
                {
                    _BeginIndex = 1;
                    return _BeginIndex;
                    Random random = new Random();
                    _BeginIndex = random.Next(0, this.Count);
                    return _BeginIndex;
                }
            }
        }

        /// <summary>
        /// 是否已到头
        /// </summary>
        public bool End
        {
            get
            {
                return this._BeginIndex >= this.Count;
            }
        }

        /// <summary>
        /// 获取当前点位的数据
        /// </summary>
        /// <returns></returns>
        public TargetData GetCurrentTargetData()
        {
            return TargetData.Read(this.record[CurrentIndex]);
        }
    }
}
