Exemplo n.º 1
0
        /// <summary>修改族徽</summary>
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
            try
            {
# if DEBUG
                XTrace.WriteLine("{0}:{1}", "FAMILY_UPDATE", "修改族徽");
#endif
                var cid            = Convert.ToInt32(data.FirstOrDefault(m => m.Key == "baseId").Value);//族徽id
                var member         = session.Player.Family;
                var family         = tg_family.GetEntityById(member.fid);
                var basefamilypost = Variable.BASE_FAMILYPOST.FirstOrDefault(m => m.post == member.degree);
                if (basefamilypost == null)
                {
                    return(Common.GetInstance().Error((int)ResultType.BASE_TABLE_ERROR));
                }
                if (basefamilypost.setBadge == (int)FamilyRightType.NORIGHT)
                {
                    return(Common.GetInstance().Error((int)ResultType.FAMILY_DROIT_LACK)); //没权利修改
                }
                family.clanbadge = cid;
                if (!tg_family.GetUpdate(family))
                {
                    return(Common.GetInstance().Error((int)ResultType.DATABASE_ERROR));
                }
                return(Common.GetInstance().SuccessResult(family, member));
            }
Exemplo n.º 2
0
        /// <summary>推送协议</summary>
        private void RoleHireEndSend(TGGSession session)
        {
            var data = new ASObject();
            var pv   = session.InitProtocol((int)ModuleNumber.ROLE, (int)RoleCommand.ROLE_HIRE_END, (int)ResponseType.TYPE_SUCCESS, data);

            session.SendData(pv);
        }
Exemplo n.º 3
0
        /// <summary>指令业务</summary>
        public void Service(ProtocolQueue model)
        {
#if DEBUG
            XTrace.WriteLine("commandNumber:{0}", model.Protocol.commandNumber);
#endif
            try
            {
                if (model.Session == null)
                {
                    return;
                }
                TGGSession session = model.Session;

                var key = string.Format("{0}_{1}_{2}", session.Player.User.id, model.Protocol.moduleNumber, model.Protocol.commandNumber);
                if (Variable.CCI.ContainsKey(key))
                {
                    session.SendData(session.InitProtocol(model, (int)ResponseType.TYPE_COMMAND_FAST, null));
                    return;
                }
                Variable.CCI.TryAdd(key, true);

                var data = CommandSwitch.GetInstance().Switch(model.Protocol.commandNumber, session, model.Protocol.data);
                var pv   = session.InitProtocol(model, (int)ResponseType.TYPE_SUCCESS, data);
                session.SendData(pv);
                RemoveCommand(key);
            }
            catch (Exception ex)
            {
                XTrace.WriteException(ex);
                if (model.Session != null)
                {
                    model.Session.CommandEnd(model);
                }
            }
        }
Exemplo n.º 4
0
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
            try
            {
#if DEBUG
                XTrace.WriteLine("{0}:{1}", "ROLE_TITLE_UNLOAD", "称号卸载");
#endif
                var rid = Convert.ToInt64(data.FirstOrDefault(m => m.Key == "roleId").Value.ToString());
                var tid = Convert.ToInt64(data.FirstOrDefault(m => m.Key == "titleId").Value.ToString());

                var role  = tg_role.GetEntityById(rid);
                var title = tg_role_title.GetTitleByTid(tid);
                if (role == null || title == null)
                {
                    return(Error((int)ResultType.DATABASE_ERROR));                                //验证称号信息
                }
                if (!CheckRole(role, tid) || !CheckTitle(title, rid))
                {
                    return(Error((int)ResultType.FRONT_DATA_ERROR));                                                  //验证武将 称号信息
                }
                if (title.title_load_state == (int)LoadStateType.UNLOAD)
                {
                    return(Error((int)ResultType.TITLE_UN_LOAD));                                                    //验证称号是否已经卸载
                }
                title = DeleteRole(title, rid);
                return(!tg_role_title.UpdateByTitle(title) ? Error((int)ResultType.DATABASE_ERROR) : UpdateRole(session, role, title.title_id, title));   //更新称号信息
            }
            catch (Exception ex)
            {
                XTrace.WriteException(ex);
                return(new ASObject());
            }
        }
Exemplo n.º 5
0
        /// <summary>指令处理</summary>
        public ASObject Switch(int moduleNumber, int commandNumber, TGGSession session, ASObject data)
        {
#if DEBUG
            var sw = Stopwatch.StartNew();
#endif
            if (commandNumber == (int)GuideCommand.REWARD)
            {
                if (!CommonHelper.IsOpen(session.Player.Role.Kind.role_level, (int)OpenModelType.大名令))
                {
                    return(CommonHelper.ErrorResult(ResultType.BASE_PLAYER_LEVEL_ERROR));
                }
            }

            var aso = new ASObject();
            //指令匹配
            switch (commandNumber)
            {
            case (int)GuideCommand.ENTER: { aso = ENTER.GetInstance().CommandStart(session, data); break; }

            case (int)GuideCommand.REWARD: { aso = REWARD.GetInstance().CommandStart(session, data); break; }

            default: break;
            }
#if DEBUG
            sw.Stop();
            XTrace.WriteLine("指令 {1} 运行总耗时:{0} 毫秒", sw.ElapsedMilliseconds.ToString(), GetType().Namespace);
#endif
            return(aso);
        }
Exemplo n.º 6
0
        /// <summary>家族模块</summary>
        private ASObject CS_FAMILY(int cmd, TGGSession session, ASObject data)
        {
            if (!CommonHelper.IsOpen(session.Player.Role.Kind.role_level, (int)OpenModelType.家族))
            {
                return(CommonHelper.ErrorResult(ResultType.BASE_PLAYER_LEVEL_ERROR));
            }
            var aso     = new ASObject();
            var blldata = data.FirstOrDefault(q => q.Key == "data").Value as ASObject;

            switch (cmd)
            {
            case (int)FamilyCommand.FAMILY_CREATE:
            {
                aso = (new FAMILY_CREATE()).Execute(session.Player.User.id, blldata); break;
            }

            case (int)FamilyCommand.FAMILY_DONATE:
            {
                aso = (new FAMILY_DONATE()).Execute(session.Player.User.id, blldata); break;
            }

            case (int)FamilyCommand.FAMILY_RECEIVE:
            {
                aso = (new FAMILY_RECEIVE()).Execute(session.Player.User.id, blldata); break;
            }
            }
            return(aso);
        }
Exemplo n.º 7
0
        /// <summary>进入游戏</summary>
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
#if DEBUG
            XTrace.WriteLine("{0}:{1}", "GAMES_JOIN", "进入游戏");
#endif
            var game       = tg_game.GetEntityByUserId(session.Player.User.id);
            var userextend = tg_user_extend.GetEntityByUserId(session.Player.User.id);
            var baselist   = Variable.BASE_YOUYIYUAN;
            if (game == null)
            {
                game = new tg_game
                {
                    user_id = session.Player.User.id
                };
                if (!tg_game.GetInsert(game))
                {
                    return(Error((int)ResultType.DATABASE_ERROR));
                }
            }
            if (!baselist.Any())
            {
                return(Error((int)ResultType.BASE_TABLE_ERROR));
            }
            return(Result(game, userextend, baselist));
        }
Exemplo n.º 8
0
        /// <summary> 得到战斗执行结果 </summary>
        /// <param name="session">session</param>
        /// <param name="rivalid">对手Id</param>
        /// <param name="type"> 枚举FightType中的类型 </param>
        /// <param name="hp">血量</param>
        /// <returns>返回NPC执行战斗结果</returns>
        private ResultType GetResult(TGGSession session, Int64 rivalid, int type, Int64 hp)
        {
            if (rivalid == 0)
            {
                return(ResultType.FIGHT_RIVAL_ID_ERROR);
            }
            var userid = session.Player.User.id;

            if (IsFight(userid))
            {
                return(ResultType.FIGHT_FIGHT_IN);                 //检验玩家是否在战斗计算中
            }
            RivalFightType      = Convert.ToInt32(type);
            session.Fight.Rival = rivalid;

            var result = FightMethod(session, hp);  //战斗执行结果

            if (result != ResultType.SUCCESS)
            {
                XTrace.WriteLine("---- 战斗发生{0}错误:{1}  己方用户Id:{2}  对手Id:{3} ----", result, (int)result, session.Player.User.id, rivalid);
                RemoveFightState(userid);   //修改玩家战斗状态
                return(result);
            }


            var iswin = vo.isWin ? FightResultType.WIN : FightResultType.LOSE;

            if (vo.isWin)
            {
                WeaponCount(session.Player.User.id); //调用武器使用统计
            }
            TaskResult(session, iswin);              //检索玩家任务
            RemoveFightState(userid);                //玩家移除战斗队列
            return(result);
        }
Exemplo n.º 9
0
        /// <summary>武将技能学习</summary>
        private ASObject RoleSkillLearn(TGGSession session, tg_role role, BaseFightSkill skill)
        {
            if (!string.IsNullOrEmpty(skill.studyCondition)) //验证所需前置技能信息
            {
                var item = SkillData(skill.studyCondition);  //获取前置技能集合信息
                foreach (var id in item)
                {
                    if (Convert.ToInt32(id) == 0)
                    {
                        continue;
                    }
                    var condition = tg_role_fight_skill.GetSkillByRidSkillId(role.id, Convert.ToInt32(id));
                    if (condition == null)
                    {
                        return(Result((int)ResultType.SKILL_CONDITION_LACK));                    //验证前置技能
                    }
                    if (condition.skill_level < skill.conditionLevel)
                    {
                        return(Result((int)ResultType.SKILL_CONDITION_LEVEL_LACK));                                              //验证前置技能等级
                    }
                }
            }
            if (role.role_level < skill.studyLevel)
            {
                return(Result((int)ResultType.BASE_ROLE_LEVEL_ERROR)); //验证武将等级
            }
            var power = RuleConvert.GetCostPower();                    //固定消耗体力

            if (!Common.GetInstance().PowerOperate(role, power))
            {
                return(Result((int)ResultType.BASE_ROLE_POWER_ERROR)); //验证体力
            }
            return(LearningSkill(session, skill, role, power));        //学习过程处理
        }
Exemplo n.º 10
0
        /// <summary>挑战结果处理</summary>
        private ASObject ChallengeResult(TGGSession session, string bprop, string bcount, FightVo fight, int cost)
        {
            var reward = new List <RewardVo>();
            var isprop = false;
            var userid = session.Player.User.id;

            if (fight.isWin)        //挑战胜利
            {
                var mainrole = session.Player.Role.Kind.CloneEntity();
                new Share.Role().PowerUpdateAndSend(mainrole, cost, userid);  //推送体力消耗
                var prop = WinReward(userid, bprop, bcount);
                isprop = prop != null;
                if (prop != null)
                {
                    Variable.TempProp.AddOrUpdate(userid, new List <tg_bag> {
                        prop
                    }, (m, n) => n);
                    var listaso = new List <ASObject> {
                        AMFConvert.ToASObject(EntityToVo.ToPropVo(prop))
                    };
                    reward.Add(new RewardVo
                    {
                        goodsType = (int)GoodsType.TYPE_PROP,
                        increases = listaso,
                    });
                }
            }
            FightSend(fight, isprop, reward, userid);    //发送战斗协议
            return(Result((int)ResultType.SUCCESS));
        }
Exemplo n.º 11
0
        /// <summary> 获取战斗Vo并的到Boss剩余血量和对Boss的伤害值 </summary>
        /// <param name="session">session</param>
        /// <param name="rivalid">对手Id</param>
        /// <param name="type"> 枚举FightType中的类型 </param>
        /// <param name="bosslife">boss血量</param>
        /// <param name="hurt">对boss的血量伤害值</param>
        public FightVo GetFightVo(TGGSession session, Int64 rivalid, int type, ref Int64 bosslife, ref Int64 hurt)
        {
            var result = GetResult(session, rivalid, type, bosslife);

            if (result != ResultType.SUCCESS)
            {
                return(null);
            }
            var fightrole  = list_role.FirstOrDefault(m => m != null && m.user_id != session.Player.User.id);
            var _fightrole = list_role_hp.FirstOrDefault(m => m != null && m.user_id != session.Player.User.id);

            if (fightrole == null || _fightrole == null)
            {
                return(null);
            }

            if (fightrole.hp <= 0)
            {
                hurt = _fightrole.hp;
            }
            else
            {
                hurt = _fightrole.hp - bosslife;
            }
            return(vo);
        }
Exemplo n.º 12
0
        //private static WAR_DEFENCE_PLAN_COST _objInstance;

        ///// <summary>WAR_DEFENCE_PLAN_COST单体模式</summary>
        //public static WAR_DEFENCE_PLAN_COST GetInstance()
        //{
        //    return _objInstance ?? (_objInstance = new WAR_DEFENCE_PLAN_COST());
        //}

        /// <summary> 修改防守方案消费 </summary>
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
            if (!data.ContainsKey("planId"))
            {
                return(null);
            }
            var   getplan  = data.FirstOrDefault(q => q.Key == "planId").Value.ToString();
            Int64 planid   = 0; Int64.TryParse(getplan, out planid);
            var   planinfo = tg_war_city_plan.GetEntityByPlanId(planid, session.Player.User.id);

            if (planinfo == null)
            {
                return
                    (CommonHelper.ErrorResult(ResultType.FRONT_DATA_ERROR));
            }

            //不是第一次修改
            if (planinfo.is_update == 1)
            {
                var city = session.Player.War.City.CloneEntity();
                if (!CheckFunds(city))
                {
                    return(CommonHelper.ErrorResult(ResultType.WAR_RES_FUNDS_ERROR));
                }
                session.Player.War.City = city;
            }
            //第一次修改
            planinfo.is_update = 1;
            planinfo.Update();

            return(BuildData(planinfo));
        }
Exemplo n.º 13
0
        /// <summary> 出征选择目标 </summary>
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
            if (!data.ContainsKey("id"))
            {
                return(null);
            }
            var id = Convert.ToInt32(data.FirstOrDefault(m => m.Key == "id").Value);    //id:[double] 据点基表id (要出征的据点)

            var userid = session.Player.User.id;

            session.Player.War.WarBattle = new WarEntity();
            var city = (new Share.War()).GetWarCity(id, userid);

            if (city == null)
            {
                return(CommonHelper.ErrorResult(ResultType.WAR_CITY_NOEXIST));
            }

            var olist = new List <int>(); //己方可操作的据点
            var rlist = new List <int>(); //敌方可操作的据点
            var time  = (DateTime.Now.Ticks - 621355968000000000) / 10000;

            var psList = tg_war_partner.GetEntityByUserId(userid);

            if (city.guard_time < time) //自己据点不在保护时间内
            {
                session.Player.War.WarBattle.rivalMap = (new Share.War()).GetBattleMaps(id, psList, userid, new List <int>(), ref rlist);
            }
            session.Player.War.WarBattle.Map                  = (new Share.War()).GetMaps(id, psList, userid, new List <int>(), ref olist);
            session.Player.War.WarBattle.warGoCityId          = id;
            session.Player.War.WarBattle.OperableCityIds      = olist;
            session.Player.War.WarBattle.OperableRivalCityIds = rlist;
            return(BulidData(olist, rlist));
        }
Exemplo n.º 14
0
        /// <summary>道具使用</summary>
        public ASObject CommandStart(int goodtype, TGGSession session, ASObject data)
        {
#if DEBUG
            XTrace.WriteLine(string.Format("{0}:{1}", "PROP_USE", "道具使用"));
#endif
            var id        = Convert.ToInt64(data.FirstOrDefault(q => q.Key == "id").Value.ToString()); //解析数据
            var propCount = Convert.ToInt32(data.FirstOrDefault(q => q.Key == "count").Value.ToString());
            var props     = tg_bag.GetEntityById(id);
            if (props == null)
            {
                return(new ASObject(Common.GetInstance().BuildData((int)ResultType.FRONT_DATA_ERROR)));
            }
            var base_prop = Common.GetInstance().GetBaseProp(props.base_id);                     //道具基表数据
            if (base_prop == null)
            {
                return(new ASObject(Common.GetInstance().BuildData((int)ResultType.BASE_TABLE_ERROR)));
            }
            if (base_prop.useMode != 1)
            {
                return(new ASObject(Common.GetInstance().BuildData((int)ResultType.PROP_UNUSED)));                                                     //玩家增加相关数据
            }
            if (base_prop.useLevel > session.Player.Role.Kind.role_level)
            {
                return(new ASObject(Common.GetInstance().BuildData((int)ResultType.BASE_PLAYER_LEVEL_ERROR)));
            }
            var temp = props.count - propCount;
            //道具资源足够使用
            if (temp < 0)
            {
                return(new ASObject(Common.GetInstance().BuildData((int)ResultType.SUCCESS)));
            }
            props.count = temp;
            var resule = (int)Common.GetInstance().BagToUse(session, base_prop.containsResources, propCount, props);
            return(new ASObject(Common.GetInstance().BuildData(resule)));
        }
Exemplo n.º 15
0
        /// <summary>装备模块</summary>
        private ASObject CS_EQUIP(int cmd, TGGSession session, ASObject data)
        {
            var aso     = new ASObject();
            var blldata = data.FirstOrDefault(q => q.Key == "data").Value as ASObject;

            switch (cmd)
            {
            case (int)EquipCommand.EQUIP_SPIRIT_LOCK:
            {
                aso = (new EQUIP_SPIRIT_LOCK()).Execute(session.Player.User.id, blldata);
                break;
            }

            case (int)EquipCommand.EQUIP_BUY:
            {
                aso = (new EQUIP_BUY()).Execute(session.Player.User.id, blldata);
                break;
            }

            case (int)EquipCommand.EQUIP_BAPTIZE_GOLD:
            {
                aso = (new EQUIP_BAPTIZE_GOLD()).Execute(session.Player.User.id, blldata);
                break;
            }
            }
            return(aso);
        }
Exemplo n.º 16
0
        /// <summary>身份俸禄领取指令</summary>
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
            var user   = session.Player.User.CloneEntity();
            var extend = session.Player.UserExtend;
            var role   = session.Player.Role.Kind;

            if (extend == null)
            {
                return(new ASObject(BuildData((int)ResultType.DATABASE_ERROR)));
            }
            if (extend.salary_state == (int)SalaryStateType.RECEIVE)
            {
                return(new ASObject(BuildData((int)ResultType.USER_RECEIVE)));
            }

            var baseident = Variable.BASE_IDENTITY.FirstOrDefault(m => m.vocation == user.player_vocation && m.id == role.role_identity);

            if (baseident == null)
            {
                return(new ASObject(BuildData((int)ResultType.BASE_TABLE_ERROR)));
            }

            user.coin           = tg_user.IsCoinMax(user.coin, baseident.salary);
            extend.salary_state = (int)SalaryStateType.RECEIVE;

            user.Update();
            extend.Update();

            session.Player.User       = user;
            session.Player.UserExtend = extend;

            (new Share.User()).REWARDS_API((int)GoodsType.TYPE_COIN, session.Player.User);
            return(new ASObject(BuildData((int)ResultType.SUCCESS, (int)SalaryStateType.RECEIVE)));
        }
Exemplo n.º 17
0
        /// <summary>职业评定模块</summary>
        private ASObject CS_TASK(int cmd, TGGSession session, ASObject data)
        {
            if (!CommonHelper.IsOpen(session.Player.Role.Kind.role_level, (int)OpenModelType.职业评定))
            {
                return(CommonHelper.ErrorResult(ResultType.BASE_PLAYER_LEVEL_ERROR));
            }

            var aso     = new ASObject();
            var blldata = data.FirstOrDefault(q => q.Key == "data").Value as ASObject;

            switch (cmd)
            {
            case (int)TaskCommand.TASK_VOCATION_BUY:
            {
                aso = (new TASK_VOCATION_BUY()).Execute(session.Player.User.id, blldata);
                break;
            }

            case (int)TaskCommand.TASK_VOCATION_REFRESH:
            {
                aso = (new TASK_VOCATION_REFRESH()).Execute(session.Player.User.id, blldata);
                break;
            }
            }
            return(aso);
        }
Exemplo n.º 18
0
        /// <summary>游艺园算术游戏开始</summary>
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
            try
            {
#if DEBUG
                XTrace.WriteLine("{0}:{1}", "GAMES_CALCULATE_START", "游艺园算术游戏开始");
#endif
                var list = data.FirstOrDefault(m => m.Key == "values").Value as object[];  //数字集合
                if (list == null)
                {
                    return(Result((int)ResultType.FRONT_DATA_ERROR));
                }

                var game   = session.Player.Game;
                var number = list.Select(Convert.ToInt32).ToList();

                if (game.GameType == (int)GameType.ACTIONGAME)     //闯关模式
                {
                    //验证剩余次数
                    var b = Common.GetInstance().CheckCount((int)GameEnterType.老虎机, session.Player.UserExtend);
                    if (!b)
                    {
                        return(Result((int)ResultType.GAME_COUNT_FAIL));
                    }
                    Common.GetInstance().CreateVariable(session.Player.User.id, (int)GameEnterType.老虎机);
                }

                return(ResultData(game, session.Player.User.id, number));
            }
            catch (Exception ex)
            {
                XTrace.WriteException(ex);
                return(new ASObject());
            }
        }
Exemplo n.º 19
0
        /// <summary>合战系统模块</summary>
        private ASObject CS_SKILL(int cmd, TGGSession session, ASObject data)
        {
            var aso     = new ASObject();
            var blldata = data.FirstOrDefault(q => q.Key == "data").Value as ASObject;

            switch (cmd)
            {
            case (int)SkillCommand.SKILL_WAR_ACCELERATE:
            {
                aso = (new SKILL_WAR_ACCELERATE()).Execute(session.Player.User.id, blldata); break;
            }

            case (int)SkillCommand.SKILL_WAR_STUDY:
            {
                aso = (new SKILL_WAR_STUDY()).Execute(session.Player.User.id, blldata); break;
            }

            case (int)SkillCommand.SKILL_WAR_UPGRADE:
            {
                aso = (new SKILL_WAR_UPGRADE()).Execute(session.Player.User.id, blldata); break;
            }

            case (int)SkillCommand.SKILL_WAR_WUCHANG:
            {
                aso = (new SKILL_WAR_WUCHANG()).Execute(session.Player.User.id, blldata); break;
            }
            }
            return(aso);
        }
Exemplo n.º 20
0
        /// <summary> 选择地图 </summary>
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
            var idss   = new List <int>();
            var cityId = session.Player.War.PlayerInCityId;

            if (cityId == 0)
            {
                return(CommonHelper.ErrorResult(ResultType.WAR_CITY_NOEXIST));
            }
            var time = (DateTime.Now.Ticks - 621355968000000000) / 10000;
            var b    = tg_war_carry.IsExistByCityId(cityId, time); //是否有空闲的运输队列

            if (!b)
            {
                return(CommonHelper.ErrorResult(ResultType.WAR_CITY_QUEUE_FULL));
            }

            var userid = session.Player.User.id;
            var psList = tg_war_partner.GetEntityByUserId(userid);
            var maps   = (new Share.War()).GetMaps(cityId, psList, userid, new List <int>(), ref idss);

            session.Player.War.Transport.OperableCityIds = idss;
            session.Player.War.Transport.Map             = maps;
            return(BuildData(idss));
        }
Exemplo n.º 21
0
        /// <summary>解除黑名单指令</summary>
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
#if DEBUG
            XTrace.WriteLine("{0}:{1}", "FRIEND_REMOVE_BLACKLIST", "解除黑名单指令");
#endif
            var id     = Convert.ToInt64(data.FirstOrDefault(q => q.Key == "id").Value);
            var entity = tg_friends.FindByid(id);
            if (entity == null)
            {
                return(new ASObject(Common.GetInstance().BuildData((int)ResultType.FRIEND_NO_DATA_ERROR)));
            }
#if DEBUG
            XTrace.WriteLine("id  {0} user_id {1} friend_id {2} friend_state {3}", entity.id, entity.user_id, entity.friend_id, entity.friend_state);
#endif
            try
            {
                var fid = entity.friend_id;
                entity.Delete();
                session.Player.BlackList.Remove(fid);
#if DEBUG
                XTrace.WriteLine("黑名单总数:{0}", session.Player.BlackList.Count);
#endif
            }
            catch { return(new ASObject(Common.GetInstance().BuildData((int)ResultType.DATABASE_ERROR))); }
            return(new ASObject(Common.GetInstance().BuildData((int)ResultType.SUCCESS)));
        }
Exemplo n.º 22
0
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
            try
            {
#if DEBUG
                XTrace.WriteLine("{0}:{1}", "ROLE_TITLE_SELECT", "称号选择");
#endif
                var btid   = Convert.ToInt32(data.FirstOrDefault(m => m.Key == "id").Value.ToString());
                var player = session.Player;

                var title = tg_role_title.GetTitleByUseridTid(player.User.id, btid);
                if (title == null)
                {
                    return(Error((int)ResultType.FRONT_DATA_ERROR));                //验证前端选择的称号信息
                }
                var btitle = Variable.BASE_ROLETITLE.FirstOrDefault(m => m.id == btid);
                if (btitle == null)
                {
                    return(Error((int)ResultType.BASE_TABLE_ERROR));                 //验证基表信息
                }
                var count = Count(player.UserExtend, btitle.methods);
                return(new ASObject(Common.GetInstance().BuildTitleSelect((int)ResultType.SUCCESS, count, title)));
            }
            catch (Exception ex)
            {
                XTrace.WriteException(ex);
                return(new ASObject());
            }
        }
Exemplo n.º 23
0
        /// <summary>处理武将信息</summary>
        private ASObject UpdateRole(TGGSession session, tg_role role, int basetid, tg_role_title title)
        {
            var mainrole = session.Player.Role.Kind.CloneEntity();
            var btitle   = Variable.BASE_ROLETITLE.FirstOrDefault(m => m.id == basetid);

            if (btitle == null)
            {
                return(Error((int)ResultType.BASE_TABLE_ERROR));                  //验证称号基表信息
            }
            if (string.IsNullOrEmpty(btitle.attAddition))
            {
                return(Error((int)ResultType.BASE_TABLE_ERROR)); //验证属性加成信息
            }
            role = RoleUpdateTitle(role, title.id);              //更新武将身上称号信息
            role = Common.GetInstance().UpdateRole(role, (int)RoleDatatype.ROLEDATA_LOSE, btitle.attAddition);
            if (!tg_role.UpdateByRole(role))
            {
                return(Error((int)ResultType.DATABASE_ERROR));
            }

            if (mainrole.id == role.id)
            {
                session.Player.Role.Kind = role;
            }
            Common.GetInstance().RoleUpdatePush(mainrole.user_id, role.id);            //推送武将属性更新

            return(new ASObject(Common.GetInstance().BuildLoadData((int)ResultType.SUCCESS, title)));
        }
Exemplo n.º 24
0
        /// <summary> 推送协议 </summary>
        /// <param name="session">session</param>
        /// <param name="model">战斗Vo</param>
        public void SendProtocol(TGGSession session, FightVo model)
        {
            var aso = new ASObject(FIGHT_PERSONAL_ENTER.GetInstance().BuildData(Convert.ToInt32(ResultType.SUCCESS), model));
            var pv  = session.InitProtocol((int)ModuleNumber.FIGHT, (int)FightCommand.FIGHT_PERSONAL_ENTER, (int)ResponseType.TYPE_SUCCESS, aso);

            session.SendData(pv);
        }
Exemplo n.º 25
0
        /// <summary>武将信息验证</summary>
        private ASObject CheckRole(TGGSession session, tg_role role, BaseRoleTitle btitle, tg_role_title title)
        {
            var mainrole = session.Player.Role.Kind.CloneEntity();
            var otid     = CheckOldTitle(role, btitle.methods, title.id);                                             //被替换称号id

            if (otid != 0)
            {
                role = CheckRoleInfo(role, (int)RoleDatatype.ROLEDATA_LOSE, otid);
            }                                                                                      //更新武将信息

            if (string.IsNullOrEmpty(btitle.attAddition))
            {
                return(Error((int)ResultType.BASE_TABLE_ERROR));                                         //验证加成信息
            }
            Common.GetInstance().UpdateRole(role, (int)RoleDatatype.ROLEDATA_ADD, btitle.attAddition);   //加成武将属性信息

            if (!tg_role.UpdateByRole(role))
            {
                return(Error((int)ResultType.DATABASE_ERROR));
            }
            if (mainrole.id == role.id)
            {
                session.Player.Role.Kind = role;                                       //装备武将为主角武将
            }
            Common.GetInstance().RoleUpdatePush(mainrole.user_id, role.id);            //推送武将信息
            if (!tg_role_title.UpdateByTitle(title))
            {
                return(Error((int)ResultType.DATABASE_ERROR));
            }

            return(new ASObject(Common.GetInstance().BuildLoadData((int)ResultType.SUCCESS, title)));
        }
Exemplo n.º 26
0
        /// <summary>
        /// 拉取印数据
        /// </summary>
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
            var user = session.Player.User;
            var list = tg_fight_yin.GetFindByUserId(user.id);

            return(new ASObject(BuildData((int)ResultType.SUCCESS, list)));
        }
Exemplo n.º 27
0
        /// <summary>处理每日完成度</summary>
        private bool CheckDay(TGGSession session, int gt)
        {
            var ex = session.Player.UserExtend.CloneEntity();

            switch (gt)
            {
            case (int)GameEnterType.辩驳游戏: ex.eloquence_count++; break;

            case (int)GameEnterType.老虎机: ex.calculate_count++; break;

            case (int)GameEnterType.花月茶道: ex.tea_count++; break;

            case (int)GameEnterType.猜宝游戏: ex.ninjutsu_count++; break;

            case (int)GameEnterType.猎魂: ex.ball_count++; break;
            }

            if (!tg_user_extend.GetUpdate(ex))
            {
                return(false);
            }
            session.Player.UserExtend = ex;

            Common.GetInstance().PushReward(ex.user_id);   //每日完成度统计
            return(true);
        }
Exemplo n.º 28
0
        /// <summary> 推送协议 </summary>
        /// <param name="session">session</param>
        /// <param name="id">战斗Vo</param>
        public void SendProtocol(TGGSession session, Int64 id)
        {
            var aso = new ASObject(BulidData(id));
            var pv  = session.InitProtocol((int)ModuleNumber.TASK, (int)TaskCommand.TASK_PUSH_DELETE, (int)ResponseType.TYPE_SUCCESS, aso);

            session.SendData(pv);
        }
Exemplo n.º 29
0
        //private static WAR_CITY_IN _objInstance;

        ///// <summary>WAR_CITY_IN单体模式</summary>
        //public static WAR_CITY_IN GetInstance()
        //{
        //    return _objInstance ?? (_objInstance = new WAR_CITY_IN());
        //}

        /// <summary> 进入据点 </summary>
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
            if (!data.ContainsKey("id"))
            {
                return(null);
            }
            var id     = Convert.ToInt32(data.FirstOrDefault(m => m.Key == "id").Value);//id:[double] 据点基表id
            var userid = session.Player.User.id;

            var temp = view_war_city.GetEntityByUserId(userid, id);

            if (temp == null)
            {
                return(CommonHelper.ErrorResult(ResultType.NO_DATA));
            }
            var city = BuildCity(temp);

            (new Share.War()).SaveWarCityAll(city);

            var roles = tg_war_role.GetPlayerWarRoleByUserId(userid, id, (int)WarRoleType.NPC); //获取备大将聚合
            var rs    = (new Share.War()).ToWarRoleInfoVos(roles);

            session.Player.War.PlayerInCityId = id;

            return(BulidData(temp, (int)WarCityCampType.OWN, rs));
        }
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
            try
            {
#if DEBUG
                XTrace.WriteLine("{0}:{1}", "TOWER_CHECKPOINT_NINJUTSU_GAME_RESULT", "忍术游戏结束");
#endif
                var position = Convert.ToInt32(data.FirstOrDefault(m => m.Key == "position").Value.ToString()); //玩家选中的盅位置
                var correct  = session.Player.Position.position;                                                //色子的正确位置
                var tower    = tg_duplicate_checkpoint.GetEntityByUserId(session.Player.User.id);

                if (tower == null || tower.state != (int)DuplicateClearanceType.CLEARANCE_FIGHTING)  //验证关卡信息及闯关状态
                {
                    return(Error((int)ResultType.DATABASE_ERROR));
                }

                var clearance = Variable.BASE_TOWERGAME.FirstOrDefault(m => m.pass == tower.site && m.type == (int)SamllGameType.NINJUTSU);
                if (clearance == null)
                {
                    return(Error((int)ResultType.BASE_TABLE_ERROR));
                }

                var nxing = clearance.standardHp;       //过关需要星星
                return(position == correct?Success(session, tower, nxing, (int)FightResultType.WIN) :
                           UnSuccess(session, tower, nxing, (int)FightResultType.LOSE));
            }
            catch (Exception ex)
            {
                XTrace.WriteException(ex);
                return(new ASObject());
            }
        }