123;
if(point[guard2][guard1]<=16)
{
g.setColor(255,255,0);
g.fillArc(x-chessR+guard1*cellWidth,x-chessR+guard2*cellWidth,2*chessR,2*chessR,0,360);
g.setColor(0x00000000);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_BOLD
,Font.SIZE_LARGE));
g.drawString(word[guard2][guard1],x+guard1*cellWidth,x+chessR+guard2*cellWidth,Graphics.HCENTER|Graphics.BOTTOM);
}
}
if(g2%2==0)
{
if(point[guard2][guard1]>16)
{
g.setColor(0,255,0);
g.fillArc(x-chessR+guard1*cellWidth,x-chessR+guard2*cellWidth,2*chessR,2*chessR,0,360);
g.setColor(0x00000000);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_BOLD
,Font.SIZE_LARGE));
g.drawString(word[guard2][guard1],x+guard1*cellWidth,x+chessR+guard2*cellWidth,Graphics.HCENTER|Graphics.BOTTOM);
}
}
}
}
protected void whoIsGoing(Graphics g)//判断该谁走了
{
checkWin();
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_BOLD
,Font.SIZE_LARGE));
if(isRedWin!=0)
{
if(g2%2==1){
g.setColor(255,0,0);
g.drawString("该红方走了",x,x+chessR+10*cellWidth,Graphics.LEFT|Graphics.BOTTOM);
}
}
else{ g.setColor(255,255,255);
g.drawString("白方胜利",x,x+chessR+10*cellWidth,Graphics.LEFT|Graphics.BOTTOM);}
if(isWhiteWin!=0)
{
if(g2%2==0){
g.setColor(255,255,255);
g.drawString("该白方走了",x,x+chessR+10*cellWidth,Graphics.LEFT|Graphics.BOTTOM);
}
}
else{ g.setColor(255,0,0);
g.drawString("红方胜利",x,x+chessR+10*cellWidth,Graphics.LEFT|Graphics.BOTTOM);}
}
protected void checkWin()//判断输赢
{ isRedWin=0;isWhiteWin=0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++){if(point[0+i][3+j]==5){isRedWin++;}}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++){if(point[7+i][3+j]==21){isWhiteWin++;}}
}
}
protected void paintSelected(Graphics g)//画选择框
{
g.setColor(0,0,255);
g.drawRect(x-chessR+selectedX*cellWidth,x-chessR+selectedY*cellWidth,2*chessR,2*chessR);
}
protected void paint(Graphics g)
{
g.setColor(0x00000000);
g.fillRect(0, 0, getWidth(), getHeight());
paintMapa(g);
paintMapb(g);
paintMapc(g);
paintAllChess(g);
if(guard%2==1)
{
chooseChess(g);
}
paintSelected(g);
whoIsGoing(g);
}
protected void changTwoChessNum(int m,int n,int selectedX,int selectedY)//改变两个格子的值
{
g2++;
p=point[selectedY][selectedX];
point[selectedY][selectedX]=point[n][m];
point[n][m]=0;
q=word[selectedY][selectedX];
word[selectedY][selectedX]=word[n][m];
word[n][m]="空";
}
protected void theRuleOfChe(int m,int n,int selectedX,int selectedY)//车的规则
{
g=0;
if(m==selectedX)
{
if(n>selectedY)
{
for(i=1;i {
if(point[selectedY+i][m]!=0){g++;}
}
}
else
{
for(i=1;i {
if(point[n+i][m]!=0){g++;}
}
}
if(g==0){changTwoChessNum(m,n,selectedX,selectedY);}
}
if(n==selectedY)
{
if(m>selectedX)
{
for(i=1;i {
if(point[n][i+selectedX]!=0){g++;}
}
}
else
{
for(i=1;i {
if(point[n][m+i]!=0){g++;}
}
}
if(g==0){changTwoChessNum(m,n,selectedX,selectedY);}
}
}
protected void theRuleOfMa(int m,int n,int selectedX,int selectedY)//马的规则
{
if(n<9){
if(point[n+1][m]==0)
{
if(selectedX-m==1){if(selectedY-n==2){changTwoChessNum(m,n,selectedX,selectedY);}}
}
}
if(n>0){
if(point[n-1][m]==0)
{
if(m-selectedX==1){if(n-selectedY==2){changTwoChessNum(m,n,selectedX,selectedY);}}
}
}
if(n<9){
if(point[n+1][m]==0)
{
if(selectedX-m==-1){if(selectedY-n==2){changTwoChessNum(m,n,selectedX,selectedY);}}
}
}
if(n>0){
if(point[n-1][m]==0)
{
if(m-selectedX==-1){if(n-selectedY==2){changTwoChessNum(m,n,selectedX,selectedY);}}
}
}
if(m<8){
if(point[n][m+1]==0)
{
if(selectedX-m==2){if(selectedY-n==1){changTwoChessNum(m,n,selectedX,selectedY);}}
}
}
if(m>0){
if(point[n][m-1]==0)
{
if(m-selectedX==2){if(n-selectedY==1){changTwoChessNum(m,n,selectedX,selectedY);}}
}
}
if(m<8){
if(point[n][m+1]==0)
{
if(selected