Loading README.md +1 −1 Changes for README.md: 1 added line, 1 removed line. Original line number Diff line number Diff line # BugChess *** BugChess是在椰树集团精神下开创的一个鲜榨项目,是一次探索与定义下一代翻棋游戏的伟大尝试 BugChess是一个在椰树精神的指导下开创的一个鲜榨项目,是一次探索与定义下一代翻棋游戏的伟大尝试 *** ## 项目配置 Loading src/chessComponent/ChessComponent.java +45 −5 Changes for src/chessComponent/ChessComponent.java: 45 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package chessComponent; import controller.ClickController; import model.ChessColor; import model.ChessType; import model.ChessboardPoint; import java.awt.*; Loading @@ -10,13 +11,51 @@ import java.awt.*; * 表示棋盘上非空棋子的格子,是所有非空棋子的父类 */ public class ChessComponent extends SquareComponent { protected String name;// 棋子名字:例如 兵,卒,士等 protected final ChessColor chessColor; protected final ChessType chessType; protected boolean alive; protected ChessComponent(ChessboardPoint chessboardPoint, Point location, ChessColor chessColor, ClickController clickController, int size) { super(chessboardPoint, location, chessColor, clickController, size); ChessColor chessColor, ChessType chessType, ClickController clickController, int size) { super(chessboardPoint, location, clickController, size); this.chessColor = chessColor; this.chessType = chessType; this.alive = true; } public ChessColor getChessColor() { return chessColor; } public ChessType getChessType() { return chessType; } public boolean isAlive() { return alive; } public void kill(){ this.alive = false; } //TODO: complete deduce public static String deduceChessName(ChessColor chessColor, ChessType chessType) { switch (chessColor) { case RED -> switch (chessType) { case GENERAL -> '帅'; case ADVISOR -> '士'; } case BLACK -> } } private String deduceChessName() { return deduceChessName(this.chessColor, this.chessType); } // public ChessComponent(){} @Override protected void paintComponent(Graphics g) { Loading @@ -32,7 +71,7 @@ public class ChessComponent extends SquareComponent{ //绘制棋子文字 g.setColor(this.getChessColor().getColor()); g.setFont(CHESS_FONT); g.drawString(this.name, this.getWidth() / 4, this.getHeight() * 2 / 3); g.drawString(this.deduceChessName(), this.getWidth() / 4, this.getHeight() * 2 / 3); //绘制棋子被选中时状态 if (isSelected()) { Loading @@ -43,4 +82,5 @@ public class ChessComponent extends SquareComponent{ } } } } src/chessComponent/EmptySlotComponent.java +1 −0 Changes for src/chessComponent/EmptySlotComponent.java: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package chessComponent; import controller.ClickController; import model.ChessColor; import model.ChessType; import model.ChessboardPoint; import java.awt.*; Loading src/chessComponent/SquareComponent.java +2 −7 Changes for src/chessComponent/SquareComponent.java: 2 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ public abstract class SquareComponent extends JComponent { * selected: 表示这个棋子是否被选中 */ private ChessboardPoint chessboardPoint; protected final ChessColor chessColor; protected boolean isReversal; private boolean selected; Loading @@ -36,12 +36,11 @@ public abstract class SquareComponent extends JComponent { */ private final ClickController clickController; protected SquareComponent(ChessboardPoint chessboardPoint, Point location, ChessColor chessColor, ClickController clickController, int size) { protected SquareComponent(ChessboardPoint chessboardPoint, Point location, ClickController clickController, int size) { enableEvents(AWTEvent.MOUSE_EVENT_MASK); setLocation(location); setSize(size, size); this.chessboardPoint = chessboardPoint; this.chessColor = chessColor; this.selected = false; this.clickController = clickController; this.isReversal = false; Loading Loading @@ -69,10 +68,6 @@ public abstract class SquareComponent extends JComponent { this.chessboardPoint = chessboardPoint; } public ChessColor getChessColor() { return chessColor; } public boolean isSelected() { return selected; } Loading src/controller/ClickController.java +10 −7 Changes for src/controller/ClickController.java: 10 added lines, 7 removed lines. Original line number Diff line number Diff line package controller; import chessComponent.SquareComponent; import chessComponent.ChessComponent; import chessComponent.EmptySlotComponent; import chessComponent.SquareComponent; import model.ChessColor; import view.ChessGameFrame; import view.Chessboard; Loading Loading @@ -47,14 +48,17 @@ public class ClickController { */ private boolean handleFirst(SquareComponent squareComponent) { if (!squareComponent.isReversal()) { squareComponent.setReversal(true); System.out.printf("onClick to reverse a chess [%d,%d]\n", squareComponent.getChessboardPoint().getX(), squareComponent.getChessboardPoint().getY()); squareComponent.repaint(); if (!(squareComponent instanceof ChessComponent chessComponent)) { return false; } if (!chessComponent.isReversal()) { chessComponent.setReversal(true); System.out.printf("onClick to reverse a chess [%d,%d]\n", chessComponent.getChessboardPoint().getX(), chessComponent.getChessboardPoint().getY()); chessComponent.repaint(); chessboard.clickController.swapPlayer(); return false; } return squareComponent.getChessColor() == chessboard.getCurrentColor(); return chessComponent.getChessColor() == chessboard.getCurrentColor(); } /** Loading @@ -63,7 +67,6 @@ public class ClickController { */ private boolean handleSecond(SquareComponent squareComponent) { //没翻开或空棋子,进入if if (!squareComponent.isReversal()) { //没翻开且非空棋子不能走 Loading Loading
README.md +1 −1 Changes for README.md: 1 added line, 1 removed line. Original line number Diff line number Diff line # BugChess *** BugChess是在椰树集团精神下开创的一个鲜榨项目,是一次探索与定义下一代翻棋游戏的伟大尝试 BugChess是一个在椰树精神的指导下开创的一个鲜榨项目,是一次探索与定义下一代翻棋游戏的伟大尝试 *** ## 项目配置 Loading
src/chessComponent/ChessComponent.java +45 −5 Changes for src/chessComponent/ChessComponent.java: 45 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package chessComponent; import controller.ClickController; import model.ChessColor; import model.ChessType; import model.ChessboardPoint; import java.awt.*; Loading @@ -10,13 +11,51 @@ import java.awt.*; * 表示棋盘上非空棋子的格子,是所有非空棋子的父类 */ public class ChessComponent extends SquareComponent { protected String name;// 棋子名字:例如 兵,卒,士等 protected final ChessColor chessColor; protected final ChessType chessType; protected boolean alive; protected ChessComponent(ChessboardPoint chessboardPoint, Point location, ChessColor chessColor, ClickController clickController, int size) { super(chessboardPoint, location, chessColor, clickController, size); ChessColor chessColor, ChessType chessType, ClickController clickController, int size) { super(chessboardPoint, location, clickController, size); this.chessColor = chessColor; this.chessType = chessType; this.alive = true; } public ChessColor getChessColor() { return chessColor; } public ChessType getChessType() { return chessType; } public boolean isAlive() { return alive; } public void kill(){ this.alive = false; } //TODO: complete deduce public static String deduceChessName(ChessColor chessColor, ChessType chessType) { switch (chessColor) { case RED -> switch (chessType) { case GENERAL -> '帅'; case ADVISOR -> '士'; } case BLACK -> } } private String deduceChessName() { return deduceChessName(this.chessColor, this.chessType); } // public ChessComponent(){} @Override protected void paintComponent(Graphics g) { Loading @@ -32,7 +71,7 @@ public class ChessComponent extends SquareComponent{ //绘制棋子文字 g.setColor(this.getChessColor().getColor()); g.setFont(CHESS_FONT); g.drawString(this.name, this.getWidth() / 4, this.getHeight() * 2 / 3); g.drawString(this.deduceChessName(), this.getWidth() / 4, this.getHeight() * 2 / 3); //绘制棋子被选中时状态 if (isSelected()) { Loading @@ -43,4 +82,5 @@ public class ChessComponent extends SquareComponent{ } } } }
src/chessComponent/EmptySlotComponent.java +1 −0 Changes for src/chessComponent/EmptySlotComponent.java: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package chessComponent; import controller.ClickController; import model.ChessColor; import model.ChessType; import model.ChessboardPoint; import java.awt.*; Loading
src/chessComponent/SquareComponent.java +2 −7 Changes for src/chessComponent/SquareComponent.java: 2 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ public abstract class SquareComponent extends JComponent { * selected: 表示这个棋子是否被选中 */ private ChessboardPoint chessboardPoint; protected final ChessColor chessColor; protected boolean isReversal; private boolean selected; Loading @@ -36,12 +36,11 @@ public abstract class SquareComponent extends JComponent { */ private final ClickController clickController; protected SquareComponent(ChessboardPoint chessboardPoint, Point location, ChessColor chessColor, ClickController clickController, int size) { protected SquareComponent(ChessboardPoint chessboardPoint, Point location, ClickController clickController, int size) { enableEvents(AWTEvent.MOUSE_EVENT_MASK); setLocation(location); setSize(size, size); this.chessboardPoint = chessboardPoint; this.chessColor = chessColor; this.selected = false; this.clickController = clickController; this.isReversal = false; Loading Loading @@ -69,10 +68,6 @@ public abstract class SquareComponent extends JComponent { this.chessboardPoint = chessboardPoint; } public ChessColor getChessColor() { return chessColor; } public boolean isSelected() { return selected; } Loading
src/controller/ClickController.java +10 −7 Changes for src/controller/ClickController.java: 10 added lines, 7 removed lines. Original line number Diff line number Diff line package controller; import chessComponent.SquareComponent; import chessComponent.ChessComponent; import chessComponent.EmptySlotComponent; import chessComponent.SquareComponent; import model.ChessColor; import view.ChessGameFrame; import view.Chessboard; Loading Loading @@ -47,14 +48,17 @@ public class ClickController { */ private boolean handleFirst(SquareComponent squareComponent) { if (!squareComponent.isReversal()) { squareComponent.setReversal(true); System.out.printf("onClick to reverse a chess [%d,%d]\n", squareComponent.getChessboardPoint().getX(), squareComponent.getChessboardPoint().getY()); squareComponent.repaint(); if (!(squareComponent instanceof ChessComponent chessComponent)) { return false; } if (!chessComponent.isReversal()) { chessComponent.setReversal(true); System.out.printf("onClick to reverse a chess [%d,%d]\n", chessComponent.getChessboardPoint().getX(), chessComponent.getChessboardPoint().getY()); chessComponent.repaint(); chessboard.clickController.swapPlayer(); return false; } return squareComponent.getChessColor() == chessboard.getCurrentColor(); return chessComponent.getChessColor() == chessboard.getCurrentColor(); } /** Loading @@ -63,7 +67,6 @@ public class ClickController { */ private boolean handleSecond(SquareComponent squareComponent) { //没翻开或空棋子,进入if if (!squareComponent.isReversal()) { //没翻开且非空棋子不能走 Loading