📄 heibaiqi.java
字号:
{
--up;
if(up<=0) return;
state=thebutton[up][j].state();
}
if(state==mode)
{
thebutton[up][j].addtochange(thebutton[i][j]);
//System.out.println("button:"+i+","+j+"add to click changelist of:"+up+","+j);
return;
}
if(state==HeiBaiButton.blank)
{
thebutton[up][j].setState(mode);
//System.out.println("button:"+up+","+j+"add to click");
thebutton[up][j].addtochange(thebutton[i][j]);
//System.out.println("button:"+i+","+j+"add to click changelist of:"+up+","+j);
return;
}
if(state==q) return;
}
public void finddown(HeiBaiButton[][] thebutton,int i,int j,int mode,int p,int q)
{
int down=i+1;
//System.out.println("down");
if(down>m) return;
int state=thebutton[down][j].state();
if(state!=p) return;
while(state==p)
{
++down;
if(down>m) return;
state=thebutton[down][j].state();
}
if(state==mode)
{
thebutton[down][j].addtochange(thebutton[i][j]);
//System.out.println("button:"+i+","+j+"add to click changelist of:"+down+","+j);
return;
}
if(state==HeiBaiButton.blank)
{
thebutton[down][j].setState(mode);
//System.out.println("button:"+down+","+j+"add to click");
thebutton[down][j].addtochange(thebutton[i][j]);
//System.out.println("button:"+i+","+j+"add to click changelist of:"+down+","+j);
return;
}
if(state==q) return;
}
public void findrightup(HeiBaiButton[][] thebutton,int i,int j,int mode,int p,int q)
{
int rightupi=i-1,rightupj=j+1;
//System.out.println("rightup");
if(rightupi<=0||rightupj>m) return;
int state=thebutton[rightupi][rightupj].state();
if(state!=p) return;
while(state==p)
{
--rightupi;
++rightupj;
if(rightupi<=0||rightupj>m) return;
state=thebutton[rightupi][rightupj].state();
}
if(state==mode)
{
thebutton[rightupi][rightupj].addtochange(thebutton[i][j]);
//System.out.println("button:"+i+","+j+"add to click changelist of:"+rightupi+","+rightupj);
return;
}
if(state==HeiBaiButton.blank)
{
thebutton[rightupi][rightupj].setState(mode);
//System.out.println("button:"+rightupi+","+rightupj+"add to click");
thebutton[rightupi][rightupj].addtochange(thebutton[i][j]);
//System.out.println("button:"+i+","+j+"add to click changelist of:"+rightupi+","+rightupj);
return;
}
if(state==q) return;
}
public void findrightdown(HeiBaiButton[][] thebutton,int i,int j,int mode,int p,int q)
{
int rightdowni=i+1,rightdownj=j+1;
//System.out.println("rightdown");
if(rightdowni>m||rightdownj>m) return;
int state=thebutton[rightdowni][rightdownj].state();
if(state!=p) return;
while(state==p)
{
++rightdowni;
++rightdownj;
if(rightdowni>m||rightdownj>m) return;
state=thebutton[rightdowni][rightdownj].state();
}
if(state==mode)
{
thebutton[rightdowni][rightdownj].addtochange(thebutton[i][j]);
//System.out.println("button:"+i+","+j+"add to click changelist of:"+rightdowni+","+rightdownj);
return;
}
if(state==HeiBaiButton.blank)
{
thebutton[rightdowni][rightdownj].setState(mode);
//System.out.println("button:"+rightdowni+","+rightdownj+"add to click");
thebutton[rightdowni][rightdownj].addtochange(thebutton[i][j]);
//System.out.println("button:"+i+","+j+"add to click changelist of:"+rightdowni+","+rightdownj);
return;
}
if(state==q) return;
}
public void findleftup(HeiBaiButton[][] thebutton,int i,int j,int mode,int p,int q)
{
int leftupi=i-1,leftupj=j-1;
//System.out.println("leftup");
if(leftupi<=0||leftupj<=0) return;
int state=thebutton[leftupi][leftupj].state();
if(state!=p) return;
while(state==p)
{
--leftupi;
--leftupj;
if(leftupi<=0||leftupj<=0) return;
state=thebutton[leftupi][leftupj].state();
}
if(state==mode)
{
thebutton[leftupi][leftupj].addtochange(thebutton[i][j]);
//System.out.println("button:"+i+","+j+"add to click changelist of:"+leftupi+","+leftupj);
return;
}
if(state==HeiBaiButton.blank)
{
thebutton[leftupi][leftupj].setState(mode);
//System.out.println("button:"+leftupi+","+leftupj+"add to click");
thebutton[leftupi][leftupj].addtochange(thebutton[i][j]);
//System.out.println("button:"+i+","+j+"add to click changelist of:"+leftupi+","+leftupj);
return;
}
if(state==q) return;
}
public void findleftdown(HeiBaiButton[][] thebutton,int i,int j,int mode,int p,int q)
{
int leftdowni=i+1,leftdownj=j-1;
//System.out.println("leftdown");
if(leftdowni>m||leftdownj<=0) return;
int state=thebutton[leftdowni][leftdownj].state();
if(state!=p) return;
while(state==p)
{
++leftdowni;
--leftdownj;
if(leftdowni>m||leftdownj<=0) return;
state=thebutton[leftdowni][leftdownj].state();
}
if(state==mode)
{
thebutton[leftdowni][leftdownj].addtochange(thebutton[i][j]);
//System.out.println("button:"+i+","+j+"add to click changelist of:"+leftdowni+","+leftdownj);
return;
}
if(state==HeiBaiButton.blank)
{
thebutton[leftdowni][leftdownj].setState(mode);
//System.out.println("button:"+leftdowni+","+leftdownj+"add to click");
thebutton[leftdowni][leftdownj].addtochange(thebutton[i][j]);
//System.out.println("button:"+i+","+j+"add to click changelist of:"+leftdowni+","+leftdownj);
return;
}
if(state==q) return;
}
public void changeToBlack(HeiBaiButton tempbutton,ArrayList<HeiBaiButton> whitearray,ArrayList<HeiBaiButton> blackarray)
{
HeiBaiButton temp=tempbutton;
for(HeiBaiButton abutton:temp.arraylist) //计算白子数和黑子数
{
//System.out.println("begin to deal with changing of white to black");
int i=abutton.i;
int j=abutton.j;
//System.out.println("the current chest of dealing is button:"+i+","+j);
if(temp.i==i)
{
if(temp.j>j)
for(int c=j+1;c<=temp.j;c++)
{
if(!blackarray.contains(thebutton[i][c]))
blackarray.add(thebutton[i][c]);
if(whitearray.contains(thebutton[i][c]))
whitearray.remove(thebutton[i][c]);
//System.out.println("the white button:"+i+","+c+"is changing to black");
}
if(temp.j<j)
for(int c=temp.j;c<j;c++)
{
if(!blackarray.contains(thebutton[i][c]))
blackarray.add(thebutton[i][c]);
if(whitearray.contains(thebutton[i][c]))
whitearray.remove(thebutton[i][c]);
//System.out.println("the white button:"+i+","+c+"is changing to black");
}
}
if(temp.j==j)
{
if(temp.i>i)
for(int c=i+1;c<=temp.i;c++)
{
if(!blackarray.contains(thebutton[c][j]))
blackarray.add(thebutton[c][j]);
if(whitearray.contains(thebutton[c][j]))
whitearray.remove(thebutton[c][j]);
//System.out.println("the white button:"+c+","+j+"is changing to black");
}
if(temp.i<i)
for(int c=temp.i;c<i;c++)
{
if(!blackarray.contains(thebutton[c][j]))
blackarray.add(thebutton[c][j]);
if(whitearray.contains(thebutton[c][j]))
whitearray.remove(thebutton[c][j]);
//System.out.println("the white button:"+c+","+j+"is changing to black");
}
}
else
{
if((temp.j>j)&&(temp.i>i))
{
for(int c=i+1;c<=temp.i;c++)
{
if(!blackarray.contains(thebutton[++i][++j]))
blackarray.add(thebutton[i][j]);
if(whitearray.contains(thebutton[i][j]))
whitearray.remove(thebutton[i][j]);
//System.out.println("the white button:"+i+","+j+"is changing to black");
}
}
if((temp.i<i)&&(temp.j<j))
{
for(int c=temp.i,d=temp.j;c<i&&d<j;)
{
if(!blackarray.contains(thebutton[c][d]))
blackarray.add(thebutton[c][d]);
if(whitearray.contains(thebutton[c][d]))
whitearray.remove(thebutton[c][d]);
//System.out.println("the white button:"+c+","+d+"is changing to black");
++c;
++d;
}
}
if((temp.i<i)&&(temp.j>j))
{
for(int c=i-1,d=j+1;c>=temp.i&&d<=temp.j;)
{
if(!blackarray.contains(thebutton[c][d]))
blackarray.add(thebutton[c][d]);
if(whitearray.contains(thebutton[c][d]))
whitearray.remove(thebutton[c][d]);
//System.out.println("the white button:"+c+","+d+"is changing to black");
--c;
++d;
}
}
if((temp.i>i)&&(temp.j<j))
{
for(int c=temp.i,d=temp.j;c>i&&d<j;)
{
if(!blackarray.contains(thebutton[c][d]))
blackarray.add(thebutton[c][d]);
if(whitearray.contains(thebutton[c][d]))
whitearray.remove(thebutton[c][d]);
//System.out.println("the white button:"+c+","+d+"is changing to black");
--c;
++d;
}
}
}
}
}
public void changeToWhite(HeiBaiButton tempbutton,ArrayList<HeiBaiButton> whitearray,ArrayList<HeiBaiButton> blackarray)
{
HeiBaiButton temp=tempbutton;
for(HeiBaiButton abutton:temp.arraylist) //计算白子数和黑子数
{
//System.out.println("begin to deal with changing of black to white ");
int i=abutton.i;
int j=abutton.j;
//System.out.println("the current chest of dealing is button:"+temp.i+","+temp.j);
if(temp.i==i)
{
if(temp.j>j)
for(int c=j+1;c<=temp.j;c++)
{
if(!whitearray.contains(thebutton[i][c]))
whitearray.add(thebutton[i][c]);
if(blackarray.contains(thebutton[i][c]))
blackarray.remove(thebutton[i][c]);
//System.out.println("the black button:"+i+","+c+"is changing to white");
}
if(temp.j<j)
for(int c=temp.j;c<j;c++)
{
if(!whitearray.contains(thebutton[i][c]))
whitearray.add(thebutton[i][c]);
if(blackarray.contains(thebutton[i][c]))
blackarray.remove(thebutton[i][c]);
//System.out.println("the black button:"+i+","+c+"is changing to white");
}
}
if(temp.j==j)
{
if(temp.i>i)
for(int c=i+1;c<=temp.i;c++)
{
if(!whitearray.contains(thebutton[c][j]))
whitearray.add(thebutton[c][j]);
if(blackarray.contains(thebutton[c][j]))
blackarray.remove(thebutton[c][j]);
//System.out.println("the black button:"+c+","+j+"is changing to white");
}
if(temp.i<i)
for(int c=temp.i;c<i;c++)
{
if(!whitearray.contains(thebutton[c][j]))
whitearray.add(thebutton[c][j]);
if(blackarray.contains(thebutton[c][j]))
blackarray.remove(thebutton[c][j]);
//System.out.println("the black button:"+c+","+j+"is changing to white");
}
}
else
{
if((temp.j>j)&&(temp.i>i))
{
for(int c=i+1;c<=temp.i;c++)
{
if(!whitearray.contains(thebutton[++i][++j]))
whitearray.add(thebutton[i][j]);
if(blackarray.contains(thebutton[i][j]))
blackarray.remove(thebutton[i][j]);
//System.out.println("the black button:"+i+","+j+"is changing to white");
}
}
if((temp.i<i)&&(temp.j<j))
{
for(int c=temp.i,d=temp.j;c<i&&d<j;)
{
if(!whitearray.contains(thebutton[c][d]))
whitearray.add(thebutton[c][d]);
if(blackarray.contains(thebutton[c][d]))
blackarray.remove(thebutton[c][d]);
//System.out.println("the black button:"+c+","+d+"is changing to white");
++c;
++d;
}
}
if((temp.i<i)&&(temp.j>j))
{
for(int c=i-1,d=j+1;c>=temp.i&&d<=temp.j;)
{
if(!whitearray.contains(thebutton[c][d]))
whitearray.add(thebutton[c][d]);
if(blackarray.contains(thebutton[c][d]))
blackarray.remove(thebutton[c][d]);
//System.out.println("the black button:"+c+","+d+"is changing to white");
--c;
++d;
}
}
if((temp.i>i)&&(temp.j<j))
{
for(int c=temp.i,d=temp.j;c>i&&d<j;)
{
if(!whitearray.contains(thebutton[c][d]))
whitearray.add(thebutton[c][d]);
if(blackarray.contains(thebutton[c][d]))
blackarray.remove(thebutton[c][d]);
//System.out.println("the black button:"+c+","+d+"is changing to white");
--c;
++d;
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -