📄 chessmodel.java
字号:
}
if(num>max_temp&&num<5)
max_temp=num;
x_temp1=x_temp;
y_temp1=y_temp;
num=0;
for(int i=1;i<5;i++){
x_temp1-=1;
y_temp1-=1;
if(y_temp1<0||x_temp1<0)
break;
if(this.arrMapShow[x_temp1][y_temp1]==black_or_red)
num++;
else
break;
}
x_temp1=x_temp;
y_temp1=y_temp;
for(int i=1;i<5;i++){
x_temp1+=1;
y_temp1+=1;
if(y_temp1>this.height||x_temp1>this.width)
break;
if(this.arrMapShow[x_temp1][y_temp1]==black_or_red)
num++;
else
break;
}
if(num>max_temp&&num<5)
max_temp=num;
x_temp1=x_temp;
y_temp1=y_temp;
num=0;
for(int i=1;i<5;i++){
x_temp1+=1;
y_temp1-=1;
if(y_temp1<0||x_temp1>this.width)
break;
if(this.arrMapShow[x_temp1][y_temp1]==black_or_red)
num++;
else
break;
}
x_temp1=x_temp;
y_temp1=y_temp;
for(int i=1;i<5;i++){
x_temp1-=1;
y_temp1+=1;
if(y_temp1>this.height||x_temp1<0)
break;
if(this.arrMapShow[x_temp1][y_temp1]==black_or_red)
num++;
else
break;
}
if(num>max_temp&&num<5)
max_temp=num;
max_num=max_temp;
return max_num;
}
public boolean judgeSuccess(int x,int y,boolean isodd){
int num=1;
int arrvalue;
int x_temp=x,y_temp=y;
if(isodd)
arrvalue=2;
else
arrvalue=1;
int x_temp1=x_temp,y_temp1=y_temp;
for(int i=1;i<6;i++){
x_temp1+=1;
if(x_temp1>this.width)
break;
if(this.arrMapShow[x_temp1][y_temp1]==arrvalue)
num++;
else
break;
}
x_temp1=x_temp;
for(int i=1;i<6;i++){
x_temp1-=1;
if(x_temp1<0)
break;
if(this.arrMapShow[x_temp1][y_temp1]==arrvalue)
num++;
else
break;
}
if(num==5)
return true;
x_temp1=x_temp;
y_temp1=y_temp;
num=1;
for(int i=1;i<6;i++){
y_temp1-=1;
if(y_temp1<0)
break;
if(this.arrMapShow[x_temp1][y_temp1]==arrvalue)
num++;
else
break;
}
y_temp1=y_temp;
for(int i=1;i<6;i++){
y_temp1+=1;
if(y_temp1>this.height)
break;
if(this.arrMapShow[x_temp1][y_temp1]==arrvalue)
num++;
else
break;
}
if(num==5)
return true;
x_temp1=x_temp;
y_temp1=y_temp;
num=1;
for(int i=1;i<6;i++){
x_temp1-=1;
y_temp1-=1;
if(y_temp1<0||x_temp1<0)
break;
if(this.arrMapShow[x_temp1][y_temp1]==arrvalue)
num++;
else
break;
}
x_temp1=x_temp;
y_temp1=y_temp;
for(int i=1;i<6;i++){
x_temp1+=1;
y_temp1+=1;
if(y_temp1>this.height||x_temp1>this.width)
break;
if(this.arrMapShow[x_temp1][x_temp1]==arrvalue)
num++;
else
break;
}
if(num==5)
return true;
x_temp1=x_temp;
y_temp1=y_temp;
num=1;
for(int i=1;i<6;i++){
x_temp1+=1;
y_temp1-=1;
if(y_temp1<0||x_temp1>this.width)
break;
if(this.arrMapShow[x_temp1][y_temp1]==arrvalue)
num++;
else
break;
}
x_temp1=x_temp;
y_temp1=y_temp;
for(int i=1;i<6;i++){
x_temp1-=1;
y_temp1+=1;
if(y_temp1>this.height||x_temp1<0)
break;
if(this.arrMapShow[x_temp1][y_temp1]==arrvalue)
num++;
else
break;
}
if(num==5)
return true;
return false;
}
public void showSuccess(JPanel jp){
JOptionPane.showMessageDialog(jp,"恭喜!你赢了游戏!",
"胜利",JOptionPane.INFORMATION_MESSAGE);
}
public void showDefeat(JPanel jp){
JOptionPane.showMessageDialog(jp,"你输了游戏,请继续努力","失败",JOptionPane.INFORMATION_MESSAGE);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -