position.dart 467 B

123456789101112131415161718192021
  1. import 'package:gobang/models/chess.dart';
  2. import 'package:gobang/models/chess_shape.dart';
  3. /// 棋子位置;颜色由享元 [Chess] 共享,形状与坐标为外部状态。
  4. class Position {
  5. double dx;
  6. double dy;
  7. int gridX;
  8. int gridY;
  9. Chess chess;
  10. ChessShape chessShape;
  11. Position(
  12. this.dx,
  13. this.dy,
  14. this.chess, {
  15. this.gridX = 0,
  16. this.gridY = 0,
  17. ChessShape? chessShape,
  18. }) : chessShape = chessShape ?? chess.chessShape;
  19. }