Skip to content

Commit

Permalink
updates + mona lisa checkmate trophy
Browse files Browse the repository at this point in the history
  • Loading branch information
fitztrev committed Nov 13, 2024
1 parent 24cd71c commit acba725
Show file tree
Hide file tree
Showing 25 changed files with 77,977 additions and 43,528 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.json
pnpm-lock.yaml

coverage
dist
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ Your browser makes the request directly to the Lichess API to get the games. The
```bash
git clone https://github.com/fitztrev/rosen-score.git
cd rosen-score
npm install
npm run dev
pnpm install
pnpm run dev
```

Will start a local server at http://localhost:5173/

```bash
## Run the test suite
npm run test
pnpm run test
## or
npm run watch
pnpm run test:watch

## Check code coverage
npm run coverage
pnpm run coverage
open coverage/index.html
```

Expand Down
13 changes: 12 additions & 1 deletion js/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
</div>
</form>

<!-- <RecentUpdates @form-fill="formFill" /> -->
<RecentUpdates @form-fill="formFill" />
</div>

<download-progress
Expand Down Expand Up @@ -556,6 +556,14 @@
:trophies="playerTrophiesByType['checkmateAtMoveNumber:4'] || {}"
gameLink="https://lichess.org/u0SKphmW/black"
></accomplishment-score>
<accomplishment-score
@register-new-trophy="onRegisterNewTrophy"
title="Mona Lisa Checkmate"
desc="Checkmate the opponent with all your pieces on their original squares"
:trophies="playerTrophiesByType['monaLisaCheckmate'] || {}"
gameLink="https://www.chess.com/analysis/game/live/121711253019?tab=analysis&flip=false"
youtubeLink="https://www.youtube.com/watch?v=XAlcDWQ6iTM"
></accomplishment-score>
</div>

<h2 class="heading">There's a Funny Line</h2>
Expand Down Expand Up @@ -753,6 +761,7 @@ import { rosenTrap } from './goals/rosen-trap'
import { alphabetOpening } from './goals/alphabet-openings'
import { PlayerTrophiesByType, ReportSource, TrophyCacheFile, TrophyCheckResult } from './types/types'
import { formatSinceDate } from './utils/format-since-date'
import { monaLisaCheckmate } from './goals/mona-lisa-checkmate'
const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
Expand Down Expand Up @@ -965,6 +974,7 @@ export default {
caches.set('https://www.chess.com/member/knvb', '/cache/chesscom/knvb.json')
caches.set('https://www.chess.com/member/magnuscarlsen', '/cache/chesscom/magnuscarlsen.json')
caches.set('https://www.chess.com/member/saltyclown', '/cache/chesscom/saltyclown.json')
caches.set('https://www.chess.com/member/witty_alien', '/cache/chesscom/witty_alien.json')
if (!caches.has(url)) {
return
Expand Down Expand Up @@ -1188,6 +1198,7 @@ export default {
this.checkForTrophy(game, 'winInsufficientMaterial', winInsufficientMaterial(game, fen), game.moves.length)
this.checkForTrophy(game, 'clutchPawn', clutchPawn(game, fen), game.moves.length)
this.checkForTrophy(game, 'doubleCheckCheckmate', doubleCheckCheckmate(game, fen), game.moves.length)
this.checkForTrophy(game, 'monaLisaCheckmate', monaLisaCheckmate(game, fen), game.moves.length)
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion js/components/AccomplishmentScore.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class="px-3 py-2 rounded text-center"
:class="{
'bg-green-600': hasTrophies,
'bg-yellow-300 text-yellow-800 accomplishment-does-not-have-games': !hasTrophies,
'bg-yellow-400 text-yellow-800 accomplishment-does-not-have-games': !hasTrophies,
}"
>
<span @click.prevent="isExpanded = !isExpanded" class="hover:underline cursor-pointer">{{ title }}</span>
Expand Down
30 changes: 6 additions & 24 deletions js/components/RecentUpdates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,12 @@
<div class="border-t border-gray-300 mt-4 text-bold font-bold pt-2">Recent Updates</div>
<ul class="text-sm">
<li>
<changelog-date :year="2023" :month="4" :day="23"></changelog-date>
- Added support for <strong>Chess.com</strong>
- See
<span class="dotted-underline text-sky-900 cursor-pointer" @click.prevent="formFill('chesscom', 'Hikaru')">Hikaru</span>,
<span class="dotted-underline text-sky-900 cursor-pointer" @click.prevent="formFill('chesscom', 'GothamChess')">GothamChess</span>,
<span class="dotted-underline text-sky-900 cursor-pointer" @click.prevent="formFill('chesscom', 'DanielNaroditsky')"
>DanielNaroditsky</span
>,
<span class="dotted-underline text-sky-900 cursor-pointer" @click.prevent="formFill('chesscom', 'AlexandraBotez')">AlexandraBotez</span>,
and others
</li>
<li>
<changelog-date :year="2023" :month="4" :day="23"></changelog-date>
- Added
<a href="https://lichess.org/g9MdhRYy/black#126" target="_blank" class="dotted-underline text-sky-900 cursor-pointer"
>"Checkmate with 0.1 seconds" trophy</a
>
</li>
<li>
<changelog-date :year="2023" :month="3" :day="17"></changelog-date>
- Added
<a href="https://lichess.org/VwNKF7ie#121" target="_blank" class="dotted-underline text-sky-900 cursor-pointer"
>"Flag Opponent Who Had Mate in 1" trophy</a
>
<changelog-date :year="2024" :month="11" :day="13"></changelog-date>
- Added <strong>Mona Lisa Checkmate</strong> trophy
<br>
&nbsp; Credit to
<span class="dotted-underline text-sky-900 cursor-pointer" @click.prevent="formFill('chesscom', 'KNVB')">GM Aman Hambleton</span>
from Chessbrah. <a href="https://www.youtube.com/watch?v=XAlcDWQ6iTM" class="dotted-underline text-sky-900" target="_blank">See video here</a>
</li>
</ul>
</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { Game } from 'chess-fetcher'
import { TrophyCheckResult } from '../types/types'
import { fenToPosition } from '../utils/fen-to-position'

export function originalSetupCheckmate(game: Game, fen: string): TrophyCheckResult {
export function monaLisaCheckmate(game: Game, fen: string): TrophyCheckResult {
if (game.result.via !== 'checkmate') {
return []
}

let position = fenToPosition(fen)

if (position.startsWith('rnbqkbnr..K') || position.endsWith('k.....RNBQKBNR')) {
if (fen.startsWith('8/8/8/8/8/8/2k5/RNBQKBNR') || fen.startsWith('rnbqkbnr/2K5/8/8/8/8/8/8')) {
return [
{
color: game.result.winner === 'white' ? 'w' : 'b',
Expand Down
Loading

0 comments on commit acba725

Please sign in to comment.