ai-dungeon-cli icon indicating copy to clipboard operation
ai-dungeon-cli copied to clipboard

Support multiplayer mode

Open p3r7 opened this issue 4 years ago • 4 comments

Seems pretty easy to do: just an hardcoded scenario-id different than the one for single player.

But how to connect with other known users?

Also, should we prompt user every time or assume single player and enable multiplayer w/ a cli option?

p3r7 avatar Jul 31 '20 09:07 p3r7

My library supports multiplayer, but it's not really documented... The general idea is, create the adventure as usual from a multiplayer scenario id, obtain the public adventure id and share it with other players. Then, there is a query

mutation ($adventurePlayPublicId: String) {
    addUserToAdventure(adventurePlayPublicId: $adventurePlayPublicId)
}

to add the current user to add it to the adventure. The query returns an adventure content id that can be used as usual.

In my library this is implemented here and there is also this client function to connect to a public adventure (it does the transaction required automatically)

mkualquiera avatar Jul 31 '20 22:07 mkualquiera

If you want to connect to an existing adventure it's also possible to do:

    api_client = AiDungeonApiClient()
    api_client.adventure_id = 'adventure:31914999'

    ai_dungeon = AiDungeonGame(api_client, conf, io)
    ai_dungeon.login()
    ai_dungeon.start_game()

akvadrako avatar Aug 10 '20 20:08 akvadrako

Thanks for the input both of you.

I've just added cli options capabilities (w/ argparse) which was a prerequisite for this feature.

Indeed, I guess we'd enable precising the (existing) adventure_id with a command line argument.

p3r7 avatar Aug 12 '20 12:08 p3r7

Basic implem with only support for public adventure id: https://github.com/Eigenbahn/ai-dungeon-cli/commit/493a45a5e648984ba46574a22f20991f8f129c2c

I'll do some code cleanup before tagging.

p3r7 avatar Aug 18 '20 14:08 p3r7