#ifndef	__Definition_h__
#define	__Definition_h__

#include "TableDef.h"

#define THINKOUT 1
#define MaxColorCircle 10
#define IndexEnd 27
#define PUSHSINGLE(i) {posStack[SCnt] = i; valueStack[SCnt++] = G[PIdx].area[mult162[i]];}

extern char basePath[256]; // 基础目录
extern bool fix[81]; // 0: unfixed, 1: fixed
extern bool oldFix[81]; // just for show 0: unfixed, 1: fixed
extern int flagAnswer; // 0: noanswer, 1: only one, 2: more than one
extern bool underQuestion; // under getting the question
extern int rightStatus; // status of the right board
extern bool dropable[81]; // can be dropped in condition of keeping flagAnswer is 1
extern int countQuestion; // the count of numbers of the question
extern bool underThinking; // computer is working to get answer or to get question
extern HANDLE runThread;
extern int transMethod; // 变换模式代号
extern int gameKind; // 0:sodoku,1:sosum,2:sopare,3:somix,4:jigsaw,5:extra default is sodoku
extern int gameKindRight;
extern LARGE_INTEGER Frequency;
extern LARGE_INTEGER StartTime;
extern LARGE_INTEGER EndTime;
extern double SpendTime;
extern bool autoSolute; // 允许自动解题
extern int editKind; // 数和:1，数扭:2
extern int rightKind; // 用于显示右盘的数扭
// 数独用
extern int board[81];
extern int bakBoard[81]; // reserve board for getting question
extern int answerBoard[81]; // save the answer
extern int leftBoard[81]; // save the left board
extern int rightBoard[81]; // save the right board
extern int tempBoard[81]; // save the temp board
extern int cntBoard;
extern bool fixation[81]; // 固定的数，clean时不会被清除
extern bool firstIntoSodoku; // 第一次进入数独状态
// 数和用
extern int sum[81];
extern int bakSum[81]; // reserve sum for getting question
extern int answerSum[81]; // save the answer
extern int leftSum[81]; // save the uniq sum
extern int rightSum[81]; // save the right sum
extern int idx[81];
extern int bakIdx[81]; // reserve idx for getting question
extern int answerIdx[81]; // save the answer
extern int leftIdx[81]; // save the left idx
extern int rightIdx[81]; // save the right idx
extern int leftHead[81]; // 簇头，每个簇只有一个
extern int rightHead[81];
extern bool leftUniq[81]; // 群头，每个群只有一个
extern bool rightUniq[81];
extern int underSumEditing; // 处在数和编辑状态
extern int selectIdx; // 选中的idx值
extern int maxIdx; // 当前最大idx数
extern bool editingIdx[81]; // 编辑中被选中的格点表
extern int editingHead; // 编辑状态时的头索引
extern POINT endPoint[100];
extern int cntEndPoint;
extern POINT endPoints[40][100];
extern int pEndPoints[40];
extern POINT rightEndPoints[40][100];
extern int pRightEndPoints[40];
extern int pCircle;
extern int pRightCircle;
extern int colorGroup[40];
extern int rightColorGroup[40];
// 数比用
extern int pare[144];
extern int bakPare[144]; // reserve pare for getting question
extern int answerPare[144]; // save the answer
extern int leftPare[144]; // save the left pare
extern int rightPare[144]; // save the right pare
extern int tempPare[144]; // save the temp pare
extern int cntPare;
extern int glidingPare; // 鼠标滑过的pare的索引
// KillerPare用
extern int kilpare[144];
extern int bakKilpare[144]; // reserve killer pare for getting question
extern int answerKilpare[144]; // save the answer
extern int leftKilpare[144]; // save the left killer pare
extern int rightKilpare[144]; // save the right killer pare
extern int tempKilpare[144]; // save the temp killer pare
extern int cntKilpare;
extern int glidingKilpare; // 鼠标滑过的killer pare的索引
// 数扭用
extern int saw[81];
extern int leftSaw[81];
extern int rightSaw[81];
extern int headSaw[81];
extern int selectSaw;
extern int colorSaw[81][4];
extern int colorSawRight[81][4];
extern bool editingSaw[81];
extern int maxSaw; // 当前最大saw数
extern int underSawEditing; // 处在数扭编辑状态
// 数超用
extern int extra[81];
extern int leftExtra[81];
extern int rightExtra[81];
extern int headExtra[81];
extern int selectExtra;
extern bool editingExtra[81];
extern int maxExtra; // 当前最大extra数
extern int underExtraEditing; // 处在数扭编辑状态

// 计算用
extern int posStack[27];
extern int valueStack[27];
extern int SCnt;
extern int PIdx;
extern struct GameBoard {
	int area[4374];
	int left[27];
	int SCnt;
	int cntGuessed;
} G[IndexEnd];

#endif