标签:
对项目最后进行了完善。
代码如下:
public void chapRule(int Man ,JLabel play,JLabel playTake,JLabel playQ[]){ //当前状态 boolean Chap = false; //上、右 if (playTake.getX() - play.getX() >= 20 && playTake.getX() - play.getX() <= 114 && play.getY() - playTake.getY() >= 2 && play.getY() - playTake.getY() <= 87){ //被吃的棋子是否和当前士相近 if (Man < 14 && playTake.getX() >= 195 && playTake.getX() <= 309 && playTake.getY() <= 170 && playTake.isVisible()){ Chap = true; } //被吃的棋子是否和当前仕相近 else if (Man > 13 && playTake.getX() >= 195 && playTake.getX() <= 309 && playTake.getY() >= 455 && playTake.isVisible()){ Chap = true; } }//if //上、左 else if (play.getX() - playTake.getX() <= 114 && play.getX() - playTake.getX() >= 25 && play.getY() - playTake.getY() >= 2 && play.getY() - playTake.getY() <= 87){ //被吃的棋子是否和当前士相近 if (Man < 14 && playTake.getX() >= 195 && playTake.getX() <= 309 && playTake.getY() <= 170 && playTake.isVisible()){ Chap = true; } //被吃的棋子是否和当前仕相近 else if (Man > 13 && playTake.getX() >= 195 && playTake.getX() <= 309 && playTake.getY() >= 455 && playTake.isVisible()){ Chap = true; } }// else if //下、左 else if (play.getX() - playTake.getX() <= 114 && play.getX() - playTake.getX() >= 25 && playTake.getY() - play.getY() >= 2 && playTake.getY() - play.getY() <= 87){ //被吃的棋子是否和当前士相近 if (Man < 14 && playTake.getX() >= 195 && playTake.getX() <= 309 && playTake.getY() <= 170 && playTake.isVisible()){ Chap = true; } //被吃的棋子是否和当前仕相近 else if (Man > 13 && playTake.getX() >= 195 && playTake.getX() <= 309 && playTake.getY() >= 455 && playTake.isVisible()){ Chap = true; } }// else if //下、右 else if (playTake.getX() - play.getX() >= 25 && playTake.getX() - play.getX() <= 114 && playTake.getY() - play.getY() >= 2 && playTake.getY() - play.getY() <= 87){ //被吃的棋子是否和当前士相近 if (Man < 14 && playTake.getX() >= 195 && playTake.getX() <= 309 && playTake.getY() <= 170 && playTake.isVisible()){ Chap = true; } //被吃的棋子是否和当前仕相近 else if (Man > 13 && playTake.getX() >= 195 && playTake.getX() <= 309 && playTake.getY() >= 455 && playTake.isVisible()){ Chap = true; } }//else if //可移动、并不能吃自己的棋子 if (Chap && playTake.getName().charAt(1) != play.getName().charAt(1)){ //当前记录添加到集合(用于悔棋) Var.add(String.valueOf(play.isVisible())); Var.add(String.valueOf(play.getX())); Var.add(String.valueOf(play.getY())); Var.add(String.valueOf(Man)); //当前记录添加到集合(用于悔棋) Var.add(String.valueOf(playTake.isVisible())); Var.add(String.valueOf(playTake.getX())); Var.add(String.valueOf(playTake.getY())); Var.add(String.valueOf(i)); playTake.setVisible(false); play.setBounds(playTake.getX(),playTake.getY(),55,55); } }//士、仕吃棋规则结束
标签:
原文地址:http://www.cnblogs.com/JohnCena/p/5527313.html