You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

92 lines
2.6 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Sog;
using ProtoCSStruct;
using Sog.IO;
namespace Game
{
/// <summary>
/// AB测试香港
/// </summary>
public static class ABTestSvc
{
public static int MakeABTestFlag(long uid, int realmId, string os, string ip,string deviceId)
{
ABTestConfig[] abTestConfigs = GameServerUtils.GetServerConfig().abTestConfigs;
if(abTestConfigs == null || abTestConfigs.Length == 0)
{
return 0;
}
int flag = 0;
foreach(var config in abTestConfigs)
{
if(config.abTestFlag <= 0)
{
continue;
}
//ip白名单判断
if (config.enableWhiteIPList == 1 && !LimitIPList.IsInWhiteList(ip, deviceId))
{
continue;
}
//realm白名单判断
if(!string.IsNullOrEmpty(config.os))
{
if(string.IsNullOrEmpty(os))
{
continue;
}
string lowCase = os.ToLower();
if(lowCase != config.os)
{
continue;
}
}
//realmId白名单
if(config.openOnRealmIds != null && config.openOnRealmIds.Length > 0)
{
bool validRealmId = false;
foreach(var id in config.openOnRealmIds)
{
if(id == realmId)
{
validRealmId = true;
break;
}
}
if(validRealmId == false)
{
continue;
}
}
//
int uidRemainder = (int)(uid % 10);
if(uidRemainder < config.uidRemainderStart || uidRemainder > config.uidRemainderEnd)
{
continue;
}
//按位,可以配置多个规则
flag |= config.abTestFlag;
TraceLog.Trace("ABTestSvc.MakeABTestFlag uid {0} realmId {1} os {2} ip {3} match abTestFlag {4} flag {5}",
uid, realmId, os, ip, config.abTestFlag, flag);
}
return flag;
}
}
}