Skip to content

Commit a615eee

Browse files
define ColorChar (#110)
* define ColorChar * bump version * enhance shell robust * fix command for linux * mild fix test * use bash * mild fix * analyzer * add comment * mild fix comment * specify shell
1 parent 5a4ef29 commit a615eee

10 files changed

Lines changed: 31 additions & 16 deletions

File tree

.github/workflows/dart_ci.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ jobs:
6464
- uses: dart-lang/setup-dart@v1
6565

6666
- name: build libedax
67+
shell: bash
6768
env:
6869
dst: '.'
6970
libedax_build_command: ${{ matrix.libedax_build_command }}
70-
run: sh scripts/build_libedax.sh
71+
run: ./scripts/build_libedax.sh
7172

7273
- name: output build info
7374
shell: bash

.github/workflows/publish_libedax_assets.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ jobs:
2626
- uses: actions/checkout@v2
2727

2828
- name: build libedax
29+
shell: bash
2930
env:
3031
dst: ${{ env.OUTPUT_DIR }}
3132
libedax_build_command: ${{ matrix.libedax_build_command }}
32-
run: sh scripts/build_libedax.sh
33+
run: ./scripts/build_libedax.sh
3334

3435
- name: output build info
3536
shell: bash

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.7.0
2+
3+
- add const `ColorChar`.
4+
15
# 2.6.0
26

37
- upgrade dependencies

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ packages:
8484
path: ".."
8585
relative: true
8686
source: path
87-
version: "2.6.0"
87+
version: "2.7.0"
8888
meta:
8989
dependency: transitive
9090
description:

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: libedax4dart_example
2-
version: 2.6.0-example
2+
version: 2.7.0-example
33
publish_to: none
44

55
environment:

lib/src/board.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class Board {
5858
///
5959
/// e.g. `-------------------*-------**O----**O*-----O--------------------W`.
6060
String stringApplicableToSetboard(final int currentColor) {
61-
final pStone = currentColor == TurnColor.black ? '*' : 'O';
62-
final oStone = currentColor == TurnColor.black ? 'O' : '*';
61+
final pStone = currentColor == TurnColor.black ? ColorChar.black : ColorChar.white;
62+
final oStone = currentColor == TurnColor.black ? ColorChar.white : ColorChar.black;
6363

6464
final buffer = StringBuffer();
6565
for (var k = 0; k < 8; k++) {
@@ -93,8 +93,8 @@ class Board {
9393
/// 8 - - - - - - - - 8 <br>
9494
/// A B C D E F G H
9595
String prettyString(final int currentColor) {
96-
final pStone = currentColor == TurnColor.black ? '*' : 'O';
97-
final oStone = currentColor == TurnColor.black ? 'O' : '*';
96+
final pStone = currentColor == TurnColor.black ? ColorChar.black : ColorChar.white;
97+
final oStone = currentColor == TurnColor.black ? ColorChar.white : ColorChar.black;
9898

9999
final buffer = StringBuffer()..writeln(' A B C D E F G H');
100100
for (var k = 0; k < 8; k++) {

lib/src/constants.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ class TurnColor {
66
static const white = 1;
77
}
88

9+
/// See: https://github.com/abulmo/edax-reversi/blob/1ae7c9fe5322ac01975f1b3196e788b0d25c1e10/src/board.c#L144-L200
10+
class ColorChar {
11+
/// BLACK char. You can use this for `LibEdax.edaxSetboard`.
12+
static const black = '*';
13+
14+
/// WHITE char. You can use this for `LibEdax.edaxSetboard`.
15+
static const white = 'O';
16+
}
17+
918
class MoveMark {
1019
/// PASS string of BLACK.
1120
///

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# See: https://dart.dev/tools/pub/publishing
22

33
name: libedax4dart
4-
version: 2.6.0
4+
version: 2.7.0
55
description: Dart wrapper for libedax. With using libedax4dart, you can execute functions equivalent to edax.
66
homepage: https://github.com/sensuikan1973/libedax4dart
77
documentation: https://sensuikan1973.github.io/libedax4dart

scripts/build_libedax.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
14
# NOTE: require some environment variables.
25
# libedax_build_command (e.g. make libbuild ARCH=x64-modern COMP=gcc OS=osx)
36
# dst: (e.g. build)
47
#
58
# example:
69
# libedax_build_command="make libbuild ARCH=x64-modern COMP=gcc OS=osx" dst="." ./scripts/build_libedax.sh
710

11+
rm -rf edax-reversi
812
git clone https://github.com/sensuikan1973/edax-reversi
913
cd edax-reversi
1014
git remote update --prune
11-
12-
git checkout .
13-
1415
git switch libedax_sensuikan1973
15-
git pull
1616
git checkout $(cat ../.libedax-version)
1717

1818
mkdir -p data

test/edax_command_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ void main() {
8383
});
8484

8585
test('setBoard', () {
86-
const boardString = '-W----W--------------------WB------WBB-----W--------------------B';
86+
const boardString = '-O----O--------------------O*------O**-----O--------------------B';
8787
final edax = LibEdax()..libedaxInitialize();
8888
sleep(const Duration(seconds: 1));
8989
edax
9090
..edaxInit()
9191
..edaxSetboard(boardString);
92-
expect(edax.edaxGetDisc(TurnColor.white), 'W'.allMatches(boardString).length);
93-
expect(edax.edaxGetDisc(TurnColor.black), 'B'.allMatches(boardString).length - 1);
92+
expect(edax.edaxGetDisc(TurnColor.white), ColorChar.white.allMatches(boardString).length);
93+
expect(edax.edaxGetDisc(TurnColor.black), ColorChar.black.allMatches(boardString).length);
9494
expect(edax.edaxGetCurrentPlayer(), TurnColor.black);
9595
edax.libedaxTerminate();
9696
});

0 commit comments

Comments
 (0)