boardgameio / boardgame.io

State Management and Multiplayer Networking for Turn-Based Games
https://boardgame.io
MIT License
10.03k stars 709 forks source link

Possibility to add players during the game? #884

Open RaphaelPI opened 3 years ago

RaphaelPI commented 3 years ago

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 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

delucis commented 3 years ago

@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!

RaphaelPI commented 3 years ago

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.