Beispiel #1
0
        /// <summary>偷窃逻辑处理</summary>
        private ASObject StealNpc(TGGSession session, tg_user_extend extend, BaseNpcMonster basenpc, tg_train_home npc)
        {
            var userid = session.Player.User.id;
            var nprob  = GetProbability(session.Player.Role.LifeSkill.sub_ninjitsu, session.Player.Role.LifeSkill.sub_ninjitsu_level); //忍术加成概率
            var bprob  = GetBrainProb(session.Player.Role);                                                                            //智谋加成概率
            var equip  = Common.GetInstance().RandomEquip(userid, basenpc, nprob, bprob);

            if (equip != null)   //偷窃成功
            {
                npc.is_steal = (int)TrainHomeStealType.STEAL_YES;
                if (!tg_train_home.UpdateNpc(npc))
                {
                    return(Error((int)ResultType.DATABASE_ERROR));
                }
                AcquireEquip(session, equip);                                                                        //获得装备信息处理

                var logdata = string.Format("{0}_{1}", "EquipSteal", equip.base_id);                                 //记录偷窃获得装备信息
                (new Share.Log()).WriteLog(userid, (int)LogType.Get, (int)ModuleNumber.ROLETRAIN, (int)RoleTrainCommand.TRAIN_HOME_NPC_STEAL, logdata);
                log.BagInsertLog(equip, (int)ModuleNumber.ROLETRAIN, (int)RoleTrainCommand.TRAIN_HOME_NPC_STEAL, 0); //记录日志
            }
            else
            {
                extend.steal_fail_count++;
                extend.Update();
                session.Player.UserExtend = extend;
                if (IsEnterPrison(extend.steal_fail_count))
                {
                    new Share.Prison().PutInPrison(userid);
                }                                                                                        //推送进入监狱
            }
            (new Share.DaMing()).CheckDaMing(userid, (int)DaMingType.武将宅偷窃);
            return(new ASObject(Common.GetInstance().NpcStealData((int)ResultType.SUCCESS, npc.is_steal)));
        }
Beispiel #2
0
        /// <summary>偷窃判断是否获得装备装备</summary>
        /// <param name="userid">用户id</param>
        /// <param name="baseinfo">npc携带装备信息</param>
        /// <param name="nprob">忍术加成的偷窃概率</param>
        /// /// <param name="bprob">智谋加成的偷窃概率</param>
        /// <returns></returns>
        public tg_bag RandomEquip(Int64 userid, BaseNpcMonster baseinfo, double nprob, double bprob)
        {
            if (string.IsNullOrEmpty(baseinfo.equip))
            {
                return(null);
            }
            var ids = new List <int>();

            if (baseinfo.equip.Contains("|"))
            {
                var n = baseinfo.equip.Split("|").ToList();
                ids.AddRange(n.Select(item => Convert.ToInt32(item)));
            }
            else
            {
                ids.Add(Convert.ToInt32(baseinfo.equip));
            }
            var change = baseinfo.rate + nprob + bprob;        //忍术技能加成后的偷窃概率

            if (change > 100)
            {
                change = 100;
            }
            var equip = CommonHelper.RateRandomEquip(userid, change, ids);

            return(equip);
        }
Beispiel #3
0
        /// <summary>对战结果处理</summary>
        private ASObject ChallengeResult(TGGSession session, BaseNpcMonster npcinfo, tg_train_home npc, FightVo fight)
        {
            var isprop      = false;
            var exp         = npcinfo.experience;
            var equips      = npcinfo.equip;
            var probability = npcinfo.probability;
            var reward      = new List <RewardVo>();
            var propreward  = new List <RewardVo>();

            if (fight.isWin)
            {
                PowerUpdate(fight.isWin, session.Player.Role.Kind); //体力更新
                reward = BuildReward(exp);
                RewardExp(session, exp);                            //推送经验奖励
                UpdateExt(session.Player.User.id);

                npc.npc_state = (int)FightResultType.WIN;                                                     //更新npc状态为已战胜
                npc.Update();
                var newequip = Common.GetInstance().RandomEquip(session.Player.User.id, equips, probability); //是否获得装备
                isprop = newequip != null;
                if (newequip != null)
                {
                    Variable.TempProp.AddOrUpdate(session.Player.User.id, new List <tg_bag>()
                    {
                        newequip
                    }, (m, n) => n);
                    var listaso = new List <ASObject> {
                        AMFConvert.ToASObject(EntityToVo.ToEquipVo(newequip))
                    };
                    propreward.Add(new RewardVo
                    {
                        goodsType = (int)GoodsType.TYPE_EQUIP,
                        increases = listaso,
                    });
                }
            }
            FightSend(fight, isprop, reward, session.Player.User.id, propreward); //发送战斗协议

            (new Share.DaMing()).CheckDaMing(session.Player.User.id, (int)DaMingType.武将宅挑战);
            return(new ASObject(Common.GetInstance().NpcChallengeData((int)ResultType.SUCCESS, fight.isWin ? (int)FightResultType.WIN : (int)FightResultType.LOSE)));
        }