/// <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)); }
/// <summary>仓库物品信息集合</summary> private List <ASObject> ToWarGoods(IEnumerable <GlobalWarGoods> list) { var war_goods = new List <ASObject>(); war_goods.AddRange(list.Select(item => AMFConvert.ToASObject(EntityToVo.ToWarGoodsVo(item)))); return(war_goods); }
/// <summary> /// 组装奖励数据 /// </summary> private List <RewardVo> BuildReward(List <tg_bag> props) { var reward = new List <RewardVo>(); var listequip = props.FindAll(q => q.type == (int)GoodsType.TYPE_EQUIP).ToList(); var listprops = props.FindAll(q => q.type == (int)GoodsType.TYPE_PROP).ToList(); if (listequip.Any()) { var listaso = listequip.Select(item => AMFConvert.ToASObject(EntityToVo.ToEquipVo(item))).ToList(); reward.Add(new RewardVo { goodsType = (int)GoodsType.TYPE_EQUIP, increases = listaso, }); } if (!listprops.Any()) { return(reward); } var listaso1 = listprops.Select(item => AMFConvert.ToASObject(EntityToVo.ToPropVo(item))).ToList(); reward.Add(new RewardVo { goodsType = (int)GoodsType.TYPE_PROP, increases = listaso1, }); return(reward); }
/// <summary>仓库物品信息集合</summary> private List <ASObject> TolistRoles(IEnumerable <view_war_role> depots) { var war_role = new List <ASObject>(); war_role.AddRange(depots.Select(item => AMFConvert.ToASObject(EntityToVo.ToViewWarRoleVo(item)))); return(war_role); }
/// <summary>家族列表集合</summary> public List <ASObject> ConvertListASObject(Int64 userid, List <tg_family> familylist, List <view_user_role_family_member> chiefmember) { var list_aso = new List <ASObject>(); var list = tg_family_apply.GetEntityByUserId(userid); if (list.Count > 0) { foreach (var item in familylist) { var apply = list.FirstOrDefault(m => m.fid == item.id); var chief = chiefmember.FirstOrDefault(m => m.userid == item.userid); if (apply != null) { var model = EntityToVo.ToFamilyListVo(item, apply.state, chief.player_name); list_aso.Add(AMFConvert.ToASObject(model)); } else { var model = EntityToVo.ToFamilyListVo(item, 0, chief.player_name); list_aso.Add(AMFConvert.ToASObject(model)); } } } else { foreach (var item in familylist) { var chief = chiefmember.FirstOrDefault(m => m.userid == item.userid); var model = EntityToVo.ToFamilyListVo(item, 0, chief.player_name); list_aso.Add(AMFConvert.ToASObject(model)); } } return(list_aso); }
/// <summary>构建奖励更新数据</summary> /// <param name="list">物品类型集合</param> /// <param name="model">玩家</param> /// <param name="increases">新增物品对象集合</param> /// <param name="decreases">更新物品对象集合</param> /// <param name="delete">删除物品ID集合</param> private ASObject RewardsASObject(IEnumerable <int> list, tg_user model, List <ASObject> increases, List <ASObject> decreases, List <double> delete) { var dic = new Dictionary <string, object>(); var aso_list = list.Select(item => AMFConvert.ToASObject(BulidReward(item, model, increases, decreases, delete))).ToList(); dic.Add("rewards", aso_list); return(new ASObject(dic)); }
private void UserUpdate(TGGSession session) { var data = new ASObject(new Dictionary <string, object> { { "result", (int)ResultType.SUCCESS }, { "userInfoVo", AMFConvert.ToASObject(EntityToVo.ToUserInfoVo(session.Player)) } }); Push(session, data, (int)ModuleNumber.USER, (int)UserCommand.USER_LOGIN); }
public Dictionary <String, Object> BuildDataUser(int result, Player player) { var dic = new Dictionary <string, object> { { "result", result }, { "userInfoVo", player != null?AMFConvert.ToASObject(EntityToVo.ToUserInfoVo(player)) : null }, }; return(dic); }
/// <summary>数据组装</summary> public Dictionary <String, Object> BuildData(int result, dynamic props) { var dic = new Dictionary <string, object> { { "result", result }, { "prop", props != null?AMFConvert.ToASObject(EntityToVo.ToPropVo(props)) : null } }; return(dic); }
public Dictionary <String, Object> BuildData(int result, view_user_role_friend model) { var dic = new Dictionary <string, object> { { "result", result }, { "friend", AMFConvert.ToASObject(EntityToVo.ToFriendVo(model)) } }; return(dic); }
/// <summary>转换为ListAsObject</summary> public List <ASObject> ListAsObject(List <tg_role_title> listtitles) { if (!listtitles.Any()) { return(null); } var list = listtitles.Select(item => AMFConvert.ToASObject(EntityToVo.ToTitleVo(item))).ToList(); return(list); }
/// <summary>执行指令</summary> public override void ExecuteCommand(TGGSession session, BinaryRequestInfo requestInfo) { #if DEBUG //XTrace.WriteLine("接收数据:{0}", BitConverter.ToString(requestInfo.Body, 0, requestInfo.Body.Length)); session.Logger.Debug(string.Format("接收数据:{0}", BitConverter.ToString(requestInfo.Body, 0, requestInfo.Body.Length))); #endif try { var sobj = new SocketObjectData { session = session, requestInfo = requestInfo }; var _temp = new CancellationTokenSource(); new Task(m => { var model = m as SocketObjectData; if (model == null) { return; } if (model.requestInfo.Body.Length <= 0) { return; } var stream = new MemoryStream(model.requestInfo.Body, 0, model.requestInfo.Body.Length); var byteArray = new ByteArray(stream); var dy = byteArray.ReadObject(); var retype = dy.GetType().Name; //判断接收数据类型 ASObject obj; switch (retype) { case "ASObject": { obj = (ASObject)dy; break; } case "ProtocolVo": { obj = AMFConvert.ToASObject(dy); break; } default: { return; } } var pv = AutoParseAsObject <ProtocolVo> .Parse(obj); if (pv.className != "ProtocolVo") { return; } ModuleQueue.GetInstance().LoadQueue(pv.moduleNumber, pv, model.session); #if DEBUG XTrace.WriteLine("Socket Handle接收数据Number:{0} - {1}", pv.moduleNumber, pv.commandNumber); #endif _temp.Cancel(); }, sobj, _temp.Token).Start(); } catch (Exception ex) { XTrace.WriteException(ex); } }
/// <summary>返回注册</summary> public Dictionary <String, Object> BuildData(int result, Player player, Int64 time) { var dic = new Dictionary <string, object> { { "result", result }, { "userInfoVo", player != null?AMFConvert.ToASObject(EntityToVo.ToUserInfoVo(player)) : null }, { "influence", tg_user.FindCampInfluence() } }; return(dic); }
/// <summary>将dynamic对象转换成ASObject对象</summary> public List <ASObject> ConvertListASObject(dynamic list) { var list_aso = new List <ASObject>(); foreach (var item in list) { dynamic model = EntityToVo.ToScenePlayerVo(item); list_aso.Add(AMFConvert.ToASObject(model)); } return(list_aso); }
/// <summary>构建奖励更新数据</summary> /// <param name="goodsType">物品类型</param> /// <param name="model">玩家</param> /// <param name="increases">新增物品对象集合</param> /// <param name="decreases">更新物品对象集合</param> /// <param name="delete">删除物品ID集合</param> private ASObject RewardsASObject(int goodsType, tg_user model, List <ASObject> increases, List <ASObject> decreases, List <double> delete) { var dic = new Dictionary <string, object>(); var aso_list = new List <ASObject> { AMFConvert.ToASObject(BulidReward(goodsType, model, increases, decreases, delete)) }; dic.Add("rewards", aso_list); return(new ASObject(dic)); }
/// <summary> /// 组装防守地形数据 /// </summary> /// <param name="planid"></param> /// <returns></returns> public List <ASObject> ConverDefenseAreas(Int64 planid) { var area = tg_war_plan_area.GetEntityByPlanId(planid); if (!area.Any()) { return(null); } area = area.Where(q => q.type != (int)AreaType.陷阱).ToList(); return(area.Select(set => AMFConvert.ToASObject(EntityToVo.ToAreaSetVo(set))).ToList()); }
public List <ASObject> ConvertListASObject(dynamic list_equip) { var list_aso = new List <ASObject>(); foreach (var item in list_equip) { var model = EntityToVo.ToEquipVo(item); list_aso.Add(AMFConvert.ToASObject(model)); } return(list_aso); }
/// <summary>数据组装</summary> public Dictionary <String, Object> BuildData(Player player, object module, object cmd, object data) { var dic = new Dictionary <string, object> { { "userinfo", AMFConvert.ToASObject(EntityToVo.ToUserInfoVo(player)) }, { "module", module }, { "cmd", cmd }, { "data", data } }; return(dic); }
/// <summary>List集合转换ASObject</summary> public List <ASObject> ConvertListAsObject(List <view_messages> list) { #if DEBUG XTrace.WriteLine("集合大小 {0}", list.Count); #endif var list_aso = new List <ASObject>(); foreach (var item in list) { list_aso.Add(AMFConvert.ToASObject(EntityToVo.ToMessagesVo(item))); } return(list_aso); }
/// <summary> /// 充值 /// </summary> internal Int32 Recharge(Int64 user_id, Int32 amount) { var s = new MvcSocket(IP, Port); var str = string.Format("{0}|{1}", user_id, amount); var dic = new Dictionary <string, object>() { { "key", "" }, { "data", CryptoHelper.Encrypt(str, "") }, }; XTrace.WriteLine("充值:{0}", str); var data = Build(new ASObject(dic)); s.Send(data); var result = s.Receive(); s.Dispose(); //解析返回结果 var len = result.Length - 8; var da = new byte[len]; Array.Copy(result, 8, da, 0, len); var bytea = new ByteArray(da); var dy = bytea.ReadObject(); var retype = dy.GetType().Name; //XTrace.WriteLine("retype:{0}", retype); ASObject obj; switch (retype) //判断接收数据类型 { case "ASObject": { obj = (ASObject)dy; break; } case "ProtocolVo": { obj = AMFConvert.ToASObject(dy); break; } default: { return((int)ApiType.FAIL); } } var pv = AutoParseAsObject <ProtocolVo> .Parse(obj); //XTrace.WriteLine("pv.className:{0}", pv.className); if (pv.className != "ProtocolVo") { return((int)ApiType.FAIL); } var r = pv.data; // 解析返回结果数据 var _state = Convert.ToInt32(r.FirstOrDefault(q => q.Key == "state").Value); return(_state); }
/// <summary>组装奖励信息</summary> private List <RewardVo> BuildReward(tg_bag equip) { var aso = new List <ASObject>(); { aso.Add(AMFConvert.ToASObject(EntityToVo.ToEquipVo(equip))); } var reward = new List <RewardVo>(); var vo = new RewardVo() { goodsType = (int)GoodsType.TYPE_EQUIP, increases = aso, }; reward.Add(vo); return(reward); }
/// <summary> /// 停止公告 /// </summary> internal Int32 StopNotice(Int64 nid) { #if DEBUG IP = "192.168.1.111"; Port = 10086; #endif var s = new MvcSocket(IP, Port); var str = string.Format("{0}", nid); var dic = new Dictionary <string, object>() { { "key", "" }, { "data", CryptoHelper.Encrypt(str, "") }, }; var data = Build(new ASObject(dic)); s.Send(data); var result = s.Receive(); s.Dispose(); //解析返回结果 var len = result.Length - 8; var da = new byte[len]; Array.Copy(result, 8, da, 0, len); var bytea = new ByteArray(da); var dy = bytea.ReadObject(); var retype = dy.GetType().Name; ASObject obj; switch (retype) //判断接收数据类型 { case "ASObject": { obj = (ASObject)dy; break; } case "ProtocolVo": { obj = AMFConvert.ToASObject(dy); break; } default: { return((int)ApiType.FAIL); } } var pv = AutoParseAsObject <ProtocolVo> .Parse(obj); if (pv.className != "ProtocolVo") { return((int)ApiType.FAIL); } var r = pv.data; // 解析返回结果数据 var state = Convert.ToInt32(r.FirstOrDefault(q => q.Key == "state").Value); return(state); }
/// <summary>将dynamic对象转换成ASObject对象</summary> public List <ASObject> ConvertListASObject(dynamic list, string classname) { var list_aso = new List <ASObject>(); foreach (var item in list) { dynamic model; switch (classname) { case "ScenePlayer": model = EntityToVo.ToScenePlayerVo(item); break; default: model = null; break; } list_aso.Add(AMFConvert.ToASObject(model)); } return(list_aso); }
public ASObject CommandStart(TGGSession session, ASObject data) { try { #if DEBUG XTrace.WriteLine("{0}:{1}", "QUERY_PLAYER_ROLE", "查看玩家信息"); #endif var playerId = Convert.ToInt64(data.FirstOrDefault(m => m.Key == "userId").Value.ToString()); var user = tg_user.GetUsersById(playerId); if (user == null) { return(Result((int)ResultType.ROLE_QUERY_NOPLAYER)); //验证是否存在该玩家信息 } if (playerId == session.Player.User.id) { return(Result((int)ResultType.ROLE_QUERY_MYERROR)); //验证要查看的玩家是否为当前玩家本身 } var lists = tg_role.GetFindAllByUserId(playerId); if (!lists.Any()) { return(Result((int)ResultType.ROLE_QUERY_NOINFO)); //验证要查看玩家的武将信息 } var ids = lists.Select(m => m.id).ToList(); //var listview = view_role.GetRoleById(ids); var roles = (new Share.Role()).GetRoleByIds(ids); if (!roles.Any()) { return(Result((int)ResultType.ROLE_QUERY_VIEWERROR)); //验证武将视图信息 } var listroles = roles.Select(item => AMFConvert.ToASObject(ConvertToVo(item))).ToList(); var equips = tg_bag.GetEquipByUserIdStateType(playerId, (int)LoadStateType.LOAD, (int)GoodsType.TYPE_EQUIP); //查询玩家武将穿戴的装备 var listequips = equips.Select(item => AMFConvert.ToASObject(EntityToVo.ToEquipVo(item))).ToList(); return(new ASObject(BuildInfo((int)ResultType.SUCCESS, user.player_name, user.player_camp, user.player_influence, listroles, listequips))); } catch (Exception ex) { XTrace.WriteException(ex); return(new ASObject()); } }
public ASObject CommandStart(TGGSession session, ASObject data) { #if DEBUG XTrace.WriteLine("{0}:{1}", "ENTER", "进入页面"); #endif var player = session.Player.CloneEntity(); var number = Variable.BASE_DAMING; if (!number.Any()) { return(Error((int)ResultType.BASE_TABLE_ERROR)); } if (!player.DamingLog.Any() || player.DamingLog.Count != number.Count) { return(Error((int)ResultType.DAMING_INFO_ERROR)); //验证大名令任务数据 } var listdata = player.DamingLog.Select(item => AMFConvert.ToASObject(EntityToVo.ToDaMingLingVo(item))).ToList(); return(new ASObject(BuildData((int)ResultType.SUCCESS, listdata))); }
/// <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))); }
/// <summary>集合转换ASObject集合</summary> public List <ASObject> ConvertListASObject(dynamic list, string classname) { var list_aso = new List <ASObject>(); foreach (var item in list) { dynamic model; switch (classname) { case "Props": model = EntityToVo.ToPropVo(item); break; case "Equip": model = EntityToVo.ToEquipVo(item); break; case "Fusion": model = EntityToVo.ToFusionPropVo(item); break; default: model = null; break; } list_aso.Add(AMFConvert.ToASObject(model)); } return(list_aso); }
public ASObject CommandStart(TGGSession session, ASObject data) { try { #if DEBUG XTrace.WriteLine("{0}:{1}", "ROLE_JOIN", "加载武将数据"); #endif var player = session.Player; var list = tg_role.GetFindAllByUserId(player.User.id); //获取该用户当前所有武将信息 var listroles = new List <ASObject>(); var ids = list.Select(m => m.id).ToList(); //var roles = view_role.GetRoleById(ids); //所有武将视图信息 var roles = (new Share.Role()).GetRoleByIds(ids); if (roles.Count == 0) { return(new ASObject(Common.GetInstance().RoleLoadData((int)ResultType.DATABASE_ERROR, null))); } var listtrainrs = tg_train_role.GetEntityByIds(ids); foreach (var item in roles) { var trainrole = listtrainrs.FirstOrDefault(m => m.rid == item.Kind.id); var genre = (new Share.Role()).LearnGenreOrNinja(item.FightSkill, item.Kind.role_genre, item.Kind.role_ninja); //开启流派 listroles.Add(trainrole != null ? AMFConvert.ToASObject((new Share.Role()).BuildRole(item, genre, trainrole)) : AMFConvert.ToASObject((new Share.Role()).BuildRole(item, genre, null))); } return(new ASObject(Common.GetInstance().RoleJoinData((int)ResultType.SUCCESS, player.UserExtend.train_bar, listroles, EntityToVo.ToRoleHomeHireVo(player.UserExtend), player.UserExtend.power_buy_count))); } catch (Exception ex) { XTrace.WriteException(ex); return(new ASObject()); } }
private List <ASObject> ConverDefenseRoles(Int64 planid) { var roles = tg_war_city_defense.GetListByPlanId(planid); return(!roles.Any() ? null : roles.Select(set => AMFConvert.ToASObject(EntityToVo.ToWarDefenceRoleVo(set))).ToList()); }
private List <ASObject> ConverDefenseAreas(Int64 planid) { var area = tg_war_plan_area.GetEntityByPlanId(planid); return(!area.Any() ? null : area.Select(set => AMFConvert.ToASObject(EntityToVo.ToAreaSetVo(set))).ToList()); }