GithubHelp home page GithubHelp logo

Comments (4)

niklasf avatar niklasf commented on June 11, 2024 1

Dropping off the board is done via:

deleteOnDropOff?: boolean; // delete a piece when it is dropped off the board

To drag a new piece onto the board, a little bit of glue is needed, because the pocket is not part of chessground. Call

dragNewPiece(piece: cg.Piece, event: cg.MouchEvent, force?: boolean): void;
from the mousedown event handler of the pocket.

from chessground.

niklasf avatar niklasf commented on June 11, 2024 1

For a new piece that's dragged in? Not directly, but you provide a callback

dropNewPiece?: (piece: cg.Piece, key: cg.Key) => void;

and reset the board state if needed. That's how lichess.org implements Crazyhouse drops.

For pieces that are already on the board, yes:

dests?: cg.Dests; // valid moves. {"a2" ["a3" "a4"] "b1" ["a3" "c3"]}

from chessground.

AhsanSarwar45 avatar AhsanSarwar45 commented on June 11, 2024

An even better example would be the crazyhouse variant in lichess. Is that done using in built features, or custom-made?

from chessground.

AhsanSarwar45 avatar AhsanSarwar45 commented on June 11, 2024

@niklasf Thank you, that worked. By any chance, is there a way to specify legal squares that the pieces can be dragged on to?

from chessground.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.