Example #1
0
        public void DealWithTeamChange(QueueLogic _this,
                                       TeamChangedType type,
                                       QueueCharacter character,
                                       List <ulong> teamList,
                                       ulong characterId)
        {
            switch (type)
            {
            case TeamChangedType.Request:
                break;

            case TeamChangedType.AcceptRequest:
            case TeamChangedType.AcceptJoin:
                var queueCharacter = QueueManager.GetMatchingCharacter(characterId);
                if (queueCharacter != null && queueCharacter.result != null)
                {
                    return;
                }
                QueueManager.PushOneCharacter(characterId, character);
                break;

            case TeamChangedType.Leave:
            case TeamChangedType.Kick:
                if (character.result == null)
                {
                    QueueManager.Pop(characterId, eLeaveMatchingType.TeamChange);
                }
                break;

            case TeamChangedType.Disband:
                break;
            }
        }
Example #2
0
        public int GetAverageTime(QueueLogic _this)
        {
            if (_this.MatchOkey.Count == 0)
            {
                return(-1);
            }
            var totalSeconds = 0;

            foreach (var i in _this.MatchOkey)
            {
                totalSeconds += i.Value;
            }
            var avgTime        = totalSeconds / _this.MatchOkey.Count;
            var maxWaitSeconds = 0;

            if (_this.mCharacters.Count > 0)
            {
                var c   = _this.mCharacters[0];
                var now = DateTime.Now;
                maxWaitSeconds = (int)(now - c.StartTime).TotalSeconds;
            }
            if (avgTime < maxWaitSeconds)
            {
                return(maxWaitSeconds + 60);
            }
            return(avgTime);
        }
Example #3
0
 //关闭定时器
 public void StopTrigger(QueueLogic _this)
 {
     if (_this.mTrigger != null)
     {
         TeamServerControl.tm.DeleteTrigger(_this.mTrigger);
         _this.mTrigger = null;
     }
 }
Example #4
0
 public void StartTrigger(QueueLogic _this)
 {
     if (_this.mTrigger != null)
     {
         Logger.Warn("StartTrigger!");
         return;
     }
     _this.mTrigger = TeamServerControl.tm.CreateTrigger(DateTime.Now.AddSeconds(1), _this.Tick, 1000);
 }
Example #5
0
        public void PushLog(QueueLogic _this)
        {
            var dddd = "";

            foreach (var data in _this.mCharacters)
            {
                dddd = dddd + data.Guid + ",";
            }
            PlayerLog.WriteLog((int)LogType.QueueLog, "Matching Id={0} Count[{1}]={2}, AverageTime={3} ",
                               _this.mQueueId, _this.mCharacters.Count, dddd, GetAverageTime(_this));
        }
Example #6
0
        public void Pop(QueueLogic _this, QueueCharacter character, eLeaveMatchingType type)
        {
            _this.mCharacters.Remove(character);
#if DEBUG
            PlayerLog.WriteLog((int)LogType.QueueMessage, "Pop mCharacters.Remove c={0}, ids={1}, type={2}",
                               character.Guid, character.mDatas.Select(d => d.Id).GetDataString(), type);
#endif
            if (_this.mCharacters.Count == 0)
            {
                StopTrigger(_this);
            }
        }
Example #7
0
 internal static void RefreshMatchRelation()
 {
     foreach (var queueLogic in Matchings)
     {
         var queue = queueLogic.Value as FightQueue;
         if (queue != null)
         {
             if (queue.NextQueue == null)
             {
                 QueueLogic next = null;
                 Matchings.TryGetValue(queue.tbQueue.PreId, out next);
                 queue.NextQueue = next as FightQueue;
             }
         }
     }
 }
Example #8
0
        public void PushSuccessTime(QueueLogic _this, int second)
        {
            var now = DateTime.Now;

            //超过1小时的会移除
            foreach (var i in _this.MatchOkey)
            {
                if ((now - i.Key).TotalSeconds > 3600)
                {
                    _this.MatchOkey.Remove(i.Key);
                    return;
                }
            }
            _this.MatchOkey[now] = second;
            //超过25个之外的会移除
            if (_this.MatchOkey.Count > 25)
            {
                _this.MatchOkey.Remove(_this.MatchOkey.First().Key);
            }
        }
Example #9
0
        public void Construct(QueueCharacter _this, QueueLogic logic, List <CharacterSimpleData> datas)
        {
            _this.mDatas    = datas;
            _this.mLogic    = logic;
            _this.Guid      = QueueCharacter.NextId++;
            _this.StartTime = DateTime.Now;
            PlayerLog.WriteLog((int)LogType.QueueMessage, "Construct Guid={0}, ids={1}", _this.Guid,
                               datas.Select(d => d.Id).GetDataString());
#if DEBUG
            var matchs = QueueManager.Matchings.Values;
            foreach (var match in matchs)
            {
                var f = match.mCharacters.Find(c => c.mDatas[0].Id == datas[0].Id);
                if (f != null)
                {
                    PlayerLog.WriteLog((int)LogType.QueueLog,
                                       "Duplicate queue, queueId0 = {0}, team0 = {1}, queueId1 = {2}, team1 = {3}", _this.Guid,
                                       datas.Select(d => d.Id).GetDataString(), f.Guid, f.mDatas.Select(d => d.Id).GetDataString());
                }
            }
#endif
        }
Example #10
0
        public void PushFront(QueueLogic _this, QueueCharacter queueC)
        {
            if (_this.mCharacters.Count == 0)
            {
                _this.StartTrigger();
            }
            PlayerLog.WriteLog((int)LogType.QueueMessage, "PushFront  queueC={1},character={0}", queueC.mDatas[0].Id,
                               queueC.Guid);
            queueC.result = null;
#if DEBUG
            foreach (var data in queueC.mDatas)
            {
                var t = QueueManager.GetMatchingCharacter(data.Id);
                if (t == null)
                {
                    PlayerLog.WriteLog((ulong)LogType.QueueMessage, "PushFront t == null!! c = {0} ids = {1}",
                                       queueC.Guid, queueC.mDatas.Select(d => d.Id).GetDataString());
                }
            }
            foreach (var queueCharacter in _this.mCharacters)
            {
                foreach (var datas in queueCharacter.mDatas)
                {
                    foreach (var data in queueC.mDatas)
                    {
                        if (datas.Id == data.Id)
                        {
                            PlayerLog.WriteLog((ulong)LogType.QueueMessage,
                                               "PushFront datas.Id == data.Id!! c = {0} ids = {1}",
                                               queueC.Guid, queueC.mDatas.Select(d => d.Id).GetDataString());
                        }
                    }
                }
            }
#endif
            PlayerLog.WriteLog((int)LogType.QueueMessage, "PushFront mCharacters.Insert c={0}, ids={1}", queueC.Guid,
                               queueC.mDatas.Select(d => d.Id).GetDataString());
            _this.mCharacters.Insert(0, queueC);
        }
Example #11
0
        public void PushBack(QueueLogic _this, QueueCharacter queueC)
        {
            if (_this.mCharacters.Count == 0)
            {
                _this.StartTrigger();
            }
#if DEBUG
            foreach (var data in queueC.mDatas)
            {
                var t = QueueManager.GetMatchingCharacter(data.Id);
                if (t == null)
                {
                    PlayerLog.WriteLog((ulong)LogType.QueueMessage, "PushBack t == null!! c = {0} ids = {1}",
                                       queueC.Guid, queueC.mDatas.Select(d => d.Id).GetDataString());
                }
            }
            foreach (var queueCharacter in _this.mCharacters)
            {
                foreach (var datas in queueCharacter.mDatas)
                {
                    foreach (var data in queueC.mDatas)
                    {
                        if (datas.Id == data.Id)
                        {
                            PlayerLog.WriteLog((ulong)LogType.QueueMessage,
                                               "PushBack datas.Id == data.Id!! c = {0} ids = {1}",
                                               queueC.Guid, queueC.mDatas.Select(d => d.Id).GetDataString());
                        }
                    }
                }
            }
#endif
            PlayerLog.WriteLog((int)LogType.QueueMessage, "PushBack mCharacters.Add c={0}, ids={1}", queueC.Guid,
                               queueC.mDatas.Select(d => d.Id).GetDataString());
            _this.mCharacters.Add(queueC);
        }
Example #12
0
 public QueueCharacter(QueueLogic logic, List <CharacterSimpleData> datas)
 {
     mImpl.Construct(this, logic, datas);
 }
Example #13
0
 public void OnAllOk(QueueLogic _this, QueueResultBase result)
 {
 }
Example #14
0
 public void Construct(QueueLogic _this, int queueId)
 {
     _this.mQueueId = queueId;
     _this.tbQueue  = Table.GetQueue(queueId);
 }
Example #15
0
 public QueueResultBase(QueueLogic q)
 {
     mImpl.Construct(this, q);
 }
Example #16
0
 public QueueResult(QueueLogic q) : base(q)
 {
 }
Example #17
0
 public void Construct(QueueResultBase _this, QueueLogic q)
 {
     _this.mQueue = q;
 }
Example #18
0
 public void Tick(QueueLogic _this)
 {
 }
Example #19
0
 public void MatchOver(QueueLogic _this)
 {
 }
Example #20
0
 public FollowQueueResult(QueueLogic q) : base(q)
 {
 }