Skip to content

Commit

Permalink
Merge pull request #148 from jcarolus/feature/duck
Browse files Browse the repository at this point in the history
Feature/duck
  • Loading branch information
jcarolus authored Dec 18, 2022
2 parents 7849c90 + 8504bcb commit 47bd862
Show file tree
Hide file tree
Showing 57 changed files with 1,932 additions and 1,640 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*.apk
*.ap_

app/.cxx/*

# Files for the Dalvik VM
*.dex

Expand All @@ -19,6 +21,7 @@ gen/
native/project/obj/
native/project/jni/chess
native/project/libs/**/*.so
native/project/jni/chess.dSYM/*

# Gradle files
.gradle/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# android-chess :: Chess game for Android
# Chess game for Android


## Objectives
Expand Down
10 changes: 8 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ android {
storeFile file('/Users/jcarolus/Projecten/Chess/android-keystore')
}
}
compileSdkVersion 30
compileSdkVersion 31
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "jwtc.android.chess"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 31
}
buildTypes {
release {
Expand All @@ -31,6 +31,12 @@ android {
dimension "deps"
}
}

externalNativeBuild {
ndkBuild {
path file('../native/project/jni/Android.mk')
}
}
}

dependencies {
Expand Down
Binary file modified app/playStore/release/app-playStore-release.aab
Binary file not shown.
66 changes: 39 additions & 27 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jwtc.android.chess"
android:installLocation="auto"
android:versionCode="175"
android:versionName="9.2.2">
android:versionCode="183"
android:versionName="9.3.1">

<application
android:name="android.app.Application"
android:icon="@drawable/ic_logo"
android:label="@string/app_name"
android:theme="@style/ChessTheme"
android:banner="@drawable/ic_feature">
<service android:name=".ics.ICSServer"></service>
<service android:name=".tools.ImportService"></service>
<service android:name=".ics.ICSServer" android:exported="true"></service>
<service android:name=".tools.ImportService" android:exported="true"></service>
<activity
android:name=".start"
android:label="@string/app_name"
android:theme="@style/ChessStart"
android:configChanges="orientation">
android:configChanges="orientation"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -33,37 +34,42 @@
<activity
android:name=".ChessPreferences"
android:label="@string/globalpreferences"
android:configChanges="orientation">
android:configChanges="orientation"
android:exported="true">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".start" />
</activity>

<activity
android:name=".HtmlActivity"
android:label="@string/app_name_help"
android:configChanges="orientation"></activity>
android:configChanges="orientation"
android:exported="true"></activity>
<activity
android:name=".activities.GlobalPreferencesActivity"
android:label="@string/globalpreferences"
android:configChanges="orientation">
android:configChanges="orientation"
android:exported="true">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".start" />
</activity>
<activity
android:name=".activities.BoardPreferencesActivity"
android:label="@string/globalpreferences"
android:configChanges="orientation">
android:configChanges="orientation"
android:exported="true">
</activity>
<activity
android:name=".activities.GamePreferenceActivity"
android:label="@string/playpreferences"
android:configChanges="orientation"></activity>
android:configChanges="orientation"
android:exported="true"></activity>
<activity
android:name=".play.PlayActivity"
android:label="@string/app_name_play"
android:configChanges="orientation">
android:configChanges="orientation"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
Expand All @@ -90,25 +96,25 @@
<activity
android:name=".setup.SetupActivity"
android:label="@string/app_name_setup"
android:configChanges="orientation">
android:configChanges="orientation"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/x-chess-fen" />
</intent-filter>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".play.PlayActivity" />
</activity>
<activity
android:name=".GamesListActivity"
android:label="@string/app_name_save_games"
android:configChanges="orientation">
android:configChanges="orientation"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
Expand All @@ -119,7 +125,8 @@
<activity
android:name="jwtc.android.chess.puzzle.PuzzleActivity"
android:label="@string/app_name"
android:configChanges="orientation">
android:configChanges="orientation"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
Expand All @@ -130,7 +137,8 @@
<activity
android:name="jwtc.android.chess.practice.PracticeActivity"
android:label="@string/app_name"
android:configChanges="orientation">
android:configChanges="orientation"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
Expand All @@ -143,7 +151,8 @@
android:label="@string/app_name_playonline"
android:screenOrientation="locked"
android:configChanges="orientation"
android:launchMode="singleInstance">
android:launchMode="singleInstance"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
Expand All @@ -154,19 +163,20 @@
<activity
android:name="jwtc.android.chess.ics.ICSPrefs"
android:label="@string/preferences"
android:configChanges="orientation">
android:configChanges="orientation"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ics.ICSClient" />
</activity>
<!-- <service android:name="jwtc.android.chess.ics.ICSService"/> -->
<activity
android:name="jwtc.android.chess.ics.CustomCommands"
android:label="@string/preferences"
android:configChanges="orientation">
android:configChanges="orientation"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
Expand All @@ -177,7 +187,8 @@
<activity
android:name="jwtc.android.chess.tools.AdvancedActivity"
android:label="@string/app_name_pgntools"
android:configChanges="orientation">
android:configChanges="orientation"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
Expand All @@ -188,7 +199,8 @@
<activity
android:name="jwtc.android.chess.tools.ImportActivity"
android:label="@string/app_name_import"
android:configChanges="orientation">
android:configChanges="orientation"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
Expand All @@ -198,15 +210,14 @@
<data android:mimeType="application/x-chess-pgn" />
</intent-filter>
</activity>

<provider
android:name=".helpers.MyPGNProvider"
android:authorities="jwtc.android.chess.helpers.MyPGNProvider"
android:exported="false" />
android:exported="true" />
<provider
android:name=".puzzle.MyPuzzleProvider"
android:authorities="jwtc.android.chess.puzzle.MyPuzzleProvider"
android:exported="false" />
android:exported="true" />
</application>
<supports-screens
android:anyDensity="true"
Expand All @@ -220,4 +231,5 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-feature android:name="android.software.leanback" android:required="false" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ abstract public class ChessBoardActivity extends BaseActivity implements GameLis
private String keyboardBuffer = "";

public boolean requestMove(final int from, final int to) {
if (jni.pieceAt(BoardConstants.WHITE, from) == BoardConstants.PAWN &&
if (jni.getDuckPos() == from) {
return gameApi.requestDuckMove(to);
} else if (jni.pieceAt(BoardConstants.WHITE, from) == BoardConstants.PAWN &&
BoardMembers.ROW_TURN[BoardConstants.WHITE][from] == 6 &&
BoardMembers.ROW_TURN[BoardConstants.WHITE][to] == 7
||
Expand Down Expand Up @@ -114,7 +116,7 @@ public void onClick(DialogInterface dialog, int item) {

@Override
public void OnMove(int move) {
Log.d(TAG, "OnMove " + move);
Log.d(TAG, "OnMove " + Move.toDbgString(move));
lastPosition = -1;

rebuildBoard();
Expand All @@ -133,6 +135,13 @@ public void OnMove(int move) {
}
}

@Override
public void OnDuckMove(int duckMove) {
Log.d(TAG, "OnDuckMove " + Pos.toString(duckMove));
lastPosition = -1;

rebuildBoard();
}


@Override
Expand Down Expand Up @@ -252,6 +261,7 @@ public void rebuildBoard() {

final int state = jni.getState();
final int turn = jni.getTurn();
final int duckPos = jni.getDuckPos();

// ⚑ ✓ ½
String labelForWhiteKing = null;
Expand Down Expand Up @@ -283,7 +293,7 @@ public void rebuildBoard() {

for (int i = 0; i < 64; i++) {
int color = ChessBoard.BLACK;
int piece = jni.pieceAt(color, i);
int piece = i == duckPos ? BoardConstants.DUCK : jni.pieceAt(color, i);
if (piece == BoardConstants.FIELD) {
color = ChessBoard.WHITE;
piece = jni.pieceAt(color, i);
Expand Down
13 changes: 9 additions & 4 deletions app/src/main/java/jwtc/android/chess/engine/EngineApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

import java.util.ArrayList;

import jwtc.chess.Move;
import jwtc.chess.Pos;

public abstract class EngineApi {
private static final String TAG = "EngineApi";

Expand All @@ -26,14 +29,15 @@ public abstract class EngineApi {
public void handleMessage(Message msg) {
if (msg.what == MSG_MOVE) {
int move = msg.getData().getInt("move");
Log.d(TAG, "handleMessage MOVE " + move);
int duckMove = msg.getData().getInt("duckMove");
Log.d(TAG, "handleMessage MOVE " + Move.toDbgString(move) + " :: " + Pos.toString(duckMove));
for (EngineListener listener: listeners) {
listener.OnEngineMove(move);
listener.OnEngineMove(move, duckMove);
}

} else if (msg.what == MSG_INFO) {
String message = msg.getData().getString("message");
Log.d(TAG, "handleMessage INFO " + message);
// Log.d(TAG, "handleMessage INFO " + message);
for (EngineListener listener: listeners) {
listener.OnEngineInfo(message);
}
Expand All @@ -55,10 +59,11 @@ public void sendMessageFromThread(String sText) {
updateHandler.sendMessage(m);
}

public void sendMoveMessageFromThread(int move) {
public void sendMoveMessageFromThread(int move, int duckMove) {
Message m = new Message();
Bundle b = new Bundle();
b.putInt("move", move);
b.putInt("duckMove", duckMove);
m.what = MSG_MOVE;
m.setData(b);
updateHandler.sendMessage(m);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jwtc.android.chess.engine;

public interface EngineListener {
void OnEngineMove(int move);
void OnEngineMove(int move, int duckMove);
void OnEngineInfo(String message);
void OnEngineStarted();
void OnEngineAborted();
Expand Down
Loading

0 comments on commit 47bd862

Please sign in to comment.