Esempio n. 1
0
        public override async Task <OnGameConfigureResponse> OnRemoteBotGameConfigure()
        {
            // Only called on remote bots, not for hosted bots.
            //
            // Hosted bots are passed their information, like user name, and what game to join.
            // But remote bots just act like external players. So when they start, you have to either join a game that's already
            // been created, or create a new game.
            //
            // This function simply gives you a nice interface to create or join a game. It's also possible to use the
            // `KokkaKoroService` object directly to call the service directly.
            // Note! All KokkaKoroService throw exceptions if there is an unexpected failure.
            Logger.Log(Log.Info, $"OnRemoteBotGameConfigure");

            // Example: List all games on the service
            // List<KokkaKoroGame> games = await KokkaKoroService.ListGames();

            // Example: Using the service SDK, you can call list bots:
            List <ServiceProtocol.Common.KokkaKoroBot> bots = await KokkaKoroService.ListBots();

            // But we know we want to beat the TestBot.
            List <string> botNames = new List <string>();

            botNames.Add("RandomBot");

            // We want to make a new game that auto starts and has the test bot to play against.
            return(OnGameConfigureResponse.CreateNewGame("MyTestBotGame", botNames, true));

            // Or if we used the service to create a game, we could join it like this.
            // return OnGameConfigureResponse.JoinGame(gameId);
        }
Esempio n. 2
0
        public override async Task OnConnected()
        {
            // Called when the bot has connected to the service.
            Logger.Log(Log.Info, $"OnConnected");

            // OnConnected is a good time to do async setup work that might take some time.
            // Once the game is joined and we start getting action requests, there's a turn time limit we must finish the turn in or it will be lost.
            // But we can block OnConnected for up to the game time limit (defaults to 1h) with no problems.
            await m_logicCore.Setup();

            // Set a logger into the SDK if we want more context for debugging.
            KokkaKoroService.SetDebugging(Logger.Get(), false);
        }
Esempio n. 3
0
        // Disconnects the bot and terminates it.
        public async Task Disconnect()
        {
            // Tell the bot we are disconnecting.
            await FireDisconnect("Client invoked", true, null);

            // Kill the connection to the service.
            if (KokkaKoroService != null)
            {
                await KokkaKoroService.Disconnect();
            }

            // Let the run function exit.
            try
            {
                m_waitHandle.Release();
            }
            catch {}
        }