Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Larry Wang
    @larry801
    @DavoMyan you need to talk to websocket directly in unity https://github.com/boardgameio/boardgame.io/blob/master/src/client/transport/socketio.ts
    Louis Deconinck
    @LouisDeconinck_twitter
    Is it better to use boardgame.io with plain JS or React?
    Eric Mun
    @DiZeroX

    I'm trying to follow the TicTacToe tutorial using Typescript, and when I try to use this.props.moves.clickCell(id); I get This expression is not callable. Not all constituents of type 'Move<GameInterface, Ctx>' are callable. Type 'LongFormMove<GameInterface, Ctx>' has no call signatures.ts(2349).

    Here is my code in Board.tsx:

    interface BoardProps {
      G: GameInterface;
      ctx: Ctx;
      moves: MoveMap<GameInterface, Ctx>;
      playerID: PlayerID;
      isActive: boolean;
    }
    
    export default class TicTacToeBoard extends React.Component<BoardProps, {}> {
      onClick = (id: number) => () => {
        this.props.moves.clickCell(id);

    Here is the GameInterface in game.ts

    export interface GameInterface {
      players: { [key: string]: Player };
      cells: Array<PlayerID>;
    }

    I looked at types.d.ts and found export declare type Move<G extends any = any, CtxWithPlugins extends Ctx = Ctx> = MoveFn<G, CtxWithPlugins> | LongFormMove<G, CtxWithPlugins>;. I saw this: boardgameio/boardgame.io#867 and looked at what the OP did with their project and they ended up making their own move dispatcher (https://github.com/dadiaogames/cspr-app/blob/master/src/Board.tsx).

    Any guidance would be much appreciated!

    2 replies
    Bobby Basnet
    @iCrashed

    I am a board game based on React client.

    I just can't find any way to update the MatchID. I refereed to the documents.

    https://github.com/boardgameio/boardgame.io/blob/master/docs/documentation/api/Client.md

    This document gives an API to update the match Id with Plain JS Client , with this call

    updateMatchID(id)

    However I can't find anything like this for React.

    Also, I would like to set the property of the match unlisted = true after the match has been started.

    How do I change that attribute as well?

    Any guidance would be much appreciated. Thanks

    Bobby Basnet
    @iCrashed
    *I am developing a board game based on React Client
    lw19901
    @lw19901
    How do we get the G and ctx objects for the client (without doing a move) when using plainJS?
    1 reply
    Sam Dobson
    @samdobson
    Hi all. Trying to work out if bgio is a good match for a new game. It's a card game where players try to build a certain hand. A "turn" consists of each player selecting one of their cards to pass to the player to their left. All players exchange simultaneously. From my (admittedly limited) understanding of bgio, I'm struggling to sensibly map this to its turn-based model. Any thoughts?
    5 replies
    Louis Deconinck
    @LouisDeconinck
    Recently came across a new subreddit for boardgame.io, might be interesting to check out: https://www.reddit.com/r/boardgameio/
    1 reply
    reatailret
    @reatailret
    Hi all . What use for "waiting for players" ? To start the game, you need at least two players. If one player has entered the game, then he waits until another joins. While waiting, the first player can exit the game. Second player join to game with "seat" move, for example. Use phases, stages? Any example code.
    3 replies
    Starz0r
    @Starz0r
    Is there documentation on the Client to Server send and recieve mechanisms? I checked the documentation and it didn't seem to describe what's going on behind the scenes. Currently entertaining the idea of using the boardgame.io as a backend server framework only, that would allow me to work on the client in whatever other language I'd please. Thinking that the protocol used is some sort of Websocket with JSON transport correct? Or is it something more adanced?
    8 replies
    Lachlan Kingsford
    @lkingsford
    Is the REST API for the Lobby usually used just on server side - given that it passes credentials and the like? Or do you open it up to clients too?
    1 reply
    Binish Manandhar
    @binish784
    hello everyone, is there a way we replace the boardgame client connecting... message with our own loading screen ?
    2 replies
    Binish Manandhar
    @binish784
    hello how can we setup a multiplayer game asynchronously from an external endpoint, let say we have a external dashboard from which we can change the card deck,.. how can we load the data on a game start or setup..
    2 replies
    Mathieu Triay
    @MathieuLoutre
    Hi! I'm trying to access a plugin inside a phase's onEnd event but it comes up undefined whereas ctx.random works fine. Is there something to say custom plugins should also be included in these lifecycle events?
    5 replies
    captaindopey
    @captaindopey
    Hi There... is there a simple way to get a list of players names from the server in a board component? It looks like the id's and connection status is included in a MatchData prop, but there doesn't appear to be any way to get the Players names?
    1 reply
    reatailret
    @reatailret

    Hello, after "startplay" phase end (endIf) next phase is null, not "waitng "

    const game = {
      name: 'tic-tac-toe',
    
      setup: (ctx, setupData) => {
        let r=new PlayersRingWhithEmpty(3);
        return {
        cells: new Array(9).fill(null),
        ring:r
      }},
      phases: {
        ///////////// phase
        waiting: {
          onBegin: (G, ctx) => {
            G.cells = new Array(9).fill(null);
          },
          turn: {
            activePlayers: { all: "iddle" },
            stages: {
              iddle: {
                moves: {
                  seat:{
                    client: false,
                    move:seat
                  }
                }
              },
              iddle_waiting: {
                moves: {
                  leave:{
                    client: false,
                    move:leave
                  }
                }
              }
            }
          },
          start:true,
          next: 'startplay',
          endIf: (G, ctx) => {
            return getTableUsersCount(G) > 1;
          },
          onEnd:(G,ctx)=>{
            setAllUsersInGame(G);
          }
    
        },
        ///////////// phase
        startplay: {
          endIf: (G, ctx) => {
            if (IsVictory(G.cells)) {
              return { next:"waiting",winner: ctx.currentPlayer };
            }
            if (G.cells.filter(c => c === null).length == 0) {
              return { next:"waiting",draw: true };
            }
          },
          next: 'waiting',
          turn :{
            activePlayers: { currentPlayer: "game", others:"game_iddle",moveLimit:1 },
            stages:
            {
              game:{
                moves:{
                  clickCell
                }
              },
              game_iddle:{
                moves:{
                  leave
                }
              }
            },
            order: {
              first: (G, ctx) => 0,
              next: (G, ctx) => { return (ctx.playOrderPos+1)<ctx.playOrder.length?(ctx.playOrderPos+1):0;},
              playOrder: (G, ctx) => G.ring.getOrderArray(),
            }
          }
        }
    
    
      }
    
    };

    Using socketio . That code is correct?

    8 replies
    Jim
    @flarbear

    Is there a known issue with processes leaking on the server end? Today I tried to use my boardgame.io service and it wasn't responding. I went in with cpanel and discovered that I had reached my process limit. Possibly as a result of that I couldn't run the node.js selector to try to shut down the apps and I couldn't ssh in either ("fork failed"). About the only thing I could do was to look at my process history and it seems to have gone up by 5-10 processes on those dates when I was messing with the boardgame app. Once my ISP kills some processes for me I can go in and experiment and see if it happens when I start/stop the app, or install new files, or ...?

    One possibility, given the timing on some of the process increases - can this be related to when cpanel tries to put the app to sleep? It seemed to happen a few hours after my weekly call with my family who play one of the games a lot. It seems common for shared hosting plans (and heroku as well) to sleep node.js apps after a period of inactivity.

    2 replies
    jorasso
    @jorasso
    Hello
    Does boardgame.io support in any way time limit for move?
    11 replies
    danielwoconnor
    @danielwoconnor
    Hey guys. How can I detect allowed moves in my React components? I'm updating from an earlier version, where there was ctx.allowedMoves but it doesn't seem to exist anymore. props.moves seems to always be a list of all the moves described in code (even in other phases or stages). So I don't know how to check if it's allowed before I call it, and as such always end up with something like ERROR: disallowed move: playCardMove in the console.
    5 replies
    misholson
    @misholson
    Can you call endTurn from the phase onBegin hook? My game is a card game where the first phase is everyone playing more or less simultaneously doing some hand management. The second phase should then start where the first player is the player who has a specific card. I'm ignoring ctx.currentPlayer for the first phase (because it's simultaneous play). Then I call ctx.events.endPhase() to go to the primary play phase. I have code in phase.onBegin that detects who has the special card and calls ctx.events.endTurn({ next: firstPlayer });, but it seems like it's not doing anything. The currentPlayer is always set to player 1 (not player 0, which is also interested). Does anyone have any ideas how I can handle this?
    4 replies
    misholson
    @misholson

    I'm trying to understand what I'm doing wrong. When I call
    ctx.events.endTurn({next: nextPlayerID})from a move it always goes to the next player in the turn order. Are there conditions that need to be met for it to work?

    I'm using a custom turn order by calling:

    order: {
      ...TurnOrder.DEFAULT,
      first: findStartPlayer
    },

    Any ideas why setting the next player isn't working?

    1 reply
    Lachlan Kingsford
    @lkingsford
    Are there any issues with undo and stages? I can't seem to undo past a phase change - but it doesn't raise any errors
    5 replies
    tom termini
    @tomtermite
    Happy V Day - I would like to implement a prototype of my (physical) board game, and I am seeking a developer to code for me. This is a paying gig, as I have a budget and a timeline. There is a design brief available here if anyone is interested: https://drive.google.com/file/d/1TvcYQlmJVXeLwlvV7MYrsqL7Qre6fJUv/view?usp=sharing
    Lachlan Kingsford
    @lkingsford
    Is there any way to step through a games history, and get its state throughout? I'm using boardgame.io for playtesting, and hoping to be able to get some data after games
    3 replies
    Stephan Hügel
    @urschrei
    From what I understand, INVALID_MOVE can't be caught on the client side, and I can't return any values from moves. Has anyone come up with a workaround? Would it be a terrible idea to set a boolean on G, listen for it in my update(state) function, and if it's true, do whatever I need and then call a move to clear it again?
    Stephan Hügel
    @urschrei
    (this is currently a single-player game, so the boolean can't be modified by anyone else)
    Chris Swithinbank
    @delucis

    @urschrei Not a terrible idea, but it might have some limitations (for example you could no longer use numMoves/moveLimit reliably). For consistency you could potentially use a custom plugin to manage this flag for you:

    import { INVALID_MOVE } from 'boardgame.io/core';
    
    InvalidMovePlugin = {
      name: 'invalid-move-workaround',
    
      fnWrap: (move) => (G, ctx, ...args) => {
        const newG = move(G, ctx, ...args);
        if (newG === INVALID_MOVE) {
          return { ...G, madeInvalidMove: true };
        }
        return { ...newG, madeInvalidMove: false };
      },
    };
    
    const game = {
      plugins: [InvalidMovePlugin],
    };

    (I’m wondering if this accounts for our use of Immer, some more work might be needed to handle that.)

    Tom
    @tomsharratt
    Can you have server-side clocks? E.g I'm making a card game and I need to deal cards out to plays one by one until there are no cards left. Say dealing one card every 0.5 second. Players should also be able to take actions during the dealing phase.
    6 replies
    Capi Etheriel
    @barraponto
    I would love to get started on boardgameio/boardgame.io#723 as I find it crucial to have error feedbacks to properly test my game.
    1 reply
    Kehino
    @Kehino
    Hi! I updated npm and bg.io, but now I have a high severity vulnerability because of immer, with a fix that downgrades bg.io to 0.27.1... What should I do?
    3 replies
    Matt Brailsford
    @mattbrailsford

    Hey folks, just come across boardgame.io and it looks really awesome. I'm hoping to make a multiplayer game using it for an event in June. Really looking forward to trying it out. One thing I'm trying to figure out is around the Lobby feature numPlayers and also how you would start a game after people have joined?

    What I'm looking to achieve is to create matches which could have up to a max of 8 players, but have it so that whoever created the match can start the game with as many number of players have joined at that time (up to 8 max). At that point no more players can join, only watch. And once the match creator "starts the game" the game should begin for everyone.

    Anyone able to provide a bit of an outline how this might be achieved? as I'm not sure if the numPlayers in a match is a fixed requirement for a game, and it's also not clear how a game begins once people have joined. Any advice would be really appreciated.

    3 replies
    Thomas Ghysels
    @thgh
    Hi, I have a turn/stage question: the goal is to let all players take 1 turn simultaneously and after all players ended their turn, it should start the next turn. I sort of have a solution based on ActivePlayers.ALL_ONCE, but a player should not be able to call endTurn() as it ends the turn of all players. Is there a way to not allow a player to end their turn? Based on the source there seems to be a hook system, but I'm not sure if it's internal only.
    I may have to go for a completely different approach as my usecase also allows multiple moves in 1 turn, so the moveLimit in ALL_ONCE is actually a blocker.
    9 replies
    Matt Brailsford
    @mattbrailsford
    Hey folks, anyone got any suggestions on how one would go about triggering an animation on all clients after the current player has made a move? The animation will have configuration based on the move of the player, which will determine the location on the board where the animation takes place. It feels like this should be something like a custom event with configuration but from what I can tell, bgio doesn't support custom events. Any suggestions?
    3 replies
    Binish Manandhar
    @binish784
    Hello i need some help with bgio-postgres, during the endif, ctx.gameover is set, however when i check the db, the gameover still remains null, same with the nextRoomId
    Stephan Hügel
    @urschrei
    Two things: just installed the latest version, and the new debug errors in case of unserializable state have led me to a fairly painless refactor, so thanks! The second thing: can someone clarify whether G can have 'simple' objects (i.e. {'foo': 'bar'} as properties? I noticed one of the issue comments said that Maps weren't allowed, so I'm just trying to get clarity on exactly what types I can use as properties.
    3 replies
    andrscyv
    @andrscyv
    Hey guys ! Is there a way to allow the players decide who starts the game ? It has to be after the setup function has run since every player needs to see their tiles to determine who starts ( its a domino game of 4 players).
    6 replies
    Jim
    @flarbear

    I'm having some odd problems publishing this on a web provider using Cpanel. Over time the account is showing an increasing number of running processes that seem to correlate to when we use the game. I'm guessing that the server tries to put the Nodejs app to sleep, but the processes remain running. Later when another game session starts, a whole new set of server processes is forked.

    What makes this more curious - my family went to play the game again this weekend and we ended up with 2 matches created - one group could only see the one match and the other group could only see the other match. I used the lobby web API to inspect the matches and only the match that I created existed on the server. I'm guessing that one of the old instances that was running was serving the one group and mine was being served by the fresh service. I thought we'd be stuck - evenly reloading the page didn't kick them over to the new server, but then someone who was in the other group decided to click on the link I had posted in Zoom chat and suddenly they saw our match - so when they used "URL autocomplete" in their browser, they connected to the server instance we had been using last week, and when they clicked on the link, somehow that got them to the server that had just woken up.

    Any suggestions on how to debug something like this? Could the standard Server.js code from the tutorials somehow not be recognizing the Cpanel's attempts to get it to sleep?

    reatailret
    @reatailret
    (node:9476) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'playerID' of undefined
        at forEachClient (H:\GITHUB\azicardgame\node_modules\boardgame.io\dist\cjs\server.js:3496:24)
        at clientIDs.forEach (H:\GITHUB\azicardgame\node_modules\boardgame.io\dist\cjs\server.js:3484:17)
        at Set.forEach (<anonymous>)
        at forEachClient (H:\GITHUB\azicardgame\node_modules\boardgame.io\dist\cjs\server.js:3482:23)
        at Object.send (H:\GITHUB\azicardgame\node_modules\boardgame.io\dist\cjs\server.js:3495:9)
        at Master.onSync (H:\GITHUB\azicardgame\node_modules\boardgame.io\dist\cjs\server.js:3382:27)
        at process._tickCallback (internal/process/next_tick.js:68:7)
    A have an error on server when testing and calling client.stop()... searching solution . On disconnect client is not deleted and master trying to send to all clients.
    1 reply
    Adrian
    @adngdb:delire.party
    [m]
    Hey folks! 👋 What is the difference between returning INVALID_MOVE in a move, versus returning nothing (i.e. return;)? Or rather, is there any added value in returning INVALID_MOVE?
    2 replies
    Stefano Cerelli
    @scerelli
    hallo do you know if it's possible
    to have a turn where all the players do something
    1 reply
    ?
    Denny
    @ninicdennis
    Hey Friends! More of a general question in terms of the engine. So I am creating a card game POC, And I am having issues determining / creating automatic phases within the game. Say for example I want the game to automatically draw me a card on a draw step, then move over to a seperate phase. What system would I be using there? Would it be phases or stages? Thank you!
    Denny
    @ninicdennis
    Scratched that, figured out my own answer. For anyone in the future, you should use stages to keep track of what phase you are on, then create something to keep track of phases. That was at least my way of fixing this solution!
    Lachlan Kingsford
    @lkingsford
    How can I keep my credential in my session? I've got generate_credentials getting the userId of the logged in user from the session, but I think the reason that my multiplayer isn't working is due to moves being unauthorized.
    8 replies
    Tobias Busch
    @Teebusch
    Hi guys, I'm implementing a game using Svelte and bg.io. I'm fairly new to both and looking for some resources or examples on connecting the two. For example a tutorial or a repo.
    1 reply
    Lachlan Kingsford
    @lkingsford

    If I've got my log from the store (for instance:

    [{"action":{"type":"MAKE_MOVE","payload":{"type":"makeBid","args":[5],"playerID":"0"}},"_stateID":0,"turn":1,"phase":"initialAuction"},{"action":{"type":"GAME_EVENT","payload":{"type":"endTurn","args":true}},"_stateID":0,"turn":1,"phase":"initialAuction","automatic":true}]

    and the initial state, is there any good ways of creating a client and forcing that data into it, step by step?

    I want to do that, and copy the state after each entry, so I can run some analytics on the state through the length of the game

    3 replies
    Denny
    @ninicdennis
    out of curiosity, does anyone know if you create a server for your game (using the multiplayer guide), where does the game state actually get tracked? I started my game, but my entire gamestate or G, does not exist anymore.
    4 replies
    Pilipo
    @Pilipo
    I am trying to tie a boardgame.io server into a Phaser 3 based client. I am not sure this is even possible, but would appreciate a pointer toward some kind of documentation or an article that describes the implementation. Thanks!
    2 replies