/******************************************************************
 *						Author:	Zhou Yundong
 *						Time: 20080425 20:49
 ******************************************************************/
#include "Stdafx.h"
#include "Think.h"

void initialSopare()
{
	moveSum('0', 'l'); // 0 to leftSum
	moveIdx('0', 'l'); // 0 to leftIdx
	moveHead('0', 'l'); // 0 to headIdx
	moveUniq('0', 'l'); // 0 to uniqIdx
	moveSaw('0', 'l'); // 0 to leftSaw
	moveExtra('0', 'l'); // 0 to leftExtra
	moveKilpare('0', 'l'); // 0 to killerPare
	editKind = 0;
	gameKind = 2;
	firstIntoSodoku = true;
}

void movePare(char from, char to)
{
	int i;
	if(from == '0' && to == 'l')
	{
		for(i=0; i<144; i++)
		{
			leftPare[i] = 0;
		}
	}
	else if(from == '0' && to == 'r')
	{
		for(i=0; i<144; i++)
		{
			rightPare[i] = 0;
		}
	}
	else if(from == 'l' && to == 'r')
	{
		for(i=0; i<144; i++)
		{
			rightPare[i] = leftPare[i];
		}
	}
	else if(from == 'r' && to == 'l')
	{
		for(i=0; i<144; i++)
		{
			leftPare[i] = rightPare[i];
		}
	}
	else if(from == 'l' && to == 'p')
	{
		for(i=0; i<144; i++)
		{
			pare[i] = leftPare[i];
		}
	}
	else if(from == 'p' && to == 'r')
	{
		for(i=0; i<144; i++)
		{
			rightPare[i] = pare[i];
		}
	}
	else if(from == 'p' && to == 't')
	{
		for(i=0; i<144; i++)
		{
			tempPare[i] = pare[i];
		}
	}
	else if(from == 't' && to == 'p')
	{
		for(i=0; i<144; i++)
		{
			pare[i] = tempPare[i];
		}
	}
	else if(from == 'p' && to == 'k')
	{
		for(i=0; i<144; i++)
		{
			bakPare[i] = pare[i];
		}
	}
	else if(from == 'k' && to == 'p')
	{
		for(i=0; i<144; i++)
		{
			pare[i] = bakPare[i];
		}
	}
	else if(from == 'p' && to == 'l')
	{
		for(i=0; i<144; i++)
		{
			leftPare[i] = pare[i];
		}
	}
	else if(from == 'p' && to == 'a')
	{
		for(i=0; i<144; i++)
		{
			answerPare[i] = pare[i];
		}
	}
}

void moveKilpare(char from, char to)
{
	int i;
	if(from == '0' && to == 'l')
	{
		for(i=0; i<144; i++)
		{
			leftKilpare[i] = 0;
		}
	}
	else if(from == '0' && to == 'r')
	{
		for(i=0; i<144; i++)
		{
			rightKilpare[i] = 0;
		}
	}
	else if(from == 'l' && to == 'r')
	{
		for(i=0; i<144; i++)
		{
			rightKilpare[i] = leftKilpare[i];
		}
	}
	else if(from == 'r' && to == 'l')
	{
		for(i=0; i<144; i++)
		{
			leftKilpare[i] = rightKilpare[i];
		}
	}
	else if(from == 'l' && to == 'k')
	{
		for(i=0; i<144; i++)
		{
			kilpare[i] = leftKilpare[i];
		}
	}
}
