Example #1
0
        public bool Exchange(MsgInformationEx MsgDTO, object[] param)
        {
            var exp   = MsgCounterSvc.Get(MsgDTO.FromQQ);
            var golds = exp / 2;

            if (golds == 0)
            {
                MsgSender.PushMsg(MsgDTO, "你没有足够的经验值兑换!");
                return(false);
            }

            var osPerson = OSPerson_Doremi.GetPerson(MsgDTO.FromQQ);

            osPerson.Golds += (int)golds;
            osPerson.Update();
            MsgCounterSvc.Consume(MsgDTO.FromQQ, exp);

            MsgSender.PushMsg(MsgDTO, $"兑换成功!你使用 {exp} 点经验值兑换了 {golds}金币,你当前拥有 {osPerson.Golds}金币!");
            return(true);
        }
Example #2
0
        public bool Upgrade(MsgInformationEx MsgDTO, object[] param)
        {
            var osPerson = OSPerson_Doremi.GetPerson(MsgDTO.FromQQ);
            var level    = LevelSvc.GetByLevel(osPerson.Level);
            var exp      = MsgCounterSvc.Get(MsgDTO.FromQQ);

            if (exp < level.Exp)
            {
                MsgSender.PushMsg(MsgDTO, "你没有足够的经验值升级!", true);
                return(false);
            }

            if (level.Level == LevelSvc.TopLevel)
            {
                MsgSender.PushMsg(MsgDTO, "你已满级,无需渡劫!", true);
                return(false);
            }

            MsgSender.PushMsg(MsgDTO, "渡劫开始!你需要回答对全部问题才能成功渡劫!");

            var qas = DujieSvc.RandQAs(DujieQACount);
            int i;

            for (i = 0; i < DujieQACount; i++)
            {
                var randAs = qas[i].RandAs;
                var msg    = $"题目({i + 1}/{DujieQACount}):\r\n" +
                             $"{qas[i].Q}\r\n" +
                             $"{string.Join("\r\n", randAs.Select((p, idx) => $"{idx + 1}:{p}"))}";
                var i1   = i;
                var info = WaiterSvc.WaitForInformation(MsgDTO, msg, information => information.FromGroup == MsgDTO.FromGroup &&
                                                        information.FromQQ == MsgDTO.FromQQ &&
                                                        int.TryParse(information.Msg, out var idx) &&
                                                        idx > 0 && idx <= qas[i1].A.Length, 10);
                if (info == null)
                {
                    MsgSender.PushMsg(MsgDTO, "回答超时!");
                    break;
                }

                var aidx = int.Parse(info.Msg) - 1;
                if (!qas[i].IsCorrect(randAs[aidx]))
                {
                    MsgSender.PushMsg(MsgDTO, "回答错误!");
                    break;
                }

                MsgSender.PushMsg(MsgDTO, "回答正确!");
            }

            MsgCounterSvc.Consume(MsgDTO.FromQQ, level.Exp);
            if (i != DujieQACount)
            {
                MsgSender.PushMsg(MsgDTO, "渡劫失败,请重新来过!", true);
                return(true);
            }

            osPerson.Level++;
            osPerson.Update();

            MsgSender.PushMsg(MsgDTO, "升级成功!");
            return(true);
        }