/// <summary> /// 发牌 /// </summary> void DealCards() { FirstDrawInfo firstDrawInfo = DataDo.Json2Object <FirstDrawInfo>(Decode.DecodeSecondContendBtyes(bytes)); Console.WriteLine("白牌的数目:" + firstDrawInfo.blackCards + " 白牌的数目:" + firstDrawInfo.whiteCards); RoomInfo roomInfo = GetRoom(firstDrawInfo.roomNum); if (roomInfo != null) { roomInfo.sealers.Add(firstDrawInfo.myId); DoSeal(roomInfo, firstDrawInfo); } }
static public void DoSeal(RoomInfo roomInfo, FirstDrawInfo firstDrawInfo) { //首摸是空 if (roomInfo.playersCards == null) { roomInfo.playersCards = new List <BaseCard>();//先分配空间,后面添加才有地方存 不能删 } #region 玩家自选 if (firstDrawInfo.blackCards > 0) { DoDeal(firstDrawInfo.blackCards, roomInfo, firstDrawInfo.myId, CardColors.BLACK); } if (firstDrawInfo.whiteCards > 0) { DoDeal(firstDrawInfo.whiteCards, roomInfo, firstDrawInfo.myId, CardColors.WHITE); } #endregion #region 系统随机摸牌 int drawCardCount = 0;//允许摸牌数 switch (roomInfo.member.Count) { case 2: drawCardCount = 4; break; case 3: drawCardCount = 4; break; case 4: drawCardCount = 3; break; } if (firstDrawInfo.blackCards + firstDrawInfo.whiteCards < drawCardCount) { //剩余的牌(玩家还没选够,交由服务器系统随机抽) int margin = drawCardCount - (firstDrawInfo.blackCards + firstDrawInfo.whiteCards); DoDeal(margin, roomInfo, firstDrawInfo.myId); } #endregion }