예제 #1
0
        protected override async Task Handle(GameStageUser stageUser, IFieldObjUser user, IPacketReader packet)
        {
            var type = (ConversationRequestType)packet.ReadByte();

            if (!user.IsConversing)
            {
                return;
            }

            var context = user.CurrentConversation.Context;

            if (type == ConversationRequestType.AskQuiz ||
                type == ConversationRequestType.AskSpeedQuiz)
            {
                await context.Respond(
                    new ConversationResponse <string>(type, packet.ReadString())
                    );

                return;
            }

            var answer = packet.ReadByte();

            if (
                type != ConversationRequestType.Say &&
                type != ConversationRequestType.AskYesNo &&
                type != ConversationRequestType.AskAccept &&
                answer == byte.MinValue ||
                (type == ConversationRequestType.Say ||
                 type == ConversationRequestType.AskYesNo ||
                 type == ConversationRequestType.AskAccept) && answer == byte.MaxValue
                )
            {
                await user.EndConversation();

                return;
            }

            switch (type)
            {
            case ConversationRequestType.AskText:
            case ConversationRequestType.AskBoxText:
                await context.Respond(
                    new ConversationResponse <string>(type, packet.ReadString())
                    );

                break;

            case ConversationRequestType.AskNumber:
            case ConversationRequestType.AskMenu:
            case ConversationRequestType.AskSlideMenu:
                await context.Respond(
                    new ConversationResponse <int>(type, packet.ReadInt())
                    );

                break;

            case ConversationRequestType.AskAvatar:
            case ConversationRequestType.AskMemberShopAvatar:
                await context.Respond(
                    new ConversationResponse <byte>(type, packet.ReadByte())
                    );

                break;

            case ConversationRequestType.AskYesNo:
            case ConversationRequestType.AskAccept:
                await context.Respond(
                    new ConversationResponse <bool>(type, Convert.ToBoolean(answer))
                    );

                break;

            default:
                await context.Respond(
                    new ConversationResponse <byte>(type, answer)
                    );

                break;
            }
        }