Where communities thrive


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

    I'm running into an error while following the Tutorial (Plain JS).

    Expected behavior

    A "Debug Panel" is shown in the client browser.

    The tutorial says:

    You can now serve the app from the command line by running: npm start
    You can make a move by clicking on clickCell on the Debug Panel

    Actual behavior

    The browser window is empty. There is no Debug Panel. Inspector panel displays:

    screenshot

    Server window

    screenshot

    Any suggestions on how I can go about troubleshooting this would be appreciated. You can open the above screenshots in a new window to view read them.

    3 replies
    Adrian Gaudebert
    @adngdb
    Hey folks, I'd like to store logs of the matches of my game, to be able to read them afterwards and look for bugs and reproduction steps and stuff. I don't find anything about doing something like this, though. Is there a supported, easy way to do that currently?
    3 replies
    Jim
    @jimu

    I would like track and report the current "round" of play, where a "round" is a single iteration through the game's phases.

    For example, a wargame might have a fixed duration of 7 years (1939-1945), where each year is a round consisting of 3 phases [reinforcements, movement, combat].
    Some turns/phases might be skipped (e.g., there might be no combat in a particular round), so ctx.turn cannot be used to derive the current round.

    I assumed ctx would be the logical place to track "rounds" because it seems closely related to stages, turns and phases.

    I naively tried to implement rounds by adding an onEnd trigger to the last phase:

    onEnd: (G, ctx) => { ctx.round++; }

    However, changes to ctx do not seem to persist outside of onEnd (is ctx readonly?)

    I suppose I can implement this functionality in G, or write a plugin. But is there a better way?

    Am I correct in assuming ctx is effectively readonly within Game.js and App.js?

    How is something like "rounds" data usually implemented in boardgame.io?

    6 replies
    Jim
    @jimu

    My game has a Movement phase that automatically ends when all units have moved.
    Each unit has a boolean "hasMoved" flag indicating whether or not it has moved yet this phase.

    This Movement phase defines:

    • onBegin which resets all the hasMoved flag on all the units

    • endIf which checks whether all units have moved

    This seemed reasonable to me, but it does not work as intended.
    endIf gets called before onBegin, terminating the phase before
    the hasMoved flags have been reset.

    Expected result

    1. onBegin is called and unit flags reset.
    2. Movement Phase is current

    Actual result

    1. onEnd terminates the phase because all units moved last turn and hasMoved flags have not been reset yet
    2. onBegin is never called
    3. Movement Phase is skipped

    Am I misunderstanding the function of onBegin and endIf and how they are supposed to be used?

    Larry Wang
    @larry801

    My game has a Movement phase that automatically ends when all units have moved.
    Each unit has a boolean "hasMoved" flag indicating whether or not it has moved yet this phase.

    This Movement phase defines:

    • onBegin which resets all the hasMoved flag on all the units

    • endIf which checks whether all units have moved

    This seemed reasonable to me, but it does not work as intended.
    endIf gets called before onBegin, terminating the phase before
    the hasMoved flags have been reset.

    Expected result

    1. onBegin is called and unit flags reset.
    2. Movement Phase is current

    Actual result

    1. onEnd terminates the phase because all units moved last turn and hasMoved flags have not been reset yet
    2. onBegin is never called
    3. Movement Phase is skipped

    Am I misunderstanding the function of onBegin and endIf and how they are supposed to be used?

    This behavior is intentional. Please refer to boardgameio/boardgame.io#569

    Jim
    @jimu
    Thanks for the help @larry801
    Jim
    @jimu
    What does the $ do in file client/debug/log/Log.svelte, line 8?
    let { log } = $client;
    3 replies
    Jim
    @jimu

    What is the purpose of LogEntry.automatic?

    types.ts:

    export interface LogEntry {
      action: ActionShape.MakeMove | ActionShape.GameEvent;
      _stateID: number;
      turn: number;
      phase: string;
      redact?: boolean;
      automatic?: boolean;
    }

    The only place I found it being used is in the client Debug panel. Rewind() skips LogEntries marked automatic.

    client/debug/log/Log.svelte (line 23):

      function rewind(logIndex) {
        let state = initialState;
        for (let i = 0; i < log.length; i++) {
          const { action, automatic } = log[i];
    
          if (!automatic) {
            state = client.reducer(state, action);
          }
    ...
    I'm guessing "automatic" LogEntries are side-effects that shouldn't be used to regenerate the state ? ? ?
    Larry Wang
    @larry801
    How to force three players for local
    multiplayer master?
    2 replies
    Johnny Wobble
    @JohnnyWobble

    So my (frontend) app only works in the dev mode, whenever I try and build it and run it will throw, when I try and load the multiplayer client

    Error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

    This is my client

    [in constructor()]
            this.MultiplayerClient = Client({
                game: Oversimplified,
                numPlayers: 2,
                board: BoardWrapper({leaveMatch: () => this.leaveMatch()}),
                multiplayer: SocketIO({server: this.matchAPI.url}),
                debug: false,
            });
    
    [in render()]
    <this.MultiplayerClient matchID={this.matchID} playerID={this.playerID} credentials={playerCredehttps://files.gitter.im/5a448416d73408ce4f85171a/HDnR/image.pngntials}/>

    This is the console log of the multiplayerClient before it is returned in the render()

    1 reply
    image.png
    Larry Wang
    @larry801
    How to set random seed for multiplayer or integrated test?
    2 replies
    Shawn Wilson
    @glassgiant
    Is there a way to serve static files? I am making my first boardgame.io game with plain JS. I am trying to serve game pieces (.svgs) in a public/ folder, setting img tags' sources to public/piece0.svg, etc.
    5 replies
    Larry Wang
    @larry801
    Why cannot access striped secret info in playerView function? Does playerView function receive stripped info?
    Larry Wang
    @larry801
    I want to calculate some info for client based on secret state. But I get error like this "cannot get playerDeck of undefined"
    Here is a minimal reproduce .
    4 replies
    Kumar Ayush
    @cheekujodhpur
    Hi. I am trying to do a card game where the players can fold. What is the best way to store player state? Is there anything the framework provides or I just do my own maintenance in the game state?
    activePlayers seemed logical, but it seems to do something entirely different
    3 replies
    Lee Matos
    @leematos
    Hiya! I'm looking to make a game where players each control 3 pieces at the start of the game, and through gameplay pieces may be removed from the board. What is the best way to represent associated actions with the pieces? For example, I'd like a turn to be roll die -> movie piece and then do it for any remaining pieces. Basically "optional stages" I think would allow for it, but wasn't sure if I was thinking about this wrong. Maybe I need to trigger the same stage multiple times, once,for each active piece?
    Kehino
    @Kehino
    Hello! I'd like to create a phase where every player can play once, whatever the order. I've used ActivePlayers.ALL_ONCE to let them play, then I set its endIf: (G, ctx) => (ctx.activePlayers === null), but the phase is skipped because setActivePlayers() is not immediately called. Could you suggest a clean way to do? For the moment, I added a ctx.numMoves > 0 condition to the endIf above, because it's at the beginning of the game.
    Larry Wang
    @larry801
    I have dealt with things like this, I added a flag for every player in G. Set flag to true in move code of
    each player. Check flags in endIf, if all player has moved then trigger end phase.
    Chris Swithinbank
    @delucis
    @Kehino ctx.numMoves represents the number of moves by the current player during the current turn, so ctx.numMoves > 0 && ctx.activePlayers === null should work later in the game too.
    Chris Swithinbank
    @delucis
    @/all Any Heroku users able to debug this question about deployment? boardgameio/boardgame.io#815
    Ruslan Hydra
    @HydraOrc
    Guys, I have published a free mobile Android strategy game based on boardgame.io called Steel Civilizations.
    You can find it here https://play.google.com/store/apps/details?id=com.hydra.steelcivs
    The AI is just a random bot, so do not expect much from it when launching the training mode. Playing vs AI works on any Android version.
    The focus was to create a multiplayer experience for players and you can try it if you have at least Android 9 (maybe 8 will also work, but I did not test yet).
    So if you login and start searching at the same time it should face you against each other.
    The multiplayer restriction on Android version is based on the fact that there are no timer events/moves in the framework and I had to workaround it with raf and it definitely does not work correctly on Android 7 or less.
    Thanks for your attention and thanks for a great framework :)
    1 reply
    Shawn Wilson
    @glassgiant
    I'm looking to create a multiplayer Connect4-type game, except each player is assigned a team of, say, up to 100. Alternating timed turns between teams. Each team member can vote for the column, in any order. When time's up, the most popular answer is chosen. Failure to vote doesn't hold up the game. Dropping out doesn't hold up the game. I have a multiplayer game working (not using React), but I am having trouble figuring out how to set the stages or phases to accomplish the team aspects, as the framework seems tied to individual player turns. Is there anything in my description that boardgame.io cannot do, on a conceptual level? From a high level, how would you implement this?
    3 replies
    Kehino
    @Kehino

    I have dealt with things like this, I added a flag for every player in G. Set flag to true in move code of
    each player. Check flags in endIf, if all player has moved then trigger end phase.

    Thanks @larry801 ! I thought about it, but instead -- in the meantime -- I opted for: (1) no endIf; (2) a call to endPhase() at the end of my onEnd() to ensure that everything is set up.

    @Kehino ctx.numMoves represents the number of moves by the current player during the current turn, so ctx.numMoves > 0 && ctx.activePlayers === null should work later in the game too.

    Thanks @delucis ! Duly noted!

    Kehino
    @Kehino
    Almost all my moves involve working with non-disclosable data -- part of the suggested G.secret and G.players -- and will thus be client:false moves: should I conceive them differently?
    Larry Wang
    @larry801
    @Kehino G.players of current player is disclosable
    4 replies
    Justin Daining
    @codequistador
    Greetings friends! I feel like I'm missing something obvious here! I'm getting the dreaded An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft. Error. This works just fine without the ... and return {} but I also need to remove the card from playerHand. I have that working but not included here.
    function discard(G, ctx, id) {
      let playerHand = [...G.players[ctx.currentPlayer].hand];
      const discardedCard = playerHand[id];
      const discardedCardColor = discardedCard.color;
    
      let discard = [...G.discard];
      discard
        .find((el) => el.color === discardedCardColor)
        .cards.unshift(discardedCard);
    
      return {
        ...G,
        discard,
      };
    }
    4 replies
    Kolja Kutschera
    @koljakutschera
    Hey, i need exactly the functionality of: https://github.com/delucis/bgio-effects but without react. I cant find something in the docs but i need something like useEffectListener for plain js... also it seemed when i tested the react version that effects are fireing on every move when used with Ai, so when Ai does its magic it is fired 1000x times not only for the move the Ai then realy does... whould be thankful for every help...
    5 replies
    Lachlan Kingsford
    @lkingsford
    Did typescript types end up getting implemented? I'm doing the tute in TS, and having to using 'any'. Is it a different import?
    2 replies
    Lachlan Kingsford
    @lkingsford
    What do most people do with the lobby? Looking at what auth and ids it offers, I implement auth somewhere else to keep track of what games players are in, run that on another service, and then create games using the REST API from the user service?
    Larry Wang
    @larry801
    @delucis Could you please release a new version of boardgame.io to include recent fixes?
    3 replies
    Kim Kyeseung
    @kimkyeseung
    is there any ways to get the game started or not???
    at lobby REST api..
    I just wanna make start button at the lobbyContainer
    Kim Kyeseung
    @kimkyeseung

    I got a good idea to solve that problem
    It's put the state of started or not to the first player's meta data
    Larry Wang
    @larry801
    @kimkyeseung Could you please explain your solution in detail? When and how to update that started state?
    Kim Kyeseung
    @kimkyeseung
    @larry801
    at the joined array, the first index of array is the game host.
    we put the meta data to first User to joined array like this
    {
      playerID: userId,
      credentials,
      data: { started: false}
    }
    and after start button click, we gonna change of firstUser's meta data started: true
    cwatsonc
    @cwatsonc
    anybody have some general knowledge about the debug console? It doesn't appear to work in remote server configurations was curious if this is a documented limitation? I am developing a fbgio hosted game and discovered this behavior.
    sorry, last post was re: debug LOG tab... which appears to only work in local games.
    Larry Wang
    @larry801
    "Does no work" is too vague, please describe your issue in detail
    aflorj
    @aflorj
    Hey! Are there any projects that use playAgain API that I could check out? My "solution" works but feels really clumsy. I was searching through repos that have bgio as a dependency but wasn't able to find an example.
    cwatsonc
    @cwatsonc
    @larry801 you want me to open an issue for a general question? or explain here in full with tests as shown in boardgameio/boardgame.io#810? When using the debug console in remote game mode, no history for moves is being accumulated in the debug > Log? Is this expected?
    Chris Swithinbank
    @delucis
    @cwatsonc The next release should improve the debug panel’s Log tab quite a bit for server games with any luck (there were a bunch of issues with both state and rewind). That said, I would still expect the move history to accumulate with the current version — just potentially with some weird gaps.