Skip to content

Commit

Permalink
Merge branch 'master' into team-simuls
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoknjas committed Jan 22, 2025
2 parents f24ed84 + cf0cae6 commit 36b180a
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 11 deletions.
2 changes: 2 additions & 0 deletions app/controllers/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,7 @@ final class Main(
env.memo.picfitApi.bodyImage
.upload(rel, image)
.map(url => JsonOk(Json.obj("imageUrl" -> url)))
.recover:
case e: Exception => JsonBadRequest(jsonError(e.getMessage))
case None => JsonBadRequest(jsonError("Image content only"))
}
11 changes: 11 additions & 0 deletions bin/mongodb/puzzle-add-theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
puzzleDb = connect(`mongodb://localhost:27317/puzzler`);
ids = ''.split(' ');
ids.forEach(id => {
puzzleDb.puzzle2_round.updateOne(
{ _id: 'lichess:' + id },
{
$push: { t: '+vukovicMate' },
},
);
});
puzzleDb.puzzle2_puzzle.updateMany({ _id: { $in: ids } }, { $set: { dirty: true } });
3 changes: 1 addition & 2 deletions modules/core/src/main/game/Game.scala
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ case class Game(
yield w -> b

def averageUsersRating: Option[IntRating] = players.flatMap(_.rating) match
// case a :: b :: Nil => Some((a + b).map(_ / 2))
case a :: b :: Nil => Some((a + b))
case a :: b :: Nil => Some((a + b).map(_ / 2))
case a :: Nil => Some((a + IntRating(1500)).map(_ / 2))
case _ => None

Expand Down
2 changes: 2 additions & 0 deletions modules/coreI18n/src/main/key.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,8 @@ object I18nKey:
val `intermezzoDescription`: I18nKey = "puzzleTheme:intermezzoDescription"
val `killBoxMate`: I18nKey = "puzzleTheme:killBoxMate"
val `killBoxMateDescription`: I18nKey = "puzzleTheme:killBoxMateDescription"
val `vukovicMate`: I18nKey = "puzzleTheme:vukovicMate"
val `vukovicMateDescription`: I18nKey = "puzzleTheme:vukovicMateDescription"
val `knightEndgame`: I18nKey = "puzzleTheme:knightEndgame"
val `knightEndgameDescription`: I18nKey = "puzzleTheme:knightEndgameDescription"
val `long`: I18nKey = "puzzleTheme:long"
Expand Down
2 changes: 2 additions & 0 deletions modules/puzzle/src/main/PuzzleTheme.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ object PuzzleTheme:
val intermezzo = PuzzleTheme(i.intermezzo, i.intermezzoDescription)
val kingsideAttack = PuzzleTheme(i.kingsideAttack, i.kingsideAttackDescription)
val killBoxMate = PuzzleTheme(i.killBoxMate, i.killBoxMateDescription)
val vukovicMate = PuzzleTheme(i.vukovicMate, i.vukovicMateDescription)
val knightEndgame = PuzzleTheme(i.knightEndgame, i.knightEndgameDescription)
val long = PuzzleTheme(i.long, i.longDescription)
val master = PuzzleTheme(i.master, i.masterDescription)
Expand Down Expand Up @@ -141,6 +142,7 @@ object PuzzleTheme:
dovetailMate,
hookMate,
killBoxMate,
vukovicMate,
smotheredMate
),
I18nKey.puzzle.specialMoves -> List(
Expand Down
3 changes: 1 addition & 2 deletions modules/relay/src/main/RelayFetch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,10 @@ final private class RelayFetch(
)

private def reportBroadcastFailure(r: RelayRound.WithTour): Unit =
if r.round.sync.log.alwaysFails then
if r.round.sync.log.alwaysFails && r.tour.official && r.round.shouldHaveStarted then
r.round.sync.log.events.lastOption
.filterNot(_.isTimeout)
.flatMap(_.error)
.ifTrue(r.tour.official && r.round.shouldHaveStarted)
.filterNot(_.contains("Cannot parse move"))
.filterNot(_.contains("Cannot parse pgn"))
.filterNot(_.contains("Found an empty PGN"))
Expand Down
1 change: 1 addition & 0 deletions public/images/puzzle-themes/vukovicMate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions translation/source/puzzleTheme.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
<string name="intermezzoDescription">Instead of playing the expected move, first interpose another move posing an immediate threat that the opponent must answer. Also known as "Zwischenzug" or "In between".</string>
<string name="killBoxMate">Kill box mate</string>
<string name="killBoxMateDescription">A rook is next to the enemy king and supported by a queen that also blocks the king's escape squares. The rook and the queen catch the enemy king in a 3 by 3 "kill box".</string>
<string name="vukovicMate">Vukovic mate</string>
<string name="vukovicMateDescription">A rook and knight team up to mate the king. The rook delivers mate while supported by a third piece, and the knight is used to block the king's escape squares.</string>
<string name="knightEndgame">Knight endgame</string>
<string name="knightEndgameDescription">An endgame with only knights and pawns.</string>
<string name="long">Long puzzle</string>
Expand Down
6 changes: 3 additions & 3 deletions ui/analyse/css/study/_player.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ $player-height: 1.6rem;

.analyse__clock {
@extend %roboto, %flex-center-nowrap;

height: 100%;
font-size: 1.2em;
@include padding-direction(0, 0.8em, 0, 0.6em);

height: 100%;
border-radius: 0 4px 0 0;
box-shadow: none;
font-size: 1.2em;
font-weight: normal;
}

&-bot .analyse__clock {
Expand Down
7 changes: 4 additions & 3 deletions ui/analyse/src/explorer/explorerConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { h, VNode } from 'snabbdom';
import { myUserId, type Prop, prop } from 'common';
import * as licon from 'common/licon';
import { snabDialog } from 'common/dialog';
import { type Dialog, snabDialog } from 'common/dialog';
import { bind, dataIcon, iconTag, onInsert } from 'common/snabbdom';
import { storedProp, storedJsonProp, type StoredProp, storedStringProp } from 'common/storage';
import { ExplorerDb, ExplorerSpeed, ExplorerMode } from './interfaces';
Expand Down Expand Up @@ -100,7 +100,6 @@ export class ExplorerConfigCtrl {
}
this.data.db('player');
this.data.playerName.value(name);
this.data.playerName.open(false);
};

removePlayer = (name?: string) => {
Expand Down Expand Up @@ -313,9 +312,10 @@ const monthSection = (ctrl: ExplorerConfigCtrl) =>
]);

const playerModal = (ctrl: ExplorerConfigCtrl) => {
let dlg: Dialog;
const onSelect = (name: string | undefined) => {
ctrl.selectPlayer(name);
ctrl.root.redraw();
dlg.close();
};
const nameToOptionalColor = (name: string | undefined) => {
if (!name) {
Expand All @@ -333,6 +333,7 @@ const playerModal = (ctrl: ExplorerConfigCtrl) => {
ctrl.data.playerName.open(false);
ctrl.root.redraw();
},
onInsert: dialog => (dlg = dialog).show(),
modal: true,
vnodes: [
h('h2', 'Personal opening explorer'),
Expand Down
2 changes: 1 addition & 1 deletion ui/common/src/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class DialogWrapper implements Dialog {

const justThen = Date.now();
const cancelOnInterval = (e: PointerEvent) => {
if (Date.now() - justThen < 200) return;
if (Date.now() - justThen < 200 || !dialog.isConnected) return;
const r = dialog.getBoundingClientRect();
if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom)
this.close('cancel');
Expand Down

0 comments on commit 36b180a

Please sign in to comment.