by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    David Friedman
    @Derongan
    Is there a simple way to end a turn once a stage ends?
    1 reply
    I tried endIf once activePlayers was null, but it seems that endIf runs before the stage is changed
    Chris Swithinbank
    @delucis
    @Derongan endIf can work, but activePlayers is null when endIf is called at the start of the turn (not sure if there’s a good reason for this), so you need to also check if any moves were made:
    endIf: (G, ctx) => ctx.numMoves > 0 && ctx.activePlayers === null,
    Joao Lucas de Carvalho Arruda
    @jlcarruda

    Hello, I'm new using the boardgame.io and I have a strange error that happens when I try to use React with the Client.

    import React from 'react'
    import { Client } from 'boardgame.io/react'
    import { BrowserRouter, Switch, Route } from 'react-router-dom'
    
    import { GameJA } from '../game'
    import { Game } from '../pages'
    
    const GameClient = Client({
      game: GameJA,
      board: Game
    })
    
    export const Routes = () => (
      <BrowserRouter>
        <Switch>
          <Route
            path="/"
            exact
            component={GameClient}
          />
        </Switch>
      </BrowserRouter>
    )

    When I use the GameClient as the component prop for the Route, I get this error:
    Error: Function called outside component initialization

    Does anyone know why? D:

    2 replies
    Ruslan Hydra
    @HydraOrc
    Guys, how do you ensure that you do not run into race conditions when you allow both players to do moves simultaniously at the same turn or also if one player issues a couple moves at the same time (ERROR: invalid stateID, was=[11], expected=[13])?
    4 replies
    kamr
    @kamr
    image.png
    any ideas why my Lobby isn't working? the FE doesn't seem to hit the backend at all
    1 reply
    David Friedman
    @Derongan
    INVALID_MOVE is nice and all, but is there a way to return a reason with it that could be surfaced to the client?
    1 reply
    Art Tosborvorn
    @artt

    I created a clone of Camel Up (graphics is still a work in progress). Let's say the basic move is rolling a dice. The token gets advanced by the number on the dice. If the token lands on a tile with a modifying property, say, +1, then the token would get bumped by one. Let's say the roll is 3, the token gets moved to tile #3, and let's say the tile has +1 mod, the token would end up on tile #4. What I have right now is something like:

    moves: {
      roll: (..) => {
        roll()
        resolveMove()
      }
    }

    where resolveMove is the function determining if the token will need to be moved (if it lands on the tile with a modifying property, that is). So the client gets only the board state after everything is done, and only knows that the token got moved from tile #0 to tile #4.

    I'd like to create an animation in between, so that the client would see a roll of 3, see the token gets moved to tile #3, then (after a delay) gets bumped to tile #4.

    My question is, how should this be done?

    One way is to have the server send out multiple state changes (so the move would be roll (return token at #3) -> delay -> resolveMove (return token at #4).

    Another way is to provide the client with resolveMove logic, so the client could figure out the animation by itself.

    My intuition is that the latter way should work better. Just wanna confirm that. Thanks a lot!

    1 reply
    kamr
    @kamr
    image.png
    9 replies
    sorry @adngdb - I don't seem to be able to paste an image in a thread
    kamr
    @kamr
    image.png
    Corentin Dancette
    @cdancette
    Hi! I'm having an issue with boardgame.io. I noticed that when I return an INVALID_MOVE, for the current player which is in a specific phase, it ends the phase instead of doing nothing
    2 replies
    Is this an expected behaviour ? From reading the doc it seems that returning INVALID_MOVE should not change the state G or ctx
    Adrian Gaudebert
    @adngdb
    Hey @delucis, is https://github.com/delucis/bgio-effects in a usable state?
    3 replies
    kamr
    @kamr
    is there a way to change the "game" of a room? e.g. if I have 2 players in a room playing tic-tac-toe and I want them to be able to switch to chess?
    I guess I would need to create a new "chess" room, and have both players leave the current room and join the new one?
    1 reply
    rather than somehow just changing the game type of the current room
    Corentin Dancette
    @cdancette
    @delucis here's a codesandbox that reproduces the behaviour
    To reproduce: Click on the button "enter stage". This sends the current player in a specific stage. Then, click on the button "Invalid move". This shouldn't do anything, but it removes the current player from its stage (as seen in ctx.activePlayers , that goes to null)
    Oops, it seems that it actually has the desired behaviour
    Corentin Dancette
    @cdancette
    I'm not sure what happened in my app then, I certainly made a mistake somewhere, sorry !
    1 reply
    It works perfectly now :)
    1 reply
    Corentin Dancette
    @cdancette
    I have another question, about the "undo" action. I tried to add a button, but any time I press it, the server outputs "ERROR: playerID=[0] cannot undo / redo right now"
    same for the other player
    is there something to configure to make it work?
    Chris Swithinbank
    @delucis
    Ah, that’s probably due to this bug: nicolodavis/boardgame.io#565
    7 replies
    The logic accepting/rejecting undo actions is not very good with stages active at the moment.
    Corentin Dancette
    @cdancette
    Ah, yes, i'm using a lot of stages
    Thanks, maybe i'll implement my own undo if it's really needed!
    About stages, in the documentation, it says that they're mostly useful for non active players, but I'm using them a lot for active players, is this a bad practice ?
    I use them to restrict the range of actions that the current player can do
    Chris Swithinbank
    @delucis
    That sounds like a good use, sure! They’re helpful for both scenarios.
    (Also, rather than implementing a whole undo system, you may like to look at the underlying code linked in that issue — there could be some very small changes we could make to fix the undo system using stages.)
    Corentin Dancette
    @cdancette
    Okay, neat :)
    I really like boardgame.io btw, so thanks a lot @nicolodavis, @delucis and other contributors for your work ! It makes it so much faster to code a multiplayer game! I enjoy particularely not having to deal with networking and state synchronization..
    Chris Swithinbank
    @delucis
    Nice to hear!
    Corentin Dancette
    @cdancette
    Hey! Is it possible to undo from the game, or is it only possible from the client ? Documentation mentions only the client this.props.undo()
    3 replies
    Davi Araki
    @DaviAraki
    I'm trying to run stages between phases, but i'm encountering 2 problems, first: i can't see which stage is as i can see the phase in ctx.phase. Second: the moves on the stage are not overriding anything
    17 replies
    Mohre
    @Mohre
    Hi. It wrote a custom player-view and need to mutate G in it.
    how can I apply immer to my custom player-view to let me change G instead of creating new one using spread syntax?
    2 replies
    Mohre
    @Mohre
    Is it possible to assign a client two different playerID?
    It is useful when a 4 player game played with 2 players each take 2 seats.
    2 replies
    aflorj
    @aflorj
    Hey, guys! I am making a card game and want to pause rendering at one point in each round.
    9 replies
    Günther
    @gunthergun
    Hey there, I am having trouble with understanding the PluginPlayer Code. I copied from the documentation what you are supposed to be using however, in my visual layer I cannot acces any values. G.player or G.players both are undefined. ctx.player is also undefined. The debug window also does not show any values from this plugin. However the setup runs at the start of the game for each player ? So what am I doing wrong ? Is there another way to access the player values that were setup at the start ?
    1 reply
    ThanosDodd
    @ThanosDodd
    Hello beautiful people. First-time user here. I'm creating a 2-player game whose movements are decided by 2 dice. Can I place the stages (and moves) of a particular phase within that phase or must I place stages separately inside turn: {} in the game constant?
    4 replies
    Alexander Craggs
    @popey456963
    Hey! Found boardgameio/boardgame.io#49 which points to simultaneous turns being possible using phases. Coudl anyone explain that somehow?
    ThanosDodd
    @ThanosDodd
    Hello! I'm making a 2-player game where each player's pieces move in opposite directions. I've solved this issue by changing the direction variable at the end of a turn but I'm a bit confused as to how to render the game in multiplayer mode. I want the board to look like their opponent's, but flipped (there is no issue with flipping the pieces as they are circular, the board is also symmetrical)
    1 reply
    Corentin Dancette
    @cdancette
    Hi! Is it possible to choose the playerID while using the default lobby implementation ?
    1 reply
    ThanosDodd
    @ThanosDodd
    Hello! Is a dice roll a 'move'? Meaning should it go in the game constant or the board.js?
    4 replies
    Alexander Craggs
    @popey456963
    Can stages have an 'onEnd'? For instance, we have a stage that applies to 'everyone' in a turn, letting them take one action. Once everyone has taken their turn, we want to run some other code.
    Oliver Ni
    @oliver-ni
    This library is awesome. Thanks for the hard work!
    1 reply