Пример #1
0
        private static List <GameGroupMember> SortGroupMember(GameOrder order, bool isDefault, List <int> posList1)
        {
            var allMemberList = GetGroupKnockUserList(order, order.BeginRankAB, order.EndRankAB);
            var memberList    = new List <GameGroupMember>();

            if (!isDefault)
            {
                //非默认,按抽签重新组织顺序
                foreach (var index in posList1)
                {
                    var pos = order.SeedList.FirstOrDefault(P => P.Index == index);
                    if (pos.UserId.IsNotNullOrEmpty())
                    {
                        foreach (var mem in allMemberList.Where(p => p.GroupId.GetId() == pos.GroupId.GetId()))
                        {
                            memberList.Add(mem);
                        }
                    }
                    else
                    {
                        //按小组补轮空位置
                        for (int i = 0; i < order.KnockoutCountAB; i++)
                        {
                            memberList.Add(new GameGroupMember {
                            });
                        }
                    }
                }
                //尝试加入抢号人员
                if (allMemberList.Count > memberList.Count)
                {
                    foreach (var more in allMemberList)
                    {
                        if (!memberList.Contains(more))
                        {
                            memberList.Add(more);
                        }
                    }
                }
            }
            else
            {
                //默认,按小组顺序
                memberList = allMemberList;

                //补人数轮空位置
                var needPos = order.KnockoutTotalAB - order.ActualCount();
                if (needPos > 0)
                {
                    for (int i = 0; i < needPos; i++)
                    {
                        memberList.Add(new GameGroupMember {
                        });
                    }
                }
            }
            return(memberList);
        }
Пример #2
0
        private static void CheckByeOrKnock(GameOrder order, List <int> posList1, List <GameGroupMember> memberList)
        {
            var count = Math.Abs(order.KnockoutTotalAB - order.ActualCount());

            if (count > 0)
            {
                if (order.KnockoutTotalAB > order.ActualCount())
                {
                    //设置轮空
                    for (int i = 0; i < count; i++)
                    {
                        var pos = posList1[i] % 2 == 0 ? posList1[i] + 1 : posList1[i] - 1;
                        //查找本middle区域非轮空的空位
                        var targetPos = order.PositionList.FirstOrDefault(p => p.Index / order.Middle() == pos / order.Middle() && p.UserId.IsNullOrEmpty() && !p.IsBye);
                        if (targetPos != null)
                        {
                            targetPos.UserId  = order.PositionList[pos].UserId;
                            targetPos.GroupId = order.PositionList[pos].GroupId;
                            order.PositionList[pos].UserId  = null;
                            order.PositionList[pos].GroupId = null;
                            order.PositionList[pos].IsBye   = true;
                        }
                    }
                }
                else
                {
                    //抢号人员
                    var knockList = memberList.Where(p => p.IsEnterPos == false).ToList();
                    //设置抢号
                    for (int i = 0; i < count; i++)
                    {
                        var pos = posList1[i] % 2 == 0 ? posList1[i] + 1 : posList1[i] - 1;
                        order.PositionList[pos].KnockUserId = knockList[i].TeamId;
                    }
                }
            }
        }