?? mantischessstd.cpp
字號(hào):
/***************************************************************
MantisChessStd.cpp : MantisChess 標(biāo)準(zhǔn)函數(shù) JiaJu 2004.10.16
******************************************************************/
#include "StdAfx.h"
#include "MantisChessDef.h"
#include "MantisChessStd.h"
/******************************************************************
CanGo: 判斷一步棋合不合法
參數(shù):
manmap: 棋位狀態(tài)
man: 所移動(dòng)的棋子
from: 所移動(dòng)的棋子原始位置
to: 所要移動(dòng)到的位置
返回值: 合法返回TRUE,不合法返回FALSE
******************************************************************/
BOOL CanGo(POINT manpoint[6],int manmap[6][13],int man,const POINT &from,const POINT &to,int side)
{
switch(man)
{
case 0:
if(to.y > from.y)return FALSE;
if(to.y <= manpoint[3].y)return FALSE;
if(abs(to.x-from.x)>0)return FALSE;
break;
case 1:
if(to.y > from.y)return FALSE;
if(to.y <= manpoint[4].y)return FALSE;
if(abs(to.x-from.x)>0)return FALSE;
break;
case 2:
if(to.y > from.y)return FALSE;
if(to.y <= manpoint[5].y)return FALSE;
if(abs(to.x-from.x)>0)return FALSE;
break;
case 3:
if(to.y < from.y)return FALSE;
if(to.y >= manpoint[0].y)return FALSE;
if(abs(to.x-from.x)>0)return FALSE;
break;
case 4:
if(to.y < from.y)return FALSE;
if(to.y >= manpoint[1].y)return FALSE;
if(abs(to.x-from.x)>0)return FALSE;
break;
case 5:
if(to.y < from.y)return FALSE;
if(to.y >= manpoint[2].y)return FALSE;
if(abs(to.x-from.x)>0)return FALSE;
break;
default:
break;
}
if(!side&&to.x==1&&to.y-manpoint[3].y==1&&manpoint[4].y==1&&manpoint[5].y==1)
return FALSE;
if(!side&&to.x==2&&to.y-manpoint[4].y==1&&manpoint[3].y==1&&manpoint[5].y==1)
return FALSE;
if(!side&&to.x==3&&to.y-manpoint[5].y==1&&manpoint[3].y==1&&manpoint[4].y==1)
return FALSE;
return TRUE; //上面的規(guī)則全通過!
}
/******************************************************************
FixManMap: 根據(jù)棋子坐標(biāo)計(jì)算棋位狀態(tài)
參數(shù):
map: 棋位狀態(tài)(存放結(jié)果)
manpoint: 棋子坐標(biāo)
side: 輪到哪一方走
返回值: 無
******************************************************************/
void FixManMap(int map[6][13],POINT manpoint[6],int side)
{
memcpy(map,_defaultmap,65*sizeof(int));
static POINT * pman;
static int i;
for(i=0;i<6;i++)
{
pman = & manpoint[i];
if(pman->x)
map[pman->x][pman->y]=i;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -