예제 #1
0
        private void askPlayerQuestion(DebugGameRoom room, DebugFiberYieldResponse answer)
        {
            gameData.TotalQuestionsAnswered++;

            var answ = answer.Question;

            if (answ == null)
            {
                ServerLogger.LogDebug("game question over", room);
                myServerManager.SendGameOver(room);
                room.Fiber.Run<DebugFiberYieldResponse>();
                //     profiler.takeSnapshot('game over ' + room.roomID);
                return;
            }
            askQuestion(answ, room);
            //ServerLogger.Log(gameData.toString());

            var dt = new DateTime();
            var then = dt.GetMilliseconds();
            //ServerLogger.Log(then - now + " Milliseconds");
            //  ServerLogger.Log(gameData.TotalQuestionsAnswered / ((dt.GetTime() - startTime.GetTime()) / 1000d) + " Answers per seconds", LogLevel.DebugInformation);
        }
예제 #2
0
        private void logGameConsoleLine(DebugGameRoom room, DebugFiberYieldResponse answer)
        {
            var answ2 = room.Fiber.Run<DebugFiberYieldResponse>();
            processGameResponse(room, answ2);

            if (!room.Game.CardGame.Emulating)
            { 
                myServerManager.SendDebugLog(room, new DebugGameLogModel(answer.Contents));
            }
        }
예제 #3
0
        private void didPlayersLeave(DebugGameRoom room, DebugFiberYieldResponse response)
        {
            room.Fiber.Run<DebugFiberYieldResponse>(room.PlayersLeft);

            room.PlayersLeft.Clear();
        }
예제 #4
0
        private void breakGameExecution(DebugGameRoom room, DebugFiberYieldResponse response)
        {

            var ganswer = new DebugGameBreakModel(response.LineNumber, response.Value);

            myServerManager.SendDebugBreak(room, ganswer);
        }
예제 #5
0
        private void processGameResponse(DebugGameRoom room, DebugFiberYieldResponse response)
        {
            if (response == null)
            {
                ServerLogger.LogDebug("game request over", room);

                myServerManager.SendGameOver(room);
                room.Fiber.Run<DebugFiberYieldResponse>();
                rooms.Remove(room);
                room.Unwind(room.Players);
                return;
            }


            switch (response.Type)
            {
                case DebugFiberYieldResponseType.AskQuestion:
                    askPlayerQuestion(room, response);
                    break;

                case DebugFiberYieldResponseType.PlayersLeft:
                    didPlayersLeave(room, response);
                    break;
                case DebugFiberYieldResponseType.GameOver:
                    gameOver(room);
                    break;
                case DebugFiberYieldResponseType.Log:
                    logGameConsoleLine(room, response);
                    break;
                case DebugFiberYieldResponseType.VariableLookup:
                    Console.WriteLine("vlook  " + Json.Stringify(response));
                    breakGameExecution(room, response);
                    break;
                case DebugFiberYieldResponseType.Break:
                    Console.WriteLine("broke  " + Json.Stringify(response));
                    breakGameExecution(room, response);
                    break;
            }
        }