Beispiel #1
0
        /// <summary>摇出来的数字不相同</summary>
        public ASObject UnSuccess(tg_duplicate_checkpoint tower, int nxing, int result)
        {
            tower.calculate_star = Common.GetInstance().StarsUpdate(tower.calculate_star, result); //更新星星位置及数量
            if (Common.GetInstance().StarsCount(tower.calculate_star, result) >= nxing)            //判断是否结束爬塔
            {
                //通关失败
                tower.state = (int)DuplicateClearanceType.CLEARANCE_FAIL;
                if (!tg_duplicate_checkpoint.UpdateSite(tower))
                {
                    return(Error((int)ResultType.DATABASE_ERROR));
                }

                TOWER_CHECKPOINT_DARE_PUSH.GetInstance().CommandStart(tower.user_id, tower.site, (int)DuplicateClearanceType.CLEARANCE_FAIL);
                return(new ASObject(Common.GetInstance().CalculateBuildData((int)ResultType.SUCCESS, tower.calculate_star)));
            }
            //继续游戏
            return(!tg_duplicate_checkpoint.UpdateSite(tower) ? Error((int)ResultType.DATABASE_ERROR) :
                   new ASObject(Common.GetInstance().CalculateBuildData((int)ResultType.SUCCESS, tower.calculate_star)));
        }
Beispiel #2
0
        /// <summary>辩才小游戏</summary>
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
#if DEBUG
            XTrace.WriteLine("{0}:{1}", "TOWER_CHECKPOINT_ELOQUENCE_GAME", "辩才小游戏");
#endif
            var type       = Convert.ToInt32(data.FirstOrDefault(m => m.Key == "type").Value);
            var checkpoint = tg_duplicate_checkpoint.GetEntityByUserId(session.Player.User.id);
            if (checkpoint == null)
            {
                return(Error((int)ResultType.DATABASE_ERROR));
            }
            if (!CheckType(type))
            {
                return(Error((int)ResultType.FRONT_DATA_ERROR));
            }

            if (checkpoint.user_blood == 0 || checkpoint.npc_blood == 0 ||
                checkpoint.state == (int)DuplicateClearanceType.CLEARANCE_FAIL)
            {
                return(Error((int)ResultType.CHALLENGE_FAIL));
            }
            var npccard = CardRandom();

            var base_tower = Variable.BASE_TOWERELOQUENCE.FirstOrDefault(m => m.myCard == type && m.enemyCard == npccard);
            var base_pass  = Variable.BASE_TOWERPASS.FirstOrDefault(m => m.pass == checkpoint.site);
            if (base_tower == null || base_pass == null)
            {
                return(Error((int)ResultType.BASE_TABLE_ERROR));
            }

            checkpoint = GameProcess(checkpoint, base_tower);
            if (!tg_duplicate_checkpoint.UpdateSite(checkpoint))
            {
                return(Error((int)ResultType.DATABASE_ERROR));
            }
            var user = session.Player.User.CloneEntity();
            if (!CheckResult(user, Convert.ToInt32(base_pass.passAward), ref checkpoint))
            {
                TOWER_CHECKPOINT_DARE_PUSH.GetInstance().CommandStart(checkpoint.user_id, checkpoint.site, checkpoint.state);
            }
            return(new ASObject(Common.GetInstance().BulidData((int)ResultType.SUCCESS, npccard, checkpoint.user_blood, checkpoint.npc_blood)));
        }
        /// <summary>根据结果处理相应信息</summary>
        private bool AcquireReward(tg_duplicate_checkpoint tower, string reward, int type)
        {
            tower.state = type;
            if (!tg_duplicate_checkpoint.UpdateSite(tower))
            {
                return(false);
            }
            TOWER_CHECKPOINT_DARE_PUSH.GetInstance().CommandStart(tower.user_id, tower.site, type);
            if (tower.state != (int)DuplicateClearanceType.CLEARANCE_SUCCESS)
            {
                return(true);
            }

            if (!Variable.OnlinePlayer.ContainsKey(tower.user_id))
            {
                return(false);                                                           //玩家在线则推送奖励
            }
            var session = Variable.OnlinePlayer[tower.user_id] as TGGSession;

            if (session == null)
            {
                return(false);
            }

            var user = session.Player.User.CloneEntity();
            var fame = user.fame;

            user.fame = tg_user.IsFameMax(user.fame, Convert.ToInt32(reward));
            user.Update();
            session.Player.User = user;
            (new Share.User()).REWARDS_API((int)GoodsType.TYPE_FAME, user);

            //记录获得魂日志
            var logdata = string.Format("{0}_{1}_{2}_{3}", "Fame", fame, Convert.ToInt32(reward), user.fame);

            (new Share.Log()).WriteLog(user.id, (int)LogType.Get, (int)ModuleNumber.DUPLICATE, (int)DuplicateCommand.TOWER_CHECKPOINT_TEA_GAME_FLOP, logdata);

            return(true);
        }
        /// <summary>当局成功判断</summary>
        public ASObject Success(TGGSession session, tg_duplicate_checkpoint tower, int nxing, int result)
        {
            var position = RNG.Next(0, 3);     //下一局随机位置

            session.Player.Position.position = position;

            tower.ninjutsu_star = Common.GetInstance().StarsUpdate(tower.ninjutsu_star, result);
            if (Common.GetInstance().StarsCount(tower.ninjutsu_star, result) >= nxing)        //通关成功
            {
                tower.state = (int)DuplicateClearanceType.CLEARANCE_SUCCESS;
                if (!tg_duplicate_checkpoint.UpdateSite(tower))
                {
                    return(Error((int)ResultType.DATABASE_ERROR));
                }
                TOWER_CHECKPOINT_DARE_PUSH.GetInstance().CommandStart(session.Player.User.id, tower.site, (int)DuplicateClearanceType.CLEARANCE_SUCCESS); //推送成功结果

                var reward = Variable.BASE_TOWERPASS.FirstOrDefault(m => m.pass == tower.site);                                                           //领取声望奖励
                if (reward == null || string.IsNullOrEmpty(reward.passAward))
                {
                    return(Error((int)ResultType.BASE_TABLE_ERROR));
                }
                var user = session.Player.User.CloneEntity();
                var fame = user.fame;
                user.fame = tg_user.IsFameMax(user.fame, Convert.ToInt32(reward.passAward));
                user.Update();
                session.Player.User = user;
                (new Share.User()).REWARDS_API((int)GoodsType.TYPE_FAME, user);   //推送声望奖励

                //记录获得魂日志
                var logdata = string.Format("{0}_{1}_{2}_{3}", "Fame", fame, Convert.ToInt32(reward.passAward), user.fame);
                (new Share.Log()).WriteLog(user.id, (int)LogType.Get, (int)ModuleNumber.DUPLICATE, (int)DuplicateCommand.TOWER_CHECKPOINT_NINJUTSU_GAME_RESULT, logdata);

                return(new ASObject(Common.GetInstance().NinjutsuBuildData((int)ResultType.SUCCESS, position, tower.ninjutsu_star)));
            }
            //继续游戏
            return(!tg_duplicate_checkpoint.UpdateSite(tower) ? Error((int)ResultType.DATABASE_ERROR) :
                   new ASObject(Common.GetInstance().NinjutsuBuildData((int)ResultType.SUCCESS, position, tower.ninjutsu_star)));
        }
        /// <summary>当局判断失败</summary>
        public ASObject UnSuccess(TGGSession session, tg_duplicate_checkpoint tower, int nxing, int result)
        {
            var position = RNG.Next(0, 3);     //下一局随机位置

            session.Player.Position.position = position;

            tower.ninjutsu_star = Common.GetInstance().StarsUpdate(tower.ninjutsu_star, result);
            if (Common.GetInstance().StarsCount(tower.ninjutsu_star, result) >= nxing)        //判断是否结束爬塔
            {
                //通关失败
                tower.state = (int)DuplicateClearanceType.CLEARANCE_FAIL;
                if (!tg_duplicate_checkpoint.UpdateSite(tower))
                {
                    return(Error((int)ResultType.DATABASE_ERROR));
                }
                TOWER_CHECKPOINT_DARE_PUSH.GetInstance().CommandStart(tower.user_id, tower.site, (int)DuplicateClearanceType.CLEARANCE_FAIL);       //推送失败结果

                return(new ASObject(Common.GetInstance().NinjutsuBuildData((int)ResultType.SUCCESS, position, tower.ninjutsu_star)));
            }
            //继续游戏
            return(!tg_duplicate_checkpoint.UpdateSite(tower) ? Error((int)ResultType.DATABASE_ERROR) :
                   new ASObject(Common.GetInstance().NinjutsuBuildData((int)ResultType.SUCCESS, position, tower.ninjutsu_star)));
        }
 /// <summary>TOWER_CHECKPOINT_DARE_PUSH单体模式</summary>
 public static TOWER_CHECKPOINT_DARE_PUSH GetInstance()
 {
     return(ObjInstance ?? (ObjInstance = new TOWER_CHECKPOINT_DARE_PUSH()));
 }
Beispiel #7
0
        /// <summary>挑战怪物</summary>
        public ASObject CommandStart(TGGSession session, ASObject data)
        {
#if DEBUG
            XTrace.WriteLine("{0}:{1}", "TOWER_CHECKPOINT_DARE", "挑战怪物");
#endif
            var             npcid      = Convert.ToInt32(data.FirstOrDefault(m => m.Key == "npcid").Value);
            var             type       = Convert.ToInt32(data.FirstOrDefault(m => m.Key == "type").Value);
            var             user       = session.Player.User.CloneEntity();
            var             checkpoint = tg_duplicate_checkpoint.GetEntityByUserId(session.Player.User.id);
            result = 0; int fightresult = 0;
            if (npcid == 0 || checkpoint == null)
            {
                return(Error((int)ResultType.DATABASE_ERROR));
            }
            var towerpass = Variable.BASE_TOWERPASS.FirstOrDefault(m => m.pass == checkpoint.site);
            if (towerpass == null)
            {
                return(Error((int)ResultType.BASE_TABLE_ERROR));
            }
            if (!CheckSiteResult(checkpoint, towerpass))
            {
                return(Error(result));
            }

            Int64 rolelife;  //主角血量
            if (type == (int)DuplicateTargetType.MONSTER)
            {
                rolelife = checkpoint.blood;
                if (!CheckDifficult(npcid, ref checkpoint))
                {
                    return(Error((int)ResultType.BASE_TABLE_ERROR));
                }
                checkpoint.Update();
                fightresult = NpcChallenge(session.Player.User.id, npcid, FightType.DUPLICATE_SHARP, ref rolelife);
                result      = RoleLifeProcess(rolelife);
            }
            else if (type == (int)DuplicateTargetType.WATCHMEM)
            {
                if (!CheckWatchMen(checkpoint, towerpass))
                {
                    return(Error(result));
                }
                rolelife    = session.Player.Role.Kind.att_life;
                fightresult = NpcChallenge(session.Player.User.id, npcid, FightType.ONE_SIDE, ref rolelife);
                result      = WatchResult(fightresult);
            }
            else
            {
                return(Error((int)ResultType.FRONT_DATA_ERROR));
            }

            if (fightresult < 0)
            {
                return(Error((int)ResultType.FIGHT_ERROR));
            }
            TOWER_CHECKPOINT_DARE_PUSH.GetInstance().CommandStart(checkpoint.user_id, type, result, rolelife);
            if (!FameReward(user, npcid, result, type)) //推送奖励
            {
                return(Error((int)ResultType.BASE_TABLE_ERROR));
            }
            return(new ASObject(Common.GetInstance().BuildData((int)ResultType.SUCCESS)));
        }