/// <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); } }); }
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); } }); }
/// <summary> /// 不要牌 /// </summary> /// <param name="client"></param> public void ngetCard(ClientPeer client) { SingleExecute.Instance.Execute( delegate() { if (userCache.IsOnline(client) == false) { return; } //必须确保在线 int userId = userCache.GetId(client); SingleRoom room = singleCache.GetRoomByUId(userId); //client.Send(OpCode._21Single, _21SingleCode.OVER_SRES, whichwin); //说明是分牌的 if (room.player.SplitNum > 1) { //room.addWeightAndMulti(1); room.SaveList(3, false); //client.Send(OpCode._21Single, _21SingleCode.SPLIT_PROMST_SRES, whichwin); //先不能判断输赢 if (room.player.SpliteCardListQueue.Count() > 0) { client.Send(OpCode._21Single, _21SingleCode.SPLIT_PROMST_SRES, 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); while (room.GetDealerWeight() < 17) { CardDto dto = room.GetOneDealerCard(); client.Send(OpCode._21Single, _21SingleCode.ADD_DCARD_SRES, dto); } int whichwin = room.whichWin(); gameOver(userId, room, whichwin); } }); }
/// <summary> /// 加倍 /// </summary> /// <param name="client"></param> public void doubleCard(ClientPeer client) { SingleExecute.Instance.Execute( delegate() { if (userCache.IsOnline(client) == false) { return; } //必须确保在线 int userId = userCache.GetId(client); SingleRoom room = singleCache.GetRoomByUId(userId); CardDto dto = room.GetOnePlayerCard(); client.Send(OpCode._21Single, _21SingleCode.GET_SRES, dto); //说明是分牌的 if (room.player.SplitNum > 1) { if (room.GetPlayerWeight() > 21) //闲家爆牌 这局结束 { room.SaveList(2, true); client.Send(OpCode._21Single, _21SingleCode.SPLIT_PROMST_SRES, 2); //闲家爆牌 //room.player.SpliteCardListList.Add(room.player.CardList); if (room.player.SpliteCardListQueue.Count() > 0) { //room.player.winOrLose.Add(-2);//加倍的时候爆牌了,所以是-2 client.Send(OpCode._21Single, _21SingleCode.SPLIT_CAN_NEXT_SRES, null); } else { gameOver(userId, room, 7); } } else { //room.addWeightAndMulti(2); room.SaveList(3, true); //client.Send(OpCode._21Single, _21SingleCode.SPLIT_PROMST_SRES, whichwin); //先不能判断输赢 if (room.player.SpliteCardListQueue.Count() > 0) { client.Send(OpCode._21Single, _21SingleCode.SPLIT_PROMST_SRES, 0); //随便提示一下 client.Send(OpCode._21Single, _21SingleCode.SPLIT_CAN_NEXT_SRES, null); } else { gameOver(userId, room, 7); } } } else { //设置倍数 room.Multiple = 2; if (room.GetPlayerWeight() > 21) //闲家爆牌 这局结束 { //client.Send(OpCode._21Single, _21SingleCode.OVER_SRES, 2); client.Send(OpCode._21Single, _21SingleCode.NGET_SRES, null); gameOver(userId, room, 2); } else { client.Send(OpCode._21Single, _21SingleCode.NGET_SRES, null); while (room.GetDealerWeight() < 17) { CardDto dto2 = room.GetOneDealerCard(); client.Send(OpCode._21Single, _21SingleCode.ADD_DCARD_SRES, dto2); } int whichwin = room.whichWin(); //client.Send(OpCode._21Single, _21SingleCode.OVER_SRES, whichwin); gameOver(userId, room, whichwin); } } }); }