/// <summary> /// 摸牌 /// </summary> void Draw() { SingleDraw singleDraw = DataDo.Json2Object <SingleDraw>(Decode.DecodeSecondContendBtyes(bytes)); RoomInfo roomInfo = GetRoom(singleDraw.roomNum); //找到自己在成员列表所对应的下标 if (roomInfo == null) { return; } int cardIndex = singleDraw.cardIndex; BaseCard card = roomInfo.cardsLibrary[cardIndex]; //////出错 “牌不一致” card.CardBelongTo = (CardBelongTo)singleDraw.myIndex; //为每个玩家发牌 //服务器房间牌库数据修改 roomInfo.playersCards.Add(card); roomInfo.cardsLibrary.Remove(card); Console.WriteLine("玩家牌数:" + roomInfo.playersCards.Count + " 牌库:" + roomInfo.cardsLibrary.Count); Console.WriteLine("singleDraw: cardIndex:" + singleDraw.cardIndex + " myId:" + singleDraw.myId + " 时间:" + DateTime.Now); //自动摸牌(托管) if (singleDraw.autoTrusteeship) { card.CardDisplay = CardDisplay.True; //每人的计时是_SingleDrawTime + _SelectMyselfCardTime+出牌按钮+再次摸牌时间 Next(roomInfo); Console.WriteLine("Next-------------Draw"); } ForeachSendDraw((int)SecondCommands.DRAW, roomInfo, cardIndex, card); }
/// <summary> /// 发牌 /// </summary> //void Deal(RoomInfo roomInfo) //{ // int cards = 0; // if (roomInfo.member.Count == 3 || roomInfo.member.Count == 2) // { // cards = 4; // } // else if (roomInfo.member.Count == 4) // { // cards = 3; // } // if (cards == 4 || cards == 3) // { // BaseCard card; // roomInfo.playersCards = new List<BaseCard>(); // for (int i = 1; i <= roomInfo.member.Count; i++)//人员 // { // for (int j = 1; j <= cards; j++)//牌数 // { // card = roomInfo.cardsLibrary[0]; // card.CardBelongTo = (CardBelongTo)i;//为每个玩家发牌 0是牌库 // Console.WriteLine("手牌:" + card.CardName); // roomInfo.playersCards.Add(card); // roomInfo.cardsLibrary.Remove(card); // } // } // Console.WriteLine("手牌数:" + roomInfo.playersCards.Count + " 牌库: " + roomInfo.cardsLibrary.Count); // } //} #endregion /// <summary> /// 公布自选牌 /// </summary> void OpenSelfSelectCard() { byte[] content = Decode.DecodeSecondContendBtyes(bytes); SingleDraw singleDraw = DataDo.Json2Object <SingleDraw>(content); RoomInfo roomInfo = GetRoom(singleDraw.roomNum); //找到自己在成员列表所对应的下标 if (roomInfo == null) { return; } Next(roomInfo); Console.WriteLine("Next-------------OpenSelfSelectCard"); //广播成员 Conn conn; for (int i = 0; i < roomInfo.member.Count; i++) { Server.connMap.TryGetValue(roomInfo.member[i].id.ToString(), out conn); byte[] data = Incode.IncodeSecondaryCommand(type, (int)SecondCommands.SelectMyCardToOpen, content); conn.SendBts(data); } }