var a = [1,2,3,4,5,6,7,8,9,10,11,12,13];
for (var i = 0; i < a.length - 1; i +=1 ){
var randIndex = i + Math.floor(Math.random() * (a.length - i));
var temp = a[i];
a[i] = a[randIndex];
a[randIndex] = temp;
}
console.log("tmpCardNew=============a==============="+JSON.stringify(a));
var b = [1,2,5,5,6,6,7,7,8,8,10,10,14,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,
24,24,25,25,26,26,27,27,28,28,29,31,36,36,37,37,38,38,39,39,40,40,41,41,42,42,
43,43,44,44,45,45,46,46,47,47,48,48,49,51];
console.log("b===============length============="+b.length);
var c ={
1:[],
2:[],
3:[],
4:[],
5:[],
6:[],
7:[],
8:[],
9:[],
10:[],
11:[],
12:[],
13:[]
}
console.log(ceilNum);
for(var i = 0;i < b.length;i++)
{
var ceilNum = Math.ceil(b[i] / 4);
c[ceilNum].push(b[i]);
}
console.log("tmpCardNew=============c========1======="+JSON.stringify(c));
for(var i = 1;i <= 13;i++)
{
var tmpcard = c[i];
c[i] = c[a[i - 1]];
c[a[i - 1]] = tmpcard;
}
var tmp1 = []; //记录随机的数据
var tmp2 = []; //单独记录随机数据超过3个的数据
console.log("tmpCardNew=============c=========2======"+JSON.stringify(c));
for(var i = 1;i <= 13;i++)
{
if(c[i].length > 6)
{
var rand = Math.floor(Math.random() * (6 - 4 + 1)) + 4;
console.log("BzhanDanRand===============length============="+rand);
// tmp1.push(c[i][0]);
// tmp1.push(c[i][1]);
// tmp1.push(c[i][2]);
// tmp1.push(c[i][4]);
for(var j =0;j < rand;j++)
{
tmp1.push(c[i][j]);
}
for(var j = rand;j < c[i].length;j++)
{
tmp2.push(c[i][j]);
}
}
else
{
for(var j = 0; j < c[i].length;j++)
{
tmp1.push(c[i][j]);
}
}
}
var tmpCard = [];
for(var i = 0;i < tmp1.length;i++)
{
tmpCard.push(tmp1[i]);
}
for(var i = 0;i < tmp2.length;i++)
{
tmpCard.push(tmp2[i]);
}
console.log("tmpCard============================"+JSON.stringify(tmpCard));
console.log("tmpCard===============length============="+tmpCard.length);
console