コード例 #1
0
        public static GlamourRecord Get(long GroupNum, long QQNum)
        {
            var record = MongoService <GlamourRecord> .GetOnly(p => p.GroupNum == GroupNum && p.QQNum == QQNum);

            if (record != null)
            {
                return(record);
            }

            record = new GlamourRecord()
            {
                GroupNum = GroupNum, QQNum = QQNum
            };
            MongoService <GlamourRecord> .Insert(record);

            return(record);
        }
コード例 #2
0
ファイル: GiftAI.cs プロジェクト: Dolany/DolanyAI
        public bool PresentGift(MsgInformationEx MsgDTO, object[] param)
        {
            var aimQQ = (long)param[0];
            var name  = param[1] as string;

            if (aimQQ == MsgDTO.FromQQ)
            {
                MsgSender.PushMsg(MsgDTO, "你居然给自己送礼物!", true);
                return(false);
            }

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

            if (osPerson.GiftDic == null || !osPerson.GiftDic.ContainsKey(name))
            {
                MsgSender.PushMsg(MsgDTO, "你没有这个礼物!", true);
                return(false);
            }

            var gift = GiftSvc[name];

            osPerson.GiftDic[name]--;
            osPerson.Update();

            var glamourRecord = GlamourRecord.Get(MsgDTO.FromGroup, aimQQ);

            glamourRecord.Glamour += gift.Glamour;
            glamourRecord.Update();

            var relationship = new IntimateRelationshipRecord()
            {
                GroupNum = MsgDTO.FromGroup,
                QQPair   = new [] { MsgDTO.FromQQ, aimQQ },
                Value    = gift.Intimate,
                Name     = gift.Name
            };

            relationship.Insert();

            var msg = $"赠送成功!对方增加了 {gift.Glamour} 点魅力值,你们之间的羁绊值增加了 {gift.Intimate} 点!";

            MsgSender.PushMsg(MsgDTO, msg, true);

            return(true);
        }