/// <summary> /// 加倍 /// </summary> /// <param name="client"></param> private void doubleCard(ClientPeer client) { SingleExecute.Instance.Execute( () => { if (userCache.IsOnline(client) == false) { return; } int userId = userCache.GetId(client); if (fightCache.IsInRoom(userId) == false) { return; } //一定要注意安全的验证 _21MutiFightRoom room = fightCache.GetRoom(userId); //把要的牌广播一下 CardDto carddto = room.HitByUId(userId); int position = room.getPosition(userId); HitBroDto hbdto = new HitBroDto(userId, position, carddto); //可以用hit的code brocast(room, OpCode._21Multi, _21MultiCode.HIT_BRO, hbdto, null); //爆牌了 if (room.GetWeightByUId(userId) > 21) { //记录一下这组牌 true代表加倍了 room.SaveListByUserId(userId, 2, true); //4代表加倍后爆牌 OverHandDto ohdto = new OverHandDto(userId, position, 4); brocast(room, OpCode._21Multi, _21MultiCode.OVER_HAND_BRO, ohdto, null); //该下一个玩家了 turnPlayer(userId, position, room); } //相当于加倍后不要牌了 else { room.SaveListByUserId(userId, 3, true); //5代表加倍 OverHandDto ohdto = new OverHandDto(userId, position, 5); brocast(room, OpCode._21Multi, _21MultiCode.OVER_HAND_BRO, ohdto, null); //该下一个玩家了 turnPlayer(userId, position, room); } } ); }
/// <summary> /// 要牌 /// </summary> /// <param name="client"></param> private void hit(ClientPeer client) { SingleExecute.Instance.Execute( () => { if (userCache.IsOnline(client) == false) { return; } int userId = userCache.GetId(client); if (fightCache.IsInRoom(userId) == false) { return; } //一定要注意安全的验证 _21MutiFightRoom room = fightCache.GetRoom(userId); int position = room.getPosition(userId); HitBroDto hbdto; //如果牌已经21点不能要牌,最好客户端设置一下 if (room.is21ByUserId(userId)) { //client.Send(OpCode._21Multi, _21MultiCode.HIT_BRO, null); //发送个空的carddto hbdto = new HitBroDto(userId, position, null); brocast(room, OpCode._21Multi, _21MultiCode.HIT_BRO, hbdto, null); return; } //把要的牌广播一下 CardDto carddto = room.HitByUId(userId); hbdto = new HitBroDto(userId, position, carddto); brocast(room, OpCode._21Multi, _21MultiCode.HIT_BRO, hbdto, null); //爆牌了 if (room.GetWeightByUId(userId) > 21) { //记录一下这组牌 room.SaveListByUserId(userId, 2, false); //int position = room.getPosition(userId); OverHandDto ohdto = new OverHandDto(userId, position, 2); brocast(room, OpCode._21Multi, _21MultiCode.OVER_HAND_BRO, ohdto, null); //该下一个玩家了 turnPlayer(userId, position, room); } } ); }