Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
Calcitem | a6b87e3819 |
|
@ -22,6 +22,7 @@ enum EngineType {
|
||||||
humanVsAi,
|
humanVsAi,
|
||||||
humanVsHuman,
|
humanVsHuman,
|
||||||
aiVsAi,
|
aiVsAi,
|
||||||
|
setPosition,
|
||||||
humanVsCloud, // Not Implemented
|
humanVsCloud, // Not Implemented
|
||||||
humanVsLAN, // Not Implemented
|
humanVsLAN, // Not Implemented
|
||||||
testViaLAN, // Not Implemented
|
testViaLAN, // Not Implemented
|
||||||
|
|
|
@ -32,6 +32,10 @@
|
||||||
"@aiVsAi": {
|
"@aiVsAi": {
|
||||||
"description": "AI Vs AI"
|
"description": "AI Vs AI"
|
||||||
},
|
},
|
||||||
|
"setPosition": "Position Setzen",
|
||||||
|
"@setPosition": {
|
||||||
|
"description": "Set Position"
|
||||||
|
},
|
||||||
"humanVsCloud": "Mensch gegen Cloud",
|
"humanVsCloud": "Mensch gegen Cloud",
|
||||||
"@humanVsCloud": {
|
"@humanVsCloud": {
|
||||||
"description": "Human Vs Cloud"
|
"description": "Human Vs Cloud"
|
||||||
|
|
|
@ -32,6 +32,10 @@
|
||||||
"@aiVsAi": {
|
"@aiVsAi": {
|
||||||
"description": "AI Vs AI"
|
"description": "AI Vs AI"
|
||||||
},
|
},
|
||||||
|
"setPosition": "Set Position",
|
||||||
|
"@setPosition": {
|
||||||
|
"description": "Set Position"
|
||||||
|
},
|
||||||
"humanVsCloud": "Human Vs Cloud",
|
"humanVsCloud": "Human Vs Cloud",
|
||||||
"@humanVsCloud": {
|
"@humanVsCloud": {
|
||||||
"description": "Human Vs Cloud"
|
"description": "Human Vs Cloud"
|
||||||
|
|
|
@ -32,6 +32,10 @@
|
||||||
"@aiVsAi": {
|
"@aiVsAi": {
|
||||||
"description": "AI Vs AI"
|
"description": "AI Vs AI"
|
||||||
},
|
},
|
||||||
|
"setPosition": "مکان را ویرایش کنید",
|
||||||
|
"@setPosition": {
|
||||||
|
"description": "Set Position"
|
||||||
|
},
|
||||||
"humanVsCloud": "Human Vs Cloud",
|
"humanVsCloud": "Human Vs Cloud",
|
||||||
"@humanVsCloud": {
|
"@humanVsCloud": {
|
||||||
"description": "Human Vs Cloud"
|
"description": "Human Vs Cloud"
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
"humanVsAi": "人机对战",
|
"humanVsAi": "人机对战",
|
||||||
"humanVsHuman": "双人对战",
|
"humanVsHuman": "双人对战",
|
||||||
"aiVsAi": "机器对战",
|
"aiVsAi": "机器对战",
|
||||||
|
"setPosition": "编辑局面",
|
||||||
"humanVsCloud": "挑战云端",
|
"humanVsCloud": "挑战云端",
|
||||||
"humanVsLAN": "联网对战",
|
"humanVsLAN": "联网对战",
|
||||||
"testViaLAN": "联网测试",
|
"testViaLAN": "联网测试",
|
||||||
|
|
|
@ -99,6 +99,7 @@ class Game {
|
||||||
isAi[PieceColor.black] = !Config.aiMovesFirst;
|
isAi[PieceColor.black] = !Config.aiMovesFirst;
|
||||||
break;
|
break;
|
||||||
case EngineType.humanVsHuman:
|
case EngineType.humanVsHuman:
|
||||||
|
case EngineType.setPosition:
|
||||||
case EngineType.humanVsLAN:
|
case EngineType.humanVsLAN:
|
||||||
case EngineType.humanVsCloud:
|
case EngineType.humanVsCloud:
|
||||||
isAi[PieceColor.white] = isAi[PieceColor.black] = false;
|
isAi[PieceColor.white] = isAi[PieceColor.black] = false;
|
||||||
|
|
|
@ -455,6 +455,48 @@ class Position {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool putPiece2(int s, String pt) {
|
||||||
|
var piece = pt;
|
||||||
|
var us = pt;
|
||||||
|
|
||||||
|
if (!(sqBegin <= s && s < sqEnd) || board[s] != Piece.noPiece) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pieceOnBoardCount[us] != null) {
|
||||||
|
if (pieceOnBoardCount[us]! + 1 > rule.piecesCount) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
pieceOnBoardCount[us] = pieceOnBoardCount[us]! + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pieceInHandCount[us] != null) {
|
||||||
|
pieceInHandCount[us] = pieceInHandCount[us]! - 1;
|
||||||
|
|
||||||
|
if (pieceInHandCount[us]! < 0) {
|
||||||
|
pieceInHandCount[us] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Need?
|
||||||
|
if (phase == Phase.ready) {
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
|
||||||
|
_grid[squareToIndex[s]!] = piece;
|
||||||
|
board[s] = piece;
|
||||||
|
|
||||||
|
record = "(" + fileOf(s).toString() + "," + rankOf(s).toString() + ")";
|
||||||
|
|
||||||
|
updateKey(s);
|
||||||
|
|
||||||
|
// TODO: need?
|
||||||
|
currentSquare = s;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool putPiece(int s) {
|
bool putPiece(int s) {
|
||||||
var piece = Piece.noPiece;
|
var piece = Piece.noPiece;
|
||||||
var us = _sideToMove;
|
var us = _sideToMove;
|
||||||
|
|
|
@ -73,6 +73,8 @@ class _GamePageState extends State<GamePage>
|
||||||
late Animation animation;
|
late Animation animation;
|
||||||
bool disposed = false;
|
bool disposed = false;
|
||||||
bool ltr = true;
|
bool ltr = true;
|
||||||
|
var setPositionPieceColor = PieceColor.white;
|
||||||
|
var pieceColorIcon = Icons.looks_one_outlined;
|
||||||
final String tag = "[game_page]";
|
final String tag = "[game_page]";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -209,7 +211,8 @@ class _GamePageState extends State<GamePage>
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// WAR: Fix first tap response slow when piece count changed
|
// WAR: Fix first tap response slow when piece count changed
|
||||||
if (position.phase == Phase.placing &&
|
if (Game.instance.engineType != EngineType.setPosition &&
|
||||||
|
position.phase == Phase.placing &&
|
||||||
position.pieceOnBoardCount[PieceColor.white] == 0 &&
|
position.pieceOnBoardCount[PieceColor.white] == 0 &&
|
||||||
position.pieceOnBoardCount[PieceColor.black] == 0) {
|
position.pieceOnBoardCount[PieceColor.black] == 0) {
|
||||||
Game.instance.newGame();
|
Game.instance.newGame();
|
||||||
|
@ -231,6 +234,13 @@ class _GamePageState extends State<GamePage>
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setPosition
|
||||||
|
if (Game.instance.engineType == EngineType.setPosition) {
|
||||||
|
print(
|
||||||
|
"$tag Engine type is set position. Put $setPositionPieceColor on $sq.");
|
||||||
|
return position.putPiece2(sq, setPositionPieceColor);
|
||||||
|
}
|
||||||
|
|
||||||
if (position.phase == Phase.ready) {
|
if (position.phase == Phase.ready) {
|
||||||
Game.instance.start();
|
Game.instance.start();
|
||||||
}
|
}
|
||||||
|
@ -1167,6 +1177,7 @@ class _GamePageState extends State<GamePage>
|
||||||
EngineType.humanVsAi: Config.aiMovesFirst ? Icons.computer : Icons.person,
|
EngineType.humanVsAi: Config.aiMovesFirst ? Icons.computer : Icons.person,
|
||||||
EngineType.humanVsHuman: Icons.person,
|
EngineType.humanVsHuman: Icons.person,
|
||||||
EngineType.aiVsAi: Icons.computer,
|
EngineType.aiVsAi: Icons.computer,
|
||||||
|
EngineType.setPosition: Icons.add_circle,
|
||||||
EngineType.humanVsCloud: Icons.person,
|
EngineType.humanVsCloud: Icons.person,
|
||||||
EngineType.humanVsLAN: Icons.person,
|
EngineType.humanVsLAN: Icons.person,
|
||||||
EngineType.testViaLAN: Icons.cast,
|
EngineType.testViaLAN: Icons.cast,
|
||||||
|
@ -1176,6 +1187,7 @@ class _GamePageState extends State<GamePage>
|
||||||
EngineType.humanVsAi: Config.aiMovesFirst ? Icons.person : Icons.computer,
|
EngineType.humanVsAi: Config.aiMovesFirst ? Icons.person : Icons.computer,
|
||||||
EngineType.humanVsHuman: Icons.person,
|
EngineType.humanVsHuman: Icons.person,
|
||||||
EngineType.aiVsAi: Icons.computer,
|
EngineType.aiVsAi: Icons.computer,
|
||||||
|
EngineType.setPosition: Icons.add_circle_outline,
|
||||||
EngineType.humanVsCloud: Icons.cloud,
|
EngineType.humanVsCloud: Icons.cloud,
|
||||||
EngineType.humanVsLAN: Icons.cast,
|
EngineType.humanVsLAN: Icons.cast,
|
||||||
EngineType.testViaLAN: Icons.cast,
|
EngineType.testViaLAN: Icons.cast,
|
||||||
|
@ -1490,6 +1502,109 @@ class _GamePageState extends State<GamePage>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget createSetPositionToolbar() {
|
||||||
|
var pieceColor = "White";
|
||||||
|
var phase = "Moving";
|
||||||
|
|
||||||
|
if (setPositionPieceColor == PieceColor.white) {
|
||||||
|
pieceColorIcon = Icons.looks_one_outlined;
|
||||||
|
} else if (setPositionPieceColor == PieceColor.black) {
|
||||||
|
pieceColorIcon = Icons.looks_two_outlined;
|
||||||
|
} else if (setPositionPieceColor == PieceColor.ban) {
|
||||||
|
pieceColorIcon = Icons.cancel_outlined;
|
||||||
|
}
|
||||||
|
|
||||||
|
var setPieceColorButton = TextButton(
|
||||||
|
child: Column(
|
||||||
|
// Replace with a Row for horizontal icon + text
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
pieceColorIcon,
|
||||||
|
color: AppTheme.toolbarIconColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onPressed: () => onSetPieceColorButtonPressed(),
|
||||||
|
);
|
||||||
|
|
||||||
|
var setPhaseButton = TextButton(
|
||||||
|
child: Column(
|
||||||
|
// Replace with a Row for horizontal icon + text
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Game.instance.position.phase == Phase.moving
|
||||||
|
? Icons.swipe
|
||||||
|
: Icons.touch_app,
|
||||||
|
color: AppTheme.toolbarIconColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onPressed: () => onTakeBackButtonPressed(pop: false),
|
||||||
|
);
|
||||||
|
|
||||||
|
var undoButton = TextButton(
|
||||||
|
child: Column(
|
||||||
|
// Replace with a Row for horizontal icon + text
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.arrow_back,
|
||||||
|
color: AppTheme.toolbarIconColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onPressed: () => onStepForwardButtonPressed(pop: false),
|
||||||
|
);
|
||||||
|
|
||||||
|
var clearButton = TextButton(
|
||||||
|
child: Column(
|
||||||
|
// Replace with a Row for horizontal icon + text
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.cleaning_services,
|
||||||
|
color: AppTheme.toolbarIconColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onPressed: () => onStepForwardAllButtonPressed(pop: false),
|
||||||
|
);
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
color: Color(Config.boardBackgroundColor),
|
||||||
|
),
|
||||||
|
margin: EdgeInsets.symmetric(horizontal: GamePage.screenPaddingH),
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 2),
|
||||||
|
child: Row(children: <Widget>[
|
||||||
|
Expanded(child: SizedBox()),
|
||||||
|
setPieceColorButton,
|
||||||
|
Expanded(child: SizedBox()),
|
||||||
|
setPhaseButton,
|
||||||
|
Expanded(child: SizedBox()),
|
||||||
|
undoButton,
|
||||||
|
Expanded(child: SizedBox()), //dashboard_outlined
|
||||||
|
clearButton,
|
||||||
|
Expanded(child: SizedBox()),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onSetPieceColorButtonPressed() {
|
||||||
|
if (setPositionPieceColor == PieceColor.white) {
|
||||||
|
setPositionPieceColor = PieceColor.black;
|
||||||
|
} else if (setPositionPieceColor == PieceColor.black) {
|
||||||
|
if (rule.hasBannedLocations) {
|
||||||
|
setPositionPieceColor = PieceColor.ban;
|
||||||
|
} else {
|
||||||
|
setPositionPieceColor = PieceColor.white;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setPositionPieceColor = PieceColor.white;
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
|
@ -1518,6 +1633,7 @@ class _GamePageState extends State<GamePage>
|
||||||
final board = createBoard();
|
final board = createBoard();
|
||||||
final toolbar = createToolbar();
|
final toolbar = createToolbar();
|
||||||
final historyNavToolbar = createHistoryNavigationToolbar();
|
final historyNavToolbar = createHistoryNavigationToolbar();
|
||||||
|
final setPositionToolbar = createSetPositionToolbar();
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Color(Config.darkBackgroundColor),
|
backgroundColor: Color(Config.darkBackgroundColor),
|
||||||
|
@ -1528,7 +1644,9 @@ class _GamePageState extends State<GamePage>
|
||||||
? historyNavToolbar
|
? historyNavToolbar
|
||||||
: SizedBox(height: 0),
|
: SizedBox(height: 0),
|
||||||
SizedBox(height: 1),
|
SizedBox(height: 1),
|
||||||
toolbar,
|
Game.instance.engineType == EngineType.setPosition
|
||||||
|
? setPositionToolbar
|
||||||
|
: toolbar,
|
||||||
]),
|
]),
|
||||||
/*
|
/*
|
||||||
body: Column(children: <Widget>[
|
body: Column(children: <Widget>[
|
||||||
|
|
|
@ -29,6 +29,7 @@ enum DrawerIndex {
|
||||||
humanVsAi,
|
humanVsAi,
|
||||||
humanVsHuman,
|
humanVsHuman,
|
||||||
aiVsAi,
|
aiVsAi,
|
||||||
|
setPosition,
|
||||||
preferences,
|
preferences,
|
||||||
ruleSettings,
|
ruleSettings,
|
||||||
personalization,
|
personalization,
|
||||||
|
@ -88,6 +89,11 @@ class _HomeDrawerState extends State<HomeDrawer> {
|
||||||
title: S.of(context).aiVsAi,
|
title: S.of(context).aiVsAi,
|
||||||
icon: Icon(Icons.computer),
|
icon: Icon(Icons.computer),
|
||||||
),
|
),
|
||||||
|
DrawerListItem(
|
||||||
|
index: DrawerIndex.setPosition,
|
||||||
|
title: S.of(context).setPosition,
|
||||||
|
icon: Icon(Icons.place),
|
||||||
|
),
|
||||||
DrawerListItem(
|
DrawerListItem(
|
||||||
index: DrawerIndex.preferences,
|
index: DrawerIndex.preferences,
|
||||||
title: S.of(context).preferences,
|
title: S.of(context).preferences,
|
||||||
|
|
|
@ -83,6 +83,7 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
|
||||||
DrawerIndex.humanVsAi: EngineType.humanVsAi,
|
DrawerIndex.humanVsAi: EngineType.humanVsAi,
|
||||||
DrawerIndex.humanVsHuman: EngineType.humanVsHuman,
|
DrawerIndex.humanVsHuman: EngineType.humanVsHuman,
|
||||||
DrawerIndex.aiVsAi: EngineType.aiVsAi,
|
DrawerIndex.aiVsAi: EngineType.aiVsAi,
|
||||||
|
DrawerIndex.setPosition: EngineType.setPosition,
|
||||||
};
|
};
|
||||||
|
|
||||||
drawerIndex = index;
|
drawerIndex = index;
|
||||||
|
|
Loading…
Reference in New Issue