project-ed70c7de

byMerington BTor

Create a fully self-contained HTML game **"Bashni (Tower Checkers)"** for two players. Everything must work in a **single HTML file** (HTML + CSS + JavaScript), with **no external libraries** and **no Internet connection** required. # Core Requirements * 8×8 board. * 12 white and 12 black pieces. * Play only on dark squares. * White moves first. * Highlight all legal moves. * Highlight all possible captures. * Prevent any illegal moves. * Fully support multiple captures in a single turn. * Display the winner when the game ends. * "New Game" button. * "Undo Last Move" button. # Rules Use the rules of **Russian Draughts**, but with the mechanics of **Bashni (Tower Checkers)**. ### Movement * A regular man moves one square diagonally forward. * A king moves any distance diagonally. * Capturing is mandatory. * If multiple capture sequences exist, the player may choose any of them. * Men capture both forward and backward. * Kings capture over any distance diagonally. * After a capture, if another capture is available with the same tower, the turn must continue. * If, during a capture sequence, a man reaches the last rank, it is **immediately promoted to a king** and must continue capturing as a king during the same turn. # Bashni (Tower Checkers) Rules This is the most important part. * A captured piece is **NOT removed from the board**. * Instead, it is placed **under the capturing piece**, forming a tower. * A tower moves as a single piece. * The movement type of a tower is determined **only by its top piece**. * If the top piece is a man, the tower moves as a man. * If the top piece is a king, the tower moves as a king. * When a tower is captured, **only its top piece is removed**. * The remainder of the tower stays on the same square. * If removing the top piece reveals a piece of the opposite color, control of the tower immediately changes to that player. * If a king becomes exposed inside the tower, it regains its king status and determines the movement of the tower. # Capture Sequence Rules During a capture sequence: * Tower ownership changes are **not applied until the entire capture sequence is finished**. * Towers that have been captured become **gray (inactive)** until the end of the capture sequence. * A tower **cannot be captured more than once during the same turn**, even if it changes ownership after the sequence. * At the end of the capture sequence: * Remove the top piece from every captured tower. * Update tower ownership if the newly exposed top piece belongs to the opposite player. * Restore the normal colors of all affected towers. # Internal Data Structure Every occupied square must store an array: ```javascript [ { color: "white", king: false }, { color: "black", king: true }, ... ] ``` The **last element of the array is always the top of the tower**. All game logic must operate directly on this structure. # User Interface * Attractive wooden/checkered board. * Towers displayed as stacked pieces. * Show the height of every tower. * Kings display a crown icon. * Highlight the selected tower. * Animate movement. * Animate captures. * Display whose turn it is. * Responsive layout that works well on desktop and mobile. # Algorithms Implement: * `getLegalMoves()` * `getCaptures()` * `makeMove()` * `undoMove()` * `promoteIfNeeded()` * `checkGameOver()` Implement classes: * `Board` * `Game` * `Renderer` Requirements: * No duplicated code. * Clean object-oriented architecture. * Efficient move generation. * Correct recursive search for all possible capture sequences. # Game Over Detection Detect: * One player has no controllable towers. * One player has no legal moves. * Opponent is completely blocked. Display the winner and prevent further moves until a new game starts. # Final Validation Before generating the code, verify that all Bashni rules are implemented correctly, especially: * placing captured pieces underneath the capturing tower; * removing **only the top piece** when a tower is captured; * immediate promotion during a capture sequence; * multiple captures in a single turn; * mandatory captures; * correct tower ownership switching after the capture sequence ends; * deferred tower updates until the end of the capture sequence; * preventing the same tower from being captured twice during one move; * proper undo functionality restoring the complete previous game state. The final result must be a **fully functional, production-quality, bug-free single HTML file** containing all HTML, CSS, and JavaScript, ready to open locally in any modern browser without any external dependencies. # Additional Requirements ## Step-by-Step Capture Mode Capture sequences must be performed **step by step**, not instantly. During a multi-capture: * After each jump, the board must visually update. * The captured tower immediately becomes **gray (inactive)**. * The player must manually choose the next capture from the available options. * The move ends only when no further captures are available. * The player cannot switch to another tower during the capture sequence. * Captured towers remain on the board until the entire capture sequence finishes. * The same tower may **never be captured twice during the same move**, even if ownership would change after the sequence. * At the end of the capture sequence, update all affected towers simultaneously according to the Bashni rules. ## Board Editor Add a complete board editor. The editor must include the following tools: * Eraser (removes the entire tower from a square). * Top-piece eraser (removes only the top piece of a tower). * White man. * White king. * Black man. * Black king. Editor behavior: * Clicking an empty square places the selected piece. * Clicking a square that already contains a tower automatically places the selected piece **on top**, creating or extending the tower. * The editor must preserve the exact internal tower structure. * The editor must allow creating towers of any height and any combination of white/black men and kings. * The editor must immediately refresh the board display after every modification. ## Editor Controls Include buttons for: * Enter/Exit Editor Mode. * Clear Board. * Standard Initial Position. * Set Side to Move (White / Black). The editor must work entirely offline and integrate seamlessly with the game engine without breaking undo, move generation, capture detection, or Bashni mechanics.

Game
Game

Comments (0)

No comments yet. Be the first!

Game design preview
Game: View Board
Editor: Enter Editor Mode
Editor: Select Tool
Editor: Place Piece
Editor: Erase Tower
Editor: Erase Top Piece
Editor: Clear Board
Editor: Set Standard Position
Editor: Set Side To Move
Editor: Exit Editor Mode
Game: View Updated Board
Game design preview
Game: View Board
Editor: Enter Editor Mode
Editor: Select Tool
Editor: Place Piece
Editor: Erase Tower
Editor: Erase Top Piece
Editor: Clear Board
Editor: Set Standard Position
Editor: Set Side To Move
Editor: Exit Editor Mode
Game: View Updated Board