예제 #1
0
int ColumnsPit::searchJoker()
{
	int iJokerCol=-1;
	for (int x=0; x<COL_PITWIDTH; x++)
		for (int y=COL_PITHEIGHT-1;y>-1; y--)
		{
			if (getStone(x,y)==COLUMNS_JOKER)
			{
				iJokerCol=getStone(x,y+1);
				break;
			}
		}

	for (int x=0; x<COL_PITWIDTH; x++)
		for (int y=0;y<COL_PITHEIGHT; y++)
		{
			if (getStone(x,y)==iJokerCol)
				vecTripleStones.insert(vecTripleStones.begin(), Point(x,y));
			if (getStone(x,y)==COLUMNS_JOKER)
				setStone(x,y,0);// der Joker wird als Punkte nicht gezählt
		}
// Clear the Stones
	for (int x=0;x<vecTripleStones.size();x++)
	{
		Point tmp=vecTripleStones[x];
		setStone(tmp.x, tmp.y,0);
	}

	return vecTripleStones.size();
}
예제 #2
0
void ColumnsPit::removeGaps()
{
	for (int x=0; x<COL_PITWIDTH ;x++)
	{
		for (int y=COL_PITHEIGHT-1; y>-1; y--)
		{
			int tmpCol=getStone(x,y);
			if (tmpCol==0 && y>0)
			{ // falls der Stone leer ist, muss die Reihe über ihm nach einem Stone abgesucht werden, der dann in das Loch gelegt wird
				for (int tmpY=y; tmpY>=0; tmpY-- )
				{
					if (getStone(x, tmpY)!=0)
					{
						setStone(x,y,getStone(x,tmpY));
						setStone(x,tmpY,0);
						break;
					}
				}
			}
		}
	}
}
예제 #3
0
// return: if some gaps occurs..
// clears all found stones which were presen in a 3er Group
bool ColumnsPit::deleteSolution()
{
	if (vecTripleStones.size()>0)
	{
		for (int x=0;x<vecTripleStones.size();x++)
		{
			Point tmp=vecTripleStones[x];
			setStone(tmp.x,tmp.y,0);
		}
		removeGaps();
		vecTripleStones.clear();
		return true;
	}
	return false;
}
예제 #4
0
void init(int status)
{
    int c;
    int flag = 0;
    time(&ts);
    paint_start(status);
    while (1)
    {
        c = mygetch();
        switch(c)
        {
            case 53:   // 向上 小键盘5号
                if (status > 1)
                {
                    status --;
                }
                paint_start(status);
                break;
            case 50:    // 向下 小键盘2号
                if (status < 4)
                {
                    status ++;
                }
                paint_start(status);
                break;
            case 10:
                if (status == 1)
                {
                    flag = 1;
                }
                if (status == 2)
                {
                    flag = 2;
                }
                if (status == 3)
                {
                    flag = 3;
                }
                if (status == 4)
                {
                    flag = 4;
                }
                break;
            case 27: // 退出游戏
                time(&te);
                miao = (int)(te - ts);
                if (miao >= 60)
                {
                    fen = miao / 60;
                    miao = miao % 60;
                    if (fen >=60)
                    {
                        shi = fen / 60;
                        fen = fen % 60;
                    }
                }
                printf("      耗时\033[1;32m%2d时:%2d分:%2d秒\033[0m\n", shi, fen, miao);
                exit(0);
        }
        if (flag >= 1)
        {
            break;
        }
    }
    if (flag == 1)
    {
        start(); // 开始游戏
    }
    if (flag == 2) // 设置石头
    {
        setStone(arr);
    }
    if (flag == 3) // 查看最高分
    {
        level();
    }
    if (flag == 4)
    {
        about(); // 关于作者
    }

}