一些常用的随机实现

if (RandomUtil.randomInt(10) > 2)
{
// 1.高频
}else if (RandomUtil.randomInt(10) > 3)
{
// 2
} else if (RandomUtil.nextBoolean())
{

}


int result = RandomUtil.randomInt(3);
switch (result)
{
case 0:
//搜索帮派
csGuildSearch();
break;
case 1:
//请求帮派列表和申请帮派
csGuildList();
break;
case 2:
//创建帮派
csGuildCreate(getClientObject().getActorID());
break;
default:
break;
}



int rankId = 0;
int[] keys = DictRankDetailData.getServerTypeKeys();
if (keys.length > 0)
{
int random1 = RandomUtil.randomInt(keys.length);
TIntArrayList records = DictRankDetailData.getRecordsByServerType(keys[random1]);
int randomRankIndex = RandomUtil.randomInt(records.size());
if (randomRankIndex > 0)
{
rankId = records.get(randomRankIndex);
}
}

posted @ 2018-12-04 21:55  lizb0907  阅读(196)  评论(0编辑  收藏  举报