Offer Maia a draw (desktop and Android)
The shared rule (play::accepts_draw): she accepts when clearly worse or mated, or when about level (at most +0.2 for her) and her last three scores agree within 0.3; after a refusal, again two of her moves later. Her judge keeps the scores of her turns. Desktop: «½ Offer a draw» beside «Resign»; Android: a «Draw» button in the game's bar (labels may take two lines). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0d7c0923fa
commit
b90bcdf3a3
18 changed files with 297 additions and 4 deletions
|
|
@ -524,6 +524,21 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
}
|
||||
}
|
||||
var resigning by remember { mutableStateOf(false) }
|
||||
val drawDeclined = stringResource(R.string.play_draw_declined)
|
||||
val drawLater = stringResource(R.string.play_draw_later)
|
||||
val drawNoEngine = stringResource(R.string.play_draw_no_engine)
|
||||
// A draw offered (§31.3): Maia answers by her judge's scores of her last turns.
|
||||
fun offerDraw() {
|
||||
val r = run ?: return
|
||||
val j = r.judge
|
||||
val say = { text: String -> scope.launch { snackbar.currentSnackbarData?.dismiss(); snackbar.showSnackbar(text) } }
|
||||
when {
|
||||
j == null -> say(drawNoEngine)
|
||||
!j.mayOfferDraw() -> say(drawLater)
|
||||
j.offerDraw() -> finishGame(PlayOver("1/2-1/2", R.string.play_draw, R.string.end_agreement))
|
||||
else -> say(drawDeclined)
|
||||
}
|
||||
}
|
||||
// The result card closed with ×: until the next game.
|
||||
var resultClosed by remember(run) { mutableStateOf(false) }
|
||||
// A change after the end (a variation, an undo): the card's result may not hold.
|
||||
|
|
@ -578,6 +593,7 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
r.thinking.value = false
|
||||
r.offer.value = false
|
||||
r.judge?.forget()
|
||||
r.judge?.forgetScores()
|
||||
r.hopeless = 0u
|
||||
runCatching { e.deleteFrom(from.toUInt()) }.getOrNull()?.let {
|
||||
apply(it)
|
||||
|
|
@ -740,6 +756,7 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
canForward = canForward,
|
||||
onTakeBack = ::takeBack,
|
||||
onResign = { resigning = true },
|
||||
onDraw = ::offerDraw,
|
||||
onAbort = {
|
||||
app.maiaGames.clear()
|
||||
onBack()
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import androidx.compose.material.icons.Icons
|
|||
import androidx.compose.material.icons.automirrored.rounded.Undo
|
||||
import androidx.compose.material.icons.rounded.Close
|
||||
import androidx.compose.material.icons.rounded.Flag
|
||||
import androidx.compose.material.icons.rounded.Handshake
|
||||
import androidx.compose.material.icons.rounded.PlayArrow
|
||||
import androidx.compose.material.icons.rounded.SwapVert
|
||||
import androidx.compose.material3.Button
|
||||
|
|
@ -109,6 +110,7 @@ fun PlayControls(
|
|||
canForward: Boolean,
|
||||
onTakeBack: () -> Unit,
|
||||
onResign: () -> Unit,
|
||||
onDraw: () -> Unit,
|
||||
onAbort: () -> Unit,
|
||||
onFlip: () -> Unit,
|
||||
onBack: () -> Unit,
|
||||
|
|
@ -121,6 +123,7 @@ fun PlayControls(
|
|||
LabeledButton(Icons.AutoMirrored.Rounded.Undo, stringResource(R.string.play_take_back).removePrefix("↶ "), canTakeBack, Modifier.weight(1f), onTakeBack)
|
||||
if (started) {
|
||||
LabeledButton(Icons.Rounded.Flag, stringResource(R.string.play_resign).removePrefix("⚑ "), true, Modifier.weight(1f), onResign)
|
||||
LabeledButton(Icons.Rounded.Handshake, stringResource(R.string.play_offer_draw), true, Modifier.weight(1f), onDraw)
|
||||
} else {
|
||||
LabeledButton(Icons.Rounded.Close, stringResource(R.string.play_abort), true, Modifier.weight(1f), onAbort)
|
||||
}
|
||||
|
|
@ -137,10 +140,11 @@ fun PlayControls(
|
|||
|
||||
@Composable
|
||||
private fun LabeledButton(icon: androidx.compose.ui.graphics.vector.ImageVector, label: String, enabled: Boolean, modifier: Modifier, onClick: () -> Unit) {
|
||||
androidx.compose.material3.TextButton(onClick = onClick, enabled = enabled, modifier = modifier.height(64.dp)) {
|
||||
androidx.compose.material3.TextButton(onClick = onClick, enabled = enabled, modifier = modifier.height(64.dp), contentPadding = androidx.compose.foundation.layout.PaddingValues(horizontal = 2.dp)) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Icon(icon, null)
|
||||
Text(label, style = MaterialTheme.typography.labelSmall, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
// Six buttons in a row: a long word goes to a second line, not cut.
|
||||
Text(label, style = MaterialTheme.typography.labelSmall, maxLines = 2, overflow = TextOverflow.Ellipsis, textAlign = androidx.compose.ui.text.style.TextAlign.Center)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -527,4 +527,9 @@
|
|||
<string name="play_continue_it">Fortsetzen</string>
|
||||
<string name="play_start_new">Neue beginnen</string>
|
||||
<string name="play_adjourned_new_text">Eine neue Partie ersetzt sie.</string>
|
||||
<string name="play_offer_draw">Remis</string>
|
||||
<string name="end_agreement">durch Einigung</string>
|
||||
<string name="play_draw_declined">Maia lehnt das Remis ab</string>
|
||||
<string name="play_draw_later">Maia hat abgelehnt; nach zwei ihrer Züge wieder anbieten</string>
|
||||
<string name="play_draw_no_engine">Maia beantwortet Remis mit Stockfish: über „Engine“ herunterladen</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -535,4 +535,9 @@
|
|||
<string name="play_continue_it">Continuarla</string>
|
||||
<string name="play_start_new">Empezar una nueva</string>
|
||||
<string name="play_adjourned_new_text">Una partida nueva la sustituye.</string>
|
||||
<string name="play_offer_draw">Tablas</string>
|
||||
<string name="end_agreement">por acuerdo</string>
|
||||
<string name="play_draw_declined">Maia rechaza las tablas</string>
|
||||
<string name="play_draw_later">Maia lo rechazó; ofrece de nuevo tras dos de sus jugadas</string>
|
||||
<string name="play_draw_no_engine">Maia responde a las tablas con Stockfish: descárgalo con «Motor»</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -535,4 +535,9 @@
|
|||
<string name="play_continue_it">La continuer</string>
|
||||
<string name="play_start_new">En commencer une nouvelle</string>
|
||||
<string name="play_adjourned_new_text">Une nouvelle partie la remplace.</string>
|
||||
<string name="play_offer_draw">Nulle</string>
|
||||
<string name="end_agreement">par accord mutuel</string>
|
||||
<string name="play_draw_declined">Maia refuse la nulle</string>
|
||||
<string name="play_draw_later">Maia a refusé ; reproposez après deux de ses coups</string>
|
||||
<string name="play_draw_no_engine">Maia répond à la nulle avec Stockfish : téléchargez-le avec « Moteur »</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -535,4 +535,9 @@
|
|||
<string name="play_continue_it">Continuala</string>
|
||||
<string name="play_start_new">Iniziarne una nuova</string>
|
||||
<string name="play_adjourned_new_text">Una nuova partita la sostituisce.</string>
|
||||
<string name="play_offer_draw">Patta</string>
|
||||
<string name="end_agreement">per accordo</string>
|
||||
<string name="play_draw_declined">Maia rifiuta la patta</string>
|
||||
<string name="play_draw_later">Maia ha rifiutato; riproponi dopo due sue mosse</string>
|
||||
<string name="play_draw_no_engine">Maia risponde alla patta con Stockfish: scaricalo con «Motore»</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -528,4 +528,9 @@
|
|||
<string name="play_continue_it">Жалғастыру</string>
|
||||
<string name="play_start_new">Жаңасын бастау</string>
|
||||
<string name="play_adjourned_new_text">Жаңа ойын оның орнын басады.</string>
|
||||
<string name="play_offer_draw">Тең</string>
|
||||
<string name="end_agreement">келісім бойынша</string>
|
||||
<string name="play_draw_declined">Maia тең ойыннан бас тартады</string>
|
||||
<string name="play_draw_later">Maia бас тартты; оның екі жүрісінен кейін қайта ұсыныңыз</string>
|
||||
<string name="play_draw_no_engine">Maia тең ойынға Stockfish арқылы жауап береді: оны «Қозғалтқыш» батырмасымен жүктеңіз</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -536,4 +536,9 @@
|
|||
<string name="play_continue_it">Continuá-la</string>
|
||||
<string name="play_start_new">Começar uma nova</string>
|
||||
<string name="play_adjourned_new_text">Uma nova partida a substitui.</string>
|
||||
<string name="play_offer_draw">Empate</string>
|
||||
<string name="end_agreement">por acordo</string>
|
||||
<string name="play_draw_declined">A Maia recusa o empate</string>
|
||||
<string name="play_draw_later">A Maia recusou; ofereça de novo após dois lances dela</string>
|
||||
<string name="play_draw_no_engine">A Maia responde ao empate com o Stockfish: baixe-o com «Motor»</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -543,4 +543,9 @@
|
|||
<string name="play_continue_it">Продолжить её</string>
|
||||
<string name="play_start_new">Начать новую</string>
|
||||
<string name="play_adjourned_new_text">Новая партия заменит её.</string>
|
||||
<string name="play_offer_draw">Ничья</string>
|
||||
<string name="end_agreement">по соглашению</string>
|
||||
<string name="play_draw_declined">Maia отказывается от ничьей</string>
|
||||
<string name="play_draw_later">Maia отказалась; снова можно предложить через два её хода</string>
|
||||
<string name="play_draw_no_engine">Maia отвечает на ничью с помощью Stockfish: скачайте его кнопкой «Движок»</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -526,4 +526,9 @@
|
|||
<string name="play_continue_it">Davom ettirish</string>
|
||||
<string name="play_start_new">Yangisini boshlash</string>
|
||||
<string name="play_adjourned_new_text">Yangi o‘yin uning o‘rnini oladi.</string>
|
||||
<string name="play_offer_draw">Durang</string>
|
||||
<string name="end_agreement">kelishuv bo‘yicha</string>
|
||||
<string name="play_draw_declined">Maia durangdan bosh tortadi</string>
|
||||
<string name="play_draw_later">Maia rad etdi; uning ikki yurishidan keyin yana taklif qiling</string>
|
||||
<string name="play_draw_no_engine">Maia durangga Stockfish bilan javob beradi: uni «Dvigatel» tugmasi bilan yuklab oling</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -531,4 +531,9 @@
|
|||
<string name="play_continue_it">Continue it</string>
|
||||
<string name="play_start_new">Start a new one</string>
|
||||
<string name="play_adjourned_new_text">A new game replaces it.</string>
|
||||
<string name="play_offer_draw">Draw</string>
|
||||
<string name="end_agreement">by agreement</string>
|
||||
<string name="play_draw_declined">Maia declines the draw</string>
|
||||
<string name="play_draw_later">Maia declined; offer again after two of her moves</string>
|
||||
<string name="play_draw_no_engine">Maia answers a draw offer with Stockfish: download it in the game screen («Engine»)</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue