/// <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)); }
/// <summary>插入游艺园数据</summary> private void InsertGame(Int64 userid) { var game = new tg_game { user_id = userid }; tg_game.Insert(game); }
/// <summary>创建游艺园vo</summary> /// <param name="type">游戏类型</param> /// <param name="tggame">游艺园实体</param> /// <param name="userextend">拓展表实体</param> /// <param name="list">游艺园基表集合</param> /// <returns>游艺园vo</returns> public YouYiyuanVo CreateGame(int type, tg_game tggame, tg_user_extend userextend, IEnumerable <BaseYouYiYuan> list) { int count; var game = list.FirstOrDefault(m => m.type == type); if (game == null) { return(null); } var youvo = new YouYiyuanVo(); switch (type) { case (int)GameEnterType.辩驳游戏: { count = game.num - userextend.eloquence_count; youvo = EntityToVo.ToYouYiyuanVo(type, count, tggame.eloquence_max_pass); } break; case (int)GameEnterType.花月茶道: { count = game.num - userextend.tea_count; youvo = EntityToVo.ToYouYiyuanVo(type, count, tggame.tea_max_pass); } break; case (int)GameEnterType.老虎机: { count = game.num - userextend.calculate_count; youvo = EntityToVo.ToYouYiyuanVo(type, count, tggame.calculate_max_pass); } break; case (int)GameEnterType.猜宝游戏: { count = game.num - userextend.ninjutsu_count; youvo = EntityToVo.ToYouYiyuanVo(type, count, tggame.ninjutsu_max_pass); } break; case (int)GameEnterType.猎魂: { count = game.num - userextend.ball_count; youvo = EntityToVo.ToYouYiyuanVo(type, count, tggame.spirit_max_pass); } break; } return(youvo); }
/// <summary>返回前端结果</summary> /// <param name="game">游艺园实体</param> /// <param name="userextend">拓展表实体</param> /// <param name="list">游艺园基表集合</param> /// <returns></returns> private ASObject Result(tg_game game, tg_user_extend userextend, List <BaseYouYiYuan> list) { var volist = new List <YouYiyuanVo>(); var youvo = Common.GetInstance().CreateGame((int)GameEnterType.猎魂, game, userextend, list); if (youvo == null) { return(Error((int)ResultType.BASE_TABLE_ERROR)); } volist.Add(youvo); youvo = Common.GetInstance().CreateGame((int)GameEnterType.猜宝游戏, game, userextend, list); if (youvo == null) { return(Error((int)ResultType.BASE_TABLE_ERROR)); } volist.Add(youvo); youvo = Common.GetInstance().CreateGame((int)GameEnterType.老虎机, game, userextend, list); if (youvo == null) { return(Error((int)ResultType.BASE_TABLE_ERROR)); } volist.Add(youvo); youvo = Common.GetInstance().CreateGame((int)GameEnterType.花月茶道, game, userextend, list); if (youvo == null) { return(Error((int)ResultType.BASE_TABLE_ERROR)); } volist.Add(youvo); youvo = Common.GetInstance().CreateGame((int)GameEnterType.辩驳游戏, game, userextend, list); if (youvo == null) { return(Error((int)ResultType.BASE_TABLE_ERROR)); } volist.Add(youvo); return(new ASObject(Common.GetInstance().BuilData((int)ResultType.SUCCESS, volist, game.week_max_pass, userextend.game_finish_count, userextend.game_receive))); }