package lyj.chess.main; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JLabel; import javax.swing.JPanel; public class MyAdpater extends MouseAdapter { JPanel jpl = null; boolean gameStatus = true; int[][] chess; int count = 0; int chessType; GameContorler who = new GameContorler(); JLabel jbs; int status = 1; BrainPower bn=new BrainPower(); public MyAdpater() { } public void setGameStatus(boolean gameStatus) { this.gameStatus = gameStatus; } public MyAdpater(JPanel jpl, int[][] chess, JLabel jbs) { this.jbs = jbs; this.jpl = jpl; this.chess = chess; bn.setComputeType(ChessHelper.BLACK_CHESS); } public void setChessType(int chessType) { this.chessType = chessType; } @Override public void mouseClicked(MouseEvent e) { if (gameStatus) { int x = (int) e.getPoint().getX(); int y = (int) e.getPoint().getY(); int x1 = (x - 50) % 30; int y1 = (y - 50) % 30; int x2 = (x - 50) / 30; int y2 = (y - 50) / 30; int row = (x1 >= 15) ? x2 + 1 : x2; int column = (y1 >= 15) ? y2 + 1 : y2; if (row >= 0 && row < 15 && column >= 0 && column < 15) { if (chess[column][row] != 0) { return; } chessType = ChessHelper.WHITE_CHESS; chess[column][row] = chessType; Integer[] point = bn.getAction(chess); if (null != point && point.length > 0) { chess[point[0]][point[1]] = bn.getComputeType(); } else if (null == point || point.length == 0) { point = bn.randomChesss(column, row,chess); chess[point[0]][point[1]] = bn.getComputeType(); } int compute = (chessType != ChessHelper.WHITE_CHESS) ? ChessHelper.WHITE_CHESS : ChessHelper.BLACK_CHESS; boolean com = false; if (point != null) { com = who.acrossLine(chess, point[1], point[0], compute, 5) || who.rightBias(chess, point[1], point[0], compute, 5) || who.leftBais(chess, point[1], point[0], compute, 5) || who.upRightLine(chess, point[1], point[0], compute, 5); } boolean play = who.acrossLine(chess, row, column, chessType, 5) || who.rightBias(chess, row, column, chessType, 5) || who.leftBais(chess, row, column, chessType, 5) || who.upRightLine(chess, row, column, chessType, 5); if (com) { jbs.setText("你输了"); setGameStatus(false); } if (play) { jbs.setText("你赢了"); setGameStatus(false); } jpl.repaint(); } } } public boolean isGameStatus() { return gameStatus; } }

gzryue LV6
2023年4月23日
刘鹏yyds LV10
2022年12月20日
123aa21a LV5
2021年6月23日
蔡 LV10
2021年6月12日
小小鹿lu LV1
2021年5月19日
ds0420 LV4
2021年1月4日
Care269031877 LV4
2020年12月18日
lxp66666 LV1
2020年12月6日
3159792465 LV10
2020年10月14日
dengge123 LV14
2020年9月2日

yzhsnjdn LV1
2024年12月17日
20201202038
2024年3月27日
暂无贡献等级
周俊杰 LV1
2023年12月25日
46562026
2023年12月22日
暂无贡献等级
2386136609 LV1
2023年12月17日
qq1434100519 LV1
2023年11月1日
wangjialiang1 LV17
2023年8月20日
2385649653 LV7
2023年6月26日
陈小灏 LV18
2023年6月5日
gzryue LV6
2023年4月23日