Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 检查扑克中的直接组合_Actionscript 3_Flash Cs6_Poker - Fatal编程技术网

Actionscript 3 检查扑克中的直接组合

Actionscript 3 检查扑克中的直接组合,actionscript-3,flash-cs6,poker,Actionscript 3,Flash Cs6,Poker,我想检查扑克游戏中的一个直接组合 我有一个数组:var-tempArr:array=newarray 我有一个用于排序数组的方法: for (i = 0; i < 7; i++) { tempArr[i] = pValue[i]; } tempArr.sort( Array.NUMERIC ); (i=0;i

我想检查扑克游戏中的一个直接组合

我有一个数组:
var-tempArr:array=newarray

我有一个用于排序数组的方法:

for (i = 0; i < 7; i++)
{
    tempArr[i] = pValue[i];
}
tempArr.sort( Array.NUMERIC );
(i=0;i<7;i++)的

{
tempArr[i]=pValue[i];
}
tempArr.sort(Array.NUMERIC);
pValue
是卡的值,其范围为2到14

如果我有这个数组:
tempArray=[2,3,3,4,5,5,6]


如何检查手中是否有直连密码?

如果手中有卡,请设置一个存储桶数组进行保存

var t:Array = [];
//t[2] = 1;mean you have 2
// t[3] = 0;mean you don't have 3

//first initialize t
for(var i:int = 0; i < 15; i++)
{ 
   t[i] = 0;
}

//then set the values from  tempArray
for (var j:int = 0; j < tempArray.length; j++)
{
   t[tempArray[j]] = 1;
}

//if you have a straight combination in your hand
//you will get a k that t[k] & t[k-1]& t[k-2] & t[k-3] & t[k-4] == 1

var existed:boolean = false;//the flag save if you got a straight combination

for (var k:int = t.length - 1; k >= 4; k--)
{

    if (t[k] == 0)
    {
        continue;
    }

    if ((t[k] & t[k-1] & t[k-2] & t[k-3] & t[k-4]) == 1)
    {
         existed = true;
         break;
    }
}
var t:Array=[];
//t[2]=1;我是说你有两个
//t[3]=0;意思是说你没有3个
//首先初始化t
对于(变量i:int=0;i<15;i++)
{ 
t[i]=0;
}
//然后从tempArray设置值
对于(var j:int=0;j=4;k--)
{
如果(t[k]==0)
{
继续;
}
if((t[k]&t[k-1]&t[k-2]&t[k-3]&t[k-4])==1)
{
存在=真实;
打破
}
}

不要忘记特殊情况2-3-4-5-14!