Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    OlgaPech
    @OlgaPech_twitter

    Hello!
    I'm trying to use typescript with boardgame.io and I get stuck with this error:

    Uncaught Error: Move state is not JSON-serialiazable.
    See https://boardgame.io/documentation/#/?id=state for more information.

    My problem seems to be, that I'm adding an array of very primitive Objects to the state:

    export class Card {
      suit: string;
      rank: number;
      shortname: string;
    
      constructor(suit: string, rank: number) {
        this.suit = suit;
        this.rank = rank;
        this.shortname = this.suit + this.rank;
      }
    }
    
    export type Hand = Card[];
    ...
    
    export interface SpadesGameState {
      bids: string[];
      score: number[];
      hands: Hand[];
      currentTrick?: Trick;
      lastTrick?: Trick;
      dealer: number;
      isSpadesOpen: boolean;
    }
    
    ...
    
    return { ...G, isSpadesOpen: false, currentTrick: undefined, lastTrick: undefined, hands: [[new Card("d", 1),new Card("d", 4)], [], [], []] as Hand[]}

    Is it really true that I cannot have a GameState that has a typed ("classed") property inside or should I search for the error elsewhere..?

    2 replies
    Juliano Rocha Barbosa
    @Juliano-rb
    Hi, anyone have the same problem below?
    I have two players in a game, when I call the leave match endpoint in one of then, the player still listed in matchData object with isConnected: true
    I'm using this endpoint: https://boardgame.io/documentation/#/api/Lobby?id=leaving-a-match
    3 replies
    Daniel Lujan
    @dlujan
    Hello. I need help please. I'm making a game that has two players. I'm running into an issue where I HAVE to MANUALLY toggle the player in the debug console in order for the player turns to work. You know, click it so that the grey box has an orange outline. How do I get this to happen automatically so that I don't have to click it each time? Thanks.
    2 replies
    Joselito Viveiros Nogueira Filho
    @joselitofilho

    Hi all,

    Does anyone have a good example of using Bots?

    Farnebald
    @farnebald_twitter
    Hello, my board (for a card game) is composed by react components (e.g. player hand) and sub-components (e.g. cards). I don't see how to access the "moves" property from those sub-components. Is it automatically available from any (sub-)component (through props.moves) or do i have to pass it from parent to children ? My intention is to run a move function when I click on a card. Do you have some examples ? Thank you for your help !
    3 replies
    Nithiwat Sirirattanachaikul
    @nitsirs
    Hi all! I wonder if it's possible to create a game frontend using Phaser JS while using boardgame.io to control the game logic. I think it would be a great way to create a fun and interactive game that people could play online. If anyone has any thoughts or knows of any tutorials that could help me out, I would really appreciate it!
    1 reply
    Nathan Saritzky
    @nsaritzky

    Certain events are double-firing inappropriately, and I'm at a loss for why. I have a phase in which most turns are automatic. In the exceptions, I shunt players into a stage to make a move before ending the turn. An onEnd hook for the turn then fires. My problem is that, sometimes, that onEnd hook fires twice. It seems to happen when either the phase ends or the event needs to call another move function. At least in the latter case, the top of the call stack looks like: (my onEnd hook) > wrapFn > produce > wrapFn, where both wrapFns come from the Immer plugin. This seems weird, and calls to mind this old bug: boardgameio/boardgame.io#544. But I don't know how to fix or work around it.

    Appreciate any help you can give.

    Gabriele Castellano
    @gabrielecastellano
    Hello everyone!
    I am trying to deploy my game in a multiplayer fashion, using a simple server and the built in lobby. I am encountering a trouble I have no clue how to solve, as client side ctx.playerID is never set, hence I am not able to identify the player (for customizing the interface based on it). Server side, ctx.playerID seems to be set correctly. I think I am missing something big as I cannot find any reference to this error anywhere.
    Thank you very much for your help.
    Farnebald
    @farnebald_twitter

    Hello, I have an array (called 'selection') in my game state (G). I want a react component to refresh when an item is added/removed to/from this array. The problem is that my 'useEffect' function does not trigger.

    export function MyBoard({ ctx, G, moves }) {
    const [selection, setSelection] = useState([]);
    useEffect(() => {
    setSelection(G.selection);
    }, [G.selection]);
    ... }

    Here is the code (in my moves) that adds an element to the array (I avoid using 'push' as it does not change the array) :

    G.selection = [...G.selection, item];

    Thank you for your help !

    3 replies
    Noé Bonnet
    @Neodark7
    Hi ! i have issues with multiplayer (and only on my staging environment) where the game clients always disconnect and reconnect when the match begins. this is not happenning on localhost, does it happen to anybody else ?
    Noé Bonnet
    @Neodark7

    Hi i just posted a new issue here : boardgameio/boardgame.io#1100

    "Hi ! i have a custom lobby mechanism on my project which implement basic matchmaking between players.
    When sufficient players have joined the lobby i create the match from my api and send an event to all the players to redirect them to the match page.
    When the match page load, an http call occurs to log the user to the game server.

    It seems that the boardgame implementation cannot handle simultaneous connection changes properly.
    When someone logs into the match (https://github.com/boardgameio/boardgame.io/blob/main/src/master/master.ts#L400)
    the match metadata is fetched from my database, modified to include the new metadata, sent to all clients and then saved to the database.

    When 2 players joins the match simultaneously, this logic is called 4 times simultaneously and it looks like that some players are overriding the metadata changes of previous users.

    For example:

    Player 1 is redirected to match page
    Player 2 is redirected to match page

    Player 1 onConnectionChange method start and fetch metadata
    Player 2 onConnectionChange method start and fetch metadata

    Player 1 onConnectionChange method modify metadata and save it to the database
    Player 2 onConnectionChange method modify metadata and save it to the database

    as Player 2 fetched the metadata before Player 1 finished modifying and saving it to the database, when Player 2 modify and save the metadata into the database, the data is outdated and does not contain Player 1 isConnected and credentials values. Player 2 is correctly logged into the match but Player 1 stay on the "Connecting..." screen indefinitely and the match get stuck when his turn start...

    Sometimes everything plays nicely in the correct order but most of the time, for example in a 4 players match, a player stay on the loading screen and the match is blocked, this is really critical for my project, how can this be fixed ?"

    Does anyone has encountered the same behavior ? and maybe found a solution for it ?

    Nick Mura
    @nickmura
    What is a 'game definition' ? How easy would it be to assimilate boardgame.io into my existing game.
    Gabriele Castellano
    @gabrielecastellano
    Hi everyone! I noticed the AI is not really documented. I managed to add bots through the enumerate function, but I have no way to specify any optimization metric. The tutorial states that it is possible "to specify a set of objectives to optimize for", but I am not able to find any example of this anywhere. Also, it seems that the "ai" object only accepts "enumerate" as child. How can I make the bot maximize a very simple metric, let's say, G.players[playerID].score ?
    evilgenious448
    @evilgenious448
    Hi Everyone,
    I am new to Boardgame.io so learning as I go and am building my game. It is a 2 player card game, where each player has stats such as resources, and the player pays these resources to either heal themselves or damage the opponent.
    So for example if the player uses a spell that costs 9 mana, it removes 9 mana from them and then deals 10 damage to the opponent's health.
    How can I affect the stats of the other player. I know to use ctx.currentplayer to affect the stats of the current player, however am unsure of how to do "other player" or "not current player". What is the best approach to achieve this without writing unoptimized code?
    4 replies
    Gabriele Castellano
    @gabrielecastellano
    Hello! I am using the ctx.log object to show a game log client-side. It works fine for moves, as I can add metadata before the move ends. However, what if I want to log something outside of a move? Let's say, on some event? For instance, I have a 'onBegin' method in one of my phases, and I want to log something from that method. If I try to modify ctx.log there, nothing arrives client-side as that happens outside of a move.
    Desmond Rivet
    @drivet

    Hello! I'm currently wrapping my head around the difference between stages and phases.

    I get that a stage works within the concept of a turn, i.e. that it retains the concept of the current player, and that a phase is a lot broader in scope, where you can change turn order, current player, etc.

    One unique thing that a stage provides that a phase does not on its own is the ability for other players to makes moves during the current player's turn, i.e. other players can make moves without modifying the value of the "current player".

    In fact, to me, this is the killer feature of stages - the ability to have more that one player making moves. I say this because if you take this feature out of consideration, then there's not much a difference between stages and phases, is there? Am I wrong about that?

    In particular, if you don't need the ability for other players to make moves on someone else's turn, then I imagine you can just treat phases like stages - especially if the phases all have a turn order of CONTINUE (i.e. the current player in the next phase is the one who ended the previous phase). With phases all having a turn order of CONTINUE, and if we don't need other players to make moves during the current player's turn, is there really a difference between phases and stages?

    7 replies
    Desmond Rivet
    @drivet
    Hello all. As far as I can tell there is no onBegin/onEnd for stages, is that correct? Has anyone ever found the need for that?
    3 replies
    Mike Sukmanowsky
    @msukmanowsky_twitter
    Hey all - have a bizarre issue trying to replicate the TicTacToe tutorial via NextJS/TypeScript and I oddly keep finding that my clickCell event handler doesn't actually update react state (though it does seem to update state seen in boardgame.io's debugger). Any obvious reason why this might happen? My code is all local, but here's a gist incase it helps https://gist.github.com/msukmanowsky/986fc87ccaa3879a878fef90718fa7bb
    2 replies
    Farnebald
    @farnebald_twitter
    How can I have access to the 'debug' property of the client in my views (i.e. React components) so that I could condition the display of some elements according to the value of this debug flag ? My current idea is to store this information in the game state but any other suggestion is welcomed ... Thank you for your help
    Farnebald
    @farnebald_twitter
    When my 'endIf' condition is triggered on a phase, the engine automatically switches to the next player (while I'd like to stay on the current one). How can I fix that ? Thanx
    Lachlan Kingsford
    @lkingsford

    I was wondering whether anybody could give me an opinion on my lobby/site to play games.
    It's https://cuberail.games, and the source is on https://github.com/lkingsford/CubeRailDotGames. The one game on it is on https://github.com/lkingsford/EmuBayOnlineClient

    Going to thread to describe what I've got happening with the lobby (and more precisely, what I'm wondering if there's a better way to do)

    15 replies
    Gabriele Castellano
    @gabrielecastellano
    Hello! I am using the ctx.log object to show a game log client-side. It works fine for moves, as I can add metadata before the move ends. However, what if I want to log something outside of a move? Let's say, on some event? For instance, I have a 'onBegin' method in one of my phases, and I want to log something from that method. If I try to modify ctx.log there, nothing arrives client-side as that happens outside of a move.
    Anthony Apollo Nardi
    @anthony-nardi
    How many socket connections could this library support simultaneously? Just curious as a ballpark, 100 players, 1000?
    Answer is probably whatever a single node server could support. But curious if someone has researched this the context of multiplayer board game.
    2 replies
    cwatsonc
    @cwatsonc

    I'm trying to run some game state tests using:

    let client = Client({ game: customGameSetup, playerID: '0', multiplayer: Local() });

    when I run the tests I get CONSOLE ERROR messages:

    ERROR: invalid value returned by turn.order.first — expected number got object “null”.

    which seems to be coming from bgio not my source... any idea what causes this issue? Likely I'm misusing the Client instance but not sure how.

    3 replies
    Nathan Saritzky
    @nsaritzky
    Does the React client support running matches with predetermined matchIDs from the lobby? It's not clear to me how to do that since it doesn't accept matchID or credentials as props.
    1 reply
    Farnebald
    @farnebald_twitter
    Hello, is it possible to make the bot play automatically for certain players ? E.g. I'd like to play player 0 and make players 1, 2 and 3 played by the bot (without having to click on 'play' in the debug panel). Also, in order to reduce the waiting time, i'd like to configure, in my code, the number of iterations and depth of the AI. Thank you for your help !
    Jeffrey Gao
    @Jeffmagma
    Hi, what's the intended method of allowing cross-origin requests when the backend and frontend are hosted on different servers? Right now the backend is hosted on render.com and my frontend is local, and I get the following error on firefox: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at <url>. (Reason: CORS request did not succeed). Status code: (null).. I currently have the origins on the server set as origins: [Origins.LOCALHOST], and I may change the setup to two servers.
    walkerchloe666
    @walkerchloe666
    Es un gran compromiso. Las tragamonedas en línea son actualmente el juego de casino más conocido del mundo. Uno de sus aspectos importantes es la versatilidad con la que se pueden incorporar distintas temáticas a los juegos del presente. Para leer más sobre ¿Qué tecnología utilizan los casinos online? ver https://www.cultture.com/110713-los-mejores-juegos-de-tragaperras-de-heroes-de-comic mi blog. Los diversos desarrolladores de software emplean regularmente superhéroes de cómics y películas. Si quieres sentir algo al máximo, prueba uno de los cinco tragamonedas que hemos elegido en este post.
    SketchyLogic
    @SketchyLogic
    Hi, can you point me to the latest resource that shows how to integrate bgio in angular please?
    Is this the only example we have? https://github.com/turn-based/boardgame.io-angular
    Jayson Harshbarger
    @Hypercubed
    Hello all... wonder if anyone has examples of other boardgame.io bots. I thinking about a minmax bot, breath first MCTS (if that is a thing), memoization, running in a web worker, etc. Anyone write a custom bot?
    Isaac
    @higherkey
    Hi everyone, I'm just getting started and I really like the look of things. I have a question about initial setup. When I ran "npm install --save-dev parcel-bundler" it threw a bunch of npm WARN messages, including a message saying
    "npm WARN deprecated parcel-bundler@1.12.5: Parcel v1 is no longer maintained. Please migrate to v2, which is published under the 'parcel' package. See https://v2.parceljs.org/getting-started/migration for details."
    Does anyone know if using Parcel v2 would break boardgame.io or if it would be OK to use the updated version?
    Jeffrey Gao
    @Jeffmagma
    Are there any React examples of using the javascript Lobby functions to create a custom lobby? I'm having trouble getting the list of matches to update when a match is created
    Nathan Saritzky
    @nsaritzky
    @Jeffmagma I have some very rough code here. The key parts for updating the match list are the "updateMatches" dispatch in the reducer and the useInterval hook, which I took from this blog post. However, this example still needs to wait for the next interval to update the list.
    I use the fast-deep-equal package to diff updates to the match list.
    Nathan Saritzky
    @nsaritzky
    Is there a good way to give the lobby client access to game state? I want some buttons (e.g. either temporarily or fully leaving a match) to depend on it. But the client doesn't seem to provide a way to pass functions down via props to the board.
    1 reply
    Anky Y.
    @ratquaza
    hey, quick question - what would be the best way to determine what has happened exactly and how to update the UI when subscribing to state changes in the client object?
    i understand that you can subscribe to listen to changes in state, but i feel as if subscribing to all state changes and not knowing what exactly has changed would be difficult in a larger scaled game
    traceyhoward65
    @traceyhoward65
    right
    Jj Medina
    @jjPlusPlus
    Hi all, my wife is working on a gameboard.io implementation in React and we have a question about fetching our initial deck of cards from an API before setting up the game. Since the tutorial immediately instantiates the Client() in the App.js, (which in turn immediately calls the setup fn in the Game object) there's no opportunity to asynchronously fetch the data before setting up the game. My first thought was that she needs to do the async fetch inside the setup fn, but boardgame.io seems to break if all of the data isn't immediately available.
    2 replies
    Jj Medina
    @jjPlusPlus
    And I should point out that for now there's no server involved (the game is only local to the current browser session)
    kamr
    @kamr
    Is there any built-in support for hex grids? looks like there was previously but doesn't seem to be in the repo anymore as far as I can tell?
    Blair Cliff
    @BoxDrop_twitter

    The answer to this is probably obvious, but I'm missing it completely. I've got a turn order setup that I can't quite make work. :

    phases: {
        setup: { // some moves that can only be made by player '0' at the start of the game, before they use a move that manually ends the phase
            start: true,
            turn: {order: TurnOrder.CONTINUE},
            next: 'phaseA',
            moves: {
                other_stuff: (...),
                progress_to_phase_a: ({events}) => {events.endPhase()}
            }
        },
        phaseA: { // normal play, starting with player '0'. 
            turn: {
                order: TurnOrder.CONTINUE,
                moveLimit: 1,
            },
            next: 'phaseB',
            moves: {
                other_stuff: (...),
                progress_to_phase_b: ({events}) => {events.endPhase()}
            }
        },
        phaseB: { // should start with the player AFTER the player who used progress_to_phase_b, and end BEFORE the player who used progress_to_phase_b. e.g., in a 3 player game, if player '1' ended phaseA, player '2' and player '0' should get a turn, at which point the phase should end
            turn: {
                order: TurnOrder.ONCE,
                moveLimit: 1
            },
            moves: {...}
        }
    }

    Every combination of TurnOrder and next I've tried has either ended with player '1' always starting phaseA, or player '0' always starting phaseB. Please help.

    5 replies
    Luis C. de Leon
    @luyzdeleon
    Hello guys, I was wondering if there was a way of stringing various games together where players could progress through these games like "world 1-1, world 1-2" and keep the same global state as they progress
    1 reply
    Thanks in advance for your time
    Luis C. de Leon
    @luyzdeleon
    How would you guys recommend serving the boardgame.io dependency to the client side (the browser)?
    Luis C. de Leon
    @luyzdeleon
    Any ideas on how to make an effect engine? My game is a TCG and I wanna know how can I somewhat generically can execute the card effects so I can mix and match effects?
    Inuka Jayasekera
    @a_new_car_twitter
    Hi, are there any working game examples with cards? I have done the tutorial but I can't see how to use assets.
    2 replies
    Blair Cliff
    @BoxDrop_twitter
    Is there an easy way to set what optional rules and house rules a game uses when you start it? I've been using a "setup" phase with moves to manipulate things like that, but that solution seems clunky to me, so I was wondering if there was anything easier.
    J.D. Lowe
    @thejdlowe_twitter
    Are there examples of making boards that involve walls? Like a maze of some kind. Thinking something like Clue/Cluedo since there are designated rooms and you have to enter at certain points, but having a hard time figuring out the best way to build the data
    4 replies