From af8a92da40bd5c7e4e1a09afbf743517ebb6bd3f Mon Sep 17 00:00:00 2001 From: Nikolay Date: Mon, 12 Aug 2024 01:54:29 +0300 Subject: [PATCH] #1544 #1543 --- client/bug/lobby.bug.ts | 3 + client/lobby.ts | 2 +- server/bug/game_bug.py | 1 + server/bug/utils_bug.py | 2 + static/bughouse.css | 127 ++++++++++++++++++++++++++++++++++------ 5 files changed, 116 insertions(+), 19 deletions(-) diff --git a/client/bug/lobby.bug.ts b/client/bug/lobby.bug.ts index 1daa1de3a..d914d8e90 100644 --- a/client/bug/lobby.bug.ts +++ b/client/bug/lobby.bug.ts @@ -25,6 +25,9 @@ export function switchEnablingLobbyControls(mode: CreateMode, variant: Variant, export function bugJoinSeek(ctrl: LobbyController, e: Event, seek: Seek, joinAs: string) { e.stopPropagation(); // seek[player] = ctrl.username; + if (ctrl.anon) { + alert(_("Anon users cannot join bughouse games")); + } ctrl.doSend({ type: "accept_seek", seekID: seek["seekID"], player: ctrl.username, joinAs: joinAs }); } diff --git a/client/lobby.ts b/client/lobby.ts index eaee442eb..f694f0eb6 100644 --- a/client/lobby.ts +++ b/client/lobby.ts @@ -559,7 +559,7 @@ export class LobbyController implements ChatController { createGame(variantName: string = '', chess960: boolean = false) { this.createMode = 'createGame'; - this.renderVariantsDropDown(variantName, chess960, []); + this.renderVariantsDropDown(variantName, chess960, this.anon ? ["bughouse"]: []); this.renderDialogHeader(createModeStr(this.createMode)); document.getElementById('game-mode')!.style.display = this.anon ? 'none' : 'inline-flex'; document.getElementById('rating-range-setting')!.style.display = 'block'; diff --git a/server/bug/game_bug.py b/server/bug/game_bug.py index 5c0ea3c98..364b59825 100644 --- a/server/bug/game_bug.py +++ b/server/bug/game_bug.py @@ -465,6 +465,7 @@ def result_string_from_value(game_result_value, board_which_ended): def check_checkmate_on_board_and_update_status(self, board: str): # it is not mate if there are possible move dests on the given board + # todo: if it is check that is blockable, but no pieces in pocket, dests might be empty but it is not mate if board == "a" and self.dests_a: return False elif board == "b" and self.dests_b: diff --git a/server/bug/utils_bug.py b/server/bug/utils_bug.py index fc30050a7..030aaa0c7 100644 --- a/server/bug/utils_bug.py +++ b/server/bug/utils_bug.py @@ -504,6 +504,8 @@ async def play_move( async def handle_accept_seek_bughouse(app_state: PychessGlobalAppState, user, data, seek): + if user.anon: + return response = await join_seek_bughouse(app_state, user, data["seekID"], None, data["joinAs"]) bug_users = set( filter( diff --git a/static/bughouse.css b/static/bughouse.css index b16f421e7..db05b202d 100644 --- a/static/bughouse.css +++ b/static/bughouse.css @@ -49,19 +49,22 @@ } /* ***************************************************************************************** - * round.css + * round.css pocket-top-partner pocket-bot-partner ******************************************************************************************* */ @media (max-width: 799px) and (orientation: portrait) { .round-app.bug { - grid-template-columns: auto auto; - grid-template-rows: auto + grid-template-columns: calc((var(--cg-width-a) / var(--files)) * var(--pocketLength)) calc(100vw - ((var(--cg-width-a) / var(--files)) * var(--pocketLength))); + grid-template-rows: + min-content + min-content + min-content + min-content min-content - auto - auto + max-content + min-content min-content - auto auto auto @@ -70,14 +73,17 @@ auto auto auto; - grid-template-areas: 'pocket-top clock-top' + grid-template-areas: + 'boardPartner pocket-top-partner' + 'boardPartner clockB-top' + 'boardPartner .' + 'boardPartner clockB-bot' + 'boardPartner pocket-bot-partner' + + 'pocket-top clock-top' 'board board' 'pocket-bot clock-bot' - 'pocket-top-partner clockB-top' - 'boardPartner boardPartner' - 'pocket-bot-partner clockB-bot' - 'tools tools' 'game-controls game-controls' 'offer offer' @@ -85,6 +91,7 @@ 'toolsB toolsB' 'uboard uboard' 'uleft uleft'; + column-gap: 0px; } under-left { display: none; @@ -96,18 +103,81 @@ font-size: var(--fs); } .pocket-top-partner .bughouse .pocket, .pocket-bot-partner .bughouse .pocket { - width: calc(var(--pocketLength) * (var(--cg-width-b) / var(--files))); - height: calc(var(--cg-height-b) / var(--ranks)); - --fs: calc(var(--cg-height-b) / var(--ranks)); + /*width: calc((100vw / (var(--files) + var(--pocketLength))) * var(--pocketLength));*/ +/* width: auto;*/ + width: calc((100vw - ((var(--cg-height-a) / var(--ranks)) * var(--pocketLength)))); + height: calc((100vw - ((var(--cg-height-a) / var(--ranks)) * var(--pocketLength))) / var(--pocketLength)); + + /*height: calc(100cqmin / var(--pocketLength));*/ +/* width: calc(var(--pocketLength) * (var(--cg-width-b) / var(--files))); + height: calc(var(--cg-height-b) / var(--ranks));*/ + --fs: calc(20px / var(--ranks)); font-size: var(--fs); } .clock-wrap { flex-direction: row-reverse; } +} + +@media (max-height: 600px) and (orientation: landscape) { + body[data-variant='bughouse'] header { + display: none; + } + .round-app.bug { + grid-template-columns: 40vh 40vh 40vh 40vh auto; + grid-template-rows: + 10vh + 20vh + 20vh + 20vh + 20vh + 10vh + auto + auto + auto + auto + auto + auto; + grid-template-areas: + + 'pocket-top clock-top pocket-top-partner clockB-top tools' + 'board board boardPartner boardPartner tools' + 'board board boardPartner boardPartner tools' + 'board board boardPartner boardPartner tools' + 'board board boardPartner boardPartner tools' + 'pocket-bot clock-bot pocket-bot-partner clockB-bot tools' + + 'game-controls game-controls game-controls game-controls game-controls' + 'offer offer offer offer offer' + 'move-controls move-controls move-controls move-controls move-controls' + 'toolsB toolsB toolsB toolsB toolsB' + 'uboard uboard uboard uboard uboard' + 'uleft uleft uleft uleft uleft'; + column-gap: 0px; + } + under-left { + display: none; + } + .pocket-top .bughouse .pocket, .pocket-bot .bughouse .pocket { + width: 40vh; + height: 10vh; + --fs: calc(var(--cg-height-a) / var(--ranks)); + font-size: var(--fs); + } + .pocket-top-partner .bughouse .pocket, .pocket-bot-partner .bughouse .pocket { + width: 40vh; + height: 10vh; + --fs: calc(20px / var(--ranks)); + font-size: var(--fs); + } + .clock-wrap { + flex-direction: row-reverse; + font-size: 5pt; + } } -@media (min-width: 800px) { +@media (min-height: 600px) and (orientation: landscape) { .bug .info-wrap0, .bug .info-wrap1, .bug .clock-wrap { justify-content: end; } @@ -178,7 +248,7 @@ main.round.bug .pocket.bottom { margin-top: unset; } -div#chatpresets{ +div#chatpresets { display: grid; grid-template-columns: auto auto auto auto auto; padding-top: 5px; @@ -186,6 +256,21 @@ div#chatpresets{ order: 3; } +@media (max-width: 799px) and (orientation: portrait) { + div#chatpresets { + grid-template-columns: auto auto auto auto auto auto auto auto auto auto; + } + .chat { + flex-direction: column-reverse; + } +} +@media (max-height: 600px) and (orientation: landscape) { + div#chatpresets { + grid-template-columns: auto auto auto auto auto; + } +} + + div#chatpresets button.bugchat { width: 60%; /*width: 15%;*/ @@ -323,13 +408,19 @@ button.bugchat::-moz-focus-inner { } @media (max-width: 799px) and (orientation: portrait) { - .bug .info-wrap0 { + .bug .info-wrap0, .info-wrap0 { + flex-direction: column-reverse; grid-area: clock-top; justify-self: flex-end; + justify-content: right; } - .bug .info-wrap1 { + .bug .info-wrap1, .info-wrap1 { grid-area: clock-bot; justify-self: flex-end; + justify-content: right; + } + .clock-wrap{ + align-self: end; } }