示例#1
0
        private static GameAvatar FindEnemy(MatchmakingEntry entry, Dictionary <long, GameAvatar> documents)
        {
            GameAvatar        document      = entry.Session.GameAvatar;
            LogicClientAvatar playerAvatar1 = document.LogicClientAvatar;

            int totalSecs       = TimeUtil.GetTimestamp() - entry.Timestamp;
            int strength1       = GameMatchmakingManager.CalculateStrength(playerAvatar1);
            int maxStrengthDiff = 50 + LogicMath.Clamp(totalSecs * 150 / 60, 0, 150);

            foreach (GameAvatar enemy in documents.Values)
            {
                LogicClientAvatar playerAvatar2 = enemy.LogicClientAvatar;

#if DEBUG
                if (ServerCore.Random.Rand(100) <= 95)
                {
                    continue;
                }
#else
                if (playerAvatar1.IsInAlliance() && playerAvatar2.IsInAlliance() && playerAvatar1.GetAllianceId().Equals(playerAvatar2.GetAllianceId()))
                {
                    continue;
                }

                int strength2 = GameMatchmakingManager.CalculateStrength(playerAvatar2);

                if (LogicMath.Abs(strength1 - strength2) >= maxStrengthDiff)
                {
                    continue;
                }
                if (document.HasRecentlyMatchedWithEnemy(enemy.Id))
                {
                    continue;
                }
#endif
                return(enemy);
            }

            return(null);
        }