/// <summary> /// 暗杠 /// </summary> /// <param name="uid"></param> /// <param name="card"></param> public void AnGang(string uid, int card) { if (this.IsFrist) { foreach (var row in Players) { if ((row.CheckKaiJuHu()) && row.PlayerUser.Uid != uid) { LogManager.Log.Debug("开局胡等待" + row.PlayerUser.Uid + "wait"); row.ResetEvent.WaitOne(); LogManager.Log.Debug("开局胡等待处理完毕" + row.PlayerUser.Uid + "wait"); } } } this.IsFrist = false; LinkedListNode <CsGamePlayer> node = FindPlayer(uid); node.Value.IsGang = true; this.Player = node; int modZhang = 108 - (this.CardIndex + 1); int dunshu = modZhang / 2; int saizi = new Random().Next(2, 12); int card1 = -1; int card2 = -1; //TODO : 筛子随出大于当前墩数 if (saizi <= dunshu) { card1 = this.ReadCard(); card2 = this.ReadCard(); } A1012Response.Builder response = A1012Response.CreateBuilder(); response.Uid = node.Value.PlayerUser.Uid; response.Card = card; response.Card1 = card1; response.Card2 = card2; response.GangType = 0; var array = response.Build().ToByteArray(); node.Value.NeedGangDaPai.Add(card1); node.Value.NeedGangDaPai.Add(card2); foreach (var row in this.Players) { WebSocketServerWrappe.SendPackgeWithUser(row.PlayerUser.Uid, 1012, array); } node.Value.AnGang(card); actionStorage.PushGang(uid, card, card1, card2); }
/// <summary> /// 杠牌 /// </summary> /// <param name="uid"></param> /// <param name="card"></param> public void Gang(string uid, string desUid, int card) { LinkedListNode <CsGamePlayer> node = FindPlayer(uid); foreach (var row in Players) { if ((row.CheckHu(card)) && row.PlayerUser.Uid != uid && row.PlayerUser.Uid != desUid) { row.ResetEvent.WaitOne(); } } if (node.Value.ResetEvent.WaitOne(0)) { return; } node.Value.Gang(card); //牌未被胡 if (this.OutCardState == OutCardState.Normal) { node.Value.IsGang = true; this.OutCardState = OutCardState.Gang; int modZhang = 108 - (this.CardIndex + 1); int dunshu = modZhang / 2; int saizi = new Random().Next(2, 12); int card1 = -1; int card2 = -1; //TODO : 筛子随出大于当前墩数 if (saizi <= dunshu) { card1 = this.ReadCard(); card2 = this.ReadCard(); } A1012Response.Builder response = A1012Response.CreateBuilder(); response.Uid = node.Value.PlayerUser.Uid; response.Card = card; response.Card1 = card1; response.Card2 = card2; var array = response.Build().ToByteArray(); foreach (var row in this.Players) { WebSocketServerWrappe.SendPackgeWithUser(row.PlayerUser.Uid, 1012, array); } actionStorage.PushGang(uid, card, card1, card2); } this.Player = node; node.Value.ResetEvent.Set(); }