Exemple #1
0
        /// <summary>
        /// 设置淘汰赛人员
        /// </summary>
        /// <param name="order"></param>
        /// <param name="isDefault"></param>
        public static void SetPositionListTwo(GameOrder order, bool isDefault)
        {
            //初始化所有位置
            order.PositionList = new List <GamePosition>();
            for (int i = 0; i < order.KnockoutTotalAB; i++)
            {
                order.PositionList.Add(new GamePosition {
                    Index = i
                });
            }

            //获取1,2名位置列表
            var posList1 = KnockoutDrawHelper.CalRankPosAndSort(order.KnockoutTotalAB, order.KnockoutCountAB, 1);
            var posList2 = KnockoutDrawHelper.CalRankPosAndSort(order.KnockoutTotalAB, order.KnockoutCountAB, 2);

            //获取出线成员列表
            var memberList = SortGroupMember(order, isDefault, posList1);

            //添加前1,2名位置
            AttachOneAndTwo(order, posList1, posList2, memberList);

            //非AB模式前4名出线,附加3,4名位置
            if (!order.IsKnockOutAB && order.KnockoutCount == 4)
            {
                AttachThreeAndFour(order, memberList);
            }

            CheckByeOrKnock(order, posList1, memberList);
        }
        /// <summary>
        /// 单淘汰,按人抽签
        /// </summary>
        /// <param name="request">Request.GameOrder.Entities</param>
        /// <returns>Response.EmptyEntity</returns>
        public Response Execute(string request)
        {
            var req   = JsonConvert.DeserializeObject <Request <GameOrder> >(request);
            var order = GameHelper.GetGameOrder(req.Filter.Id);

            if (order.State != GameOrderState.NOTSTART.Id)
            {
                return(ResultHelper.Fail("比赛已经开始,不能再进行抽签。"));
            }

            var memberList = GetGameTeamList(order);

            if (memberList.IsNullOrEmpty())
            {
                return(ResultHelper.Fail("无参赛人员,不能进行抽签。"));
            }

            //参照2名算法
            order.KnockoutCount = 2;
            order.SetKnockOutAB(GameHelper.GetGame(order.GameId).IsKnockOutAB);

            //获取1,2名位置列表
            var posListAll = KnockoutDrawHelper.CalRankPosAndSort(order.KnockoutTotal, order.KnockoutCount, 1);
            var posListTwo = KnockoutDrawHelper.CalRankPosAndSort(order.KnockoutTotal, order.KnockoutCount, 2);

            posListAll.AddRange(posListTwo);
            //初始化所有位置
            order.PositionList = new List <GamePosition>();
            for (int i = 0; i < order.KnockoutTotal; i++)
            {
                order.PositionList.Add(new GamePosition {
                    Index = i
                });
            }
            //取小值循环
            int count = Math.Min(posListAll.Count, memberList.Count);

            for (int i = 0; i < count; i++)
            {
                order.PositionList[posListAll[i]].UserId = memberList[i].Id.Link(memberList[i].TeamName);
                if (i < posListAll.Count / 2)
                {
                    order.PositionList[posListAll[i]].IsSeed = true;
                }
                memberList[i].IsEnterPos = true;
            }
            //检查轮空或者抢号
            CheckByeOrKnock(order, posListAll, memberList);
            //检查相同单位
            GetGamePositionList.CheckSameCorpTeamId(order);

            var resultOrder = ResultHelper.Success(new List <EntityBase> {
                order
            });

            return(resultOrder);
        }
Exemple #3
0
        private static void SetPositionListFirst(GameOrder order)
        {
            //获取抽签位置
            order.PositionList = new List <GamePosition>();
            for (int i = 0; i < order.KnockoutTotalAB; i++)
            {
                order.PositionList.Add(new GamePosition {
                    Index = i
                });
            }
            //设置种子位置
            var seedList = KnockoutDrawHelper.CalRankPosAndSort(order.KnockoutTotalAB, order.KnockoutCountAB, 1);

            foreach (int index in seedList)
            {
                order.PositionList[index].Index  = index;
                order.PositionList[index].IsSeed = true;
            }
        }
Exemple #4
0
        private static void AttachThreeAndFour(GameOrder order, List <GameGroupMember> memberList)
        {
            var posList3 = KnockoutDrawHelper.CalRankPosAndSort(order.KnockoutTotalAB, order.KnockoutCountAB, 3);
            var posList4 = KnockoutDrawHelper.CalRankPosAndSort(order.KnockoutTotalAB, order.KnockoutCountAB, 4);

            for (int i = 0; i < order.KnockoutTotalAB / order.KnockoutCountAB; i++)
            {
                order.PositionList[posList3[i]].UserId  = memberList[i * order.KnockoutCountAB + 2].TeamId;
                order.PositionList[posList3[i]].GroupId = memberList[i * order.KnockoutCountAB + 2].GroupId;

                memberList[i * order.KnockoutCountAB + 2].IsEnterPos = true;
            }

            for (int i = 0; i < order.KnockoutTotalAB / order.KnockoutCountAB; i++)
            {
                order.PositionList[posList4[i]].UserId  = memberList[i * order.KnockoutCountAB + 3].TeamId;
                order.PositionList[posList4[i]].GroupId = memberList[i * order.KnockoutCountAB + 3].GroupId;

                memberList[i * order.KnockoutCountAB + 3].IsEnterPos = true;
            }
        }