From 7a519ea493c2c38d602dcd3045da81d4d4c0ce2c Mon Sep 17 00:00:00 2001 From: Jacek Kowalski <Jacek@jacekk.info> Date: Sat, 17 Jan 2015 21:10:28 +0000 Subject: [PATCH] Switch to Android Studio IDE and use English as the default language. --- app/src/main/res/layout/main.xml | 195 ++++++++++ .gitignore | 6 app/src/main/java/net/jacekk/bridge/BridgeResult.java | 2 app/src/main/res/values/styles.xml | 5 app/src/main/java/net/jacekk/bridge/android/MainActivity.java | 140 +++--- gradle/wrapper/gradle-wrapper.properties | 6 .idea/misc.xml | 21 app/src/main/java/net/jacekk/bridge/BridgeCompute.java | 224 +++++++++++ app/src/main/res/drawable-mdpi/icon.png | 0 .idea/modules.xml | 3 .idea/gradle.xml | 19 + build.gradle | 19 + Bridge.iml | 21 + app/build.gradle | 24 + app/src/main/res/drawable-xxhdpi/icon.png | 0 app/app.iml | 91 ++++ app/.gitignore | 1 settings.gradle | 1 app/src/main/res/values/strings.xml | 37 + .idea/copyright/profiles_settings.xml | 4 app/src/androidTest/java/net/jacekk/bridge/ApplicationTest.java | 10 app/src/main/AndroidManifest.xml | 12 app/src/main/res/values-pl/strings.xml | 37 + app/src/main/res/drawable-xhdpi/icon.png | 0 /dev/null | 196 ---------- app/src/main/res/drawable-ldpi/icon.png | 0 .idea/.name | 2 app/src/main/res/drawable-hdpi/icon.png | 0 app/proguard-rules.pro | 9 29 files changed, 804 insertions(+), 281 deletions(-) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..afbdab3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build diff --git a/.idea/.name b/.idea/.name index cc9ea0d..7697dfa 100644 --- a/.idea/.name +++ b/.idea/.name @@ -1 +1 @@ -Obliczenia brydżowe \ No newline at end of file +Bridge \ No newline at end of file diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml deleted file mode 100644 index cab819f..0000000 --- a/.idea/codeStyleSettings.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="ProjectCodeStyleSettingsManager"> - <option name="PER_PROJECT_SETTINGS"> - <value> - <XML> - <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" /> - </XML> - </value> - </option> - <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" /> - </component> -</project> - diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml index 3572571..e7bedf3 100644 --- a/.idea/copyright/profiles_settings.xml +++ b/.idea/copyright/profiles_settings.xml @@ -1,5 +1,3 @@ <component name="CopyrightManager"> - <settings default=""> - <module2copyright /> - </settings> + <settings default="" /> </component> \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..490397e --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="GradleSettings"> + <option name="linkedExternalProjectsSettings"> + <GradleProjectSettings> + <option name="distributionType" value="DEFAULT_WRAPPED" /> + <option name="externalProjectPath" value="$PROJECT_DIR$" /> + <option name="gradleHome" value="$APPLICATION_HOME_DIR$/plugins/gradle" /> + <option name="modules"> + <set> + <option value="$PROJECT_DIR$" /> + <option value="$PROJECT_DIR$/app" /> + </set> + </option> + </GradleProjectSettings> + </option> + </component> +</project> + diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 9df8655..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,7 +0,0 @@ -<component name="InspectionProjectProfileManager"> - <profile version="1.0" is_locked="false"> - <option name="myName" value="Project Default" /> - <option name="myLocal" value="false" /> - <inspection_tool class="AndroidLintNewApi" enabled="false" level="ERROR" enabled_by_default="false" /> - </profile> -</component> \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 3b31283..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ -<component name="InspectionProjectProfileManager"> - <settings> - <option name="PROJECT_PROFILE" value="Project Default" /> - <option name="USE_PROJECT_PROFILE" value="true" /> - <version value="1.0" /> - </settings> -</component> \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 6832b13..1f6b7aa 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,10 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> - <component name="EntryPointsManager"> - <entry_points version="2.0" /> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/classes" /> </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="Android SDK" project-jdk-type="Android SDK"> - <output url="file://$PROJECT_DIR$/out" /> + <component name="masterDetails"> + <states> + <state key="ProjectJDKs.UI"> + <settings> + <last-edited>1.7</last-edited> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + </states> </component> </project> diff --git a/.idea/modules.xml b/.idea/modules.xml index 746019c..52e1b34 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,8 @@ <project version="4"> <component name="ProjectModuleManager"> <modules> - <module fileurl="file://$PROJECT_DIR$/Android.iml" filepath="$PROJECT_DIR$/Android.iml" /> + <module fileurl="file://$PROJECT_DIR$/Bridge.iml" filepath="$PROJECT_DIR$/Bridge.iml" /> + <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> </modules> </component> </project> diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml deleted file mode 100644 index 3b00020..0000000 --- a/.idea/uiDesigner.xml +++ /dev/null @@ -1,125 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="Palette2"> - <group name="Swing"> - <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> - <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" /> - </item> - <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> - <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" /> - </item> - <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false"> - <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" /> - </item> - <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true"> - <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" /> - </item> - <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false"> - <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" /> - <initial-values> - <property name="text" value="Button" /> - </initial-values> - </item> - <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false"> - <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> - <initial-values> - <property name="text" value="RadioButton" /> - </initial-values> - </item> - <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false"> - <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> - <initial-values> - <property name="text" value="CheckBox" /> - </initial-values> - </item> - <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false"> - <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" /> - <initial-values> - <property name="text" value="Label" /> - </initial-values> - </item> - <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true"> - <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> - <preferred-size width="150" height="-1" /> - </default-constraints> - </item> - <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true"> - <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> - <preferred-size width="150" height="-1" /> - </default-constraints> - </item> - <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true"> - <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> - <preferred-size width="150" height="-1" /> - </default-constraints> - </item> - <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true"> - <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> - <preferred-size width="150" height="50" /> - </default-constraints> - </item> - <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> - <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> - <preferred-size width="150" height="50" /> - </default-constraints> - </item> - <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> - <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> - <preferred-size width="150" height="50" /> - </default-constraints> - </item> - <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true"> - <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" /> - </item> - <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false"> - <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> - <preferred-size width="150" height="50" /> - </default-constraints> - </item> - <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false"> - <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3"> - <preferred-size width="150" height="50" /> - </default-constraints> - </item> - <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false"> - <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> - <preferred-size width="150" height="50" /> - </default-constraints> - </item> - <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false"> - <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> - <preferred-size width="200" height="200" /> - </default-constraints> - </item> - <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false"> - <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> - <preferred-size width="200" height="200" /> - </default-constraints> - </item> - <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true"> - <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> - </item> - <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false"> - <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> - </item> - <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false"> - <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" /> - </item> - <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> - <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" /> - </item> - <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false"> - <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1"> - <preferred-size width="-1" height="20" /> - </default-constraints> - </item> - <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false"> - <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" /> - </item> - <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> - <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" /> - </item> - </group> - </component> -</project> - diff --git a/Android.iml b/Android.iml deleted file mode 100644 index 08a9591..0000000 --- a/Android.iml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module type="JAVA_MODULE" version="4"> - <component name="FacetManager"> - <facet type="android" name="Android"> - <configuration> - <option name="UPDATE_PROPERTY_FILES" value="true" /> - </configuration> - </facet> - </component> - <component name="NewModuleRootManager" inherit-compiler-output="true"> - <exclude-output /> - <content url="file://$MODULE_DIR$"> - <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" /> - </content> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - </component> -</module> - diff --git a/AndroidManifest.xml b/AndroidManifest.xml deleted file mode 100644 index bff0dc9..0000000 --- a/AndroidManifest.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="net.jacekk.brydz.android" - android:versionCode="1" - android:versionName="1.0"> - <uses-sdk android:minSdkVersion="14"/> - <application android:label="@string/app_name" android:icon="@drawable/icon"> - <activity android:name="MainActivity" - android:label="@string/app_name"> - <intent-filter> - <action android:name="android.intent.action.MAIN"/> - <category android:name="android.intent.category.LAUNCHER"/> - </intent-filter> - </activity> - </application> -</manifest> diff --git a/Bridge.iml b/Bridge.iml new file mode 100644 index 0000000..2a02201 --- /dev/null +++ b/Bridge.iml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4"> + <component name="FacetManager"> + <facet type="java-gradle" name="Java-Gradle"> + <configuration> + <option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" /> + </configuration> + </facet> + </component> + <component name="NewModuleRootManager" inherit-compiler-output="false"> + <output url="file://$MODULE_DIR$/build/classes/main" /> + <output-test url="file://$MODULE_DIR$/build/classes/test" /> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <excludeFolder url="file://$MODULE_DIR$/.gradle" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> + diff --git a/ant.properties b/ant.properties deleted file mode 100644 index b0971e8..0000000 --- a/ant.properties +++ /dev/null @@ -1,17 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked into Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/app.iml b/app/app.iml new file mode 100644 index 0000000..c6c55c4 --- /dev/null +++ b/app/app.iml @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4"> + <component name="FacetManager"> + <facet type="android-gradle" name="Android-Gradle"> + <configuration> + <option name="GRADLE_PROJECT_PATH" value=":app" /> + </configuration> + </facet> + <facet type="android" name="Android"> + <configuration> + <option name="SELECTED_BUILD_VARIANT" value="debug" /> + <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" /> + <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" /> + <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" /> + <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" /> + <option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" /> + <option name="ALLOW_USER_CONFIGURATION" value="false" /> + <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" /> + <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" /> + <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" /> + <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" /> + </configuration> + </facet> + </component> + <component name="NewModuleRootManager" inherit-compiler-output="false"> + <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" /> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" /> + <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" /> + <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" /> + <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" /> + <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" /> + <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" /> + <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" /> + <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" /> + <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" /> + <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" /> + <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" /> + <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" /> + <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" /> + <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" /> + <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" /> + <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" /> + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" /> + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" /> + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" /> + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" /> + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" /> + <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" /> + <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" /> + <excludeFolder url="file://$MODULE_DIR$/build/outputs" /> + <excludeFolder url="file://$MODULE_DIR$/build/tmp" /> + </content> + <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" /> + <orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" /> + <orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" /> + </component> +</module> + diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..2d32d42 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,24 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "21.1.2" + + defaultConfig { + applicationId "net.jacekk.bridge" + minSdkVersion 14 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:21.0.3' +} diff --git a/proguard-project.txt b/app/proguard-rules.pro similarity index 61% rename from proguard-project.txt rename to app/proguard-rules.pro index f2fe155..5a22a40 100644 --- a/proguard-project.txt +++ b/app/proguard-rules.pro @@ -1,11 +1,8 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. +# in /home/jacek/Android/Sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/app/src/androidTest/java/net/jacekk/bridge/ApplicationTest.java b/app/src/androidTest/java/net/jacekk/bridge/ApplicationTest.java new file mode 100644 index 0000000..ace8b75 --- /dev/null +++ b/app/src/androidTest/java/net/jacekk/bridge/ApplicationTest.java @@ -0,0 +1,10 @@ +package net.jacekk.bridge; + +import android.app.Application; +import android.test.ApplicationTestCase; + +public class ApplicationTest extends ApplicationTestCase<Application> { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..407198c --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,12 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.jacekk.bridge"> + <application android:allowBackup="true" android:label="@string/app_name" + android:icon="@drawable/icon" android:theme="@style/AppTheme"> + <activity android:name="net.jacekk.bridge.android.MainActivity" + android:label="@string/app_name"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + </activity> + </application> +</manifest> diff --git a/app/src/main/java/net/jacekk/bridge/BridgeCompute.java b/app/src/main/java/net/jacekk/bridge/BridgeCompute.java new file mode 100644 index 0000000..57fd304 --- /dev/null +++ b/app/src/main/java/net/jacekk/bridge/BridgeCompute.java @@ -0,0 +1,224 @@ +package net.jacekk.bridge; + +public class BridgeCompute { + // Points for tricks + protected int tricks[][] = { + {0, 20, 40, 60, 80, 100, 120, 140}, // minor suits + {0, 30, 60, 90, 120, 150, 180, 210}, // major suits + {0, 40, 70, 100, 130, 160, 190, 220} // no trump + }; + + // Points for [i] undertricks + protected int undertricks[][][] = { + { // non vulnerable + {0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650}, // normal + {0, 100, 300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900, 2100, 2300, 2500}, // double + {0, 200, 600, 1000, 1400, 1800, 2200, 2600, 3000, 3400, 3800, 4200, 4600, 5000} // redouble + }, + { // vulnerable + {0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300}, // normal + {0, 200, 500, 800, 1100, 1400, 1700, 2000, 2300, 2600, 2900, 3200, 3500, 3800}, // double + {0, 400, 1000, 1600, 2200, 2800, 3400, 4000, 4600, 5200, 5800, 6400, 7000, 7600}// redouble + } + }; + + // Points required per Milton Work Point Count + protected int PC[][][] = { + { // We: non vulnerable, they: non vulnerable + {-1400, -1400, -1400, -1400, -1200, -1100, -1000, -900, -700, -600, -490, + -460, -430, -400, -350, -300, -200, -110, -70, -50, 0, + 50, 70, 110, 200, 300, 350, 400, 430, 460, 490, + 600, 700, 900, 1000, 1100, 1200, 1400, 1400, 1400, 1400}, + // We: non vulnerable, they: vulnerable + {-2100, -2100, -2100, -2100, -1800, -1650, -1500, -1350, -1050, -800, -690, + -660, -630, -600, -520, -440, -290, -110, -70, -50, 0, + 50, 70, 110, 200, 300, 350, 400, 430, 460, 490, + 600, 700, 900, 1000, 1100, 1200, 1400, 1400, 1400, 1400} + }, + { // We: vulnerable, they: non vulnerable + {-1400, -1400, -1400, -1400, -1200, -1100, -1000, -900, -700, -600, -490, + -460, -430, -400, -350, -300, -200, -110, -70, -50, 0, + 50, 70, 110, 290, 440, 520, 600, 630, 660, 690, + 800, 1050, 1350, 1500, 1650, 1800, 2100, 2100, 2100, 2100}, + // We: vulnerable, they: vulnerable + {-2100, -2100, -2100, -2100, -1800, -1650, -1500, -1350, -1050, -800, -690, + -660, -630, -600, -520, -440, -290, -110, -70, -50, 0, + 50, 70, 110, 290, 440, 520, 600, 630, 660, 690, + 800, 1050, 1350, 1500, 1650, 1800, 2100, 2100, 2100, 2100} + } + }; + + // Points required for [i] IMPs + protected int IMPs[] = { 0, 20, 50, 90, 130, 170, 220, 270, 320, 370, 430, 500, 600, 750, 900, + 1100, 1300, 1500, 1750, 2000, 2250, 2500, 3000, 3500, 4000, 9999999}; + + + // percent* properties are related to scoring system by Adam Królik + // See: http://www.gplewniak.republika.pl/strony/zapis.html + + // Points received - [i] used to access row from percent variable + protected int percent_points[][] = { + {0, 50, 90, 120, 150, 180, 210, 300, 400, 430, 460, 490, 520, 800, 920, 940, 980, 990, + 1020, 1400, 1440, 1520, 1530, 9999999}, // non vulnerable + {0, 50, 90, 120, 150, 180, 210, 500, 600, 360, 660, 690, 720, 810, 1370, 1390, 1430, + 1440, 1470, 1700, 2000, 2220, 2230, 9999999} // vulnerable + }; + + // Work Point Count - [i] used to access column from property percent + protected int percent_PC[] = {0, 6, 10, 16, 21, 25, 31, 35, 9999999}; + + // Percent score per [i] - points scored, [j] - PC had + protected int percent[][] = { + {-1, -1, -1, 50, 44, 26, 8, 0}, + {83, 74, 65, 56, 47, 29, 11, 0}, + {86, 77, 68, 59, 50, 32, 14, 0}, + {89, 80, 71, 62, 53, 35, 17, 0}, + {92, 83, 74, 65, 56, 38, 20, 2}, + {95, 86, 77, 68, 59, 41, 23, 5}, + {98, 89, 80, 71, 62, 44, 26, 8}, + {100, 92, 83, 74, 65, 47, 29, 11}, + {100, 95, 86, 77, 68, 50, 32, 14}, + {100, 98, 89, 80, 71, 53, 35, 17}, + {100, 100, 92, 83, 74, 56, 38, 20}, + {100, 100, 95, 86, 77, 59, 41, 23}, + {100, 100, 98, 89, 80, 62, 44, 26}, + {100, 100, 100, 92, 83, 65, 47, 29}, + {100, 100, 100, 95, 86, 68, 50, 32}, + {100, 100, 100, 98, 89, 71, 53, 35}, + {100, 100, 100, 100, 92, 74, 56, 38}, + {100, 100, 100, 100, 95, 77, 59, 41}, + {100, 100, 100, 100, 98, 80, 62, 44}, + {100, 100, 100, 100, 100, 83, 65, 47}, + {100, 100, 100, 100, 100, 86, 68, 50}, + {100, 100, 100, 100, 100, 89, 71, 53}, + {100, 100, 100, 100, 100, 100, 95, 90} + }; + + // Finds IMP score for points given (using IMPs property) + protected int IMP(int points) { + int i = 0; + while (IMPs[i + 1] <= points) { + i++; + } + return i; + } + + // Finds percent score for data given (using percent* properties) + protected int percent(int PC, int points, int vulnerability) { + int points_i = 0; + int PC_i = 0; + + while (this.percent_points[vulnerability][points_i + 1] <= points) { + points_i++; + } + + while (this.percent_PC[PC_i + 1] <= PC) { + PC_i++; + } + + return this.percent[points_i][PC_i]; + } + + public BridgeResult compute(int bid, int color, int dbl, int vulnerability, int PC, int tricks) { + BridgeResult result = new BridgeResult(); + int weVulnerable = vulnerability / 2; + int theyVulnerable = vulnerability % 2; + + // 4 passes + if (bid == 0) { + result.pointsFor = BridgeResult.PointsFor.Them; + result.points = this.PC[weVulnerable][theyVulnerable][PC]; + result.IMPs = this.IMP(result.points); + result.percent = 100 - this.percent(PC, 0, weVulnerable); + + return result; + } + + + // Result in points + int resultPoints; + // Points for tricks + int pointsForTricks; + // Result minus points required, according to PC property + int pointsForScoring; + + // Number of overtricks (or undertricks if negative) + int additionalTricks = tricks - 6 - bid; + + // Double/redouble multiplier + int multiplier = dbl + 1; + if (multiplier == 3) { + multiplier = 4; + } + + // Contract made + if (additionalTricks >= 0) { + // Ordinary contract + if (multiplier == 1) { + pointsForTricks = this.tricks[color][bid]; + resultPoints = this.tricks[color][tricks - 6]; + } + // Contract doubled/redoubled + else { + pointsForTricks = this.tricks[color][bid] * multiplier; + resultPoints = pointsForTricks; + + // Bonus for winning doubled/redoubled contract + resultPoints += 25 * multiplier; + // For overtricks + resultPoints += additionalTricks * (weVulnerable == 0 ? 50 : 100) * multiplier; + } + + if (bid == 6) { + // Bonus for small slam + resultPoints += (weVulnerable == 0 ? 500 : 750); + } else if (bid == 7) { + // Bonus for grand slam + resultPoints += (weVulnerable == 0 ? 1000 : 1500); + } + + if (pointsForTricks >= 100) { + // Bonus for game + resultPoints += (weVulnerable == 0 ? 300 : 500); + } else { + // Bonus for part-game + resultPoints += 50; + } + } + // Contract defeated + else { + // Points for undertricks (for defending side) + resultPoints = -1 * this.undertricks[weVulnerable][dbl][-1 * additionalTricks]; + } + + // Deduct points required + pointsForScoring = resultPoints - this.PC[weVulnerable][theyVulnerable][PC]; + + // Score for defeaters + if (pointsForScoring < 0) { + result.pointsFor = BridgeResult.PointsFor.Them; + result.pointsBefore = -1 * resultPoints; + result.points = -1 * pointsForScoring; + result.IMPs = IMP(result.points); + if (resultPoints < 0) { + result.percent = percent(40 - PC, -1 * resultPoints, theyVulnerable); + } else { + result.percent = 100 - percent(PC, resultPoints, weVulnerable); + } + } + // Score for declarers + else { + result.pointsFor = BridgeResult.PointsFor.Us; + result.pointsBefore = resultPoints; + result.points = pointsForScoring; + result.IMPs = IMP(result.points); + if (resultPoints > 0) { + result.percent = percent(PC, resultPoints, weVulnerable); + } else { + result.percent = 100 - percent(40 - PC, -1 * resultPoints, theyVulnerable); + } + } + + return result; + } +} diff --git a/src/net/jacekk/brydz/BridgeResult.java b/app/src/main/java/net/jacekk/bridge/BridgeResult.java similarity index 88% rename from src/net/jacekk/brydz/BridgeResult.java rename to app/src/main/java/net/jacekk/bridge/BridgeResult.java index fb80371..090cc20 100644 --- a/src/net/jacekk/brydz/BridgeResult.java +++ b/app/src/main/java/net/jacekk/bridge/BridgeResult.java @@ -1,4 +1,4 @@ -package net.jacekk.brydz; +package net.jacekk.bridge; public class BridgeResult { public enum PointsFor { diff --git a/src/net/jacekk/brydz/android/MainActivity.java b/app/src/main/java/net/jacekk/bridge/android/MainActivity.java similarity index 61% rename from src/net/jacekk/brydz/android/MainActivity.java rename to app/src/main/java/net/jacekk/bridge/android/MainActivity.java index e33375f..744ecd6 100644 --- a/src/net/jacekk/brydz/android/MainActivity.java +++ b/app/src/main/java/net/jacekk/bridge/android/MainActivity.java @@ -1,4 +1,4 @@ -package net.jacekk.brydz.android; +package net.jacekk.bridge.android; import android.app.Activity; import android.os.Bundle; @@ -9,25 +9,27 @@ import android.widget.SeekBar; import android.widget.TextView; import android.widget.ToggleButton; -import net.jacekk.brydz.BridgeCompute; -import net.jacekk.brydz.BridgeResult; + +import net.jacekk.bridge.R; +import net.jacekk.bridge.BridgeCompute; +import net.jacekk.bridge.BridgeResult; public class MainActivity extends Activity { private SeekBar BidSlider; private TextView BidText; - private ToggleButton CDToggle; - private ToggleButton HSToggle; - private ToggleButton NTToggle; + private ToggleButton MinorSuitsToggle; + private ToggleButton MajorSuitsToggle; + private ToggleButton NoTrumpToggle; - private ToggleButton NormToggle; - private ToggleButton DblToggle; - private ToggleButton ReDblToggle; + private ToggleButton ContractToggle; + private ToggleButton DoubleToggle; + private ToggleButton RedoubleToggle; - private ToggleButton BBToggle; - private ToggleButton BAToggle; - private ToggleButton ABToggle; - private ToggleButton AAToggle; + private ToggleButton NNToggle; + private ToggleButton NVToggle; + private ToggleButton VNToggle; + private ToggleButton VVToggle; private EditText PCInput; private EditText TricksInput; @@ -53,23 +55,23 @@ BidSlider = (SeekBar) findViewById(R.id.BidSlider); BidText = (TextView) findViewById(R.id.BidText); - CDToggle = (ToggleButton) findViewById(R.id.CDToggle); - HSToggle = (ToggleButton) findViewById(R.id.HSToggle); - NTToggle = (ToggleButton) findViewById(R.id.NTToggle); + MinorSuitsToggle = (ToggleButton) findViewById(R.id.MinorSuitsToggle); + MajorSuitsToggle = (ToggleButton) findViewById(R.id.MajorSuitsToggle); + NoTrumpToggle = (ToggleButton) findViewById(R.id.NoTrumpToggle); - NormToggle = (ToggleButton) findViewById(R.id.NormToggle); - DblToggle = (ToggleButton) findViewById(R.id.DblToggle); - ReDblToggle = (ToggleButton) findViewById(R.id.ReDblToggle); + ContractToggle = (ToggleButton) findViewById(R.id.ContractToggle); + DoubleToggle = (ToggleButton) findViewById(R.id.DoubleToggle); + RedoubleToggle = (ToggleButton) findViewById(R.id.RedoubleToggle); - BBToggle = (ToggleButton) findViewById(R.id.BBToggle); - BAToggle = (ToggleButton) findViewById(R.id.BAToggle); - ABToggle = (ToggleButton) findViewById(R.id.ABToggle); - AAToggle = (ToggleButton) findViewById(R.id.AAToggle); + NNToggle = (ToggleButton) findViewById(R.id.NNToggle); + NVToggle = (ToggleButton) findViewById(R.id.NVToggle); + VNToggle = (ToggleButton) findViewById(R.id.VNToggle); + VVToggle = (ToggleButton) findViewById(R.id.VVToggle); PCInput = (EditText) findViewById(R.id.PCInput); TricksInput = (EditText) findViewById(R.id.TricksInput); - resultText = (TextView) findViewById(R.id.resultText); + resultText = (TextView) findViewById(R.id.ResultsText); BidSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override @@ -92,62 +94,62 @@ public void onClick(View view) { ToggleButton toggle = (ToggleButton) view; - if (!toggle.equals(CDToggle)) - CDToggle.setChecked(false); - if (!toggle.equals(HSToggle)) - HSToggle.setChecked(false); - if (!toggle.equals(NTToggle)) - NTToggle.setChecked(false); + if (!toggle.equals(MinorSuitsToggle)) + MinorSuitsToggle.setChecked(false); + if (!toggle.equals(MajorSuitsToggle)) + MajorSuitsToggle.setChecked(false); + if (!toggle.equals(NoTrumpToggle)) + NoTrumpToggle.setChecked(false); updateResults(); } }; - CDToggle.setOnClickListener(colorClickListener); - HSToggle.setOnClickListener(colorClickListener); - NTToggle.setOnClickListener(colorClickListener); + MinorSuitsToggle.setOnClickListener(colorClickListener); + MajorSuitsToggle.setOnClickListener(colorClickListener); + NoTrumpToggle.setOnClickListener(colorClickListener); ToggleButton.OnClickListener bidClickListener = new ToggleButton.OnClickListener() { @Override public void onClick(View view) { ToggleButton toggle = (ToggleButton) view; - if (!toggle.equals(NormToggle)) - NormToggle.setChecked(false); - if (!toggle.equals(DblToggle)) - DblToggle.setChecked(false); - if (!toggle.equals(ReDblToggle)) - ReDblToggle.setChecked(false); + if (!toggle.equals(ContractToggle)) + ContractToggle.setChecked(false); + if (!toggle.equals(DoubleToggle)) + DoubleToggle.setChecked(false); + if (!toggle.equals(RedoubleToggle)) + RedoubleToggle.setChecked(false); updateResults(); } }; - NormToggle.setOnClickListener(bidClickListener); - DblToggle.setOnClickListener(bidClickListener); - ReDblToggle.setOnClickListener(bidClickListener); + ContractToggle.setOnClickListener(bidClickListener); + DoubleToggle.setOnClickListener(bidClickListener); + RedoubleToggle.setOnClickListener(bidClickListener); ToggleButton.OnClickListener baClickListener = new ToggleButton.OnClickListener() { public void onClick(View view) { ToggleButton toggle = (ToggleButton) view; - if (!toggle.equals(AAToggle)) - AAToggle.setChecked(false); - if (!toggle.equals(ABToggle)) - ABToggle.setChecked(false); - if (!toggle.equals(BAToggle)) - BAToggle.setChecked(false); - if (!toggle.equals(BBToggle)) - BBToggle.setChecked(false); + if (!toggle.equals(VVToggle)) + VVToggle.setChecked(false); + if (!toggle.equals(VNToggle)) + VNToggle.setChecked(false); + if (!toggle.equals(NVToggle)) + NVToggle.setChecked(false); + if (!toggle.equals(NNToggle)) + NNToggle.setChecked(false); updateResults(); } }; - AAToggle.setOnClickListener(baClickListener); - ABToggle.setOnClickListener(baClickListener); - BAToggle.setOnClickListener(baClickListener); - BBToggle.setOnClickListener(baClickListener); + VVToggle.setOnClickListener(baClickListener); + VNToggle.setOnClickListener(baClickListener); + NVToggle.setOnClickListener(baClickListener); + NNToggle.setOnClickListener(baClickListener); PCInput.addTextChangedListener( new TextWatcher() { @@ -188,35 +190,35 @@ int bid = BidSlider.getProgress(); int color = 0; - if (HSToggle.isChecked()) + if (MajorSuitsToggle.isChecked()) color = 1; - if (NTToggle.isChecked()) + if (NoTrumpToggle.isChecked()) color = 2; int dbl = 0; - if (DblToggle.isChecked()) + if (DoubleToggle.isChecked()) dbl = 1; - if (ReDblToggle.isChecked()) + if (RedoubleToggle.isChecked()) dbl = 2; - int baba = 0; - if (BAToggle.isChecked()) - baba = 1; - if (ABToggle.isChecked()) - baba = 2; - if (AAToggle.isChecked()) - baba = 3; + int vulnerability = 0; + if (NVToggle.isChecked()) + vulnerability = 1; + if (VNToggle.isChecked()) + vulnerability = 2; + if (VVToggle.isChecked()) + vulnerability = 3; int PC = -1; try { PC = Integer.parseInt(PCInput.getText().toString()); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { } int tricks = -1; try { tricks = Integer.parseInt(TricksInput.getText().toString()); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { } if (bid < 0 || bid > 7) { @@ -234,7 +236,7 @@ return; } - if (baba < 0 || baba > 3) { + if (vulnerability < 0 || vulnerability > 3) { resultText.setText(getString(R.string.invalid_baba)); return; } @@ -254,7 +256,7 @@ return; } - BridgeResult result = bridgeCompute.compute(bid, color, dbl, baba, PC, tricks); + BridgeResult result = bridgeCompute.compute(bid, color, dbl, vulnerability, PC, tricks); resultText.setText( (result.pointsFor == BridgeResult.PointsFor.Us ? getString(R.string.result_for_us) : getString(R.string.result_for_them)) + "\n" + getString(R.string.result_pts_wo_pc) + " " + result.pointsBefore + diff --git a/res/drawable-hdpi/icon.png b/app/src/main/res/drawable-hdpi/icon.png similarity index 100% rename from res/drawable-hdpi/icon.png rename to app/src/main/res/drawable-hdpi/icon.png Binary files differ diff --git a/res/drawable-ldpi/icon.png b/app/src/main/res/drawable-ldpi/icon.png similarity index 100% rename from res/drawable-ldpi/icon.png rename to app/src/main/res/drawable-ldpi/icon.png Binary files differ diff --git a/res/drawable-mdpi/icon.png b/app/src/main/res/drawable-mdpi/icon.png similarity index 100% rename from res/drawable-mdpi/icon.png rename to app/src/main/res/drawable-mdpi/icon.png Binary files differ diff --git a/res/drawable-xhdpi/icon.png b/app/src/main/res/drawable-xhdpi/icon.png similarity index 100% rename from res/drawable-xhdpi/icon.png rename to app/src/main/res/drawable-xhdpi/icon.png Binary files differ diff --git a/app/src/main/res/drawable-xxhdpi/icon.png b/app/src/main/res/drawable-xxhdpi/icon.png new file mode 100644 index 0000000..48377b4 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/icon.png Binary files differ diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml new file mode 100644 index 0000000..6683a97 --- /dev/null +++ b/app/src/main/res/layout/main.xml @@ -0,0 +1,195 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:layout_margin="10dp" + android:orientation="vertical"> + + <SeekBar + android:id="@+id/BidSlider" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:indeterminate="false" + android:max="7" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:orientation="horizontal" + android:weightSum="1"> + + <TextView + android:id="@+id/BidText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_weight="0.25" + android:text="0" + android:textAlignment="gravity" + android:textAppearance="?android:attr/textAppearanceLarge" /> + + <ToggleButton + android:id="@+id/MinorSuitsToggle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="0.25" + android:checked="true" + android:text="@string/minor_suits" + android:textOff="@string/minor_suits" + android:textOn="@string/minor_suits" /> + + <ToggleButton + android:id="@+id/MajorSuitsToggle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="0.25" + android:checked="false" + android:text="@string/major_suits" + android:textOff="@string/major_suits" + android:textOn="@string/major_suits" /> + + <ToggleButton + android:id="@+id/NoTrumpToggle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="0.25" + android:checked="false" + android:text="@string/no_trumph" + android:textOff="@string/no_trumph" + android:textOn="@string/no_trumph" /> + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <ToggleButton + android:id="@+id/ContractToggle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:checked="true" + android:text="@string/bid_normal" + android:textOff="@string/bid_normal" + android:textOn="@string/bid_normal" /> + + <ToggleButton + android:id="@+id/DoubleToggle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:checked="false" + android:text="@string/bid_double" + android:textOff="@string/bid_double" + android:textOn="@string/bid_double" /> + + <ToggleButton + android:id="@+id/RedoubleToggle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:checked="false" + android:text="@string/bid_redouble" + android:textOff="@string/bid_redouble" + android:textOn="@string/bid_redouble" /> + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <ToggleButton + android:id="@+id/NNToggle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:checked="true" + android:text="@string/before_before" + android:textOff="@string/before_before" + android:textOn="@string/before_before" /> + + <ToggleButton + android:id="@+id/NVToggle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:checked="false" + android:text="@string/before_after" + android:textOff="@string/before_after" + android:textOn="@string/before_after" /> + + <ToggleButton + android:id="@+id/VNToggle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:checked="false" + android:text="@string/after_before" + android:textOff="@string/after_before" + android:textOn="@string/after_before" /> + + <ToggleButton + android:id="@+id/VVToggle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:checked="false" + android:text="@string/after_after" + android:textOff="@string/after_after" + android:textOn="@string/after_after" /> + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <TextView + android:id="@+id/PCText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginRight="10dp" + android:labelFor="@+id/PCInput" + android:text="@string/pc" + android:textAppearance="?android:attr/textAppearanceLarge" /> + + <EditText + android:id="@+id/PCInput" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:ems="4" + android:inputType="number" /> + + <Space + android:layout_width="20dp" + android:layout_height="wrap_content" /> + + <TextView + android:id="@+id/TricksText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginRight="10dp" + android:labelFor="@+id/TricksInput" + android:text="@string/tricks" + android:textAppearance="?android:attr/textAppearanceLarge" /> + + <EditText + android:id="@+id/TricksInput" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:ems="4" + android:inputType="number" /> + </LinearLayout> + + <TextView + android:id="@+id/ResultsText" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginTop="10dp" + android:text="@string/invalid_empty" + android:textAppearance="?android:attr/textAppearanceMedium" /> +</LinearLayout> + diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml new file mode 100644 index 0000000..b607da1 --- /dev/null +++ b/app/src/main/res/values-pl/strings.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="app_name">Obliczenia brydżowe</string> + + <string name="minor_suits">♣ / ♦</string> + <string name="major_suits">♥ / ♠</string> + <string name="no_trumph">NT</string> + + <string name="before_before">przed/przed</string> + <string name="before_after">przed/po</string> + <string name="after_before">po/przed</string> + <string name="after_after">po/po</string> + + <string name="bid_normal">norm.</string> + <string name="bid_double">ktr.</string> + <string name="bid_redouble">rektr.</string> + + <string name="pc">PC:</string> + <string name="tricks">Lew:</string> + + <string name="invalid_empty">Podaj wszystkie dane.</string> + <string name="invalid_bid">Niepoprawny kontrakt.</string> + <string name="invalid_color">Niepoprawny kolor kontraktu.</string> + <string name="invalid_dbl">Niepoprawna informacja o kontrze.</string> + <string name="invalid_baba">Niepoprawna informacja o partii.</string> + <string name="invalid_pc">Niepoprawna ilość punktów.</string> + <string name="invalid_tricks">Niepoprawna ilość wziętych lew.</string> + <string name="invalid_pass">Przy czterech pasach podaj większą liczę punktów.</string> + + <string name="result_for_us">Zapis dla rozgrywających.</string> + <string name="result_for_them">Zapis dla przeciwników.</string> + + <string name="result_pts_wo_pc">Punktów (bez PC):</string> + <string name="result_pts">Punktów (z PC):</string> + <string name="result_imps">IMP-ów:</string> + <string name="result_percent">Procent:</string> +</resources> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..6ffd67e --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="app_name">Bridge scoring</string> + + <string name="minor_suits">♣ / ♦</string> + <string name="major_suits">♥ / ♠</string> + <string name="no_trumph">NT</string> + + <string name="before_before">non./non</string> + <string name="before_after">non./vuln.</string> + <string name="after_before">vunl./non.</string> + <string name="after_after">vuln./vuln.</string> + + <string name="bid_normal">norm.</string> + <string name="bid_double">dbl.</string> + <string name="bid_redouble">redbl.</string> + + <string name="pc">PC:</string> + <string name="tricks">Tricks:</string> + + <string name="invalid_empty">Enter required information.</string> + <string name="invalid_bid">Invalid contract level.</string> + <string name="invalid_color">Invalid contract color.</string> + <string name="invalid_dbl">Invalid information about doubling/redoubling.</string> + <string name="invalid_baba">Invalid information about vulnerability.</string> + <string name="invalid_pc">Invalid number for Milton Work Point Count.</string> + <string name="invalid_tricks">Invalid number of tricks taken.</string> + <string name="invalid_pass">For four passes enter data for side with more PCs.</string> + + <string name="result_for_us">Score for declaring side.</string> + <string name="result_for_them">Score for defending side.</string> + + <string name="result_pts_wo_pc">Points (excl. PC):</string> + <string name="result_pts">Points (incl. PC):</string> + <string name="result_imps">IMPs:</string> + <string name="result_percent">Percent:</string> +</resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..0c332ef --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="AppTheme" parent="android:Theme.Holo"> + </style> +</resources> \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..6356aab --- /dev/null +++ b/build.gradle @@ -0,0 +1,19 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.0.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} diff --git a/build.xml b/build.xml deleted file mode 100644 index 58ac6f0..0000000 --- a/build.xml +++ /dev/null @@ -1,92 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="Android" default="help"> - - <!-- The local.properties file is created and updated by the 'android' tool. - It contains the path to the SDK. It should *NOT* be checked into - Version Control Systems. --> - <property file="local.properties"/> - - <!-- The ant.properties file can be created by you. It is only edited by the - 'android' tool to add properties to it. - This is the place to change some Ant specific build properties. - Here are some properties you may want to change/update: - - source.dir - The name of the source directory. Default is 'src'. - out.dir - The name of the output directory. Default is 'bin'. - - For other overridable properties, look at the beginning of the rules - files in the SDK, at tools/ant/build.xml - - Properties related to the SDK location or the project target should - be updated using the 'android' tool with the 'update' action. - - This file is an integral part of the build system for your - application and should be checked into Version Control Systems. - - --> - <property file="ant.properties"/> - - <!-- if sdk.dir was not set from one of the property file, then - get it from the ANDROID_HOME env var. - This must be done before we load project.properties since - the proguard config can use sdk.dir --> - <property environment="env"/> - <condition property="sdk.dir" value="${env.ANDROID_HOME}"> - <isset property="env.ANDROID_HOME"/> - </condition> - - <!-- The project.properties file is created and updated by the 'android' - tool, as well as ADT. - - This contains project specific properties such as project target, and library - dependencies. Lower level build properties are stored in ant.properties - (or in .classpath for Eclipse projects). - - This file is an integral part of the build system for your - application and should be checked into Version Control Systems. --> - <loadproperties srcFile="project.properties"/> - - <!-- quick check on sdk.dir --> - <fail - message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable." - unless="sdk.dir" - /> - - <!-- - Import per project custom build rules if present at the root of the project. - This is the place to put custom intermediary targets such as: - -pre-build - -pre-compile - -post-compile (This is typically used for code obfuscation. - Compiled code location: ${out.classes.absolute.dir} - If this is not done in place, override ${out.dex.input.absolute.dir}) - -post-package - -post-build - -pre-clean - --> - <import file="custom_rules.xml" optional="true"/> - - <!-- Import the actual build file. - - To customize existing targets, there are two options: - - Customize only one target: - - copy/paste the target into this file, *before* the - <import> task. - - customize it to your needs. - - Customize the whole content of build.xml - - copy/paste the content of the rules files (minus the top node) - into this file, replacing the <import> task. - - customize to your needs. - - *********************** - ****** IMPORTANT ****** - *********************** - In all cases you must update the value of version-tag below to read 'custom' instead of an integer, - in order to avoid having your file be overridden by tools such as "android update project" - --> - <!-- version-tag: 1 --> - <import file="${sdk.dir}/tools/ant/build.xml"/> - -</project> diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..0c71e76 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Apr 10 15:27:10 PDT 2013 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip diff --git a/project.properties b/project.properties deleted file mode 100644 index 4ab1256..0000000 --- a/project.properties +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-19 diff --git a/res/layout/main.xml b/res/layout/main.xml deleted file mode 100644 index 42861a8..0000000 --- a/res/layout/main.xml +++ /dev/null @@ -1,137 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - > - <LinearLayout - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" android:layout_margin="10dp"> - <SeekBar - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:id="@+id/BidSlider" android:max="7" android:indeterminate="false" - /> - <LinearLayout - android:orientation="horizontal" - android:layout_width="match_parent" - android:layout_height="wrap_content" android:gravity="center_vertical" android:weightSum="1" - > - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceLarge" - android:text="0" - android:id="@+id/BidText" android:layout_weight="0.25" android:textAlignment="gravity" - android:layout_gravity="center"/> - <ToggleButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/clubs_or_diamonds" - android:id="@+id/CDToggle" android:textOff="@string/clubs_or_diamonds" - android:textOn="@string/clubs_or_diamonds" android:checked="true" android:layout_weight="0.25"/> - <ToggleButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/hearts_or_spades" - android:id="@+id/HSToggle" android:textOff="@string/hearts_or_spades" - android:textOn="@string/hearts_or_spades" android:layout_weight="0.25" android:checked="false"/> - <ToggleButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/no_trumph" - android:id="@+id/NTToggle" android:textOff="@string/no_trumph" - android:textOn="@string/no_trumph" android:layout_weight="0.25" android:checked="false"/> - </LinearLayout> - <LinearLayout - android:orientation="horizontal" - android:layout_width="match_parent" - android:layout_height="wrap_content"> - <ToggleButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/bid_normal" - android:id="@+id/NormToggle" android:textOff="@string/bid_normal" - android:textOn="@string/bid_normal" android:checked="true" android:layout_weight="1"/> - <ToggleButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/bid_double" - android:id="@+id/DblToggle" android:textOff="@string/bid_double" - android:textOn="@string/bid_double" android:layout_weight="1" android:checked="false"/> - <ToggleButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/bid_redouble" - android:id="@+id/ReDblToggle" android:textOff="@string/bid_redouble" - android:textOn="@string/bid_redouble" android:layout_weight="1" android:checked="false"/> - </LinearLayout> - <LinearLayout - android:orientation="horizontal" - android:layout_width="match_parent" - android:layout_height="wrap_content"> - <ToggleButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/before_before" - android:id="@+id/BBToggle" android:textOff="@string/before_before" - android:textOn="@string/before_before" android:layout_weight="1" android:checked="true"/> - <ToggleButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/before_after" - android:id="@+id/BAToggle" android:textOff="@string/before_after" - android:textOn="@string/before_after" android:layout_weight="1" android:checked="false"/> - <ToggleButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/after_before" - android:id="@+id/ABToggle" android:textOff="@string/after_before" - android:textOn="@string/after_before" android:layout_weight="1" android:checked="false"/> - <ToggleButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/after_after" - android:id="@+id/AAToggle" android:textOff="@string/after_after" - android:textOn="@string/after_after" android:layout_weight="1" android:checked="false"/> - </LinearLayout> - <LinearLayout - android:orientation="horizontal" - android:layout_width="match_parent" - android:layout_height="wrap_content"> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceLarge" - android:text="@string/pc" - android:id="@+id/PCText" android:labelFor="@+id/PCInput" android:layout_marginRight="10dp"/> - <EditText - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:inputType="number" - android:id="@+id/PCInput" android:editable="false" android:ems="4"/> - <Space - android:layout_width="20dp" - android:layout_height="wrap_content" - /> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceLarge" - android:text="@string/tricks" - android:id="@+id/TricksText" android:labelFor="@+id/TricksInput" android:layout_marginRight="10dp"/> - <EditText - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:inputType="number" - android:id="@+id/TricksInput" android:ems="4"/> - </LinearLayout> - <TextView - android:layout_width="match_parent" - android:layout_height="match_parent" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/resultText" android:text="@string/invalid_empty" android:layout_marginTop="10dp"/> - </LinearLayout> -</LinearLayout> - diff --git a/res/values/strings.xml b/res/values/strings.xml deleted file mode 100644 index 9cb668a..0000000 --- a/res/values/strings.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="app_name">Obliczenia brydżowe</string> - - <string name="clubs_or_diamonds">♣ / ♦</string> - <string name="hearts_or_spades">♥ / ♠</string> - <string name="no_trumph">NT</string> - - <string name="before_before">przed/przed</string> - <string name="before_after">przed/po</string> - <string name="after_before">po/przed</string> - <string name="after_after">po/po</string> - - <string name="bid_normal">norm.</string> - <string name="bid_double">ktr.</string> - <string name="bid_redouble">rektr.</string> - - <string name="pc">PC:</string> - <string name="tricks">Lew:</string> - - <string name="invalid_empty">Podaj wszystkie dane.</string> - <string name="invalid_bid">Niepoprawny kontrakt.</string> - <string name="invalid_color">Niepoprawny kolor kontraktu.</string> - <string name="invalid_dbl">Niepoprawna informacja o kontrze.</string> - <string name="invalid_baba">Niepoprawna informacja o partii.</string> - <string name="invalid_pc">Niepoprawna ilość punktów.</string> - <string name="invalid_tricks">Niepoprawna ilość wziętych lew.</string> - <string name="invalid_pass">Przy czterech pasach podaj większą liczę punktów.</string> - - <string name="result_for_us">Zapis dla rozgrywających.</string> - <string name="result_for_them">Zapis dla przeciwników.</string> - - <string name="result_pts_wo_pc">Punktów (bez PC):</string> - <string name="result_pts">Punktów (z PC):</string> - <string name="result_imps">IMP-ów:</string> - <string name="result_percent">Procent:</string> -</resources> diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/src/net/jacekk/brydz/BridgeCompute.java b/src/net/jacekk/brydz/BridgeCompute.java deleted file mode 100644 index 9428009..0000000 --- a/src/net/jacekk/brydz/BridgeCompute.java +++ /dev/null @@ -1,196 +0,0 @@ -package net.jacekk.brydz; - -public class BridgeCompute { - protected int tricks[][] = { - {0, 20, 40, 60, 80, 100, 120, 140}, // młodsze - {0, 30, 60, 90, 120, 150, 180, 210}, // starsze - {0, 40, 70, 100, 130, 160, 190, 220} // bez atu - }; - - protected int wpadki[][][] = { - { // przed partią - {0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650}, // normalnie - {0, 100, 300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900, 2100, 2300, 2500}, // kontra - {0, 200, 600, 1000, 1400, 1800, 2200, 2600, 3000, 3400, 3800, 4200, 4600, 5000} // rekontra - }, - { // po partii - {0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300}, // normalnie - {0, 200, 500, 800, 1100, 1400, 1700, 2000, 2300, 2600, 2900, 3200, 3500, 3800}, // kontra - {0, 400, 1000, 1600, 2200, 2800, 3400, 4000, 4600, 5200, 5800, 6400, 7000, 7600} // rekontra - } - }; - - protected int PC[][][] = { - { // MY: przed, WY: przed partią - {-1400, -1400, -1400, -1400, -1200, -1100, -1000, -900, -700, -600, -490, -460, -430, -400, -350, -300, -200, -110, -70, -50, 0, 50, 70, 110, 200, 300, 350, 400, 430, 460, 490, 600, 700, 900, 1000, 1100, 1200, 1400, 1400, 1400, 1400}, - // MY: przed, WY: po partii - {-2100, -2100, -2100, -2100, -1800, -1650, -1500, -1350, -1050, -800, -690, -660, -630, -600, -520, -440, -290, -110, -70, -50, 0, 50, 70, 110, 200, 300, 350, 400, 430, 460, 490, 600, 700, 900, 1000, 1100, 1200, 1400, 1400, 1400, 1400} - }, - { // MY: po, WY: przed partią - {-1400, -1400, -1400, -1400, -1200, -1100, -1000, -900, -700, -600, -490, -460, -430, -400, -350, -300, -200, -110, -70, -50, 0, 50, 70, 110, 290, 440, 520, 600, 630, 660, 690, 800, 1050, 1350, 1500, 1650, 1800, 2100, 2100, 2100, 2100}, - // MY: po, WY: po partii - {-2100, -2100, -2100, -2100, -1800, -1650, -1500, -1350, -1050, -800, -690, -660, -630, -600, -520, -440, -290, -110, -70, -50, 0, 50, 70, 110, 290, 440, 520, 600, 630, 660, 690, 800, 1050, 1350, 1500, 1650, 1800, 2100, 2100, 2100, 2100} - } - }; - - protected int IMPs[] = {0, 20, 50, 90, 130, 170, 220, 270, 320, 370, 430, 500, 600, 750, 900, 1100, 1300, 1500, 1750, 2000, 2250, 2500, 3000, 3500, 4000, 9999999}; - - protected int percent_points[][] = { - {0, 50, 90, 120, 150, 180, 210, 300, 400, 430, 460, 490, 520, 800, 920, 940, 980, 990, 1020, 1400, 1440, 1520, 1530, 9999999}, // przed - {0, 50, 90, 120, 150, 180, 210, 500, 600, 360, 660, 690, 720, 810, 1370, 1390, 1430, 1440, 1470, 1700, 2000, 2220, 2230, 9999999} //po - }; - - protected int percent_PC[] = {0, 6, 10, 16, 21, 25, 31, 35, 9999999}; - - protected int percent[][] = { - {-1, -1, -1, 50, 44, 26, 8, 0}, - {83, 74, 65, 56, 47, 29, 11, 0}, - {86, 77, 68, 59, 50, 32, 14, 0}, - {89, 80, 71, 62, 53, 35, 17, 0}, - {92, 83, 74, 65, 56, 38, 20, 2}, - {95, 86, 77, 68, 59, 41, 23, 5}, - {98, 89, 80, 71, 62, 44, 26, 8}, - {100, 92, 83, 74, 65, 47, 29, 11}, - {100, 95, 86, 77, 68, 50, 32, 14}, - {100, 98, 89, 80, 71, 53, 35, 17}, - {100, 100, 92, 83, 74, 56, 38, 20}, - {100, 100, 95, 86, 77, 59, 41, 23}, - {100, 100, 98, 89, 80, 62, 44, 26}, - {100, 100, 100, 92, 83, 65, 47, 29}, - {100, 100, 100, 95, 86, 68, 50, 32}, - {100, 100, 100, 98, 89, 71, 53, 35}, - {100, 100, 100, 100, 92, 74, 56, 38}, - {100, 100, 100, 100, 95, 77, 59, 41}, - {100, 100, 100, 100, 98, 80, 62, 44}, - {100, 100, 100, 100, 100, 83, 65, 47}, - {100, 100, 100, 100, 100, 86, 68, 50}, - {100, 100, 100, 100, 100, 89, 71, 53}, - {100, 100, 100, 100, 100, 100, 95, 90} - }; - - protected int IMP(int points) { - int i = 0; - while (IMPs[i + 1] <= points) { - i++; - } - return i; - } - - protected int percent(int PC, int points, int ba) { - int points_i = 0; - int PC_i = 0; - - while (this.percent_points[ba][points_i + 1] <= points) { - points_i++; - } - - while (this.percent_PC[PC_i + 1] <= PC) { - PC_i++; - } - - return this.percent[points_i][PC_i]; - } - - public BridgeResult compute(int bid, int color, int dbl, int baba, int PC, int tricks) { - BridgeResult result = new BridgeResult(); - int we_ba = baba / 2; - int you_ba = baba % 2; - - // 4 pasy - if (bid == 0) { - result.pointsFor = BridgeResult.PointsFor.Them; - result.points = this.PC[we_ba][you_ba][PC]; - result.IMPs = this.IMP(result.points); - result.percent = 100 - this.percent(PC, 0, we_ba); - - return result; - } - - - // Wynik w punktach - int result_points; - // Punkty za lewy kontraktowe - int result_tricks; - // Wynik w punktach, uwzględniając ilość PC - int result_tricks_w_PC; - - // Ilość nadróbek - int additional_tricks = tricks - 6 - bid; - - // Mnożnik przy kontrze - int multiplier = dbl + 1; - if (multiplier == 3) { - multiplier = 4; - } - - // Kontrakt ugrany - if (additional_tricks >= 0) { - // "Nadróbki: jak za lewy" - if (multiplier == 1) { - result_tricks = this.tricks[color][bid]; - result_points = this.tricks[color][tricks - 6]; - } - // Kontra lub rekontra - else { - result_tricks = this.tricks[color][bid] * multiplier; - result_points = result_tricks; - - // Za wygranie z kontrą - result_points += 25 * multiplier; - // Za nadróbki - result_points += additional_tricks * (we_ba == 0 ? 50 : 100) * multiplier; - } - - if (bid == 6) { - // Za szlemika - result_points += (we_ba == 0 ? 500 : 750); - } else if (bid == 7) { - // Za szlema - result_points += (we_ba == 0 ? 1000 : 1500); - } - - if (result_tricks >= 100) { - // Za partię - result_points += (we_ba == 0 ? 300 : 500); - } else { - // Za częściówkę - result_points += 50; - } - } - // Wpadka - else { - // Punkty za wpadkę - result_points = -1 * this.wpadki[we_ba][dbl][-1 * additional_tricks]; - } - - // Uwzględniamy ilość punktów, którą trzeba było zdobyć - result_tricks_w_PC = result_points - this.PC[we_ba][you_ba][PC]; - - // Zapis dla przeciwników - if (result_tricks_w_PC < 0) { - result.pointsFor = BridgeResult.PointsFor.Them; - result.pointsBefore = -1 * result_points; - result.points = -1 * result_tricks_w_PC; - result.IMPs = IMP(result.points); - if (result_points < 0) { - result.percent = percent(40 - PC, -1 * result_points, you_ba); - } else { - result.percent = 100 - percent(PC, result_points, we_ba); - } - } - // Zapis dla rozgrywających - else { - result.pointsFor = BridgeResult.PointsFor.Us; - result.pointsBefore = result_points; - result.points = result_tricks_w_PC; - result.IMPs = IMP(result.points); - if (result_points > 0) { - result.percent = percent(PC, result_points, we_ba); - } else { - result.percent = 100 - percent(40 - PC, -1 * result_points, you_ba); - } - } - - return result; - } -} -- Gitblit v1.9.1