/// <summary> /// 要牌 /// </summary> /// <param name="client"></param> public void getCard(ClientPeer client) { SingleExecute.Instance.Execute( delegate() { if (userCache.IsOnline(client) == false) { return; } //必须确保在线 int userId = userCache.GetId(client); SingleRoom room = singleCache.GetRoomByUId(userId); if (room.isPlayer21()) { client.Send(OpCode._21Single, _21SingleCode.GET_SRES, null); //已经21点不能要牌,最好客户端设置一下 return; } CardDto dto = room.GetOnePlayerCard(); client.Send(OpCode._21Single, _21SingleCode.GET_SRES, dto); if (room.GetPlayerWeight() > 21) //闲家爆牌 这局结束 { if (room.player.SplitNum > 1) //是分牌的情况 { client.Send(OpCode._21Single, _21SingleCode.SPLIT_PROMST_SRES, 2); //闲家爆牌 //room.player.winOrLose.Add(-1); //room.player.SpliteCardListList.Add(room.player.CardList); room.SaveList(1, false); if (room.player.SpliteCardListQueue.Count() > 0) { client.Send(OpCode._21Single, _21SingleCode.SPLIT_CAN_NEXT_SRES, null); } else { gameOver(userId, room, 7); } } else { client.Send(OpCode._21Single, _21SingleCode.NGET_SRES, null); gameOver(userId, room, 2); } } else if (room.GetPlayerWeight() != 21) { BasicStrategyDto basicStrategyDto = new BasicStrategyDto(); basicStrategyDto.dealerCardType = room.getDealerCardType(); basicStrategyDto.playerCardType = room.getPlayerCardType(); basicStrategyDto.realAns = basicStrategy.trueStrategy(basicStrategyDto.dealerCardType, basicStrategyDto.playerCardType); client.Send(OpCode._21Single, _21SingleCode.BASIC_STRATEGY_SRES, basicStrategyDto); } else { client.Send(OpCode._21Single, _21SingleCode.BASIC_STRATEGY_SRES, null); } }); }
/// <summary> /// 下一把 /// </summary> /// <param name="client"></param> public void nextGame(ClientPeer client) { SingleExecute.Instance.Execute( delegate() { if (userCache.IsOnline(client) == false) { return; } //必须确保在线 int userId = userCache.GetId(client); SingleRoom room = singleCache.GetRoomByUId(userId); room.Multiple = 1; if (room.libraryModel.CardQueue.Count() < 12) { room.libraryModel.Init(); client.Send(OpCode._21Single, _21SingleCode.RESHUFF_SRES, null); //重新洗牌,给客户端,让客户端给提示 } //测试,只发俩A //room.TestInitPlayerCards(); room.InitPlayerCards(); //发送给客户端 他自身有什么牌 庄家有什么牌 List <CardDto> cardList = room.GetUserCards(userId); client.Send(OpCode._21Single, _21SingleCode.GET_PCARD_SRES, cardList); client.Send(OpCode._21Single, _21SingleCode.GET_DCARD_SRES, room.DealerCardList); Thread.Sleep(100); //摸到21点,牛逼,游戏结束 if (room.isPlayer21()) //21点 这局结束 { //client.Send(OpCode._21Single, _21SingleCode.OVER_SRES, 1); client.Send(OpCode._21Single, _21SingleCode.NGET_SRES, null); gameOver(userId, room, 1); } //能够分牌了 else if (cardList.Count > 1 && cardList[0].Weight == cardList[1].Weight) { BasicStrategyDto basicStrategyDto = new BasicStrategyDto(); basicStrategyDto.dealerCardType = room.getDealerCardType(); basicStrategyDto.playerCardType = room.getPlayerCardType(); basicStrategyDto.realAns = basicStrategy.trueStrategy(basicStrategyDto.dealerCardType, basicStrategyDto.playerCardType); client.Send(OpCode._21Single, _21SingleCode.BASIC_STRATEGY_SRES, basicStrategyDto); client.Send(OpCode._21Single, _21SingleCode.CAN_SPLIT_SRES, null); } else { BasicStrategyDto basicStrategyDto = new BasicStrategyDto(); basicStrategyDto.dealerCardType = room.getDealerCardType(); basicStrategyDto.playerCardType = room.getPlayerCardType(); basicStrategyDto.realAns = basicStrategy.trueStrategy(basicStrategyDto.dealerCardType, basicStrategyDto.playerCardType); client.Send(OpCode._21Single, _21SingleCode.BASIC_STRATEGY_SRES, basicStrategyDto); } }); }
public void splitNextCard(ClientPeer client) { SingleExecute.Instance.Execute( delegate() { if (userCache.IsOnline(client) == false) { return; } //必须确保在线 int userId = userCache.GetId(client); SingleRoom room = singleCache.GetRoomByUId(userId); room.NextHandCard(); List <CardDto> cardList = room.GetUserCards(userId); client.Send(OpCode._21Single, _21SingleCode.GET_PCARD_SRES, cardList); if (room.isPlayer21()) //21点 这局结束 { room.SaveList(1, false); //room.player.SpliteCardListList.Add(cardList); if (room.player.SpliteCardListQueue.Count() > 0) { client.Send(OpCode._21Single, _21SingleCode.SPLIT_PROMST_SRES, 1); //21点牛逼 //room.player.winOrLose.Add(1.5); client.Send(OpCode._21Single, _21SingleCode.SPLIT_CAN_NEXT_SRES, null); } else { gameOver(userId, room, 7); } } else if (cardList.Count > 1 && cardList[0].Weight == cardList[1].Weight) { BasicStrategyDto basicStrategyDto = new BasicStrategyDto(); basicStrategyDto.dealerCardType = room.getDealerCardType(); basicStrategyDto.playerCardType = room.getPlayerCardType(); basicStrategyDto.realAns = basicStrategy.trueStrategy(basicStrategyDto.dealerCardType, basicStrategyDto.playerCardType); client.Send(OpCode._21Single, _21SingleCode.BASIC_STRATEGY_SRES, basicStrategyDto); client.Send(OpCode._21Single, _21SingleCode.CAN_SPLIT_SRES, null); } else { BasicStrategyDto basicStrategyDto = new BasicStrategyDto(); basicStrategyDto.dealerCardType = room.getDealerCardType(); basicStrategyDto.playerCardType = room.getPlayerCardType(); basicStrategyDto.realAns = basicStrategy.trueStrategy(basicStrategyDto.dealerCardType, basicStrategyDto.playerCardType); client.Send(OpCode._21Single, _21SingleCode.BASIC_STRATEGY_SRES, basicStrategyDto); } }); }