|
|
@@ -7,6 +7,7 @@
|
|
|
//#include <dolphin/dolphin.h>
|
|
|
#include <string.h>
|
|
|
//#include "flipchess_icons.h"
|
|
|
+#include "../helpers/flipchess_voice.h"
|
|
|
#include "../helpers/flipchess_haptic.h"
|
|
|
|
|
|
#define SCL_960_CASTLING 0 // setting to 1 compiles a 960 version of smolchess
|
|
|
@@ -161,7 +162,7 @@ void flipchess_drawBoard(FlipChessScene1Model* model) {
|
|
|
|
|
|
uint8_t flipchess_turn(FlipChessScene1Model* model) {
|
|
|
// 0: none, 1: player, 2: AI, 3: undo
|
|
|
- uint8_t moveType = 0;
|
|
|
+ uint8_t moveType = FlipChessStatusNone;
|
|
|
|
|
|
// if(model->paramInfo) {
|
|
|
|
|
|
@@ -207,7 +208,7 @@ uint8_t flipchess_turn(FlipChessScene1Model* model) {
|
|
|
// }
|
|
|
|
|
|
if(model->game.state != SCL_GAME_STATE_PLAYING) {
|
|
|
- model->paramExit = FlipChessStatusReturn;
|
|
|
+ model->paramExit = FlipChessStatusNone;
|
|
|
return model->paramExit;
|
|
|
}
|
|
|
|
|
|
@@ -215,7 +216,7 @@ uint8_t flipchess_turn(FlipChessScene1Model* model) {
|
|
|
|
|
|
if(flipchess_isPlayerTurn(model)) {
|
|
|
// if(stringsEqual(string, "undo", 5))
|
|
|
- // moveType = 3;
|
|
|
+ // moveType = FlipChessStatusMoveUndo;
|
|
|
// else if(stringsEqual(string, "quit", 5))
|
|
|
// break;
|
|
|
|
|
|
@@ -237,7 +238,7 @@ uint8_t flipchess_turn(FlipChessScene1Model* model) {
|
|
|
}
|
|
|
} else if(model->turnState == 2) {
|
|
|
if(SCL_squareSetContains(model->moveHighlight, model->squareTo)) {
|
|
|
- moveType = 1;
|
|
|
+ moveType = FlipChessStatusMovePlayer;
|
|
|
}
|
|
|
model->turnState = 0;
|
|
|
SCL_squareSetClear(model->moveHighlight);
|
|
|
@@ -247,11 +248,11 @@ uint8_t flipchess_turn(FlipChessScene1Model* model) {
|
|
|
model->squareSelected = 255;
|
|
|
flipchess_makeAIMove(
|
|
|
model->game.board, &(model->squareFrom), &(model->squareTo), &movePromote, model);
|
|
|
- moveType = 2;
|
|
|
+ moveType = FlipChessStatusMoveAI;
|
|
|
model->turnState = 0;
|
|
|
}
|
|
|
|
|
|
- if(moveType == 1 || moveType == 2) {
|
|
|
+ if(moveType == FlipChessStatusMovePlayer || moveType == FlipChessStatusMoveAI) {
|
|
|
flipchess_shiftMessages(model);
|
|
|
|
|
|
SCL_moveToString(
|
|
|
@@ -262,7 +263,7 @@ uint8_t flipchess_turn(FlipChessScene1Model* model) {
|
|
|
SCL_squareSetClear(model->moveHighlight);
|
|
|
SCL_squareSetAdd(model->moveHighlight, model->squareFrom);
|
|
|
SCL_squareSetAdd(model->moveHighlight, model->squareTo);
|
|
|
- } else if(moveType == 3) {
|
|
|
+ } else if(moveType == FlipChessStatusMoveUndo) {
|
|
|
flipchess_shiftMessages(model);
|
|
|
|
|
|
if(model->paramPlayerW != 0 || model->paramPlayerB != 0) SCL_gameUndoMove(&(model->game));
|
|
|
@@ -381,7 +382,7 @@ static int flipchess_scene_1_model_init(
|
|
|
model->paramMoves = 0;
|
|
|
model->paramInfo = 1;
|
|
|
model->paramFlipBoard = 0;
|
|
|
- model->paramExit = FlipChessStatusSuccess;
|
|
|
+ model->paramExit = FlipChessStatusNone;
|
|
|
model->paramStep = 0;
|
|
|
model->paramFEN = import_game_text;
|
|
|
model->paramPGN = NULL;
|
|
|
@@ -484,7 +485,7 @@ static int flipchess_scene_1_model_init(
|
|
|
model->msg = (SCL_boardWhitesTurn(model->game.board) ? "white to move" : "black to move");
|
|
|
|
|
|
// 0 = success
|
|
|
- return FlipChessStatusSuccess;
|
|
|
+ return FlipChessStatusNone;
|
|
|
}
|
|
|
|
|
|
bool flipchess_scene_1_input(InputEvent* event, void* context) {
|
|
|
@@ -586,7 +587,10 @@ bool flipchess_scene_1_input(InputEvent* event, void* context) {
|
|
|
FlipChessScene1Model * model,
|
|
|
{
|
|
|
// first turn of round, probably player but could be AI
|
|
|
- flipchess_turn(model);
|
|
|
+ if(flipchess_turn(model) == FlipChessStatusReturn) {
|
|
|
+ if(app->sound == 1) flipchess_voice_a_strange_game();
|
|
|
+ flipchess_play_long_bump(app);
|
|
|
+ }
|
|
|
SCL_boardToFEN(model->game.board, app->import_game_text);
|
|
|
app->import_game = 1;
|
|
|
flipchess_drawBoard(model);
|
|
|
@@ -610,7 +614,10 @@ bool flipchess_scene_1_input(InputEvent* event, void* context) {
|
|
|
{
|
|
|
// if player played, let AI play
|
|
|
if(!flipchess_isPlayerTurn(model)) {
|
|
|
- flipchess_turn(model);
|
|
|
+ if(flipchess_turn(model) == FlipChessStatusReturn) {
|
|
|
+ if(app->sound == 1) flipchess_voice_a_strange_game();
|
|
|
+ flipchess_play_long_bump(app);
|
|
|
+ }
|
|
|
SCL_boardToFEN(model->game.board, app->import_game_text);
|
|
|
app->import_game = 1;
|
|
|
flipchess_drawBoard(model);
|
|
|
@@ -653,8 +660,7 @@ void flipchess_scene_1_enter(void* context) {
|
|
|
int init = flipchess_scene_1_model_init(
|
|
|
model, app->white_mode, app->black_mode, import_game_text);
|
|
|
|
|
|
- // nonzero status
|
|
|
- if(init == FlipChessStatusSuccess) {
|
|
|
+ if(init == FlipChessStatusNone) {
|
|
|
// perform initial turn, sets up and lets white
|
|
|
// AI play if applicable
|
|
|
const uint8_t turn = flipchess_turn(model);
|