Code Monkey home page Code Monkey logo

goban's Introduction

Goban

Pub

Goban

Customizable Go board widget for Flutter.

Usage

Initialize a GobanController like so:

gobanController = GobanController(boardSize: BoardSize.Thirteen);

Then subscribe to the move stream:

gobanController.gobanStream.stream.listen((Position position) {
    // A move at 'position' was played
    // Decide what to do here
});

Whenever an intersection is clicked, the above method will fire.

Goban does not have any game logic; this is by design. Goban make no assumptions on what you want to do, so that it can be used for all purposes. Maybe you want to use it for Tsumego purposes, or maybe you want to use it for online multiplayer. Both of these required different logic, therefore Goban delegates all game logic responsibilities to the client.

For example, a simple local board would be:

player = Player.Black;

gobanController.gobanStream.stream.listen((Position position) {
    // A move at 'position; has been made.
    var clickedPlayer = gobanController.getPlayerFromPosition(pos); // Get the intersection at 'position'
    if (clickedPlayer == Player.Empty) { // If the intersection is empty;
        var move = Move(player, pos); // Create move

        gobanController.addMove(move); // Make the move on the goban.

        setState(() {
            player = player == Player.Black ? Player.White : Player.Black; // Other players' turn
        });
    }
});

Please see here for a more concrete example.

Customization Options

The board and the stones are fully customizable:

gobanController = GobanController(
    boardSize: BoardSize.Nine,
    gobanTheme: GobanTheme(
        stoneThemes: StoneThemes(
            blackStoneTheme: BlackStoneTheme(
                stoneColor: Colors.black45, borderColor: Colors.black),
            whiteStoneTheme: WhiteStoneTheme(
                borderColor: Colors.white, stoneColor: Colors.tealAccent)),
        boardTheme: BoardTheme(
            boardColor: Colors.yellow,
            lineColor: Colors.red,
            lineWidth: 3)));

Aside from the default theme, there are also two preset themes available:

Book Theme

Book Theme

gobanController = GobanController(
    boardSize: boardSize, gobanTheme: GobanTheme.bookTheme());

Jade Theme

Jade Theme

gobanController = GobanController(
    boardSize: boardSize, gobanTheme: GobanTheme.jadeTheme());

Todo

  • Stone shadow when while pressing down
  • Ability to show just one corner (like SmartGo on iOS)
  • Coordinates
  • SGF support

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.