public static void GameStart() { Player player1 = new Player(playerName[0], remote[0]); Player player2 = new Player(playerName[1], remote[1]); Player player3 = new Player(playerName[2], remote[2]); Player player4 = new Player(playerName[3], remote[3]); listAllCards = CardOperation.CreateCards();//生成所有牌 PlayerGround = playerName; SendAllPlayerName(playerName);//给所有客户端发送所有ID //给所有玩家发牌 foreach (Player p in listAllPlayer) { p.listPlayerCards = CardOperation.GiveAndSortPlayerCards(listAllCards); p.playerCardSize = Convert.ToInt32(WinLogicCode.getPlayerCardSize(p.listPlayerCards)); //将牌权值发送至客户端 for (int i = 0; i < 3; i++) { Card poker = new Card(); poker = (Card)p.listPlayerCards[i]; SendSingleMsg(poker.Value.ToString(), p.remotePoint); Thread.Sleep(1000); } } SendAllMsg("GameStart"); Thread.Sleep(1000); MsgControl.IsGroundOver = true; GroundSystem(); }
public static void MsgJudge(string message, Socket sef) { int i = 0; if (message == "abandon") { //传入的是弃牌的相应处理 GameFlow.i--; GameFlow.AllPlayerNum--; GameFlow.PlayerGround.Remove(Form1.PointName[sef.RemoteEndPoint.ToString()]); GameFlow.SendAllMsg("玩家: " + Form1.PointName[sef.RemoteEndPoint.ToString()] + " 弃牌"); IsGroundOver = true; } else { try { //接收到筹码信息所做的处理 i = Convert.ToInt32(message); Player.AllChip += i; Player.MinChip = i; GameFlow.SendAllMsg("玩家 " + Form1.PointName[sef.RemoteEndPoint.ToString()] + " 下注:" + message); IsGroundOver = true; } catch { //传入的是与其他玩家比较的处理 Player p1 = null; foreach (Player p in GameFlow.listAllPlayer) { if (p.playerName == Form1.PointName[sef.RemoteEndPoint.ToString()]) { p1 = p; } } foreach (Player p2 in GameFlow.listAllPlayer) { if (message == "compare with " + p2.playerName) { GameFlow.i--; GameFlow.AllPlayerNum--; if (WinLogicCode.AThanB(p1, p2))//p1赢 { GameFlow.SendAllMsg("玩家: " + p2.playerName + " 弃牌"); Thread.Sleep(1000); GameFlow.PlayerGround.Remove(p2.playerName); IsGroundOver = true; } else//p2赢 { GameFlow.SendAllMsg("玩家: " + p1.playerName + " 弃牌"); GameFlow.PlayerGround.Remove(p1.playerName); IsGroundOver = true; } } } } } }