/// <summary> /// 发牌 (初始化角色手牌) /// </summary> public InitCardDto InitPlayerCards() { InitCardDto initCardDto = new InitCardDto(); //庄家 for (int i = 0; i < 2; i++) { CardDto card = libraryModel.Deal(); DealerCardList.Add(card); } initCardDto.InitCardLists[0] = DealerCardList; for (int i = 0; i < 4; i++) { if (PlayerList[i] != null) { for (int j = 0; j < 2; j++) { CardDto card = libraryModel.Deal(); PlayerList[i].CardList.Add(card); } initCardDto.InitCardLists[i + 1] = PlayerList[i].CardList; } } return(initCardDto); }
private void initCardBro(InitCardDto initCardDto) { Dispatch(AreaCode.CHARACTER, CharacterEvent.MULTI_INIT_DEALER_CARD, initCardDto.InitCardLists[0]); for (int i = 1; i < 5; i++) { if (initCardDto.InitCardLists[i] != null) { initPlayerCardByPosition(i, initCardDto.InitCardLists[i]); } } }
private void StartFight(int roomId) { //房间设置为开始 fightCache.SetRoomPlayByRoomId(roomId); _21MutiFightRoom room = fightCache.GetRoomByRoomId(roomId); //初始发牌 InitCardDto initCardDto = room.InitPlayerCards(); brocast(room, OpCode._21Multi, _21MultiCode.INIT_CARD_BRO, initCardDto, null); //发送开始HIT或STAND的响应 int firstUserId = room.GetFirstUId(); room.SetPlayingUId(firstUserId); if (room.is21ByUserId(firstUserId))//21点 直接赢了 { //记录一下这组牌 room.SaveListByUserId(firstUserId, 1, false); int position = room.getPosition(firstUserId); OverHandDto ohdto = new OverHandDto(firstUserId, position, 1); brocast(room, OpCode._21Multi, _21MultiCode.OVER_HAND_BRO, ohdto, null); //该下一个玩家了 turnPlayer(firstUserId, position, room); } else { if (room.isCanSplitByUserId(firstUserId))//能够分牌 { TurnHandDto thdto = new TurnHandDto(true, firstUserId); //client.Send(OpCode._21Multi, _21MultiCode.TURN_HS_BRO, thdto); brocast(room, OpCode._21Multi, _21MultiCode.TURN_HS_BRO, thdto, null); } else { TurnHandDto thdto = new TurnHandDto(false, firstUserId); //client.Send(OpCode._21Multi, _21MultiCode.TURN_HS_BRO, thdto); brocast(room, OpCode._21Multi, _21MultiCode.TURN_HS_BRO, thdto, null); } } }