feat: scaffold mvp shell and content runtime

This commit is contained in:
manpengan
2026-03-29 00:36:28 +08:00
parent 25a38cbf05
commit c118e24bd1
25 changed files with 2903 additions and 7 deletions

View File

@@ -0,0 +1,47 @@
import { getClickablePieces } from './overlap-graph.js'
function getPotentialMatches(slot, clickablePieces) {
return clickablePieces.filter((piece) => {
const sameCount = slot.filter((slottedPiece) => slottedPiece.elementId === piece.elementId).length
return sameCount >= 2
})
}
export function classifyDeadlock(runtimeState, boardState) {
const slot = runtimeState.slot ?? []
const bypass = runtimeState.bypass ?? []
const clickablePieces = getClickablePieces(boardState)
if (slot.length < 7) {
return {
type: 'none',
clickablePieces,
}
}
const matchablePieces = getPotentialMatches(slot, clickablePieces)
if (matchablePieces.length > 0) {
return {
type: 'none',
clickablePieces,
matchablePieces,
}
}
if (bypass.length > 0) {
return {
type: 'soft',
clickablePieces,
matchablePieces: [],
}
}
return {
type: 'hard',
clickablePieces,
matchablePieces: [],
}
}
export default classifyDeadlock