Exemplo n.º 1
0
        private void processGameResponse(GameRoom room, FiberYieldResponse response)
        {
            if (response == null) {
                Logger.Log("game request over", LogLevel.DebugInformation);

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

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

                case FiberYieldResponseType.PlayersLeft:
                    didPlayersLeave(room, response);
                    break;
                case FiberYieldResponseType.GameOver:
                    gameOver(room);
                    break;
                case FiberYieldResponseType.Log:
                    logGameConsoleLine(room, response);
                    break;
                case FiberYieldResponseType.Break:
                    breakGameExecution(room, response);
                    break;
            }
        }
Exemplo n.º 2
0
        private void logGameConsoleLine(GameRoom room, FiberYieldResponse answer)
        {
            var answ2 = room.Fiber.Run<FiberYieldResponse>();
            processGameResponse(room, answ2);

            if (!room.Game.CardGame.Emulating && room.Debuggable) {
                //Logger.Log(gameData.toString());
                var ganswer = new GameAnswerModel(0, answer.Contents);

                myServerManager.SendDebugLog(room, ganswer);
            }
        }
Exemplo n.º 3
0
        private void breakGameExecution(GameRoom room, FiberYieldResponse response)
        {
            if (!room.Debuggable) {
                var answ3 = room.Fiber.Run<FiberYieldResponse>();
                processGameResponse(room, answ3);
                return;
            }
            if (!room.Game.CardGame.Emulating) {
                var ganswer = new GameAnswerModel(response.LineNumber + 2, 0);

                myServerManager.SendDebugBreak(room, ganswer);
            }
        }
Exemplo n.º 4
0
        private void didPlayersLeave(GameRoom room, FiberYieldResponse response)
        {
            room.Fiber.Run<FiberYieldResponse>(room.PlayersLeft);

            room.PlayersLeft.Clear();
        }
Exemplo n.º 5
0
        private void askPlayerQuestion(GameRoom room, FiberYieldResponse answer)
        {
            gameData.TotalQuestionsAnswered++;

            var answ = answer.question;

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

            var dt = new DateTime();
            var then = dt.GetMilliseconds();
            //Logger.Log(then - now + " Milliseconds");
            //  Logger.Log(gameData.TotalQuestionsAnswered / ((dt.GetTime() - startTime.GetTime()) / 1000d) + " Answers per seconds", LogLevel.DebugInformation);
        }