├── res ├── licenses │ ├── this │ ├── modal_progress_hud │ ├── flutter_chess_board │ └── chess ├── drawable │ ├── moo.png │ └── ic_launcher.png ├── chess_board │ ├── brown_board.png │ ├── chess_board.png │ ├── green_board.png │ ├── orange_board.png │ ├── 2.0x │ │ ├── brown_board.png │ │ ├── green_board.png │ │ ├── orange_board.png │ │ └── dark_brown_board.png │ ├── 3.0x │ │ ├── brown_board.png │ │ ├── green_board.png │ │ ├── orange_board.png │ │ └── dark_brown_board.png │ └── dark_brown_board.png └── string │ ├── string_de.json │ └── string_en.json ├── linux ├── .gitignore ├── main.cc ├── flutter │ ├── generated_plugin_registrant.h │ ├── generated_plugin_registrant.cc │ ├── generated_plugins.cmake │ └── CMakeLists.txt ├── my_application.h ├── my_application.cc └── CMakeLists.txt ├── android ├── settings_aar.gradle ├── gradle.properties ├── app │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── drawable │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable-v21 │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── values │ │ │ │ │ └── styles.xml │ │ │ │ └── values-night │ │ │ │ │ └── styles.xml │ │ │ ├── jniLibs │ │ │ │ ├── x86 │ │ │ │ │ └── libtensorflowlite_c.so │ │ │ │ ├── x86_64 │ │ │ │ │ └── libtensorflowlite_c.so │ │ │ │ ├── arm64-v8a │ │ │ │ │ └── libtensorflowlite_c.so │ │ │ │ └── armeabi-v7a │ │ │ │ │ └── libtensorflowlite_c.so │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── lurzapps │ │ │ │ │ └── chess │ │ │ │ │ └── MainActivity.java │ │ │ └── AndroidManifest.xml │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── google-services.json │ └── build.gradle ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle └── build.gradle ├── ios ├── Flutter │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── AppFrameworkInfo.plist ├── Runner │ ├── Runner-Bridging-Header.h │ ├── Assets.xcassets │ │ ├── LaunchImage.imageset │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ ├── README.md │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ └── Contents.json │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ └── Info.plist ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── WorkspaceSettings.xcsettings │ │ └── IDEWorkspaceChecks.plist ├── Runner.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── .gitignore └── GoogleService-Info.plist ├── .firebaserc ├── macos ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── .gitignore ├── Runner │ ├── Configs │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ ├── Warnings.xcconfig │ │ └── AppInfo.xcconfig │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── app_icon_1024.png │ │ │ ├── app_icon_128.png │ │ │ ├── app_icon_16.png │ │ │ ├── app_icon_256.png │ │ │ ├── app_icon_32.png │ │ │ ├── app_icon_512.png │ │ │ ├── app_icon_64.png │ │ │ └── Contents.json │ ├── AppDelegate.swift │ ├── Release.entitlements │ ├── DebugProfile.entitlements │ ├── MainFlutterWindow.swift │ └── Info.plist ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── Runner.xcodeproj │ ├── project.xcworkspace │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ └── xcschemes │ └── Runner.xcscheme ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ └── Icon-512.png ├── manifest.json └── index.html ├── store ├── android │ ├── logo.jpeg │ ├── ic_launcher512.png │ └── screenshots │ │ ├── Screenshot_20201125-224244.jpg │ │ ├── Screenshot_20201125-224304.jpg │ │ ├── Screenshot_20201125-224536.jpg │ │ ├── Screenshot_20201125-224543.jpg │ │ └── Screenshot_20201125-224556.jpg └── windows │ └── ic_launcher.ico ├── windows ├── runner │ ├── resources │ │ └── app_icon.ico │ ├── resource.h │ ├── CMakeLists.txt │ ├── utils.h │ ├── runner.exe.manifest │ ├── run_loop.h │ ├── flutter_window.h │ ├── main.cpp │ ├── utils.cpp │ ├── flutter_window.cpp │ ├── run_loop.cpp │ ├── Runner.rc │ ├── win32_window.h │ └── win32_window.cpp ├── flutter │ ├── generated_plugin_registrant.h │ ├── generated_plugin_registrant.cc │ ├── generated_plugins.cmake │ └── CMakeLists.txt ├── .gitignore └── CMakeLists.txt ├── lib ├── chess_board │ ├── flutter_chess_board.dart │ └── src │ │ ├── board_rank.dart │ │ ├── chess_board_controller.dart │ │ ├── board_model.dart │ │ ├── chess_sub.dart │ │ ├── chess_board.dart │ │ └── board_square.dart ├── widgets │ ├── divider.dart │ ├── circular_button.dart │ ├── modal_progress_hud.dart │ ├── fancy_options.dart │ └── fancy_button.dart ├── util │ ├── utils.dart │ ├── online_game_utils.dart │ └── widget_utils.dart ├── eval │ └── eval.dart └── generated │ ├── i18n.dart │ └── messages_all.dart ├── firebase.json ├── .metadata ├── local.properties ├── README.md ├── .gitignore ├── pubspec.yaml └── .firebase └── hosting.YnVpbGRcd2Vi.cache /res/licenses/this: -------------------------------------------------------------------------------- 1 | by Lurzapps -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /android/settings_aar.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /.firebaserc: -------------------------------------------------------------------------------- 1 | { 2 | "projects": { 3 | "default": "chess-45a81" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/web/favicon.png -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /res/drawable/moo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/drawable/moo.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/web/icons/Icon-512.png -------------------------------------------------------------------------------- /store/android/logo.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/store/android/logo.jpeg -------------------------------------------------------------------------------- /res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /store/windows/ic_launcher.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/store/windows/ic_launcher.ico -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/xcuserdata/ 7 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /res/chess_board/brown_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/chess_board/brown_board.png -------------------------------------------------------------------------------- /res/chess_board/chess_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/chess_board/chess_board.png -------------------------------------------------------------------------------- /res/chess_board/green_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/chess_board/green_board.png -------------------------------------------------------------------------------- /res/chess_board/orange_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/chess_board/orange_board.png -------------------------------------------------------------------------------- /store/android/ic_launcher512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/store/android/ic_launcher512.png -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /res/chess_board/2.0x/brown_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/chess_board/2.0x/brown_board.png -------------------------------------------------------------------------------- /res/chess_board/2.0x/green_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/chess_board/2.0x/green_board.png -------------------------------------------------------------------------------- /res/chess_board/2.0x/orange_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/chess_board/2.0x/orange_board.png -------------------------------------------------------------------------------- /res/chess_board/3.0x/brown_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/chess_board/3.0x/brown_board.png -------------------------------------------------------------------------------- /res/chess_board/3.0x/green_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/chess_board/3.0x/green_board.png -------------------------------------------------------------------------------- /res/chess_board/3.0x/orange_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/chess_board/3.0x/orange_board.png -------------------------------------------------------------------------------- /res/chess_board/dark_brown_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/chess_board/dark_brown_board.png -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | android.enableR8=true -------------------------------------------------------------------------------- /res/chess_board/2.0x/dark_brown_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/chess_board/2.0x/dark_brown_board.png -------------------------------------------------------------------------------- /res/chess_board/3.0x/dark_brown_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/res/chess_board/3.0x/dark_brown_board.png -------------------------------------------------------------------------------- /lib/chess_board/flutter_chess_board.dart: -------------------------------------------------------------------------------- 1 | library chess_board; 2 | 3 | export 'src/chess_board.dart'; 4 | export 'src/chess_board_controller.dart'; 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/jniLibs/x86/libtensorflowlite_c.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/android/app/src/main/jniLibs/x86/libtensorflowlite_c.so -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /store/android/screenshots/Screenshot_20201125-224244.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/store/android/screenshots/Screenshot_20201125-224244.jpg -------------------------------------------------------------------------------- /store/android/screenshots/Screenshot_20201125-224304.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/store/android/screenshots/Screenshot_20201125-224304.jpg -------------------------------------------------------------------------------- /store/android/screenshots/Screenshot_20201125-224536.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/store/android/screenshots/Screenshot_20201125-224536.jpg -------------------------------------------------------------------------------- /store/android/screenshots/Screenshot_20201125-224543.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/store/android/screenshots/Screenshot_20201125-224543.jpg -------------------------------------------------------------------------------- /store/android/screenshots/Screenshot_20201125-224556.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/store/android/screenshots/Screenshot_20201125-224556.jpg -------------------------------------------------------------------------------- /android/app/src/main/jniLibs/x86_64/libtensorflowlite_c.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/android/app/src/main/jniLibs/x86_64/libtensorflowlite_c.so -------------------------------------------------------------------------------- /android/app/src/main/jniLibs/arm64-v8a/libtensorflowlite_c.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/android/app/src/main/jniLibs/arm64-v8a/libtensorflowlite_c.so -------------------------------------------------------------------------------- /android/app/src/main/jniLibs/armeabi-v7a/libtensorflowlite_c.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/android/app/src/main/jniLibs/armeabi-v7a/libtensorflowlite_c.so -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larsaars/flutter_chess/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip 7 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "hosting": { 3 | "public": "build/web", 4 | "ignore": [ 5 | "firebase.json", 6 | "**/.*", 7 | "**/node_modules/**" 8 | ], 9 | "rewrites": [ 10 | { 11 | "source": "**", 12 | "destination": "/index.html" 13 | } 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: f30b7f4db93ee747cd727df747941a28ead25ff5 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 6 | #define GENERATED_PLUGIN_REGISTRANT_ 7 | 8 | #include 9 | 10 | // Registers Flutter plugins. 11 | void fl_register_plugins(FlPluginRegistry* registry); 12 | 13 | #endif // GENERATED_PLUGIN_REGISTRANT_ 14 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 6 | #define GENERATED_PLUGIN_REGISTRANT_ 7 | 8 | #include 9 | 10 | // Registers Flutter plugins. 11 | void RegisterPlugins(flutter::PluginRegistry* registry); 12 | 13 | #endif // GENERATED_PLUGIN_REGISTRANT_ 14 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /local.properties: -------------------------------------------------------------------------------- 1 | ## This file must *NOT* be checked into Version Control Systems, 2 | # as it contains information specific to your local configuration. 3 | # 4 | # Location of the SDK. This is only used by Gradle. 5 | # For customization when using a Version Control System, please read the 6 | # header note. 7 | #Sun Feb 28 20:12:21 CET 2021 8 | sdk.dir=C\:\\Users\\larsl\\AppData\\Local\\Android\\Sdk 9 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | #include "generated_plugin_registrant.h" 6 | 7 | #include 8 | 9 | void RegisterPlugins(flutter::PluginRegistry* registry) { 10 | UrlLauncherPluginRegisterWithRegistrar( 11 | registry->GetRegistrarForPlugin("UrlLauncherPlugin")); 12 | } 13 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | #include "generated_plugin_registrant.h" 6 | 7 | #include 8 | 9 | void fl_register_plugins(FlPluginRegistry* registry) { 10 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 11 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 12 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 13 | } 14 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /lib/widgets/divider.dart: -------------------------------------------------------------------------------- 1 | import 'package:chess_bot/util/online_game_utils.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | 4 | class DividerIfOffline extends StatelessWidget { 5 | @override 6 | Widget build(BuildContext context) { 7 | return Visibility( 8 | visible: !inOnlineGame, 9 | child: Divider8() 10 | ); 11 | } 12 | } 13 | 14 | class Divider8 extends StatelessWidget { 15 | @override 16 | Widget build(BuildContext context) { 17 | return SizedBox(width: 8,); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter chess 2 | A flutter chess application with integrated bot, local game as well as online-multiplayer support. 3 | 4 |
5 | 6 | Get it on Google Playwebsite 7 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_linux 7 | ) 8 | 9 | set(PLUGIN_BUNDLED_LIBRARIES) 10 | 11 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 12 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 13 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 14 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 15 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 16 | endforeach(plugin) 17 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_windows 7 | ) 8 | 9 | set(PLUGIN_BUNDLED_LIBRARIES) 10 | 11 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 12 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 13 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 14 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 15 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 16 | endforeach(plugin) 17 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chess", 3 | "short_name": "chess", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "a chess bot..", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:4.1.2' 9 | classpath 'com.google.gms:google-services:4.3.5' 10 | } 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | google() 16 | jcenter() 17 | } 18 | } 19 | 20 | rootProject.buildDir = '../build' 21 | subprojects { 22 | project.buildDir = "${rootProject.buildDir}/${project.name}" 23 | } 24 | subprojects { 25 | project.evaluationDependsOn(':app') 26 | } 27 | 28 | task clean(type: Delete) { 29 | delete rootProject.buildDir 30 | } 31 | -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = chess 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.lurzapps.chess 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2020 com.lurzapps. All rights reserved. 15 | -------------------------------------------------------------------------------- /lib/widgets/circular_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class CircularButton extends StatelessWidget { 4 | 5 | final double width; 6 | final double height; 7 | final Color color; 8 | final Icon icon; 9 | final Function onClick; 10 | 11 | CircularButton({this.color, this.width, this.height, this.icon, this.onClick}); 12 | 13 | 14 | @override 15 | Widget build(BuildContext context) { 16 | return Container( 17 | decoration: BoxDecoration(color: color,shape: BoxShape.circle), 18 | width: width, 19 | height: height, 20 | child: IconButton(icon: icon,enableFeedback: true, onPressed: onClick), 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "run_loop.cpp" 8 | "utils.cpp" 9 | "win32_window.cpp" 10 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 11 | "Runner.rc" 12 | "runner.exe.manifest" 13 | ) 14 | apply_standard_settings(${BINARY_NAME}) 15 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 16 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 17 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 18 | add_dependencies(${BINARY_NAME} flutter_assemble) 19 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /lib/chess_board/src/board_rank.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'board_square.dart'; 4 | 5 | /// Creates a rank(row) on the chessboard 6 | class ChessBoardRank extends StatelessWidget { 7 | /// The list of squares in the rank 8 | final List children; 9 | 10 | ChessBoardRank({this.children}); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return Expanded( 15 | flex: 1, 16 | child: Row( 17 | children: children 18 | .map( 19 | (squareName) => BoardSquare( 20 | squareName: squareName, 21 | ), 22 | ) 23 | .toList(), 24 | ), 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | #firebase related 44 | .firebase/ 45 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 9.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import cloud_firestore 9 | import connectivity_macos 10 | import firebase_core 11 | import path_provider_macos 12 | import shared_preferences_macos 13 | import url_launcher_macos 14 | 15 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 16 | FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) 17 | ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) 18 | FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) 19 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 20 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 21 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 22 | } 23 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /res/licenses/modal_progress_hud: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Maurice McCabe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /android/app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "758852323501", 4 | "project_id": "chess-45a81", 5 | "storage_bucket": "chess-45a81.appspot.com" 6 | }, 7 | "client": [ 8 | { 9 | "client_info": { 10 | "mobilesdk_app_id": "1:758852323501:android:ce395340d03d72a94b9e24", 11 | "android_client_info": { 12 | "package_name": "com.lurzapps.chess" 13 | } 14 | }, 15 | "oauth_client": [ 16 | { 17 | "client_id": "758852323501-8m18b65i084vf44n5vj8bo4eeoh942q7.apps.googleusercontent.com", 18 | "client_type": 3 19 | } 20 | ], 21 | "api_key": [ 22 | { 23 | "current_key": "AIzaSyCJ70kNbOMcog2vHy1N0UMvxPLQQuYR4a4" 24 | } 25 | ], 26 | "services": { 27 | "appinvite_service": { 28 | "other_platform_oauth_client": [ 29 | { 30 | "client_id": "758852323501-8m18b65i084vf44n5vj8bo4eeoh942q7.apps.googleusercontent.com", 31 | "client_type": 3 32 | } 33 | ] 34 | } 35 | } 36 | } 37 | ], 38 | "configuration_version": "1" 39 | } -------------------------------------------------------------------------------- /windows/runner/run_loop.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_RUN_LOOP_H_ 2 | #define RUNNER_RUN_LOOP_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | // A runloop that will service events for Flutter instances as well 10 | // as native messages. 11 | class RunLoop { 12 | public: 13 | RunLoop(); 14 | ~RunLoop(); 15 | 16 | // Prevent copying 17 | RunLoop(RunLoop const&) = delete; 18 | RunLoop& operator=(RunLoop const&) = delete; 19 | 20 | // Runs the run loop until the application quits. 21 | void Run(); 22 | 23 | // Registers the given Flutter instance for event servicing. 24 | void RegisterFlutterInstance( 25 | flutter::FlutterEngine* flutter_instance); 26 | 27 | // Unregisters the given Flutter instance from event servicing. 28 | void UnregisterFlutterInstance( 29 | flutter::FlutterEngine* flutter_instance); 30 | 31 | private: 32 | using TimePoint = std::chrono::steady_clock::time_point; 33 | 34 | // Processes all currently pending messages for registered Flutter instances. 35 | TimePoint ProcessFlutterMessages(); 36 | 37 | std::set flutter_instances_; 38 | }; 39 | 40 | #endif // RUNNER_RUN_LOOP_H_ 41 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /ios/GoogleService-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CLIENT_ID 6 | 758852323501-04scr50n54s7lj5cn9des6mo63onqq78.apps.googleusercontent.com 7 | REVERSED_CLIENT_ID 8 | com.googleusercontent.apps.758852323501-04scr50n54s7lj5cn9des6mo63onqq78 9 | API_KEY 10 | AIzaSyBcLMh4qkajIWRzUFngKhkGhE3Rh02HedU 11 | GCM_SENDER_ID 12 | 758852323501 13 | PLIST_VERSION 14 | 1 15 | BUNDLE_ID 16 | com.lurzapps.chess 17 | PROJECT_ID 18 | chess-45a81 19 | STORAGE_BUCKET 20 | chess-45a81.appspot.com 21 | IS_ADS_ENABLED 22 | 23 | IS_ANALYTICS_ENABLED 24 | 25 | IS_APPINVITE_ENABLED 26 | 27 | IS_GCM_ENABLED 28 | 29 | IS_SIGNIN_ENABLED 30 | 31 | GOOGLE_APP_ID 32 | 1:758852323501:ios:548d2046c13798104b9e24 33 | 34 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "run_loop.h" 10 | #include "win32_window.h" 11 | 12 | // A window that does nothing but host a Flutter view. 13 | class FlutterWindow : public Win32Window { 14 | public: 15 | // Creates a new FlutterWindow driven by the |run_loop|, hosting a 16 | // Flutter view running |project|. 17 | explicit FlutterWindow(RunLoop* run_loop, 18 | const flutter::DartProject& project); 19 | virtual ~FlutterWindow(); 20 | 21 | protected: 22 | // Win32Window: 23 | bool OnCreate() override; 24 | void OnDestroy() override; 25 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 26 | LPARAM const lparam) noexcept override; 27 | 28 | private: 29 | // The run loop driving events for this window. 30 | RunLoop* run_loop_; 31 | 32 | // The project to run. 33 | flutter::DartProject project_; 34 | 35 | // The Flutter instance hosted by this window. 36 | std::unique_ptr flutter_controller_; 37 | }; 38 | 39 | #endif // RUNNER_FLUTTER_WINDOW_H_ 40 | -------------------------------------------------------------------------------- /res/licenses/flutter_chess_board: -------------------------------------------------------------------------------- 1 | Copyright 2018 Deven Joshi 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | 11 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "run_loop.h" 7 | #include "utils.h" 8 | 9 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 10 | _In_ wchar_t *command_line, _In_ int show_command) { 11 | // Attach to console when present (e.g., 'flutter run') or create a 12 | // new console when running with a debugger. 13 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 14 | CreateAndAttachConsole(); 15 | } 16 | 17 | // Initialize COM, so that it is available for use in the library and/or 18 | // plugins. 19 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 20 | 21 | RunLoop run_loop; 22 | 23 | flutter::DartProject project(L"data"); 24 | 25 | std::vector command_line_arguments = 26 | GetCommandLineArguments(); 27 | 28 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 29 | 30 | FlutterWindow window(&run_loop, project); 31 | Win32Window::Point origin(10, 10); 32 | Win32Window::Size size(1280, 720); 33 | if (!window.CreateAndShow(L"chess", origin, size)) { 34 | return EXIT_FAILURE; 35 | } 36 | window.SetQuitOnClose(true); 37 | 38 | run_loop.Run(); 39 | 40 | ::CoUninitialize(); 41 | return EXIT_SUCCESS; 42 | } 43 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | chess 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /lib/widgets/modal_progress_hud.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | import '../main.dart'; 5 | 6 | class ModalProgressHUD extends StatelessWidget { 7 | final bool inAsyncCall; 8 | final double opacity; 9 | final Color color; 10 | final Widget progressIndicator; 11 | final Offset offset; 12 | final bool dismissible; 13 | final Widget child; 14 | 15 | ModalProgressHUD({ 16 | Key key, 17 | @required this.inAsyncCall, 18 | this.opacity = 0.3, 19 | this.color = Colors.grey, 20 | this.progressIndicator, 21 | this.offset, 22 | this.dismissible = false, 23 | @required this.child, 24 | }) : assert(child != null), 25 | assert(inAsyncCall != null), 26 | super(key: key); 27 | 28 | @override 29 | Widget build(BuildContext context) { 30 | List widgetList = []; 31 | widgetList.add(child); 32 | if (inAsyncCall) { 33 | Widget layOutProgressIndicator; 34 | if (offset == null) 35 | layOutProgressIndicator = Center(child: progressIndicator); 36 | else { 37 | layOutProgressIndicator = Positioned( 38 | child: Padding( 39 | padding: const EdgeInsets.all(8.0), 40 | child: progressIndicator == null ? Container() : progressIndicator, 41 | ), 42 | left: offset.dx, 43 | top: offset.dy, 44 | ); 45 | } 46 | final modal = [ 47 | new Opacity( 48 | child: new ModalBarrier(dismissible: dismissible, color: color), 49 | opacity: opacity, 50 | ), 51 | layOutProgressIndicator 52 | ]; 53 | widgetList += modal; 54 | } 55 | return new Stack( 56 | children: widgetList, 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /res/string/string_de.json: -------------------------------------------------------------------------------- 1 | { 2 | "app_name": "Schach", 3 | "cancel": "schließen", 4 | "choose_promotion": "Umwandlung wählen", 5 | "checkmate": "Schachmatt", 6 | "draw": "Unentschieden", 7 | "error": "Fehler", 8 | "draw_desc": "Das Spiel wurde mit einem Unentschieden beendet!", 9 | "replay": "neu spielen", 10 | "ok": "ok", 11 | "white": "weiß", 12 | "black": "schwarz", 13 | "check_mate_desc": "${loser} ist Schachmatt. ${winner} hat gewonnen.", 14 | "turn_of_x": "${turn} ist am Zug", 15 | "replay_desc": "Bist du dir sicher, dass du das Spiel neustarten willst?", 16 | "undo_impossible": "Zug kann nicht rückgänig gemacht werden", 17 | "undo": "rückgängig", 18 | "choose_style": "Brett-Stil ändern", 19 | "bot_on": "bot an", 20 | "bot_off": "bot aus", 21 | "legal": "von Lurzapps", 22 | "moves_done": "${progress} Bretter verarbeitet", 23 | "difficulty": "Tiefe", 24 | "difficulties": "auto,2,3,4,5", 25 | "fen_options": "in Zwischenablage,aus Zwischenablage", 26 | "bot_vs_bot": "bot vs. bot", 27 | "copy_fen": "fen kopieren", 28 | "loading_moves_web": "lädt Züge...", 29 | "online_game_options": "online-Spiel", 30 | "join_code": "Spiel beitreten", 31 | "create_code": "Spiel erstellen", 32 | "local": "[lokales Spiel]", 33 | "warning": "Warnung!", 34 | "game_reset_join_code_warning": "Durch diese Aktion wird ein neues Spiel erstellt, über das einer deiner Freunde über einen generierten code beitreten kann. Dabei werden alle lokalen Spiele zurückgesetzt und die Verbindung zu einem laufenden anderen Spiele-Code getrennt. Der Ersteller des Spiels ist immer weiß", 35 | "proceed": "fortfahren", 36 | "leave_online_game": "Spiel verlassen", 37 | "enter_game_id": "Spiele-Code eingeben", 38 | "game_id_not_found": "Spiele-Code wurde nicht gefunden", 39 | "game_id_ex": "z.B.: KDFGHQ", 40 | "join": "beitreten", 41 | "deleting_as_host_info": "Dadurch wird das gesamte Spiel gelöscht, da du der Host bist.", 42 | "switch_colors": "brett drehen", 43 | "availability_other_devices": "Plattformen" 44 | } -------------------------------------------------------------------------------- /res/string/string_en.json: -------------------------------------------------------------------------------- 1 | { 2 | "app_name": "Chess", 3 | "cancel": "cancel", 4 | "choose_promotion": "choose promotion", 5 | "checkmate": "checkmate", 6 | "draw": "draw", 7 | "error": "error", 8 | "draw_desc": "The game finished with a draw!", 9 | "replay": "replay", 10 | "ok": "ok", 11 | "white": "white", 12 | "black": "black", 13 | "check_mate_desc": "${loser} is in checkmate. ${winner} won.", 14 | "turn_of_x": "${turn}'s turn", 15 | "replay_desc": "Are you sure to restart the game and reset the board?", 16 | "undo_impossible": "can't perform undo", 17 | "undo": "undo", 18 | "choose_style": "change board style", 19 | "bot_on": "bot on", 20 | "bot_off": "bot off", 21 | "moves_done": "${progress} boards processed", 22 | "difficulty": "depth", 23 | "difficulties": "auto,2,3,4,5", 24 | "fen_options": "to clipboard,from clipboard", 25 | "bot_vs_bot": "bot vs. bot", 26 | "copy_fen": "copy fen", 27 | "privacy_url": "https://l-chess.flycricket.io/privacy.html", 28 | "terms_url": "https://l-chess.flycricket.io/terms.html", 29 | "privacy_title": "privacy policy", 30 | "loading_moves_web": "loading moves...", 31 | "online_game_options": "online game", 32 | "join_code": "join game", 33 | "create_code": "create game", 34 | "local": "[local game]", 35 | "warning": "warning!", 36 | "game_reset_join_code_warning": "By creating a new game code, you will reset your local board and leave a running online game. A friend can join your game via the generated code. The creator of the game is always white.", 37 | "proceed": "proceed", 38 | "leave_online_game": "leave game", 39 | "enter_game_id": "enter a game id", 40 | "game_id_not_found": "game id not found", 41 | "game_id_ex": "ex.: KDFGHQ", 42 | "join": "join", 43 | "deleting_as_host_info": "Since you are hosting the game, leaving it means deleting it.", 44 | "switch_colors": "turn board", 45 | "availability_other_devices": "platforms", 46 | "android": "android", 47 | "web": "web", 48 | "website_url": "https://chess-45a81.web.app/#/", 49 | "playstore_url": "https://play.google.com/store/apps/details?id=com.lurzapps.chess" 50 | } -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(RunLoop* run_loop, 8 | const flutter::DartProject& project) 9 | : run_loop_(run_loop), project_(project) {} 10 | 11 | FlutterWindow::~FlutterWindow() {} 12 | 13 | bool FlutterWindow::OnCreate() { 14 | if (!Win32Window::OnCreate()) { 15 | return false; 16 | } 17 | 18 | RECT frame = GetClientArea(); 19 | 20 | // The size here must match the window dimensions to avoid unnecessary surface 21 | // creation / destruction in the startup path. 22 | flutter_controller_ = std::make_unique( 23 | frame.right - frame.left, frame.bottom - frame.top, project_); 24 | // Ensure that basic setup of the controller was successful. 25 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 26 | return false; 27 | } 28 | RegisterPlugins(flutter_controller_->engine()); 29 | run_loop_->RegisterFlutterInstance(flutter_controller_->engine()); 30 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 31 | return true; 32 | } 33 | 34 | void FlutterWindow::OnDestroy() { 35 | if (flutter_controller_) { 36 | run_loop_->UnregisterFlutterInstance(flutter_controller_->engine()); 37 | flutter_controller_ = nullptr; 38 | } 39 | 40 | Win32Window::OnDestroy(); 41 | } 42 | 43 | LRESULT 44 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 45 | WPARAM const wparam, 46 | LPARAM const lparam) noexcept { 47 | // Give Flutter, including plugins, an opporutunity to handle window messages. 48 | if (flutter_controller_) { 49 | std::optional result = 50 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 51 | lparam); 52 | if (result) { 53 | return *result; 54 | } 55 | } 56 | 57 | switch (message) { 58 | case WM_FONTCHANGE: 59 | flutter_controller_->engine()->ReloadSystemFonts(); 60 | break; 61 | } 62 | 63 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 64 | } 65 | -------------------------------------------------------------------------------- /lib/chess_board/src/chess_board_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:chess_bot/chess_board/chess.dart'; 2 | import 'package:chess_bot/chess_board/src/chess_sub.dart' as chess; 3 | 4 | import 'chess_sub.dart'; 5 | 6 | enum PieceColor { 7 | White, 8 | Black, 9 | } 10 | 11 | /// Controller for programmatically controlling the board 12 | class ChessBoardController { 13 | /// The game attached to the controller 14 | Chess game; 15 | 16 | /// Function from the ScopedModel to refresh board 17 | Function refreshBoard; 18 | 19 | bool userCanMakeMoves = true; 20 | 21 | /// Resets square 22 | void resetBoard() { 23 | game?.reset(); 24 | refreshBoard == null ? this._throwNotAttachedException() : refreshBoard(); 25 | } 26 | 27 | /// Clears board 28 | void clearBoard() { 29 | game?.clear(); 30 | refreshBoard == null ? this._throwNotAttachedException() : refreshBoard(); 31 | } 32 | 33 | /// Puts piece on a square 34 | void putPiece(PieceType piece, String square, PieceColor color) { 35 | game?.put(_getPiece(piece, color), square); 36 | refreshBoard == null ? this._throwNotAttachedException() : refreshBoard(); 37 | } 38 | 39 | /// Exception when a controller is not attached to a board 40 | void _throwNotAttachedException() { 41 | throw Exception("Controller not attached to a ChessBoard widget!"); 42 | } 43 | 44 | /// Gets respective piece 45 | chess.Piece _getPiece(PieceType piece, PieceColor color) { 46 | chess.Color _getColor(PieceColor color) { 47 | return color == PieceColor.White ? chess.Color.WHITE : chess.Color.BLACK; 48 | } 49 | 50 | switch (piece) { 51 | case PieceType.BISHOP: 52 | return chess.Piece(chess.PieceType.BISHOP, _getColor(color)); 53 | case PieceType.QUEEN: 54 | return chess.Piece(chess.PieceType.QUEEN, _getColor(color)); 55 | case PieceType.KING: 56 | return chess.Piece(chess.PieceType.KING, _getColor(color)); 57 | case PieceType.KNIGHT: 58 | return chess.Piece(chess.PieceType.KNIGHT, _getColor(color)); 59 | case PieceType.PAWN: 60 | return chess.Piece(chess.PieceType.PAWN, _getColor(color)); 61 | case PieceType.ROOK: 62 | return chess.Piece(chess.PieceType.ROOK, _getColor(color)); 63 | } 64 | 65 | return chess.Piece(chess.PieceType.PAWN, chess.Color.WHITE); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/chess_board/src/board_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:chess_bot/chess_board/chess.dart'; 4 | import 'package:chess_bot/chess_board/src/chess_sub.dart' as chess; 5 | import 'package:scoped_model/scoped_model.dart'; 6 | 7 | import 'chess_board_controller.dart'; 8 | 9 | typedef void MoveCallback(move); 10 | typedef void CheckMateCallback(PieceColor color); 11 | typedef void CheckCallback(PieceColor color); 12 | typedef void GameCallback(); 13 | 14 | class BoardModel extends Model { 15 | /// The size of the board (The board is a square) 16 | double size; 17 | 18 | /// Callback for when a move is made 19 | MoveCallback onMove; 20 | 21 | /// Callback for when a player is checkmated 22 | CheckMateCallback onCheckMate; 23 | 24 | ///Callback for when a player is in check 25 | CheckCallback onCheck; 26 | 27 | /// Callback for when the game is a draw (Example: K v K) 28 | VoidCallback onDraw; 29 | 30 | //the callbacks for returning the controller and game 31 | GameCallback onGame; 32 | 33 | /// If the white side of the board is towards the user 34 | bool whiteSideTowardsUser; 35 | 36 | /// The controller for programmatically making moves 37 | ChessBoardController chessBoardController; 38 | 39 | /// Creates a logical game 40 | Chess game; 41 | 42 | String fen; 43 | 44 | /// Refreshes board 45 | void refreshBoard() { 46 | bool generatedMovesLen0 = game.moveCountIsZero(); 47 | if (game.inCheckmate(generatedMovesLen0)) { 48 | onCheckMate(game.game.turn == chess.Color.WHITE ? PieceColor.White : PieceColor.Black); 49 | } 50 | else if (game.inDraw(generatedMovesLen0) || game.inStalemate(generatedMovesLen0) || game.in_threefold_repetition() || game.insufficientMaterial()) { 51 | onDraw(); 52 | } 53 | else if (game.in_check()) { 54 | onCheck(game.game.turn == chess.Color.WHITE ? PieceColor.White : PieceColor.Black); 55 | } 56 | notifyListeners(); 57 | } 58 | 59 | BoardModel( 60 | this.size, 61 | this.onMove, 62 | this.onCheckMate, 63 | this.onCheck, 64 | this.onDraw, 65 | this.whiteSideTowardsUser, 66 | this.chessBoardController, 67 | bool userCanMakeMoves, 68 | this.game) { 69 | chessBoardController?.game = game; 70 | chessBoardController?.refreshBoard = refreshBoard; 71 | chessBoardController?.userCanMakeMoves = userCanMakeMoves; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /windows/runner/run_loop.cpp: -------------------------------------------------------------------------------- 1 | #include "run_loop.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | RunLoop::RunLoop() {} 8 | 9 | RunLoop::~RunLoop() {} 10 | 11 | void RunLoop::Run() { 12 | bool keep_running = true; 13 | TimePoint next_flutter_event_time = TimePoint::clock::now(); 14 | while (keep_running) { 15 | std::chrono::nanoseconds wait_duration = 16 | std::max(std::chrono::nanoseconds(0), 17 | next_flutter_event_time - TimePoint::clock::now()); 18 | ::MsgWaitForMultipleObjects( 19 | 0, nullptr, FALSE, static_cast(wait_duration.count() / 1000), 20 | QS_ALLINPUT); 21 | bool processed_events = false; 22 | MSG message; 23 | // All pending Windows messages must be processed; MsgWaitForMultipleObjects 24 | // won't return again for items left in the queue after PeekMessage. 25 | while (::PeekMessage(&message, nullptr, 0, 0, PM_REMOVE)) { 26 | processed_events = true; 27 | if (message.message == WM_QUIT) { 28 | keep_running = false; 29 | break; 30 | } 31 | ::TranslateMessage(&message); 32 | ::DispatchMessage(&message); 33 | // Allow Flutter to process messages each time a Windows message is 34 | // processed, to prevent starvation. 35 | next_flutter_event_time = 36 | std::min(next_flutter_event_time, ProcessFlutterMessages()); 37 | } 38 | // If the PeekMessage loop didn't run, process Flutter messages. 39 | if (!processed_events) { 40 | next_flutter_event_time = 41 | std::min(next_flutter_event_time, ProcessFlutterMessages()); 42 | } 43 | } 44 | } 45 | 46 | void RunLoop::RegisterFlutterInstance( 47 | flutter::FlutterEngine* flutter_instance) { 48 | flutter_instances_.insert(flutter_instance); 49 | } 50 | 51 | void RunLoop::UnregisterFlutterInstance( 52 | flutter::FlutterEngine* flutter_instance) { 53 | flutter_instances_.erase(flutter_instance); 54 | } 55 | 56 | RunLoop::TimePoint RunLoop::ProcessFlutterMessages() { 57 | TimePoint next_event_time = TimePoint::max(); 58 | for (auto instance : flutter_instances_) { 59 | std::chrono::nanoseconds wait_duration = instance->ProcessMessages(); 60 | if (wait_duration != std::chrono::nanoseconds::max()) { 61 | next_event_time = 62 | std::min(next_event_time, TimePoint::clock::now() + wait_duration); 63 | } 64 | } 65 | return next_event_time; 66 | } 67 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /lib/util/utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:connectivity/connectivity.dart'; 4 | import 'package:data_connection_checker/data_connection_checker.dart'; 5 | import 'package:flutter/foundation.dart'; 6 | import 'package:flutter/material.dart'; 7 | import 'package:flutter/services.dart' show rootBundle; 8 | import 'package:path_provider/path_provider.dart'; 9 | 10 | import '../main.dart'; 11 | 12 | const version = '1.0'; 13 | const app_name = 'chess!'; 14 | 15 | final Random random = Random(); 16 | 17 | Future get rootDir async { 18 | final directory = await getApplicationDocumentsDirectory(); 19 | // For your reference print the AppDoc directory 20 | return directory.path; 21 | } 22 | 23 | class ContextSingleton { 24 | static ContextSingleton _instance; 25 | final BuildContext _context; 26 | 27 | ContextSingleton(this._context) { 28 | _instance = this; 29 | } 30 | 31 | static get context { 32 | return _instance._context; 33 | } 34 | } 35 | 36 | Future get hasInternet async { 37 | var connectivityResult = await (Connectivity().checkConnectivity()); 38 | if (connectivityResult == ConnectivityResult.mobile) { 39 | // I am connected to a mobile network, make sure there is actually a net connection. 40 | if (await DataConnectionChecker().hasConnection) { 41 | // Mobile data detected & internet connection confirmed. 42 | return true; 43 | } else { 44 | // Mobile data detected but no internet connection found. 45 | return false; 46 | } 47 | } else if (connectivityResult == ConnectivityResult.wifi) { 48 | // I am connected to a WIFI network, make sure there is actually a net connection. 49 | if (await DataConnectionChecker().hasConnection) { 50 | // Wifi detected & internet connection confirmed. 51 | return true; 52 | } else { 53 | // Wifi detected but no internet connection found. 54 | return false; 55 | } 56 | } else { 57 | // Neither mobile data or WIFI detected, not internet connection found. 58 | return false; 59 | } 60 | } 61 | 62 | void addLicenses() { 63 | LicenseRegistry.addLicense(() async* { 64 | yield LicenseEntryWithLineBreaks(['flutter_chess_board'], 65 | await rootBundle.loadString('res/licenses/flutter_chess_board')); 66 | yield LicenseEntryWithLineBreaks( 67 | ['chess'], await rootBundle.loadString('res/licenses/chess')); 68 | yield LicenseEntryWithLineBreaks(['modal_progress_hud'], 69 | await rootBundle.loadString('res/licenses/modal_progress_hud')); 70 | }); 71 | } -------------------------------------------------------------------------------- /res/licenses/chess: -------------------------------------------------------------------------------- 1 | chess.dart 2 | 3 | Copyright (c) 2014 David Kopec 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | 23 | Based on chess.js 24 | 25 | Copyright (c) 2014, Jeff Hlywa (jhlywa@gmail.com) 26 | All rights reserved. 27 | 28 | Redistribution and use in source and binary forms, with or without 29 | modification, are permitted provided that the following conditions are met: 30 | 31 | 1. Redistributions of source code must retain the above copyright notice, 32 | this list of conditions and the following disclaimer. 33 | 2. Redistributions in binary form must reproduce the above copyright notice, 34 | this list of conditions and the following disclaimer in the documentation 35 | and/or other materials provided with the distribution. 36 | 37 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 38 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 39 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 40 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 41 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 42 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 43 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 44 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 45 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 47 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /android/app/src/main/java/com/lurzapps/chess/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.lurzapps.chess; 2 | 3 | import android.os.Bundle; 4 | import androidx.annotation.Nullable; 5 | 6 | import io.flutter.embedding.android.FlutterActivity; 7 | 8 | public class MainActivity extends FlutterActivity { 9 | //private Model model; 10 | 11 | @Override 12 | public void onCreate(@Nullable Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | 15 | /*try { 16 | model = Model.newInstance(this); 17 | 18 | new MethodChannel(getFlutterEngine().getDartExecutor().getBinaryMessenger(), "flutter.native/helper"). 19 | setMethodCallHandler((call, result) -> { 20 | if (call.method.equals("predictWithTf")) { 21 | //in argument of this method is an flat int array of the shape (1, 8, 8, 12) 22 | //this must be converted into a tensor buffer with the data type float32 23 | ArrayList flatArray = (ArrayList) call.arguments; 24 | TensorBuffer buffer = TensorBuffer.createFixedSize(new int[]{1, 8, 8, 12}, DataType.FLOAT32); 25 | 26 | //allocate enough space for the byte array (4 because float in java is 4 byte) 27 | ByteBuffer byteBuffer = ByteBuffer.allocate(4 * flatArray.size()); 28 | //put every fourth position the next float in byte buffer 29 | for (int i = 0; i < (flatArray.size() * 4); i += 4) 30 | byteBuffer.putFloat(i, flatArray.get(i / 4)); 31 | //load into tensor buffer 32 | buffer.loadBuffer(byteBuffer); 33 | 34 | //process and get main output 35 | TensorBuffer predictionTensor = model.process(buffer).getOutputFeature0AsTensorBuffer(); 36 | //this is normally a float but must be typed as double to be able to be sent back as result 37 | double predictionDouble = predictionTensor.getFloatArray()[0]; 38 | 39 | //send result back to main flutter application 40 | result.success(predictionDouble); 41 | } 42 | }); 43 | } catch (IOException | NullPointerException e) { 44 | e.printStackTrace(); 45 | }*/ 46 | } 47 | 48 | @Override 49 | protected void onDestroy() { 50 | super.onDestroy(); 51 | //model.close(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 25 | 26 | 27 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | chess 53 | 54 | 55 | 56 | 59 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 10 | 14 | 21 | 25 | 29 | 34 | 38 | 39 | 40 | 41 | 42 | 43 | 45 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new Exception("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | def keystoreProperties = new Properties() 25 | def keystorePropertiesFile = rootProject.file('key.properties') 26 | if (keystorePropertiesFile.exists()) { 27 | keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) 28 | } 29 | 30 | apply plugin: 'com.android.application' 31 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 32 | apply plugin: 'com.google.gms.google-services' 33 | 34 | android { 35 | compileSdkVersion 30 36 | 37 | sourceSets { 38 | main.java.srcDirs += 'src/main/kotlin' 39 | } 40 | 41 | lintOptions { 42 | disable 'InvalidPackage' 43 | } 44 | 45 | defaultConfig { 46 | applicationId "com.lurzapps.chess" 47 | minSdkVersion 19 48 | targetSdkVersion 30 49 | versionCode flutterVersionCode.toInteger() 50 | versionName flutterVersionName 51 | multiDexEnabled true 52 | 53 | ndk { 54 | abiFilters 'armeabi-v7a', 'arm64-v8a' 55 | } 56 | } 57 | 58 | signingConfigs { 59 | release { 60 | keyAlias keystoreProperties['keyAlias'] 61 | keyPassword keystoreProperties['keyPassword'] 62 | storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null 63 | storePassword keystoreProperties['storePassword'] 64 | } 65 | } 66 | 67 | buildTypes { 68 | release { 69 | // Signing with the debug keys for now, so `flutter run --release` works. 70 | signingConfig signingConfigs.release 71 | } 72 | } 73 | 74 | aaptOptions { 75 | noCompress 'tflite' 76 | noCompress 'lite' 77 | } 78 | 79 | buildFeatures { 80 | mlModelBinding true 81 | } 82 | } 83 | 84 | flutter { 85 | source '../..' 86 | } 87 | 88 | dependencies { 89 | //firebase 90 | implementation 'com.google.firebase:firebase-analytics' 91 | implementation 'com.google.firebase:firebase-firestore' 92 | //multi-dex 93 | implementation 'androidx.multidex:multidex:2.0.1' 94 | } 95 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | 11 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 12 | # which isn't available in 3.10. 13 | function(list_prepend LIST_NAME PREFIX) 14 | set(NEW_LIST "") 15 | foreach(element ${${LIST_NAME}}) 16 | list(APPEND NEW_LIST "${PREFIX}${element}") 17 | endforeach(element) 18 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 19 | endfunction() 20 | 21 | # === Flutter Library === 22 | # System-level dependencies. 23 | find_package(PkgConfig REQUIRED) 24 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 25 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 26 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 27 | pkg_check_modules(BLKID REQUIRED IMPORTED_TARGET blkid) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | PkgConfig::BLKID 70 | ) 71 | add_dependencies(flutter flutter_assemble) 72 | 73 | # === Flutter tool backend === 74 | # _phony_ is a non-existent file to force this command to run every time, 75 | # since currently there's no way to get a full input/output list from the 76 | # flutter tool. 77 | add_custom_command( 78 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 79 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 80 | COMMAND ${CMAKE_COMMAND} -E env 81 | ${FLUTTER_TOOL_ENVIRONMENT} 82 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 83 | linux-x64 ${CMAKE_BUILD_TYPE} 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: chess_bot 2 | description: "a chess bot." 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `pub publish`. This is preferred for private packages. 6 | publish_to: 'none' 7 | 8 | version: 1.2.2+11 9 | 10 | environment: 11 | sdk: ">=2.7.0 <3.0.0" 12 | 13 | dependencies: 14 | flutter: 15 | sdk: flutter 16 | flutter_localizations: 17 | sdk: flutter 18 | 19 | path_provider: ^2.0.0 20 | intl: ^0.17.0 21 | flutter_launcher_icons: ^0.8.1 22 | lite_rolling_switch: ^0.1.1 23 | shared_preferences: ^2.0.1 24 | group_radio_button: ^1.0.1 25 | url_launcher: ^6.0.1 26 | #with fixed versions because else other packages fail to work (because they depend on older versions etc.) 27 | uuid: 2.2.2 28 | quiver: 2.1.5 29 | #firebase 30 | firebase_core: ^1.0.0 31 | firebase_analytics: ^7.1.0 32 | cloud_firestore: ^1.0.0 33 | #internet connection checking 34 | connectivity: ^3.0.0 35 | data_connection_checker: ^0.3.4 36 | #json serialization 37 | json_annotation: ^4.0.0 38 | #for the chess board 39 | chess_vectors_flutter: ^1.0.12 40 | scoped_model: ^1.1.0 41 | 42 | 43 | dev_dependencies: 44 | gen_lang: ^0.1.3 45 | json_serializable: ^4.0.1 46 | build_runner: ^1.11.5 47 | 48 | flutter_test: 49 | sdk: flutter 50 | 51 | # For information on the generic Dart part of this file, see the 52 | # following page: https://dart.dev/tools/pub/pubspec 53 | 54 | # The following section is specific to Flutter. 55 | flutter: 56 | uses-material-design: true 57 | 58 | # To add assets to your application, add an assets section, like this: 59 | # assets: 60 | # - images/a_dot_burr.jpeg 61 | # - images/a_dot_ham.jpeg 62 | 63 | # An image asset can refer to one or more resolution-specific "variants", see 64 | # https://flutter.dev/assets-and-images/#resolution-aware. 65 | 66 | # For details regarding adding assets from package dependencies, see 67 | # https://flutter.dev/assets-and-images/#from-packages 68 | 69 | # To add custom fonts to your application, add a fonts section here, 70 | # in this "flutter" section. Each entry in this list should have a 71 | # "family" key with the font family name, and a "fonts" key with a 72 | # list giving the asset and other descriptors for the font. For 73 | # example: 74 | # fonts: 75 | # - family: Schyler 76 | # fonts: 77 | # - asset: fonts/Schyler-Regular.ttf 78 | # - asset: fonts/Schyler-Italic.ttf 79 | # style: italic 80 | # - family: Trajan Pro 81 | # fonts: 82 | # - asset: fonts/TrajanPro.ttf 83 | # - asset: fonts/TrajanPro_Bold.ttf 84 | # weight: 700 85 | # 86 | # For details regarding fonts from package dependencies, 87 | # see https://flutter.dev/custom-fonts/#from-packages 88 | 89 | #the assets 90 | assets: 91 | - res/string/ 92 | - res/drawable/ 93 | - res/chess_board/ 94 | - res/licenses/ 95 | - assets/ 96 | 97 | #icons 98 | flutter_icons: 99 | image_path_android: "res/drawable/ic_launcher.png" 100 | image_path_ios: "res/drawable/ic_launcher.png" 101 | android: true 102 | ios: true -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #ifdef FLUTTER_BUILD_NUMBER 64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0 67 | #endif 68 | 69 | #ifdef FLUTTER_BUILD_NAME 70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.lurzapps" "\0" 93 | VALUE "FileDescription", "a chess bot.." "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "chess" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2020 com.lurzapps. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "chess.exe" "\0" 98 | VALUE "ProductName", "chess" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /.firebase/hosting.YnVpbGRcd2Vi.cache: -------------------------------------------------------------------------------- 1 | favicon.png,1605007593178,1f962f625fed6d3672c86709d97609f2a735bd6d087a828374e40bfe83e7b682 2 | manifest.json,1607343472552,5a1275549a42edbe6dced998c9c9a0f16869f0fd5ccc087988f4d7e735482eee 3 | assets/fonts/MaterialIcons-Regular.otf,1602193639342,0f68fedebd1cdda23d988dc25ac5e50b517322b79e04ed19e743bef2a4364d25 4 | assets/res/chess_board/brown_board.png,1605204048978,afcb56d65fb827dd071120867c8bee6fefc75381517e7cb4082aa50dbc7c43e9 5 | assets/res/chess_board/chess_board.png,1605204041916,e4a006a99a1069dc9e53bb6096e47d734bd1336ce42202d05c12103a83f15c6c 6 | assets/res/chess_board/dark_brown_board.png,1605204049010,fdd7435fb5640b2f2f469ea36162351a76bbcb3ff4e5d8e8b6fb6fca7b7935ff 7 | assets/res/chess_board/green_board.png,1605204049047,fcb86205d59bc171cb54b841ce3eed73664e48ddd49cc09d40d37e6520e5876e 8 | assets/res/chess_board/orange_board.png,1605204049081,a14742a0ca0bf964122036bc0244e1667ae731e0f49f3556afcbda2ac261b83f 9 | assets/res/chess_board/2.0x/brown_board.png,1605204041985,ccb51456b11119bd5afc36a6959fd6c3dce09cf86a47b289a2609c2f483ec964 10 | assets/res/chess_board/2.0x/dark_brown_board.png,1605204042019,f7d4ea614c3622db5533a40835b113f3032860dbe19ee52d97cfe73240ffe85e 11 | assets/res/chess_board/2.0x/green_board.png,1605204042055,60e5e9611d6d62c611f181a39235595194c74057d373b504d88bbc0ea0228638 12 | assets/res/chess_board/2.0x/orange_board.png,1605204042092,9e981adda8e129e6e83827b1afe73e3df17accf933782a297c99fbbf10ae1cab 13 | assets/res/chess_board/3.0x/brown_board.png,1605204042141,f0ee70871fc2c711a79b85f1c84a4127ca63531420f23c0dc88309d9fed78849 14 | assets/res/chess_board/3.0x/dark_brown_board.png,1605204042176,fa9f6e003d695a51f5978ef6c6e52b0d62cb0e566adafe96b22d2f13b1c21cb5 15 | assets/res/chess_board/3.0x/green_board.png,1605204042211,30fb6f718d9ede8b3ad3dfaa14845b63c97b5102a0864b3ea934ee04cd188e64 16 | assets/res/chess_board/3.0x/orange_board.png,1605204042246,c281a4e00c4745fd4824a84052313695bc41c7dfdb983fdad86cb98efface725 17 | assets/res/drawable/ic_launcher.png,1605007613544,f49fd57814a66b4ff78b064a141556349699d8a6abe6b0b847d1a3b231fe9416 18 | assets/res/drawable/moo.png,1606829433691,87cc3b7bde141474556f447b48e5c152b0f364d8be32bccab6a409c03d94f352 19 | assets/res/licenses/chess,1605737658739,fb2369830a33a1245bbe73f544f1818691e56e817d959bea2642988c907adf11 20 | assets/res/licenses/flutter_chess_board,1605204035591,5b591b8e2a2f8624807c0d810dc23a05ca3841963ad290f54a68dc5dd7d788ab 21 | assets/res/licenses/modal_progress_hud,1605737568214,d16050fcc74881db0e9af599f94b11e687671d1e562ee8dd9ac7b2d7ce839b93 22 | assets/res/licenses/this,1605808303822,457900b02f282bcbd1e7d25547453cf094149fd859cb5dc5d8c01229d64cde51 23 | assets/res/string/string_de.json,1607455472027,4c0151d1aeee19f628f4f158f0e5d17b68abcc9c85a32ce4d3ef922d1b281c46 24 | assets/res/string/string_en.json,1607455472022,fc8db0562e7bc09289964582868491c26227736331e4899494a4c1d52d5a6f81 25 | icons/Icon-192.png,1607025759941,3088bd8bfdf1bec94ebd899b3d8a46adacfca0a958ee24ea6037ba3d751f608a 26 | icons/Icon-512.png,1605007593178,1f962f625fed6d3672c86709d97609f2a735bd6d087a828374e40bfe83e7b682 27 | index.html,1607509321036,cfebc91129205e9514dee06517c20f1715164e2909058b7b0d834f8bc888456b 28 | version.json,1607509320849,98f85e10e524de74454c3f1285b6df566e830725b0cfd0382f59073806d6f43e 29 | flutter_service_worker.js,1607509321199,593892ef9e31fa24275d32c2f3e074b16dc65f197ea4dcd05a6c026909bd7e12 30 | assets/AssetManifest.json,1607509321011,eb3ed59000905587d9c3e469b8731f07f21eafcec716b0ac3a59d439cdf5f34a 31 | assets/FontManifest.json,1607509321011,210667deefef655c75d32a0c4132f33b81f91d01861ca0dca46e4a50fc7f4296 32 | assets/NOTICES,1607509321012,9bda82636a08bfd4cdcaa8a0dc6406e0d9ebd90c51f6dc15d605576cf4fddd1b 33 | main.dart.js,1607509320498,42e008303e7235c207ed3bab5c3e78d2a4c1eb2a2c4821342451a75eaf35c467 34 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | project(chess LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "chess") 5 | 6 | cmake_policy(SET CMP0063 NEW) 7 | 8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 9 | 10 | # Configure build options. 11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 12 | if(IS_MULTICONFIG) 13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 14 | CACHE STRING "" FORCE) 15 | else() 16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 17 | set(CMAKE_BUILD_TYPE "Debug" CACHE 18 | STRING "Flutter build mode" FORCE) 19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 20 | "Debug" "Profile" "Release") 21 | endif() 22 | endif() 23 | 24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 28 | 29 | # Use Unicode for all projects. 30 | add_definitions(-DUNICODE -D_UNICODE) 31 | 32 | # Compilation settings that should be applied to most targets. 33 | function(APPLY_STANDARD_SETTINGS TARGET) 34 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 36 | target_compile_options(${TARGET} PRIVATE /EHsc) 37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 39 | endfunction() 40 | 41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 42 | 43 | # Flutter library and tool build rules. 44 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 45 | 46 | # Application build 47 | add_subdirectory("runner") 48 | 49 | # Generated plugin build rules, which manage building the plugins and adding 50 | # them to the application. 51 | include(flutter/generated_plugins.cmake) 52 | 53 | 54 | # === Installation === 55 | # Support files are copied into place next to the executable, so that it can 56 | # run in place. This is done instead of making a separate bundle (as on Linux) 57 | # so that building and running from within Visual Studio will work. 58 | set(BUILD_BUNDLE_DIR "$") 59 | # Make the "install" step default, as it's required to run. 60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 63 | endif() 64 | 65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 67 | 68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 69 | COMPONENT Runtime) 70 | 71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 72 | COMPONENT Runtime) 73 | 74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 75 | COMPONENT Runtime) 76 | 77 | if(PLUGIN_BUNDLED_LIBRARIES) 78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 80 | COMPONENT Runtime) 81 | endif() 82 | 83 | # Fully re-copy the assets directory on each build to avoid having stale files 84 | # from a previous install. 85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 86 | install(CODE " 87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 88 | " COMPONENT Runtime) 89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 91 | 92 | # Install the AOT library on non-Debug builds only. 93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 94 | CONFIGURATIONS Profile;Release 95 | COMPONENT Runtime) 96 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 11 | 12 | # === Flutter Library === 13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 14 | 15 | # Published to parent scope for install step. 16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 20 | 21 | list(APPEND FLUTTER_LIBRARY_HEADERS 22 | "flutter_export.h" 23 | "flutter_windows.h" 24 | "flutter_messenger.h" 25 | "flutter_plugin_registrar.h" 26 | ) 27 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 28 | add_library(flutter INTERFACE) 29 | target_include_directories(flutter INTERFACE 30 | "${EPHEMERAL_DIR}" 31 | ) 32 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 33 | add_dependencies(flutter flutter_assemble) 34 | 35 | # === Wrapper === 36 | list(APPEND CPP_WRAPPER_SOURCES_CORE 37 | "core_implementations.cc" 38 | "standard_codec.cc" 39 | ) 40 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 41 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 42 | "plugin_registrar.cc" 43 | ) 44 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 45 | list(APPEND CPP_WRAPPER_SOURCES_APP 46 | "flutter_engine.cc" 47 | "flutter_view_controller.cc" 48 | ) 49 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 50 | 51 | # Wrapper sources needed for a plugin. 52 | add_library(flutter_wrapper_plugin STATIC 53 | ${CPP_WRAPPER_SOURCES_CORE} 54 | ${CPP_WRAPPER_SOURCES_PLUGIN} 55 | ) 56 | apply_standard_settings(flutter_wrapper_plugin) 57 | set_target_properties(flutter_wrapper_plugin PROPERTIES 58 | POSITION_INDEPENDENT_CODE ON) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | CXX_VISIBILITY_PRESET hidden) 61 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 62 | target_include_directories(flutter_wrapper_plugin PUBLIC 63 | "${WRAPPER_ROOT}/include" 64 | ) 65 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 66 | 67 | # Wrapper sources needed for the runner. 68 | add_library(flutter_wrapper_app STATIC 69 | ${CPP_WRAPPER_SOURCES_CORE} 70 | ${CPP_WRAPPER_SOURCES_APP} 71 | ) 72 | apply_standard_settings(flutter_wrapper_app) 73 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 74 | target_include_directories(flutter_wrapper_app PUBLIC 75 | "${WRAPPER_ROOT}/include" 76 | ) 77 | add_dependencies(flutter_wrapper_app flutter_assemble) 78 | 79 | # === Flutter tool backend === 80 | # _phony_ is a non-existent file to force this command to run every time, 81 | # since currently there's no way to get a full input/output list from the 82 | # flutter tool. 83 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 84 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 85 | add_custom_command( 86 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 87 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 88 | ${CPP_WRAPPER_SOURCES_APP} 89 | ${PHONY_OUTPUT} 90 | COMMAND ${CMAKE_COMMAND} -E env 91 | ${FLUTTER_TOOL_ENVIRONMENT} 92 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 93 | windows-x64 $ 94 | ) 95 | add_custom_target(flutter_assemble DEPENDS 96 | "${FLUTTER_LIBRARY}" 97 | ${FLUTTER_LIBRARY_HEADERS} 98 | ${CPP_WRAPPER_SOURCES_CORE} 99 | ${CPP_WRAPPER_SOURCES_PLUGIN} 100 | ${CPP_WRAPPER_SOURCES_APP} 101 | ) 102 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen *screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "chess"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } 47 | else { 48 | gtk_window_set_title(window, "chess"); 49 | } 50 | 51 | gtk_window_set_default_size(window, 1280, 720); 52 | gtk_widget_show(GTK_WIDGET(window)); 53 | 54 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 55 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 56 | 57 | FlView* view = fl_view_new(project); 58 | gtk_widget_show(GTK_WIDGET(view)); 59 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 60 | 61 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 62 | 63 | gtk_widget_grab_focus(GTK_WIDGET(view)); 64 | } 65 | 66 | // Implements GApplication::local_command_line. 67 | static gboolean my_application_local_command_line(GApplication* application, gchar ***arguments, int *exit_status) { 68 | MyApplication* self = MY_APPLICATION(application); 69 | // Strip out the first argument as it is the binary name. 70 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 71 | 72 | g_autoptr(GError) error = nullptr; 73 | if (!g_application_register(application, nullptr, &error)) { 74 | g_warning("Failed to register: %s", error->message); 75 | *exit_status = 1; 76 | return TRUE; 77 | } 78 | 79 | g_application_activate(application); 80 | *exit_status = 0; 81 | 82 | return TRUE; 83 | } 84 | 85 | // Implements GObject::dispose. 86 | static void my_application_dispose(GObject *object) { 87 | MyApplication* self = MY_APPLICATION(object); 88 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 89 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 90 | } 91 | 92 | static void my_application_class_init(MyApplicationClass* klass) { 93 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 94 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 95 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 96 | } 97 | 98 | static void my_application_init(MyApplication* self) {} 99 | 100 | MyApplication* my_application_new() { 101 | return MY_APPLICATION(g_object_new(my_application_get_type(), 102 | "application-id", APPLICATION_ID, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | project(runner LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "chess") 5 | set(APPLICATION_ID "com.lurzapps.chess") 6 | 7 | cmake_policy(SET CMP0063 NEW) 8 | 9 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 10 | 11 | # Configure build options. 12 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 13 | set(CMAKE_BUILD_TYPE "Debug" CACHE 14 | STRING "Flutter build mode" FORCE) 15 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 16 | "Debug" "Profile" "Release") 17 | endif() 18 | 19 | # Compilation settings that should be applied to most targets. 20 | function(APPLY_STANDARD_SETTINGS TARGET) 21 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 22 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 23 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 24 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 25 | endfunction() 26 | 27 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 28 | 29 | # Flutter library and tool build rules. 30 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 31 | 32 | # System-level dependencies. 33 | find_package(PkgConfig REQUIRED) 34 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 35 | 36 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 37 | 38 | # Application build 39 | add_executable(${BINARY_NAME} 40 | "main.cc" 41 | "my_application.cc" 42 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 43 | ) 44 | apply_standard_settings(${BINARY_NAME}) 45 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 46 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 47 | add_dependencies(${BINARY_NAME} flutter_assemble) 48 | # Only the install-generated bundle's copy of the executable will launch 49 | # correctly, since the resources must in the right relative locations. To avoid 50 | # people trying to run the unbundled copy, put it in a subdirectory instead of 51 | # the default top-level location. 52 | set_target_properties(${BINARY_NAME} 53 | PROPERTIES 54 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 55 | ) 56 | 57 | # Generated plugin build rules, which manage building the plugins and adding 58 | # them to the application. 59 | include(flutter/generated_plugins.cmake) 60 | 61 | 62 | # === Installation === 63 | # By default, "installing" just makes a relocatable bundle in the build 64 | # directory. 65 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 66 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 67 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 68 | endif() 69 | 70 | # Start with a clean build bundle directory every time. 71 | install(CODE " 72 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 73 | " COMPONENT Runtime) 74 | 75 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 76 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 77 | 78 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 82 | COMPONENT Runtime) 83 | 84 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 85 | COMPONENT Runtime) 86 | 87 | if(PLUGIN_BUNDLED_LIBRARIES) 88 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 89 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 90 | COMPONENT Runtime) 91 | endif() 92 | 93 | # Fully re-copy the assets directory on each build to avoid having stale files 94 | # from a previous install. 95 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 96 | install(CODE " 97 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 98 | " COMPONENT Runtime) 99 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 100 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 101 | 102 | # Install the AOT library on non-Debug builds only. 103 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 104 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 105 | COMPONENT Runtime) 106 | endif() 107 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /lib/widgets/fancy_options.dart: -------------------------------------------------------------------------------- 1 | import 'package:chess_bot/util/utils.dart'; 2 | import 'package:chess_bot/widgets/fancy_button.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | bool collapseFancyOptions = false; 6 | 7 | class FancyOptions extends StatefulWidget { 8 | final List children; 9 | final String rootText; 10 | final IconData rootIcon; 11 | final bool up; 12 | final double widgetHeight, widgetWidth; 13 | 14 | FancyOptions({ 15 | Key key, 16 | this.children = const [], 17 | this.rootText, 18 | this.rootIcon, 19 | this.up = true, 20 | this.widgetHeight = 40, 21 | this.widgetWidth = 150, 22 | }) : super(key: key); 23 | 24 | @override 25 | _FancyOptionsState createState() => _FancyOptionsState(); 26 | } 27 | 28 | class _FancyOptionsState extends State 29 | with SingleTickerProviderStateMixin { 30 | AnimationController _controller; 31 | List animations = []; 32 | bool visible = false; 33 | 34 | @override 35 | void initState() { 36 | //create controller once 37 | _controller = 38 | AnimationController(vsync: this, duration: Duration(milliseconds: 150)); 39 | //and the animations for the children 40 | double yOffset = additionalHeight; 41 | for (int i = 0; i < widget.children.length; i++) { 42 | double randomWeight = random.nextDouble() * 100, 43 | randomDistribution = random.nextDouble() * yOffset; 44 | animations.add(TweenSequence([ 45 | TweenSequenceItem( 46 | tween: Tween(begin: 0.0, end: randomDistribution), 47 | weight: randomWeight), 48 | TweenSequenceItem( 49 | tween: Tween(begin: randomDistribution, end: yOffset), 50 | weight: 100 - randomWeight), 51 | ]).animate(_controller)); 52 | 53 | yOffset += additionalHeight; 54 | } 55 | 56 | //call super to init 57 | super.initState(); 58 | //then add the listener 59 | _controller.addListener(() { 60 | setState(() {}); 61 | }); 62 | //if is dismissed (reversed) set visible false again 63 | _controller.addStatusListener((status) { 64 | if (status == AnimationStatus.dismissed) visible = false; 65 | }); 66 | } 67 | 68 | double get additionalHeight { 69 | return (widget.up ? -1 : 1) * (widget.widgetHeight + 4); 70 | } 71 | 72 | @override 73 | void dispose() { 74 | _controller.dispose(); 75 | super.dispose(); 76 | } 77 | 78 | @override 79 | Widget build(BuildContext context) { 80 | if (collapseFancyOptions && _controller.isCompleted) { 81 | collapseFancyOptions = false; 82 | _controller.reverse(); 83 | } 84 | 85 | List childrenTransforms = []; 86 | //create the transforms for the children 87 | for (int i = 0; i < widget.children.length; i++) { 88 | childrenTransforms.add(Visibility( 89 | visible: visible, 90 | child: Transform.translate( 91 | offset: Offset(0, animations[i].value), 92 | child: widget.children[i], 93 | ), 94 | )); 95 | } 96 | 97 | List ignorePointer = []; 98 | if (_controller.isCompleted) { 99 | double maxHeight = additionalHeight.abs() * (widget.children.length + 1); 100 | ignorePointer = [ 101 | IgnorePointer( 102 | child: Container( 103 | width: widget.widgetWidth, 104 | height: maxHeight, 105 | ), 106 | ) 107 | ]; 108 | } 109 | 110 | return Stack( 111 | alignment: Alignment.bottomCenter, 112 | children: ignorePointer + 113 | childrenTransforms + 114 | [ 115 | FancyButton( 116 | onPressed: () { 117 | if (_controller.isCompleted) 118 | _controller.reverse(); 119 | else { 120 | _controller.forward(); 121 | visible = true; 122 | } 123 | }, 124 | animation: FancyButtonAnimation.pulse, 125 | icon: widget.rootIcon, 126 | text: widget.rootText, 127 | width: -1, 128 | ), 129 | ], 130 | ); 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /lib/widgets/fancy_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | enum FancyButtonAnimation { rotate_right, rotate_left, pulse } 4 | 5 | class FancyButton extends StatefulWidget { 6 | final VoidCallback onPressed; 7 | final String text; 8 | final IconData icon; 9 | final Color splashColor, fillColor, iconColor; 10 | final bool visible; 11 | final double width; 12 | 13 | final FancyButtonAnimation animation; 14 | 15 | FancyButton({ 16 | Key key, 17 | this.width = -1, 18 | this.onPressed, 19 | this.visible = true, 20 | this.text = "", 21 | this.icon, 22 | this.splashColor = Colors.white60, 23 | this.fillColor = Colors.brown, 24 | this.iconColor = Colors.white60, 25 | this.animation = FancyButtonAnimation.rotate_right, 26 | }) : super(key: key); 27 | 28 | @override 29 | _FancyButtonState createState() => _FancyButtonState(); 30 | } 31 | 32 | class _FancyButtonState extends State 33 | with SingleTickerProviderStateMixin { 34 | AnimationController animationController; 35 | 36 | void onTapped() { 37 | //animate, then call callback 38 | animationController.forward(); 39 | widget?.onPressed(); 40 | } 41 | 42 | @override 43 | Widget build(BuildContext context) { 44 | //predefine icon since anim could change 45 | var icon = Icon( 46 | widget.icon, 47 | color: widget.iconColor, 48 | ); 49 | //set the transition according to enum with switch case 50 | var _transition; 51 | switch (widget.animation) { 52 | case FancyButtonAnimation.rotate_right: 53 | _transition = RotationTransition( 54 | turns: Tween( 55 | begin: 0.0, 56 | end: 1.0, 57 | ).animate(animationController), 58 | child: icon, 59 | ); 60 | break; 61 | case FancyButtonAnimation.rotate_left: 62 | _transition = RotationTransition( 63 | turns: Tween( 64 | begin: 1.0, 65 | end: 0.0, 66 | ).animate(animationController), 67 | child: icon, 68 | ); 69 | break; 70 | case FancyButtonAnimation.pulse: 71 | _transition = FadeTransition( 72 | opacity: Tween(begin: 1.0, end: 0.0).animate(animationController), 73 | child: icon, 74 | ); 75 | break; 76 | default: 77 | break; 78 | } 79 | 80 | //the button 81 | Widget button = Visibility( 82 | visible: widget.visible, 83 | child: Container( 84 | height: 40, 85 | child: Align( 86 | alignment: Alignment.bottomCenter, 87 | child: RawMaterialButton( 88 | onPressed: onTapped, 89 | splashColor: widget.splashColor, 90 | fillColor: widget.fillColor, 91 | shape: StadiumBorder(), 92 | child: Padding( 93 | padding: const EdgeInsets.symmetric( 94 | vertical: 8.0, 95 | horizontal: 20.0, 96 | ), 97 | child: Row( 98 | mainAxisSize: MainAxisSize.min, 99 | children: [ 100 | widget.icon == null ? Container() : _transition, 101 | SizedBox( 102 | //set the sized box only 8 wide when a text is set 103 | width: widget.text.length == 0 || widget.icon == null 104 | ? 0.0 105 | : 8.0, 106 | ), 107 | Text( 108 | widget.text ?? "", 109 | style: TextStyle( 110 | color: widget.iconColor, 111 | ), 112 | ), 113 | ], 114 | ), 115 | ), 116 | ), 117 | ), 118 | ), 119 | ); 120 | 121 | if (widget.width != -1) 122 | return Container( 123 | width: widget.width, 124 | child: button, 125 | ); 126 | else 127 | return button; 128 | } 129 | 130 | @override 131 | void dispose() { 132 | animationController.dispose(); 133 | super.dispose(); 134 | } 135 | 136 | @override 137 | void initState() { 138 | animationController = AnimationController( 139 | duration: const Duration(milliseconds: 400), 140 | vsync: this, 141 | ); 142 | 143 | animationController.addStatusListener((status) { 144 | if (status == AnimationStatus.completed) animationController.reset(); 145 | }); 146 | super.initState(); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /lib/chess_board/src/chess_sub.dart: -------------------------------------------------------------------------------- 1 | import 'package:quiver/core.dart'; 2 | 3 | import '../chess.dart'; 4 | 5 | class Game { 6 | Game(); 7 | 8 | List board = List.filled(128, null); 9 | ColorMap kings = ColorMap.of(-1); 10 | Color turn = Color.WHITE; 11 | ColorMap castling = ColorMap.of(0); 12 | int epSquare = -1; 13 | int halfMoves = 0; 14 | int moveNumber = 1; 15 | List history = []; 16 | } 17 | 18 | class Move { 19 | final Color color; 20 | final int from; 21 | final int to; 22 | final int flags; 23 | final PieceType piece; 24 | final PieceType captured; 25 | final PieceType promotion; 26 | 27 | //for iterative deepening 28 | List children = []; 29 | num eval = 0; 30 | bool gameOver = false, gameDraw = false, additionalEvaluated = false; 31 | 32 | Move(this.color, this.from, this.to, this.flags, this.piece, 33 | this.captured, this.promotion); 34 | 35 | String get fromAlgebraic { 36 | return Chess.algebraic(from); 37 | } 38 | 39 | String get toAlgebraic { 40 | return Chess.algebraic(to); 41 | } 42 | 43 | @override 44 | String toString() { 45 | String fromAlg = Chess.algebraic(from), toAlg = Chess.algebraic(to); 46 | return 'from: $fromAlg to $toAlg'; 47 | } 48 | 49 | @override 50 | bool operator ==(Object other) { 51 | return (other is Move) && (hashCode == other.hashCode); 52 | } 53 | 54 | @override 55 | int get hashCode { 56 | return hashObjects([color, from, to, flags, piece, captured, promotion]); 57 | } 58 | } 59 | 60 | class State { 61 | final Move move; 62 | final ColorMap kings; 63 | final Color turn; 64 | final ColorMap castling; 65 | final int epSquare; 66 | final int halfMoves; 67 | final int moveNumber; 68 | 69 | State(this.move, this.kings, this.turn, this.castling, this.epSquare, 70 | this.halfMoves, this.moveNumber); 71 | } 72 | 73 | class State2 { 74 | final Move move; 75 | final ColorMap castling; 76 | final Color turn; 77 | final int epSquare, halfMoves, moveNumber; 78 | final Map pawnControl, squaresNearKing, pawnCountsByRank, pawnCountsByFile; 79 | 80 | State2( 81 | this.move, 82 | this.turn, 83 | this.castling, 84 | this.epSquare, 85 | this.halfMoves, 86 | this.moveNumber, 87 | this.pawnControl, 88 | this.squaresNearKing, 89 | this.pawnCountsByRank, 90 | this.pawnCountsByFile); 91 | } 92 | 93 | class Piece { 94 | PieceType type; 95 | final Color color; 96 | 97 | Piece(this.type, this.color); 98 | 99 | @override 100 | int get hashCode => hash2(type, color); 101 | 102 | @override 103 | bool operator ==(Object other) { 104 | return (other is Piece) && (other.hashCode == hashCode); 105 | } 106 | 107 | //white is upper case 108 | @override 109 | String toString() => color == Color.WHITE ? type.name.toUpperCase() : type.name; 110 | 111 | } 112 | 113 | class PieceType { 114 | PieceType({this.name, this.shift}); 115 | 116 | final int shift; 117 | final String name; 118 | 119 | const PieceType._internal(this.shift, this.name); 120 | 121 | static const PieceType PAWN = const PieceType._internal(0, 'p'); 122 | static const PieceType KNIGHT = const PieceType._internal(1, 'n'); 123 | static const PieceType BISHOP = const PieceType._internal(2, 'b'); 124 | static const PieceType ROOK = const PieceType._internal(3, 'r'); 125 | static const PieceType QUEEN = const PieceType._internal(4, 'q'); 126 | static const PieceType KING = const PieceType._internal(5, 'k'); 127 | 128 | int get hashCode => shift; 129 | 130 | String toString() => name; 131 | 132 | String toLowerCase() => name; 133 | 134 | String toUpperCase() => name.toUpperCase(); 135 | } 136 | 137 | class Color { 138 | static Color flip(Color color) { 139 | return (color == WHITE) ? BLACK : WHITE; 140 | } 141 | 142 | final int value; 143 | 144 | Color.fromInt(this.value); 145 | 146 | const Color._internal(this.value); 147 | 148 | static const Color WHITE = Color._internal(0); 149 | static const Color BLACK = Color._internal(1); 150 | 151 | int get hashCode => value; 152 | 153 | String toString() => (this == WHITE) ? 'w' : 'b'; 154 | 155 | @override 156 | bool operator ==(Object other) { 157 | return ((other is Color) && (this.value == other.value)) || 158 | ((other is String) && (other == toString())); 159 | } 160 | } 161 | 162 | class ColorMap { 163 | int white; 164 | int black; 165 | 166 | ColorMap.of(int value) 167 | : white = value, 168 | black = value; 169 | 170 | ColorMap.clone(ColorMap other) 171 | : white = other.white, 172 | black = other.black; 173 | 174 | ColorMap(); 175 | 176 | int operator [](Color color) { 177 | return (color == Color.WHITE) ? white : black; 178 | } 179 | 180 | void operator []=(Color color, int value) { 181 | if (color == Color.WHITE) { 182 | white = value; 183 | } else { 184 | black = value; 185 | } 186 | } 187 | 188 | @override 189 | int get hashCode => hash2(white, black); 190 | 191 | @override 192 | bool operator ==(Object other) { 193 | return (other is ColorMap) && (other.hashCode == hashCode); 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /lib/chess_board/src/chess_board.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:scoped_model/scoped_model.dart'; 3 | 4 | import '../chess.dart'; 5 | import 'board_model.dart'; 6 | import 'board_rank.dart'; 7 | import 'chess_board_controller.dart'; 8 | 9 | var whiteSquareList = [ 10 | ["a8", "b8", "c8", "d8", "e8", "f8", "g8", "h8"], 11 | ["a7", "b7", "c7", "d7", "e7", "f7", "g7", "h7"], 12 | ["a6", "b6", "c6", "d6", "e6", "f6", "g6", "h6"], 13 | ["a5", "b5", "c5", "d5", "e5", "f5", "g5", "h5"], 14 | ["a4", "b4", "c4", "d4", "e4", "f4", "g4", "h4"], 15 | ["a3", "b3", "c3", "d3", "e3", "f3", "g3", "h3"], 16 | ["a2", "b2", "c2", "d2", "e2", "f2", "g2", "h2"], 17 | ["a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1"], 18 | ]; 19 | 20 | /// Enum which stores board types 21 | enum BoardType { 22 | brown, 23 | darkBrown, 24 | orange, 25 | green, 26 | } 27 | 28 | BoardType boardTypeFromString(String type) { 29 | switch (type) { 30 | case 'b': 31 | return BoardType.brown; 32 | case 'o': 33 | return BoardType.orange; 34 | case 'g': 35 | return BoardType.green; 36 | default: 37 | return BoardType.darkBrown; 38 | } 39 | } 40 | 41 | /// The Chessboard Widget 42 | class ChessBoard extends StatefulWidget { 43 | /// Size of chessboard 44 | final double size; 45 | 46 | /// Callback for when move is made 47 | final MoveCallback onMove; 48 | 49 | /// Callback for when a player is checkmated 50 | final CheckMateCallback onCheckMate; 51 | 52 | /// Callback for when a player is in check 53 | final CheckCallback onCheck; 54 | 55 | /// Callback for when the game is a draw 56 | final VoidCallback onDraw; 57 | 58 | //the callbacks for returning the controller and game 59 | final Chess chess; 60 | 61 | /// A boolean which notes if white board side is towards users 62 | final bool whiteSideTowardsUser; 63 | 64 | /// A controller to programmatically control the chess board 65 | final ChessBoardController chessBoardController; 66 | 67 | /// A boolean which checks if the user should be allowed to make moves 68 | final bool enableUserMoves; 69 | 70 | /// The color type of the board 71 | final BoardType boardType; 72 | 73 | ChessBoard( 74 | {this.size = 200.0, 75 | this.whiteSideTowardsUser = true, 76 | @required this.onMove, 77 | @required this.onCheckMate, 78 | @required this.onCheck, 79 | @required this.onDraw, 80 | this.chessBoardController, 81 | this.enableUserMoves = true, 82 | this.boardType = BoardType.brown, 83 | this.chess}); 84 | 85 | @override 86 | _ChessBoardState createState() => _ChessBoardState(); 87 | } 88 | 89 | class _ChessBoardState extends State { 90 | @override 91 | Widget build(BuildContext context) { 92 | return ScopedModel( 93 | model: BoardModel( 94 | widget.size, 95 | widget.onMove, 96 | widget.onCheckMate, 97 | widget.onCheck, 98 | widget.onDraw, 99 | widget.whiteSideTowardsUser, 100 | widget.chessBoardController, 101 | widget.enableUserMoves, 102 | widget.chess, 103 | ), 104 | child: Container( 105 | height: widget.size, 106 | width: widget.size, 107 | child: Stack( 108 | children: [ 109 | Container( 110 | height: widget.size, 111 | width: widget.size, 112 | child: _getBoardImage(), 113 | ), 114 | //Overlaying draggables / dragTargets onto the squares 115 | Center( 116 | child: Container( 117 | height: widget.size, 118 | width: widget.size, 119 | child: buildChessBoard(), 120 | ), 121 | ) 122 | ], 123 | ), 124 | ), 125 | ); 126 | } 127 | 128 | /// Builds the board 129 | Widget buildChessBoard() { 130 | return Column( 131 | children: widget.whiteSideTowardsUser 132 | ? whiteSquareList.map((row) { 133 | return ChessBoardRank( 134 | children: row, 135 | ); 136 | }).toList() 137 | : whiteSquareList.reversed.map((row) { 138 | return ChessBoardRank( 139 | children: row.reversed.toList(), 140 | ); 141 | }).toList(), 142 | ); 143 | } 144 | 145 | /// Returns the board image 146 | Image _getBoardImage() { 147 | switch (widget.boardType) { 148 | case BoardType.brown: 149 | return Image.asset( 150 | "res/chess_board/brown_board.png", 151 | fit: BoxFit.cover, 152 | ); 153 | case BoardType.darkBrown: 154 | return Image.asset( 155 | "res/chess_board/dark_brown_board.png", 156 | fit: BoxFit.cover, 157 | ); 158 | case BoardType.green: 159 | return Image.asset( 160 | "res/chess_board/green_board.png", 161 | fit: BoxFit.cover, 162 | ); 163 | case BoardType.orange: 164 | return Image.asset( 165 | "res/chess_board/orange_board.png", 166 | fit: BoxFit.cover, 167 | ); 168 | default: 169 | return null; 170 | } 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /lib/util/online_game_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:chess_bot/chess_board/chess.dart'; 2 | import 'package:chess_bot/chess_control/chess_controller.dart'; 3 | import 'package:chess_bot/util/utils.dart'; 4 | import 'package:chess_bot/util/widget_utils.dart'; 5 | import 'package:cloud_firestore/cloud_firestore.dart'; 6 | import 'package:flutter/material.dart'; 7 | 8 | import '../main.dart'; 9 | 10 | String _createGameCode() { 11 | final availableChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 12 | .runes 13 | .map((int rune) => String.fromCharCode(rune)) 14 | .toList(); 15 | String out = ''; 16 | for (int i = 0; i < 6; i++) 17 | out += availableChars[random.nextInt(availableChars.length)]; 18 | return out; 19 | } 20 | 21 | String _currentGameCode; 22 | 23 | String joinGameCodeWithoutFirebaseCreation({String gameCode}) { 24 | if (gameCode != null) 25 | return _currentGameCode = gameCode; 26 | else 27 | return _currentGameCode = _createGameCode(); 28 | } 29 | 30 | DocumentReference get currentGameDoc { 31 | if (inOnlineGame) 32 | return FirebaseFirestore.instance.collection('games').doc(_currentGameCode); 33 | else 34 | return null; 35 | } 36 | 37 | String get currentGameCode { 38 | return _currentGameCode == null ? strings.local : _currentGameCode; 39 | } 40 | 41 | bool get inOnlineGame { 42 | return _currentGameCode != null; 43 | } 44 | 45 | class OnlineGameController { 46 | final ChessController _chessController; 47 | Function update; 48 | 49 | OnlineGameController(this._chessController); 50 | 51 | void finallyCreateGameCode() { 52 | //create new game id locally 53 | String gameId = joinGameCodeWithoutFirebaseCreation(); 54 | //create the bucket in cloud firestore 55 | //set the local bot disabled etc 56 | _chessController.botBattle = false; 57 | prefs.setBool('bot', false); 58 | prefs.setBool('botbattle', false); 59 | //reset the local game 60 | _chessController.controller.resetBoard(); 61 | //new game map 62 | Map game = {}; 63 | game['white'] = uuid; 64 | game['black'] = null; 65 | game['fen'] = _chessController.game.fen; 66 | game['moveFrom'] = null; 67 | game['moveTo'] = null; 68 | game['id'] = gameId; 69 | //white towards user 70 | _chessController.whiteSideTowardsUser = true; 71 | prefs.setBool('whiteSideTowardsUser', true); 72 | //upload to firebase 73 | currentGameDoc.set(game); 74 | //lock listener 75 | lockListener(); 76 | //update views 77 | update(); 78 | } 79 | 80 | //join and init the game code 81 | void joinGame(String code) { 82 | //create the game locally 83 | joinGameCodeWithoutFirebaseCreation(gameCode: code.toUpperCase()); 84 | //check if the code exists 85 | currentGameDoc.get().then((event) { 86 | //check if doc exists and white is not already this user 87 | if (event.exists) { 88 | //set the local bot disabled etc 89 | _chessController.botBattle = false; 90 | prefs.setBool('bot', false); 91 | prefs.setBool('botbattle', false); 92 | //the player is not white, not rejoining 93 | if(event.get('white') != uuid) { 94 | //if rejoining, overwrite old data 95 | _chessController.game = Chess.fromFEN(event.get('fen')); 96 | ChessController.moveFrom = event.get('moveFrom'); 97 | ChessController.moveTo = event.get('moveTo'); 98 | _chessController.setKingInCheckSquare(); 99 | //set the black id 100 | currentGameDoc.update({'black': uuid}); 101 | //black towards user 102 | _chessController.whiteSideTowardsUser = false; 103 | prefs.setBool('whiteSideTowardsUser', false); 104 | }else { 105 | //reset the local 106 | _chessController.controller.resetBoard(); 107 | //rejoin the game 108 | //black towards user 109 | _chessController.whiteSideTowardsUser = true; 110 | prefs.setBool('whiteSideTowardsUser', true); 111 | } 112 | //lock the listener since the game exists 113 | lockListener(); 114 | //update 115 | update(); 116 | } else { 117 | //game code is null then, inform user 118 | _currentGameCode = null; 119 | showAnimatedDialog( 120 | icon: Icons.warning, 121 | title: strings.warning, 122 | text: strings.game_id_not_found); 123 | } 124 | }); 125 | } 126 | 127 | //leave the online game / set the code to null then update views 128 | void leaveGame() { 129 | //if this player's color was white, delete the doc since he was host 130 | currentGameDoc.get().then((event) { 131 | if(event.get('white') == uuid) 132 | currentGameDoc.delete(); 133 | 134 | //set code to null 135 | _currentGameCode = null; 136 | //refresh views 137 | update(); 138 | }); 139 | } 140 | 141 | void lockListener() { 142 | currentGameDoc.snapshots(includeMetadataChanges: true).listen((event) { 143 | //if the doc does not exist, set game code to null 144 | if (!event.exists) { 145 | _currentGameCode = null; 146 | //reset the game, update the ui 147 | _chessController.controller.resetBoard(); 148 | //and exit this void 149 | return; 150 | } 151 | //only update if the listener is sure that this is not an old game code 152 | //and the data are not null 153 | if (event.data() != null && (event.get('id') == _currentGameCode)) { 154 | //update complete game 155 | _chessController.game = Chess.fromFEN(event.get('fen')); 156 | ChessController.moveFrom = event.get('moveFrom'); 157 | ChessController.moveTo = event.get('moveTo'); 158 | //update king square 159 | _chessController.setKingInCheckSquare(); 160 | //update all views 161 | update(); 162 | } 163 | }); 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /lib/util/widget_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:chess_bot/util/utils.dart'; 2 | import 'package:chess_bot/widgets/divider.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | import '../main.dart'; 6 | 7 | RoundedRectangleBorder roundButtonShape = 8 | RoundedRectangleBorder(borderRadius: BorderRadius.circular(45)); 9 | 10 | typedef void OnDialogCancelCallback(value); 11 | typedef void OnDialogReturnSetStateCallback(BuildContext context, setState); 12 | 13 | bool _showing = false; 14 | 15 | void showAnimatedDialog({ 16 | String title, 17 | String text, 18 | String onDoneText, 19 | String forceCancelText, 20 | List children = const [], 21 | OnDialogCancelCallback onDone, 22 | OnDialogReturnSetStateCallback setStateCallback, 23 | IconData icon, 24 | var update, 25 | bool showAnyActionButton = true, 26 | bool withInputField = false, 27 | String inputFieldHint, 28 | }) async { 29 | if (_showing) return; 30 | 31 | _showing = true; 32 | 33 | String inputText; 34 | 35 | //show dialog 36 | showGeneralDialog( 37 | context: ContextSingleton.context, 38 | barrierDismissible: true, 39 | barrierLabel: "showTextDialog", 40 | pageBuilder: (context, animation1, animation2) { 41 | return Container(); 42 | }, 43 | transitionBuilder: (context, a1, a2, widget) { 44 | final curvedValue = Curves.easeInOutBack.transform(a1.value) - 1.0; 45 | return Transform( 46 | transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0), 47 | child: Opacity( 48 | opacity: a1.value, 49 | child: StatefulBuilder(builder: (context, setState) { 50 | //call the listener that returns the set state 51 | if (setStateCallback != null) setStateCallback(context, setState); 52 | //create the alert dialog object 53 | return AlertDialog( 54 | title: Padding( 55 | padding: EdgeInsets.all(8.0), 56 | child: Row( 57 | mainAxisAlignment: MainAxisAlignment.start, 58 | mainAxisSize: MainAxisSize.min, 59 | children: [ 60 | icon == null ? Container() : Icon(icon), 61 | Divider8(), 62 | Text( 63 | title ?? "", 64 | style: Theme.of(context).textTheme.subtitle1, 65 | ), 66 | ], 67 | )), 68 | content: Column( 69 | mainAxisAlignment: MainAxisAlignment.center, 70 | crossAxisAlignment: CrossAxisAlignment.center, 71 | mainAxisSize: MainAxisSize.min, 72 | children: [ 73 | (text == null) 74 | ? SizedBox() 75 | : Center( 76 | child: Container( 77 | constraints: BoxConstraints(maxWidth: 400), 78 | child: Text( 79 | text ?? "", 80 | textAlign: TextAlign.center, 81 | style: Theme.of(context).textTheme.subtitle2, 82 | ), 83 | ), 84 | ), 85 | Column( 86 | mainAxisSize: MainAxisSize.min, 87 | mainAxisAlignment: MainAxisAlignment.start, 88 | children: [ 89 | Visibility( 90 | visible: withInputField, 91 | child: TextFormField( 92 | maxLines: 1, 93 | onChanged: (value) => inputText = value, 94 | decoration: new InputDecoration( 95 | border: InputBorder.none, 96 | focusedBorder: InputBorder.none, 97 | enabledBorder: InputBorder.none, 98 | errorBorder: InputBorder.none, 99 | disabledBorder: InputBorder.none, 100 | contentPadding: EdgeInsets.only( 101 | left: 15, bottom: 11, top: 11, right: 15), 102 | hintText: inputFieldHint), 103 | ), 104 | ) 105 | ] + 106 | children, 107 | ), 108 | ], 109 | ), 110 | actions: showAnyActionButton 111 | ? [ 112 | FlatButton( 113 | shape: roundButtonShape, 114 | child: Text(forceCancelText != null 115 | ? forceCancelText 116 | : (onDone == null ? strings.ok : strings.cancel)), 117 | onPressed: () { 118 | _showing = false; 119 | Navigator.of(context) 120 | .pop(onDone == null ? 'ok' : null); 121 | }), 122 | onDone != null 123 | ? FlatButton( 124 | shape: roundButtonShape, 125 | child: Text(onDoneText ?? ""), 126 | onPressed: () { 127 | _showing = false; 128 | Navigator.of(context).pop('ok'); 129 | }) 130 | : Container() 131 | ] 132 | : [], 133 | ); 134 | }), 135 | ), 136 | ); 137 | }, 138 | transitionDuration: Duration(milliseconds: 300), 139 | ).then((value) { 140 | //set showing dialog false 141 | _showing = false; 142 | //execute the on done 143 | if (onDone != null && value != null) { 144 | if(withInputField) 145 | onDone(inputText); 146 | else 147 | onDone(value); 148 | } 149 | }); 150 | } 151 | -------------------------------------------------------------------------------- /lib/eval/eval.dart: -------------------------------------------------------------------------------- 1 | import 'package:chess_bot/chess_board/chess.dart'; 2 | import 'package:chess_bot/chess_board/src/chess_sub.dart'; 3 | 4 | class Evaluation { 5 | // ignore: non_constant_identifier_names 6 | final Color _MAX; 7 | 8 | // ignore: non_constant_identifier_names 9 | final bool endGame; 10 | 11 | // ignore: non_constant_identifier_names 12 | final double _LARGE; 13 | 14 | Evaluation(this._MAX, this._LARGE, this.endGame); 15 | 16 | // simple material based evaluation 17 | double evaluatePosition(Chess c, bool gameOver, bool inDraw, int depth) { 18 | if (gameOver) { 19 | if (inDraw) { 20 | // draw is a neutral outcome 21 | return 0.0; 22 | } else { 23 | // otherwise must be a mate 24 | if (c.game.turn == _MAX) { 25 | // avoid mates loss, the deeper the better 26 | //(earlier is worse) 27 | return -_LARGE - depth; 28 | } else { 29 | // go for the loss of the other one, the deeper the worse 30 | //(earlier is better) 31 | return _LARGE - depth; 32 | } 33 | } 34 | } else { 35 | //the final evaluation to be returned 36 | double eval = 0.0; 37 | //loop through all squares 38 | for (int i = Chess.SQUARES_A8; i <= Chess.SQUARES_H1; i++) { 39 | if ((i & 0x88) != 0) { 40 | i += 7; 41 | continue; 42 | } 43 | 44 | Piece piece = c.game.board[i]; 45 | if (piece != null) { 46 | //get the x and y from the map 47 | final x = Chess.file(i), y = Chess.rank(i); 48 | //evaluate the piece at the position 49 | eval += _getPieceValue(piece, x, y); 50 | } 51 | } 52 | 53 | return eval; 54 | } 55 | } 56 | 57 | num _getPieceValue(Piece piece, int x, int y) { 58 | if (piece == null) { 59 | return 0; 60 | } 61 | 62 | var absoluteValue = 63 | _getAbsoluteValue(piece.type, piece.color == Color.WHITE, x, y); 64 | 65 | if (piece.color == _MAX) { 66 | //* lower factor to make the game play rather defensive than losing a piece 67 | return absoluteValue; 68 | } else { 69 | return -absoluteValue; 70 | } 71 | } 72 | 73 | num _getAbsoluteValue(PieceType piece, bool isWhite, int x, int y) { 74 | if (piece.name == 'p') { 75 | return _pieceValues[PieceType.PAWN] + 76 | (isWhite ? _whitePawnEval[y][x] : _blackPawnEval[y][x]); 77 | } else if (piece.name == 'r') { 78 | return _pieceValues[PieceType.ROOK] + 79 | (isWhite ? _whiteRookEval[y][x] : _blackRookEval[y][x]); 80 | } else if (piece.name == 'n') { 81 | return _pieceValues[PieceType.KNIGHT] + _knightEval[y][x]; 82 | } else if (piece.name == 'b') { 83 | return _pieceValues[PieceType.BISHOP] + 84 | (isWhite ? _whiteBishopEval[y][x] : _blackBishopEval[y][x]); 85 | } else if (piece.name == 'q') { 86 | return _pieceValues[PieceType.QUEEN] + _evalQueen[y][x]; 87 | } else if (piece.name == 'k') { 88 | if (endGame) { 89 | return _pieceValues[PieceType.KING] + 90 | (isWhite 91 | ? _whiteKingEvalEndGame[y][x] 92 | : _blackKingEvalEndGame[y][x]); 93 | } else { 94 | return _pieceValues[PieceType.KING] + 95 | (isWhite ? _whiteKingEval[y][x] : _blackKingEval[y][x]); 96 | } 97 | } 98 | 99 | return 0; 100 | } 101 | 102 | //the piece values 103 | static const Map _pieceValues = const { 104 | PieceType.PAWN: 100, 105 | PieceType.KNIGHT: 320, 106 | PieceType.BISHOP: 330, 107 | PieceType.ROOK: 500, 108 | PieceType.QUEEN: 900, 109 | PieceType.KING: 20000 110 | }; 111 | 112 | static List _reverseList(List list) { 113 | return [...list].reversed.toList(); 114 | } 115 | 116 | static const _whitePawnEval = [ 117 | [0, 0, 0, 0, 0, 0, 0, 0], 118 | [5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0], 119 | [1.0, 1.0, 2.0, 3.0, 3.0, 2.0, 1.0, 1.0], 120 | [0.5, 0.5, 1.0, 2.5, 2.5, 1.0, 0.5, 0.5], 121 | [0, 0, 0, 2.0, 2.0, 0, 0, 0], 122 | [0.5, -0.5, -1.0, 0, 0, -1.0, -0.5, 0.5], 123 | [0.5, 1.0, 1.0, -2.0, -2.0, 1.0, 1.0, 0.5], 124 | [0, 0, 0, 0, 0, 0, 0, 0] 125 | ]; 126 | 127 | static final _blackPawnEval = _reverseList(_whitePawnEval); 128 | 129 | static const _knightEval = [ 130 | [-5.0, -4.0, -3.0, -3.0, -3.0, -3.0, -4.0, -5.0], 131 | [-4.0, -2.0, 0, 0, 0, 0, -2.0, -4.0], 132 | [-3.0, 0, 1.0, 1.5, 1.5, 1.0, 0, -3.0], 133 | [-3.0, 0.5, 1.5, 2.0, 2.0, 1.5, 0.5, -3.0], 134 | [-3.0, 0, 1.5, 2.0, 2.0, 1.5, 0, -3.0], 135 | [-3.0, 0.5, 1.0, 1.5, 1.5, 1.0, 0.5, -3.0], 136 | [-4.0, -2.0, 0, 0.5, 0.5, 0, -2.0, -4.0], 137 | [-5.0, -4.0, -3.0, -3.0, -3.0, -3.0, -4.0, -5.0], 138 | ]; 139 | 140 | static const _whiteBishopEval = [ 141 | [-2.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -2.0], 142 | [-1.0, 0, 0, 0, 0, 0, 0, -1.0], 143 | [-1.0, 0, 0.5, 1.0, 1.0, 0.5, 0, -1.0], 144 | [-1.0, 0.5, 0.5, 1.0, 1.0, 0.5, 0.5, -1.0], 145 | [-1.0, 0, 1.0, 1.0, 1.0, 1.0, 0, -1.0], 146 | [-1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0], 147 | [-1.0, 0.5, 0, 0, 0, 0, 0.5, -1.0], 148 | [-2.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -2.0], 149 | ]; 150 | 151 | static final _blackBishopEval = _reverseList(_whiteBishopEval); 152 | 153 | static const _whiteRookEval = [ 154 | [0, 0, 0, 0, 0, 0, 0, 0], 155 | [0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5], 156 | [-0.5, 0, 0, 0, 0, 0, 0, -0.5], 157 | [-0.5, 0, 0, 0, 0, 0, 0, -0.5], 158 | [-0.5, 0, 0, 0, 0, 0, 0, -0.5], 159 | [-0.5, 0, 0, 0, 0, 0, 0, -0.5], 160 | [-0.5, 0, 0, 0, 0, 0, 0, -0.5], 161 | [0, 0, 0, 0.5, 0.5, 0, 0, 0] 162 | ]; 163 | 164 | static final _blackRookEval = _reverseList(_whiteRookEval); 165 | 166 | static const _evalQueen = [ 167 | [-2.0, -1.0, -1.0, -0.5, -0.5, -1.0, -1.0, -2.0], 168 | [-1.0, 0, 0, 0, 0, 0, 0, -1.0], 169 | [-1.0, 0, 0.5, 0.5, 0.5, 0.5, 0, -1.0], 170 | [-0.5, 0, 0.5, 0.5, 0.5, 0.5, 0, -0.5], 171 | [0, 0, 0.5, 0.5, 0.5, 0.5, 0, -0.5], 172 | [-1.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0, -1.0], 173 | [-1.0, 0, 0.5, 0, 0, 0, 0, -1.0], 174 | [-2.0, -1.0, -1.0, -0.5, -0.5, -1.0, -1.0, -2.0] 175 | ]; 176 | 177 | static const _whiteKingEval = [ 178 | [-3.0, -4.0, -4.0, -5.0, -5.0, -4.0, -4.0, -3.0], 179 | [-3.0, -4.0, -4.0, -5.0, -5.0, -4.0, -4.0, -3.0], 180 | [-3.0, -4.0, -4.0, -5.0, -5.0, -4.0, -4.0, -3.0], 181 | [-3.0, -4.0, -4.0, -5.0, -5.0, -4.0, -4.0, -3.0], 182 | [-2.0, -3.0, -3.0, -4.0, -4.0, -3.0, -3.0, -2.0], 183 | [-1.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -1.0], 184 | [2.0, 2.0, 0, 0, 0, 0, 2.0, 2.0], 185 | [2.0, 3.0, 1.0, 0, 0, 1.0, 3.0, 2.0] 186 | ]; 187 | 188 | static final _blackKingEval = _reverseList(_whiteKingEval); 189 | 190 | static const _whiteKingEvalEndGame = [ 191 | [-5.0, -4.0, -3.0, -2.0, -2.0, -3.0, -4.0, -5.0], 192 | [-3.0, -2.0, -1.0, 0, 0, -1.0, -2.0, -3.0], 193 | [-3.0, -1.0, 2.0, 3.0, 3.0, 2.0, -1.0, -3.0], 194 | [-3.0, -1.0, 3.0, 4.0, 4.0, 3.0, -1.0, -3.0], 195 | [-3.0, -1.0, 3.0, 4.0, 4.0, 3.0, -1.0, -3.0], 196 | [-3.0, -1.0, 2.0, 3.0, 3.0, 2.0, -1.0, -3.0], 197 | [-3.0, -3.0, 0, 0, 0, 0, -3.0, -3.0], 198 | [-5.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -5.0] 199 | ]; 200 | 201 | static final _blackKingEvalEndGame = _reverseList(_whiteKingEvalEndGame); 202 | 203 | //for taking good positions, but not for losing a piece 204 | static const _OWN_LOSS_WORSE_FACTOR = 1; 205 | 206 | static bool isEndGame(Chess chess) { 207 | int pieceCount = 0; 208 | chess.forEachPiece((piece) { 209 | pieceCount++; 210 | }); 211 | 212 | return pieceCount < 12; 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /lib/generated/i18n.dart: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. This is code generated via package:gen_lang/generate.dart 2 | 3 | import 'dart:async'; 4 | 5 | import 'package:intl/intl.dart'; 6 | import 'package:flutter/material.dart'; 7 | 8 | import 'messages_all.dart'; 9 | 10 | class S { 11 | 12 | static const GeneratedLocalizationsDelegate delegate = GeneratedLocalizationsDelegate(); 13 | 14 | static S of(BuildContext context) { 15 | return Localizations.of(context, S); 16 | } 17 | 18 | static Future load(Locale locale) { 19 | final String name = locale.countryCode == null ? locale.languageCode : locale.toString(); 20 | 21 | final String localeName = Intl.canonicalizedLocale(name); 22 | 23 | return initializeMessages(localeName).then((bool _) { 24 | Intl.defaultLocale = localeName; 25 | return new S(); 26 | }); 27 | } 28 | 29 | String get app_name { 30 | return Intl.message("Chess", name: 'app_name'); 31 | } 32 | 33 | String get cancel { 34 | return Intl.message("cancel", name: 'cancel'); 35 | } 36 | 37 | String get choose_promotion { 38 | return Intl.message("choose promotion", name: 'choose_promotion'); 39 | } 40 | 41 | String get checkmate { 42 | return Intl.message("checkmate", name: 'checkmate'); 43 | } 44 | 45 | String get draw { 46 | return Intl.message("draw", name: 'draw'); 47 | } 48 | 49 | String get error { 50 | return Intl.message("error", name: 'error'); 51 | } 52 | 53 | String get draw_desc { 54 | return Intl.message("The game finished with a draw!", name: 'draw_desc'); 55 | } 56 | 57 | String get replay { 58 | return Intl.message("replay", name: 'replay'); 59 | } 60 | 61 | String get ok { 62 | return Intl.message("ok", name: 'ok'); 63 | } 64 | 65 | String get white { 66 | return Intl.message("white", name: 'white'); 67 | } 68 | 69 | String get black { 70 | return Intl.message("black", name: 'black'); 71 | } 72 | 73 | String check_mate_desc(loser, winner) { 74 | return Intl.message("${loser} is in checkmate. ${winner} won.", name: 'check_mate_desc', args: [loser, winner]); 75 | } 76 | 77 | String turn_of_x(turn) { 78 | return Intl.message("${turn}'s turn", name: 'turn_of_x', args: [turn]); 79 | } 80 | 81 | String get replay_desc { 82 | return Intl.message("Are you sure to restart the game and reset the board?", name: 'replay_desc'); 83 | } 84 | 85 | String get undo_impossible { 86 | return Intl.message("can't perform undo", name: 'undo_impossible'); 87 | } 88 | 89 | String get undo { 90 | return Intl.message("undo", name: 'undo'); 91 | } 92 | 93 | String get choose_style { 94 | return Intl.message("change board style", name: 'choose_style'); 95 | } 96 | 97 | String get bot_on { 98 | return Intl.message("bot on", name: 'bot_on'); 99 | } 100 | 101 | String get bot_off { 102 | return Intl.message("bot off", name: 'bot_off'); 103 | } 104 | 105 | String moves_done(progress) { 106 | return Intl.message("${progress} boards processed", name: 'moves_done', args: [progress]); 107 | } 108 | 109 | String get difficulty { 110 | return Intl.message("depth", name: 'difficulty'); 111 | } 112 | 113 | String get difficulties { 114 | return Intl.message("auto,2,3,4,5", name: 'difficulties'); 115 | } 116 | 117 | String get fen_options { 118 | return Intl.message("to clipboard,from clipboard", name: 'fen_options'); 119 | } 120 | 121 | String get bot_vs_bot { 122 | return Intl.message("bot vs. bot", name: 'bot_vs_bot'); 123 | } 124 | 125 | String get copy_fen { 126 | return Intl.message("copy fen", name: 'copy_fen'); 127 | } 128 | 129 | String get privacy_url { 130 | return Intl.message("https://l-chess.flycricket.io/privacy.html", name: 'privacy_url'); 131 | } 132 | 133 | String get terms_url { 134 | return Intl.message("https://l-chess.flycricket.io/terms.html", name: 'terms_url'); 135 | } 136 | 137 | String get privacy_title { 138 | return Intl.message("privacy policy", name: 'privacy_title'); 139 | } 140 | 141 | String get loading_moves_web { 142 | return Intl.message("loading moves...", name: 'loading_moves_web'); 143 | } 144 | 145 | String get online_game_options { 146 | return Intl.message("online game", name: 'online_game_options'); 147 | } 148 | 149 | String get join_code { 150 | return Intl.message("join game", name: 'join_code'); 151 | } 152 | 153 | String get create_code { 154 | return Intl.message("create game", name: 'create_code'); 155 | } 156 | 157 | String get local { 158 | return Intl.message("[local game]", name: 'local'); 159 | } 160 | 161 | String get warning { 162 | return Intl.message("warning!", name: 'warning'); 163 | } 164 | 165 | String get game_reset_join_code_warning { 166 | return Intl.message("By creating a new game code, you will reset your local board and leave a running online game. A friend can join your game via the generated code. The creator of the game is always white.", name: 'game_reset_join_code_warning'); 167 | } 168 | 169 | String get proceed { 170 | return Intl.message("proceed", name: 'proceed'); 171 | } 172 | 173 | String get leave_online_game { 174 | return Intl.message("leave game", name: 'leave_online_game'); 175 | } 176 | 177 | String get enter_game_id { 178 | return Intl.message("enter a game id", name: 'enter_game_id'); 179 | } 180 | 181 | String get game_id_not_found { 182 | return Intl.message("game id not found", name: 'game_id_not_found'); 183 | } 184 | 185 | String get game_id_ex { 186 | return Intl.message("ex.: KDFGHQ", name: 'game_id_ex'); 187 | } 188 | 189 | String get join { 190 | return Intl.message("join", name: 'join'); 191 | } 192 | 193 | String get deleting_as_host_info { 194 | return Intl.message("Since you are hosting the game, leaving it means deleting it.", name: 'deleting_as_host_info'); 195 | } 196 | 197 | String get switch_colors { 198 | return Intl.message("turn board", name: 'switch_colors'); 199 | } 200 | 201 | String get availability_other_devices { 202 | return Intl.message("platforms", name: 'availability_other_devices'); 203 | } 204 | 205 | String get android { 206 | return Intl.message("android", name: 'android'); 207 | } 208 | 209 | String get web { 210 | return Intl.message("web", name: 'web'); 211 | } 212 | 213 | String get website_url { 214 | return Intl.message("https://chess-45a81.web.app/#/", name: 'website_url'); 215 | } 216 | 217 | String get playstore_url { 218 | return Intl.message("https://play.google.com/store/apps/details?id=com.lurzapps.chess", name: 'playstore_url'); 219 | } 220 | 221 | 222 | } 223 | 224 | class GeneratedLocalizationsDelegate extends LocalizationsDelegate { 225 | const GeneratedLocalizationsDelegate(); 226 | 227 | List get supportedLocales { 228 | return const [ 229 | Locale("en", ""), 230 | Locale("de", ""), 231 | 232 | ]; 233 | } 234 | 235 | LocaleListResolutionCallback listResolution({Locale fallback}) { 236 | return (List locales, Iterable supported) { 237 | if (locales == null || locales.isEmpty) { 238 | return fallback ?? supported.first; 239 | } else { 240 | return _resolve(locales.first, fallback, supported); 241 | } 242 | }; 243 | } 244 | 245 | LocaleResolutionCallback resolution({Locale fallback}) { 246 | return (Locale locale, Iterable supported) { 247 | return _resolve(locale, fallback, supported); 248 | }; 249 | } 250 | 251 | Locale _resolve(Locale locale, Locale fallback, Iterable supported) { 252 | if (locale == null || !isSupported(locale)) { 253 | return fallback ?? supported.first; 254 | } 255 | 256 | final Locale languageLocale = Locale(locale.languageCode, ""); 257 | if (supported.contains(locale)) { 258 | return locale; 259 | } else if (supported.contains(languageLocale)) { 260 | return languageLocale; 261 | } else { 262 | final Locale fallbackLocale = fallback ?? supported.first; 263 | return fallbackLocale; 264 | } 265 | } 266 | 267 | @override 268 | Future load(Locale locale) { 269 | return S.load(locale); 270 | } 271 | 272 | @override 273 | bool isSupported(Locale locale) => 274 | locale != null && supportedLocales.contains(locale); 275 | 276 | @override 277 | bool shouldReload(GeneratedLocalizationsDelegate old) => false; 278 | } 279 | 280 | // ignore_for_file: unnecessary_brace_in_string_interps 281 | -------------------------------------------------------------------------------- /lib/chess_board/src/board_square.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:chess_bot/chess_board/src/chess_sub.dart' as chess; 4 | import 'package:chess_vectors_flutter/chess_vectors_flutter.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:scoped_model/scoped_model.dart'; 7 | 8 | import '../../chess_control/chess_controller.dart'; 9 | import '../../main.dart'; 10 | import 'board_model.dart'; 11 | 12 | class BoardSquare extends StatefulWidget { 13 | final String squareName; 14 | 15 | BoardSquare({Key key, this.squareName}) : super(key: key); 16 | 17 | @override 18 | _BoardSquareState createState() => _BoardSquareState(); 19 | } 20 | 21 | /// A single square on the chessboard 22 | class _BoardSquareState extends State 23 | with SingleTickerProviderStateMixin { 24 | AnimationController _animationController; 25 | 26 | @override 27 | void initState() { 28 | _animationController = 29 | new AnimationController(vsync: this, duration: Duration(seconds: 0)); 30 | super.initState(); 31 | } 32 | 33 | @override 34 | void dispose() { 35 | _animationController.dispose(); 36 | super.dispose(); 37 | } 38 | 39 | @override 40 | Widget build(BuildContext context) { 41 | Color background = Colors.transparent; 42 | 43 | int milliseconds = 0; 44 | if (((widget.squareName == ChessController.moveFrom) || 45 | (widget.squareName == ChessController.moveTo))) { 46 | if (!ChessController.loadingBotMoves) milliseconds = 600; 47 | background = Colors.green[700]; 48 | } 49 | 50 | if (ChessController.kingInCheck == widget.squareName) 51 | background = Colors.red[800]; 52 | 53 | _animationController.duration = Duration(milliseconds: milliseconds); 54 | _animationController.forward(from: 0); 55 | 56 | return ScopedModelDescendant(builder: (context, _, model) { 57 | return Expanded( 58 | flex: 1, 59 | child: Stack(children: [ 60 | Padding( 61 | padding: const EdgeInsets.all(4.0), 62 | child: ClipRRect( 63 | borderRadius: BorderRadius.circular(4.0), 64 | child: Container( 65 | color: background, 66 | ), 67 | ), 68 | ), 69 | FadeTransition( 70 | opacity: _animationController, 71 | child: DragTarget(builder: (context, accepted, rejected) { 72 | var childImage = 73 | _getImageToDisplay(size: model.size / 8, model: model); 74 | var feedbackImage = _getImageToDisplay( 75 | size: (1.2 * (model.size / 8)), model: model); 76 | 77 | return model.game.get(widget.squareName) != null 78 | ? Draggable( 79 | child: childImage, 80 | feedback: feedbackImage, 81 | childWhenDragging: Container(), 82 | data: [ 83 | widget.squareName, 84 | model.game.get(widget.squareName).type.toUpperCase(), 85 | model.game.get(widget.squareName).color, 86 | ], 87 | ) 88 | : Container(); 89 | }, onWillAccept: (willAccept) { 90 | return (model?.chessBoardController?.userCanMakeMoves ?? false); 91 | }, onAccept: (List moveInfo) { 92 | // A way to check if move occurred. 93 | chess.Color moveColor = model.game.game.turn; 94 | 95 | if (moveInfo[1] == "P" && 96 | ((moveInfo[0][1] == "7" && 97 | widget.squareName[1] == "8" && 98 | moveInfo[2] == chess.Color.WHITE) || 99 | (moveInfo[0][1] == "2" && 100 | widget.squareName[1] == "1" && 101 | moveInfo[2] == chess.Color.BLACK))) { 102 | _promotionDialog(context).then((value) { 103 | model.game.move({ 104 | "from": moveInfo[0], 105 | "to": widget.squareName, 106 | "promotion": value 107 | }); 108 | //refresh the board 109 | model.refreshBoard(); 110 | //after the promotion refresh the board and call on move 111 | if (model.game.game.turn != moveColor) { 112 | model 113 | .onMove({'from': moveInfo[0], 'to': widget.squareName}); 114 | } 115 | }); 116 | } else { 117 | model.game.move({"from": moveInfo[0], "to": widget.squareName}); 118 | } 119 | 120 | model.refreshBoard(); 121 | 122 | if (model.game.game.turn != moveColor) { 123 | model.onMove({'from': moveInfo[0], 'to': widget.squareName}); 124 | } 125 | }), 126 | ), 127 | ]), 128 | ); 129 | }); 130 | } 131 | 132 | //Show dialog when pawn reaches last square 133 | Future _promotionDialog(BuildContext context) async { 134 | return showDialog( 135 | context: context, 136 | barrierDismissible: false, 137 | builder: (BuildContext context) { 138 | return new AlertDialog( 139 | title: Text(strings.choose_promotion), 140 | content: Row( 141 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 142 | children: [ 143 | InkWell( 144 | child: WhiteQueen(), 145 | onTap: () { 146 | Navigator.of(context).pop("q"); 147 | }, 148 | ), 149 | InkWell( 150 | child: WhiteRook(), 151 | onTap: () { 152 | Navigator.of(context).pop("r"); 153 | }, 154 | ), 155 | InkWell( 156 | child: WhiteBishop(), 157 | onTap: () { 158 | Navigator.of(context).pop("b"); 159 | }, 160 | ), 161 | InkWell( 162 | child: WhiteKnight(), 163 | onTap: () { 164 | Navigator.of(context).pop("n"); 165 | }, 166 | ), 167 | ], 168 | ), 169 | ); 170 | }, 171 | ).then((value) { 172 | return value; 173 | }); 174 | } 175 | 176 | /// Get image to display on square 177 | Widget _getImageToDisplay({double size, BoardModel model}) { 178 | Widget imageToDisplay = Container(); 179 | 180 | if (model.game.get(widget.squareName) == null) { 181 | return Container(); 182 | } 183 | 184 | var piece0 = model.game.get(widget.squareName); 185 | String piece = piece0.color.toString().substring(0, 1).toUpperCase() + 186 | model.game.get(widget.squareName).type.toUpperCase(); 187 | 188 | switch (piece) { 189 | case "WP": 190 | imageToDisplay = WhitePawn(size: size); 191 | break; 192 | case "WR": 193 | imageToDisplay = WhiteRook(size: size); 194 | break; 195 | case "WN": 196 | imageToDisplay = WhiteKnight(size: size); 197 | break; 198 | case "WB": 199 | imageToDisplay = WhiteBishop(size: size); 200 | break; 201 | case "WQ": 202 | imageToDisplay = WhiteQueen(size: size); 203 | break; 204 | case "WK": 205 | imageToDisplay = WhiteKing(size: size); 206 | break; 207 | case "BP": 208 | imageToDisplay = BlackPawn(size: size); 209 | break; 210 | case "BR": 211 | imageToDisplay = BlackRook(size: size); 212 | break; 213 | case "BN": 214 | imageToDisplay = BlackKnight(size: size); 215 | break; 216 | case "BB": 217 | imageToDisplay = BlackBishop(size: size); 218 | break; 219 | case "BQ": 220 | imageToDisplay = BlackQueen(size: size); 221 | break; 222 | case "BK": 223 | imageToDisplay = BlackKing(size: size); 224 | break; 225 | default: 226 | imageToDisplay = WhitePawn(size: size); 227 | } 228 | 229 | /*//turn the image in if is needed 230 | if ((ChessController.whiteSideTowardsUser && 231 | piece0.color == chess.Color.BLACK) || 232 | (!ChessController.whiteSideTowardsUser && 233 | piece0.color == chess.Color.WHITE)) 234 | return Transform.rotate( 235 | angle: pi, 236 | child: imageToDisplay, 237 | );*/ 238 | 239 | return imageToDisplay; 240 | } 241 | } 242 | -------------------------------------------------------------------------------- /lib/generated/messages_all.dart: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. This is code generated via package:gen_lang/generate.dart 2 | 3 | import 'dart:async'; 4 | 5 | import 'package:intl/intl.dart'; 6 | import 'package:intl/message_lookup_by_library.dart'; 7 | // ignore: implementation_imports 8 | import 'package:intl/src/intl_helpers.dart'; 9 | 10 | final _$de = $de(); 11 | 12 | class $de extends MessageLookupByLibrary { 13 | get localeName => 'de'; 14 | 15 | final messages = { 16 | "app_name" : MessageLookupByLibrary.simpleMessage("Schach"), 17 | "cancel" : MessageLookupByLibrary.simpleMessage("schließen"), 18 | "choose_promotion" : MessageLookupByLibrary.simpleMessage("Umwandlung wählen"), 19 | "checkmate" : MessageLookupByLibrary.simpleMessage("Schachmatt"), 20 | "draw" : MessageLookupByLibrary.simpleMessage("Unentschieden"), 21 | "error" : MessageLookupByLibrary.simpleMessage("Fehler"), 22 | "draw_desc" : MessageLookupByLibrary.simpleMessage("Das Spiel wurde mit einem Unentschieden beendet!"), 23 | "replay" : MessageLookupByLibrary.simpleMessage("neu spielen"), 24 | "ok" : MessageLookupByLibrary.simpleMessage("ok"), 25 | "white" : MessageLookupByLibrary.simpleMessage("weiß"), 26 | "black" : MessageLookupByLibrary.simpleMessage("schwarz"), 27 | "check_mate_desc" : (loser, winner) => "${loser} ist Schachmatt. ${winner} hat gewonnen.", 28 | "turn_of_x" : (turn) => "${turn} ist am Zug", 29 | "replay_desc" : MessageLookupByLibrary.simpleMessage("Bist du dir sicher, dass du das Spiel neustarten willst?"), 30 | "undo_impossible" : MessageLookupByLibrary.simpleMessage("Zug kann nicht rückgänig gemacht werden"), 31 | "undo" : MessageLookupByLibrary.simpleMessage("rückgängig"), 32 | "choose_style" : MessageLookupByLibrary.simpleMessage("Brett-Stil ändern"), 33 | "bot_on" : MessageLookupByLibrary.simpleMessage("bot an"), 34 | "bot_off" : MessageLookupByLibrary.simpleMessage("bot aus"), 35 | "legal" : MessageLookupByLibrary.simpleMessage("von Lurzapps"), 36 | "moves_done" : (progress) => "${progress} Bretter verarbeitet", 37 | "difficulty" : MessageLookupByLibrary.simpleMessage("Tiefe"), 38 | "difficulties" : MessageLookupByLibrary.simpleMessage("auto,2,3,4,5"), 39 | "fen_options" : MessageLookupByLibrary.simpleMessage("in Zwischenablage,aus Zwischenablage"), 40 | "bot_vs_bot" : MessageLookupByLibrary.simpleMessage("bot vs. bot"), 41 | "copy_fen" : MessageLookupByLibrary.simpleMessage("fen kopieren"), 42 | "loading_moves_web" : MessageLookupByLibrary.simpleMessage("lädt Züge..."), 43 | "online_game_options" : MessageLookupByLibrary.simpleMessage("online-Spiel"), 44 | "join_code" : MessageLookupByLibrary.simpleMessage("Spiel beitreten"), 45 | "create_code" : MessageLookupByLibrary.simpleMessage("Spiel erstellen"), 46 | "local" : MessageLookupByLibrary.simpleMessage("[lokales Spiel]"), 47 | "warning" : MessageLookupByLibrary.simpleMessage("Warnung!"), 48 | "game_reset_join_code_warning" : MessageLookupByLibrary.simpleMessage("Durch diese Aktion wird ein neues Spiel erstellt, über das einer deiner Freunde über einen generierten code beitreten kann. Dabei werden alle lokalen Spiele zurückgesetzt und die Verbindung zu einem laufenden anderen Spiele-Code getrennt. Der Ersteller des Spiels ist immer weiß"), 49 | "proceed" : MessageLookupByLibrary.simpleMessage("fortfahren"), 50 | "leave_online_game" : MessageLookupByLibrary.simpleMessage("Spiel verlassen"), 51 | "enter_game_id" : MessageLookupByLibrary.simpleMessage("Spiele-Code eingeben"), 52 | "game_id_not_found" : MessageLookupByLibrary.simpleMessage("Spiele-Code wurde nicht gefunden"), 53 | "game_id_ex" : MessageLookupByLibrary.simpleMessage("z.B.: KDFGHQ"), 54 | "join" : MessageLookupByLibrary.simpleMessage("beitreten"), 55 | "deleting_as_host_info" : MessageLookupByLibrary.simpleMessage("Dadurch wird das gesamte Spiel gelöscht, da du der Host bist."), 56 | "switch_colors" : MessageLookupByLibrary.simpleMessage("brett drehen"), 57 | "availability_other_devices" : MessageLookupByLibrary.simpleMessage("Plattformen"), 58 | 59 | }; 60 | } 61 | 62 | final _$en = $en(); 63 | 64 | class $en extends MessageLookupByLibrary { 65 | get localeName => 'en'; 66 | 67 | final messages = { 68 | "app_name" : MessageLookupByLibrary.simpleMessage("Chess"), 69 | "cancel" : MessageLookupByLibrary.simpleMessage("cancel"), 70 | "choose_promotion" : MessageLookupByLibrary.simpleMessage("choose promotion"), 71 | "checkmate" : MessageLookupByLibrary.simpleMessage("checkmate"), 72 | "draw" : MessageLookupByLibrary.simpleMessage("draw"), 73 | "error" : MessageLookupByLibrary.simpleMessage("error"), 74 | "draw_desc" : MessageLookupByLibrary.simpleMessage("The game finished with a draw!"), 75 | "replay" : MessageLookupByLibrary.simpleMessage("replay"), 76 | "ok" : MessageLookupByLibrary.simpleMessage("ok"), 77 | "white" : MessageLookupByLibrary.simpleMessage("white"), 78 | "black" : MessageLookupByLibrary.simpleMessage("black"), 79 | "check_mate_desc" : (loser, winner) => "${loser} is in checkmate. ${winner} won.", 80 | "turn_of_x" : (turn) => "${turn}'s turn", 81 | "replay_desc" : MessageLookupByLibrary.simpleMessage("Are you sure to restart the game and reset the board?"), 82 | "undo_impossible" : MessageLookupByLibrary.simpleMessage("can't perform undo"), 83 | "undo" : MessageLookupByLibrary.simpleMessage("undo"), 84 | "choose_style" : MessageLookupByLibrary.simpleMessage("change board style"), 85 | "bot_on" : MessageLookupByLibrary.simpleMessage("bot on"), 86 | "bot_off" : MessageLookupByLibrary.simpleMessage("bot off"), 87 | "moves_done" : (progress) => "${progress} boards processed", 88 | "difficulty" : MessageLookupByLibrary.simpleMessage("depth"), 89 | "difficulties" : MessageLookupByLibrary.simpleMessage("auto,2,3,4,5"), 90 | "fen_options" : MessageLookupByLibrary.simpleMessage("to clipboard,from clipboard"), 91 | "bot_vs_bot" : MessageLookupByLibrary.simpleMessage("bot vs. bot"), 92 | "copy_fen" : MessageLookupByLibrary.simpleMessage("copy fen"), 93 | "privacy_url" : MessageLookupByLibrary.simpleMessage("https://l-chess.flycricket.io/privacy.html"), 94 | "terms_url" : MessageLookupByLibrary.simpleMessage("https://l-chess.flycricket.io/terms.html"), 95 | "privacy_title" : MessageLookupByLibrary.simpleMessage("privacy policy"), 96 | "loading_moves_web" : MessageLookupByLibrary.simpleMessage("loading moves..."), 97 | "online_game_options" : MessageLookupByLibrary.simpleMessage("online game"), 98 | "join_code" : MessageLookupByLibrary.simpleMessage("join game"), 99 | "create_code" : MessageLookupByLibrary.simpleMessage("create game"), 100 | "local" : MessageLookupByLibrary.simpleMessage("[local game]"), 101 | "warning" : MessageLookupByLibrary.simpleMessage("warning!"), 102 | "game_reset_join_code_warning" : MessageLookupByLibrary.simpleMessage("By creating a new game code, you will reset your local board and leave a running online game. A friend can join your game via the generated code. The creator of the game is always white."), 103 | "proceed" : MessageLookupByLibrary.simpleMessage("proceed"), 104 | "leave_online_game" : MessageLookupByLibrary.simpleMessage("leave game"), 105 | "enter_game_id" : MessageLookupByLibrary.simpleMessage("enter a game id"), 106 | "game_id_not_found" : MessageLookupByLibrary.simpleMessage("game id not found"), 107 | "game_id_ex" : MessageLookupByLibrary.simpleMessage("ex.: KDFGHQ"), 108 | "join" : MessageLookupByLibrary.simpleMessage("join"), 109 | "deleting_as_host_info" : MessageLookupByLibrary.simpleMessage("Since you are hosting the game, leaving it means deleting it."), 110 | "switch_colors" : MessageLookupByLibrary.simpleMessage("turn board"), 111 | "availability_other_devices" : MessageLookupByLibrary.simpleMessage("platforms"), 112 | "android" : MessageLookupByLibrary.simpleMessage("android"), 113 | "web" : MessageLookupByLibrary.simpleMessage("web"), 114 | "website_url" : MessageLookupByLibrary.simpleMessage("https://chess-45a81.web.app/#/"), 115 | "playstore_url" : MessageLookupByLibrary.simpleMessage("https://play.google.com/store/apps/details?id=com.lurzapps.chess"), 116 | 117 | }; 118 | } 119 | 120 | 121 | 122 | typedef Future LibraryLoader(); 123 | Map _deferredLibraries = { 124 | "de": () => Future.value(null), 125 | "en": () => Future.value(null), 126 | 127 | }; 128 | 129 | MessageLookupByLibrary _findExact(localeName) { 130 | switch (localeName) { 131 | case "de": 132 | return _$de; 133 | case "en": 134 | return _$en; 135 | 136 | default: 137 | return null; 138 | } 139 | } 140 | 141 | /// User programs should call this before using [localeName] for messages. 142 | Future initializeMessages(String localeName) async { 143 | var availableLocale = Intl.verifiedLocale( 144 | localeName, 145 | (locale) => _deferredLibraries[locale] != null, 146 | onFailure: (_) => null); 147 | if (availableLocale == null) { 148 | return Future.value(false); 149 | } 150 | var lib = _deferredLibraries[availableLocale]; 151 | await (lib == null ? Future.value(false) : lib()); 152 | 153 | initializeInternalMessageLookup(() => CompositeMessageLookup()); 154 | messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); 155 | 156 | return Future.value(true); 157 | } 158 | 159 | bool _messagesExistFor(String locale) { 160 | try { 161 | return _findExact(locale) != null; 162 | } catch (e) { 163 | return false; 164 | } 165 | } 166 | 167 | MessageLookupByLibrary _findGeneratedMessagesFor(locale) { 168 | var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, 169 | onFailure: (_) => null); 170 | if (actualLocale == null) return null; 171 | return _findExact(actualLocale); 172 | } 173 | 174 | // ignore_for_file: unnecessary_brace_in_string_interps 175 | --------------------------------------------------------------------------------