boardgame.io icon indicating copy to clipboard operation
boardgame.io copied to clipboard

Possibility to add players during the game?

Open RaphaelPI opened this issue 3 years ago • 2 comments

Hi,

I discovered boardgame.io 2 months ago and introduced it into my unfinished game (Slay The Spire like). It's really nice, good job guys 😄

I use one player for each Monster that your hero is facing (total player = hero + number of monsters) and everything went perfectly before this problem:

  • I want my players (hero and monsters) to be able to call some allies, so add new players in the game.

I currently use the solution you provided in #794 to eliminate a player from my game and it works cause the G.playOrder become a subset of ctx.playOrder. But I don't have any solutions if I want to add one :(

Do you know if there is a way to do it? Or maybe I have to change the way I'm using boardgame.io and only have 2 players (player and IA) ? Would be great if i won't have to do it that way 🙏

Thank you for your time

RaphaelPI avatar Jan 03 '21 18:01 RaphaelPI

@RaphaelPI The only way I think you could achieve something similar currently would be to extend the #794 solution. Start the game with a pool of extra players, so you set numPlayers to some upper bound, but start with only some of those active. Then you could use those additional players later. (Players could also be recycled if they become inactive.) This would still be a hard limit, so if the game has a potentially exponential number of extra characters, this wouldn’t work and you might indeed need to switch to a “2-player” model like you suggest.

Having core methods to add and remove players seems like it would be a useful addition though!

delucis avatar Jan 03 '21 18:01 delucis

Thanks @delucis for your response.

Yes, i think it might be the best option :) My actual playOrder is an Array of uid, so I will have to refactor some stuff but defenitely less than the “2-player” model.

RaphaelPI avatar Jan 03 '21 21:01 RaphaelPI