/// <summary> /// 结束 /// </summary> public static void GameOver(RoomInfo roomInfo, List <int> exitList) { ForeachSendOneOpen((int)SecondCommands.Over, roomInfo, DataDo.Object2Json(exitList)); Console.WriteLine("发送结束命令"); }
/// <summary> /// 下一位【改成房间的成员方法】 /// </summary> /// <param name="roomInfo"></param> public static void Next(RoomInfo roomInfo) { roomInfo.Time = (int)Time._SingleDrawTime + (int)Time._SelectMyselfCardTime; //Console.WriteLine("执行下一位 " + DateTime.Now); }
/// <summary> /// 出局 /// </summary> void Out(RoomInfo roomInfo, int id) { //将服务器的房间内的玩家移除 roomInfo.RemoveTempMember(id); }
/// <summary> /// 抽取指定 张数 的牌 /// </summary> /// <param name="colorCardsCount">指定颜色的牌数</param> /// <param name="roomInfo">房间信息(修改手牌和牌库)</param> /// <param name="id">玩家id</param> public static void DoDeal(int colorCardsCount, RoomInfo roomInfo, int id) { for (int i = 0; i < colorCardsCount; i++) { #region 测试代码 ///////////////////////////////////////////////////////////// 测试代码 /////////////////////////////// //if (id==1) //{ // BaseCard tempCard=null; // foreach (var item in roomInfo.cardsLibrary) // { // if (item.CardWeight == CardWeight.Line) // { // tempCard = item; // } // } // BaseCard card; // if (tempCard!=null) // { // card = tempCard; // } // else // { // card = roomInfo.cardsLibrary[0]; // } // int index = roomInfo.member.FindIndex(it => // { // if (it.id == 1)//找到该玩家在成员列表中的下标(索引) // { // return true; // } // else return false; // }); // roomInfo.cardsLibrary.Remove(card); // card.CardBelongTo = (CardBelongTo)(index + 1);//为每个玩家发牌 0是牌库 成员的0代表所属的1 // roomInfo.playersCards.Add(card); //} /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // else #endregion { BaseCard card = roomInfo.cardsLibrary[0]; int index = roomInfo.member.FindIndex(it => { if (it.id == id)//找到该玩家在成员列表中的下标(索引) { return(true); } else { return(false); } }); roomInfo.cardsLibrary.Remove(card); card.CardBelongTo = (CardBelongTo)(index + 1);//为每个玩家发牌 0是牌库 成员的0代表所属的1 roomInfo.playersCards.Add(card); } } }
public override void DoCommand() { int command = BitConverter.ToInt32(bytes, 8); switch (command) { case 0: //暂无 break; case 1: Console.WriteLine("开始游戏-------创建一副牌,洗牌"); BeginGame(); break; case 2: Console.WriteLine("接收到发牌命令-----处理 发牌 和 猜先 + 开始轮回(计时 + 下一位)"); DealCards(); break; //case 3: // Console.WriteLine("猜先"); // break; case 4: //Console.WriteLine("pass"); ////Next(); //break; case 5: Console.WriteLine("摸牌 " + DateTime.Now); Draw(); break; case 6: Console.WriteLine("猜牌结果"); SendResult2Other(); break; case 7: Console.WriteLine("-----------玩家自选了要公布的牌"); OpenSelfSelectCard(); break; case 8: Console.WriteLine("自动公布牌"); SendID((int)SecondCommands.AutoOpenOnesCard); break; case 9: Console.WriteLine("-------------------接收到" + BitConverter.ToInt32(bytes, 12) + "出局要求"); SendID((int)SecondCommands.Out); break; case 10: Console.WriteLine("-----------结束"); break; case 11: Console.WriteLine("-----------创建自选计时器"); CreatSelectSelfCardTimer(); break; case 12: Console.WriteLine("-----------玩家要继续猜牌"); Continue(); break; case 13: Console.WriteLine("-----------玩家选择【过】"); Pass(); break; case 14: Console.WriteLine("-----------首摸移动万能牌"); SendLineCardMoveInfo(); break; case 15: Console.WriteLine("-----------准备好……"); RoomInfo roomInfo = GetRoom(Encoding.UTF8.GetString(Decode.DecodeSecondContendBtyes(bytes))); if (!roomInfo.isStartTime) { roomInfo.WaitToDo(Time._1stDrawTime); } break; } }