Esempio n. 1
0
        /// <summary>背包日志</summary>
        public void BagLog(tg_bag prop, LogType type, int mn, int cn, string cnname, int count, int getcoin = 0)
        {
            try
            {
                var temp_prop = prop.CloneEntity();

                log.BagInsertLog(temp_prop, mn, cn, getcoin); //记录日志
                string s   = GetString(temp_prop);
                var    obj = new DataObject(temp_prop.type, temp_prop.count, temp_prop.count - count, count, s);
                WriteLog(temp_prop.user_id, (int)type, mn, cn, cnname, obj);
            }
            catch (Exception ex) { XTrace.WriteException(ex); }
        }
Esempio n. 2
0
        public ASObject Execute(Int64 userid, ASObject data)
        {
            try
            {
# if DEBUG
                XTrace.WriteLine("{0}:{1}", "EQUIP_BUY", "装备买");
#endif
                var session = Variable.OnlinePlayer[userid] as TGGSession;
                if (session == null)
                {
                    return(CommonHelper.ErrorResult((int)ResultType.FAIL));
                }
                var baseid = Convert.ToInt32(data.FirstOrDefault(q => q.Key == "id").Value);
                var count  = Convert.ToInt32(data.FirstOrDefault(q => q.Key == "count").Value);

                if (count <= 0 || baseid == 0)
                {
                    return(ResultData((int)ResultType.FRONT_DATA_ERROR));                          //前端数据不对
                }
                var baseinfo = Variable.BASE_EQUIP.FirstOrDefault(q => q.id == baseid);
                if (baseinfo == null || baseinfo.grade != 1)
                {
                    return(ResultData((int)ResultType.BASE_TABLE_ERROR));//该装备不能购买
                }
                var user  = session.Player.User.CloneEntity();
                var price = baseinfo.buyPrice;
                if (!CheckMoney(session, price * count)) //金钱验证
                {
                    return(ResultData((int)ResultType.BASE_PLAYER_COIN_ERROR));
                }
                if (!CheckBox(session, count)) //格子数验证
                {
                    return(ResultData((int)ResultType.EQUIP_BAG_FULL));
                }
                var equiplist = new List <tg_bag>();
                var newequip  = new tg_bag();
                GetEntity(baseinfo, session.Player.User.id, newequip); //基本属性设置
                AddAtt(newequip, baseinfo);                            //根据装备类型设置属性
                for (var i = 0; i < count; i++)
                {
                    equiplist.Add(newequip.CloneEntity());
                }

                CreateLog(user.id, user.coin, baseid, count, price * count);

                var list = tg_bag.GetSaveList(equiplist); //批量插入
                SendReward(list, session);
                return(ResultData((int)ResultType.SUCCESS));
            }