Skip to content

Commit

Permalink
Challenge: "Play On The Same File"
Browse files Browse the repository at this point in the history
  • Loading branch information
neongreen committed Jun 29, 2023
1 parent 7165b05 commit 7174d0b
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/challenges/chess-simp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getMovePiece, getCapture, isCapture, Move, moveIsEqual } from '@/move'
import { getCapture, getMoveCoord, getMovePiece, isCapture, moveIsEqual } from '@/move'
import { legalMoves_slow } from '@/move/legal'
import { isBlack, isKing, isPawn, pieceType } from '@/piece'
import _ from 'lodash'
Expand Down Expand Up @@ -209,10 +209,37 @@ const _2023_06_09: Challenge = {
},
}

const _2021_08_17: Challenge = {
uuid: 'ad9def81-d090-468d-91fb-58570ec87f39',
title: 'Play On The Same File',
link: 'https://www.youtube.com/watch?v=yyI9jKf85TY',
challenge:
"When your opponent's piece (or pawn) lands on a column, you must play a piece (or pawn) that is on the same column.",
isMoveAllowed({ history, move }): boolean {
// When the opponent does castling, we'll actually the player to use either the rook column or the king column. (For the purposes of "play a piece" part, we still count castling as a king move.)
const lastMove = _.last(history)
if (!lastMove) return true
const ourMoveFrom = getMoveCoord(move).from
return match(lastMove.move)
.with(
{ kind: P.union('normal', 'enPassant') },
({ to: lastMoveTo }) => ourMoveFrom.x === lastMoveTo.x
)
.with(
{ kind: 'castling' },
({ kingTo: lastMoveKingTo, rookTo: lastMoveRookTo }) =>
ourMoveFrom.x === lastMoveKingTo.x || ourMoveFrom.x === lastMoveRookTo.x
)
.exhaustive()
},
}

/**
* All Chess Simp challenges.
*/
export const chessSimpChallenges: Challenge[] = _.concat(
// Aug 2021
[_2021_08_17],
// Dec 2021
[_2021_12_04],
// Jan 2022
Expand Down

1 comment on commit 7174d0b

@vercel
Copy link

@vercel vercel bot commented on 7174d0b Jun 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ches – ./

ches-neongreen.vercel.app
ches.vercel.app
ches-git-main-neongreen.vercel.app

Please sign in to comment.