Merge pull request #210 from lucasnlm/fix-bug

No Guessing option
This commit is contained in:
Lucas Nunes 2020-11-07 00:03:00 -03:00 committed by GitHub
commit 77c45321a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 84 additions and 12 deletions

View file

@ -40,18 +40,21 @@ class CloudSaveManager(
squareRadius = preferencesRepository.squareRadius(),
squareSize = preferencesRepository.squareSizeMultiplier(),
touchTiming = preferencesRepository.customLongPressTimeout().toInt(),
questionMark = if (preferencesRepository.useQuestionMark()) 1 else 0,
gameAssistance = if (preferencesRepository.useFlagAssistant()) 1 else 0,
help = if (preferencesRepository.useHelp()) 1 else 0,
hapticFeedback = if (preferencesRepository.useHapticFeedback()) 1 else 0,
soundEffects = if (preferencesRepository.isSoundEffectsEnabled()) 1 else 0,
questionMark = preferencesRepository.useQuestionMark().toInt(),
gameAssistance = preferencesRepository.useFlagAssistant().toInt(),
help = preferencesRepository.useHelp().toInt(),
hapticFeedback = preferencesRepository.useHapticFeedback().toInt(),
soundEffects = preferencesRepository.isSoundEffectsEnabled().toInt(),
stats = statsRepository.getAllStats(minId).map { it.toHashMap() },
premiumFeatures = if (preferencesRepository.isPremiumEnabled()) 1 else 0,
premiumFeatures = preferencesRepository.isPremiumEnabled().toInt(),
controlStyle = preferencesRepository.controlStyle().ordinal,
noGuessing = preferencesRepository.useNoGuessingAlgorithm().toInt(),
)
}
} catch (e: Exception) {
return null
}
}
private fun Boolean.toInt() = if (this) 1 else 0
}

View file

@ -54,6 +54,7 @@ class SplashViewModel(
setSquareMultiplier(cloudSave.squareSize)
setCustomLongPressTimeout(cloudSave.touchTiming.toLong())
setQuestionMark(cloudSave.questionMark != 0)
setNoGuessingAlgorithm(cloudSave.noGuessing != 0)
setFlagAssistant(gameAssistance != 0)
setHapticFeedback(hapticFeedback != 0)
setHelp(help != 0)

View file

@ -97,6 +97,10 @@ class MockPreferencesRepository : IPreferencesRepository {
override fun useAnimations(): Boolean = false
override fun setNoGuessingAlgorithm(value: Boolean) { }
override fun useNoGuessingAlgorithm(): Boolean = true
override fun useQuestionMark(): Boolean = false
override fun setQuestionMark(value: Boolean) { }

View file

@ -26,6 +26,7 @@ class GameController {
private var gameControl: GameControl = GameControl.Standard
private var useQuestionMark = true
private var useOpenOnSwitchControl = true
private var useNoGuessing = true
val seed: Long
@ -70,7 +71,7 @@ class GameController {
val fieldCopy = field.map { it.copy() }.toMutableList()
val minefieldHandler = MinefieldHandler(fieldCopy, false)
minefieldHandler.openAt(safeId, false)
} while (solver.keepTrying() && !solver.trySolve(minefieldHandler.result().toMutableList()))
} while (useNoGuessing && solver.keepTrying() && !solver.trySolve(minefieldHandler.result().toMutableList()))
firstOpen = FirstOpen.Position(safeId)
}
@ -322,6 +323,10 @@ class GameController {
this.useQuestionMark = useQuestionMark
}
fun useNoGuessing(noGuessing: Boolean) {
this.useNoGuessing = noGuessing
}
fun useOpenOnSwitchControl(useOpen: Boolean) {
this.useOpenOnSwitchControl = useOpen
}

View file

@ -349,6 +349,7 @@ open class GameViewModel(
updateGameControl(gameControl)
useQuestionMark(preferencesRepository.useQuestionMark())
useNoGuessing(preferencesRepository.useNoGuessingAlgorithm())
}
}
}

View file

@ -431,7 +431,9 @@ class FixedGridLayoutManager : RecyclerView.LayoutManager() {
*/
measureChildWithMargins(view, 0, 0)
layoutDecorated(
view, leftOffset, topOffset,
view,
leftOffset,
topOffset,
leftOffset + mDecoratedChildWidth,
topOffset + mDecoratedChildHeight
)
@ -821,7 +823,9 @@ class FixedGridLayoutManager : RecyclerView.LayoutManager() {
measureChildWithMargins(child, 0, 0)
layoutDecorated(
child, layoutLeft, layoutTop,
child,
layoutLeft,
layoutTop,
layoutLeft + mDecoratedChildWidth,
layoutTop + mDecoratedChildHeight
)

View file

@ -69,6 +69,9 @@ interface IPreferencesRepository {
fun useAnimations(): Boolean
fun setNoGuessingAlgorithm(value: Boolean)
fun useNoGuessingAlgorithm(): Boolean
fun useQuestionMark(): Boolean
fun setQuestionMark(value: Boolean)

View file

@ -69,6 +69,13 @@ class PreferencesRepository(
override fun useAnimations(): Boolean =
preferencesManager.getBoolean(PREFERENCE_ANIMATION, true)
override fun setNoGuessingAlgorithm(value: Boolean) {
preferencesManager.putBoolean(PREFERENCE_NO_GUESSING, value)
}
override fun useNoGuessingAlgorithm(): Boolean =
preferencesManager.getBoolean(PREFERENCE_NO_GUESSING, true)
override fun useQuestionMark(): Boolean =
preferencesManager.getBoolean(PREFERENCE_QUESTION_MARK, false)
@ -266,6 +273,7 @@ class PreferencesRepository(
private const val PREFERENCE_VIBRATION = "preference_vibration"
private const val PREFERENCE_ASSISTANT = "preference_assistant"
private const val PREFERENCE_ANIMATION = "preference_animation"
private const val PREFERENCE_NO_GUESSING = "preference_no_guessing"
private const val PREFERENCE_AREA_SIZE = "preference_area_size"
private const val PREFERENCE_QUESTION_MARK = "preference_use_question_mark"
private const val PREFERENCE_USE_HELP = "preference_use_help"

View file

@ -69,6 +69,7 @@
<string name="performance">Werkverrigting</string>
<string name="ok">OK</string>
<string name="use_question_mark">Gebruik die vraagteken</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Kontrole</string>
<string name="arrow"></string>
<string name="single_click">Enkele tik</string>

View file

@ -69,6 +69,7 @@
<string name="performance">أداء</string>
<string name="ok">حسناً</string>
<string name="use_question_mark">استخدام علامة السؤال</string>
<string name="no_guessing_mode">وضع \"لا تخمين\"</string>
<string name="control">التحكم</string>
<string name="arrow">🠨</string>
<string name="single_click">نقرة واحدة</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Изпълнение</string>
<string name="ok">ОК</string>
<string name="use_question_mark">Въпросителен знак</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Управление</string>
<string name="arrow"></string>
<string name="single_click">Едно натискане</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Rendiment</string>
<string name="ok">OK</string>
<string name="use_question_mark">Utilitza l\'interrogant</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Controls</string>
<string name="arrow"></string>
<string name="single_click">Un sol clic</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Výkon</string>
<string name="ok">OK</string>
<string name="use_question_mark">Použít otazníky</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Ovládání</string>
<string name="arrow"></string>
<string name="single_click">Jedno klepnutí</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Ydeevne</string>
<string name="ok">OK</string>
<string name="use_question_mark">Brug flag med spørgsmålstegn</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Controls</string>
<string name="arrow"></string>
<string name="single_click">Enkelt tryk</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Erfolgsergebnis</string>
<string name="ok">Ok</string>
<string name="use_question_mark">Fragezeichen benutzen</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Steuerung</string>
<string name="arrow"></string>
<string name="single_click">Einzelklick</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Επίδοση</string>
<string name="ok">Εντάξει</string>
<string name="use_question_mark">Χρήση ερωτηματικών</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Ελεγχος</string>
<string name="arrow"></string>
<string name="single_click">Με ένα κλικ</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Performance</string>
<string name="ok">OK</string>
<string name="use_question_mark">Use Question Mark</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Controls</string>
<string name="arrow"></string>
<string name="single_click">Single Click</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Desempeño</string>
<string name="ok">OK</string>
<string name="use_question_mark">Usar signo de interrogación</string>
<string name="no_guessing_mode">Modo \'Sin adivinación\'</string>
<string name="control">Controles</string>
<string name="arrow"></string>
<string name="single_click">Un clic</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Suorituskyky</string>
<string name="ok">OK</string>
<string name="use_question_mark">Käytä kysymysmerkkiä</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Kontrollit</string>
<string name="arrow"></string>
<string name="single_click">Napautus</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Performance</string>
<string name="ok">OK</string>
<string name="use_question_mark">Utiliser des drapeaux points dinterrogation</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Contrôles</string>
<string name="arrow"></string>
<string name="single_click">Clic simple</string>

View file

@ -69,6 +69,7 @@
<string name="performance">प्रदर्शन</string>
<string name="ok">ओके</string>
<string name="use_question_mark">\"मैं सुनिश्चित नहीं हूं\" झंडे का उपयोग करें</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">नियंत्रण</string>
<string name="arrow"></string>
<string name="single_click">सिंगल क्लिक</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Teljesítmény</string>
<string name="ok">Rendben</string>
<string name="use_question_mark">Kérdőjel használata</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Irányítások</string>
<string name="arrow"></string>
<string name="single_click">Egyszeri kattintás</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Peforma</string>
<string name="ok">OK</string>
<string name="use_question_mark">Pakai Bendera Tanda Tanya</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Kontrol</string>
<string name="arrow"></string>
<string name="single_click">Satu klik</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Prestazione</string>
<string name="ok">OK</string>
<string name="use_question_mark">Usa il Punto Interrogativo</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Comandi</string>
<string name="arrow"></string>
<string name="single_click">Singolo click</string>

View file

@ -69,6 +69,7 @@
<string name="performance">ביצועים</string>
<string name="ok">OK</string>
<string name="use_question_mark">סימן שאלה</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">פקדים</string>
<string name="arrow">🠨</string>
<string name="single_click">לחיצה בודדת</string>

View file

@ -69,6 +69,7 @@
<string name="performance">パフォーマンス</string>
<string name="ok">OK</string>
<string name="use_question_mark">クエスチョンマークを使う</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">コントロール</string>
<string name="arrow"></string>
<string name="single_click">タップ</string>

View file

@ -69,6 +69,7 @@
<string name="performance">퍼포먼스</string>
<string name="ok">OK</string>
<string name="use_question_mark">물음표 깃발 사용</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">컨트롤</string>
<string name="arrow"></string>
<string name="single_click">단일 클릭</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Prestatie</string>
<string name="ok">Oké</string>
<string name="use_question_mark">Gebruik vraagteken</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Besturing</string>
<string name="arrow"></string>
<string name="single_click">Enkele klik</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Ytelse</string>
<string name="ok">OK</string>
<string name="use_question_mark">Bruk Spørsmålstegn</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Styring</string>
<string name="arrow"></string>
<string name="single_click">Enkeltklikk</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Skuteczność</string>
<string name="ok">OK</string>
<string name="use_question_mark">Używaj Znaku zapytania</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Sterowanie</string>
<string name="arrow"></string>
<string name="single_click">Pojedyncze kliknięcie</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Desempenho</string>
<string name="ok">OK</string>
<string name="use_question_mark">Usar Ponto de Interrogação</string>
<string name="no_guessing_mode">Modo \"Sem adivinhação\"</string>
<string name="control">Controles</string>
<string name="arrow"></string>
<string name="single_click">Unico Clique</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Desempenho</string>
<string name="ok">OK</string>
<string name="use_question_mark">Usar Ponto de Interrogação</string>
<string name="no_guessing_mode">Modo \"Sem adivinhação\"</string>
<string name="control">Controlos</string>
<string name="arrow"></string>
<string name="single_click">Toque Único</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Performanță</string>
<string name="ok">OK</string>
<string name="use_question_mark">Folosește Semn de Întrebare</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Controale</string>
<string name="arrow"></string>
<string name="single_click">Atingere simplă</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Производительность</string>
<string name="ok">OK</string>
<string name="use_question_mark">Использовать знак вопроса</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Управление</string>
<string name="arrow"></string>
<string name="single_click">Одно нажатие</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Prestanda</string>
<string name="ok">Okej</string>
<string name="use_question_mark">Använd frågetecken</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Kontroller</string>
<string name="arrow"></string>
<string name="single_click">Enkel klick</string>

View file

@ -69,6 +69,7 @@
<string name="performance">ประสิทธิภาพ</string>
<string name="ok">ตกลง</string>
<string name="use_question_mark">เครื่องหมายคำถาม</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">การควบคุม</string>
<string name="arrow"></string>
<string name="single_click">แตะครั้งเดียว</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Performans</string>
<string name="ok">Tamam</string>
<string name="use_question_mark">Soru İşareti Kullan</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Kontroller</string>
<string name="arrow"></string>
<string name="single_click">Tek Tıklama</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Ефективність</string>
<string name="ok">Гаразд</string>
<string name="use_question_mark">Використовувати прапорці «?»</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Елементи керування</string>
<string name="arrow"></string>
<string name="single_click">Одинарний клік</string>

View file

@ -69,6 +69,7 @@
<string name="performance">Hiệu năng</string>
<string name="ok">OK</string>
<string name="use_question_mark">Dùng cờ câu hỏi</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Điều khiển</string>
<string name="arrow"></string>
<string name="single_click">Một lần bấm</string>

View file

@ -69,6 +69,7 @@
<string name="performance">性能</string>
<string name="ok">确定</string>
<string name="use_question_mark">使用问号标记</string>
<string name="no_guessing_mode">“没有猜测”模式</string>
<string name="control">控制</string>
<string name="arrow"></string>
<string name="single_click">单击</string>
@ -122,9 +123,9 @@
<string name="flag_removed">标记已移除!</string>
<string name="remove_ad">去除广告</string>
<string name="help">帮助</string>
<string name="show_windows">Show windows</string>
<string name="switch_control">Switch: Flag and Open</string>
<string name="switch_control_desc">Use button to switch between Flag and Open</string>
<string name="show_windows">显示窗口</string>
<string name="switch_control">切换:标记并打开</string>
<string name="switch_control_desc">使用按钮在标记和打开之间切换</string>
<string name="app_description">你需要清除一个隐藏着地雷的矩形面板,不能使任何地雷爆炸。</string>
<string name="app_name">扫雷 (踩地雷) - Antimine</string>
</resources>

View file

@ -69,6 +69,7 @@
<string name="performance">Performance</string>
<string name="ok">OK</string>
<string name="use_question_mark">Use Question Mark</string>
<string name="no_guessing_mode">\'No guessing\' mode</string>
<string name="control">Controls</string>
<string name="arrow"></string>
<string name="single_click">Single Click</string>

View file

@ -21,6 +21,13 @@
android:title="@string/enable_automatic_flags"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:checked="true"
android:defaultValue="true"
android:key="preference_no_guessing"
android:title="@string/no_guessing_mode"
app:iconSpaceReserved="false"/>
<SwitchPreferenceCompat
android:checked="true"
android:defaultValue="false"

View file

@ -15,6 +15,7 @@ data class CloudSave(
val stats: List<HashMap<String, String>>,
val premiumFeatures: Int,
val controlStyle: Int,
val noGuessing: Int,
)
fun CloudSave.toHashMap(): HashMap<String, Any> = hashMapOf(
@ -31,6 +32,7 @@ fun CloudSave.toHashMap(): HashMap<String, Any> = hashMapOf(
"stats" to stats,
"premiumFeatures" to premiumFeatures,
"controlStyle" to controlStyle,
"noGuessing" to noGuessing,
)
@Suppress("UNCHECKED_CAST")
@ -50,4 +52,5 @@ fun cloudSaveOf(id: String, data: Map<String, Any>) =
data["stats"] as List<HashMap<String, String>>,
data["premiumFeatures"].toString().toInt(),
data["controlStyle"].toString().toInt(),
(data["noGuessing"] ?: 1).toString().toInt(),
)