/// <summary> /// 检测是否可以一次把牌全出去的牌型 /// </summary> private CardType CheckCanOutCdsOneTime(CdSplitStruct hdcdSplitGp) { var cdType = PokerRuleUtil.GetCdsType(HdCdsListTemp.ToArray()); //如果可以一次出,则直接全出 if (cdType != CardType.None && cdType != CardType.Exception) { GlobalData.ServInstance.ThrowOutCard(HdCdsListTemp.ToArray(), new int[] { -1 }, (int)cdType); return(cdType); } //如果是3张或者3带1的情况直接发送出牌信息 if (CheckOutCdsC3OrC31()) { GlobalData.ServInstance.ThrowOutCard(HdCdsListTemp.ToArray(), new int[] { -1 }, (int)CardType.C32); return(CardType.C32); } if (CheckOutCdsC1112223434(hdcdSplitGp)) { GlobalData.ServInstance.ThrowOutCard(HdCdsListTemp.ToArray(), new int[] { -1 }, (int)CardType.C1112223434); return(CardType.C1112223434); } return(CardType.None); }
/// <summary> /// 最终检测手牌 /// </summary> /// <param name="isgetcdsWithoutCompare">是不是在没有其他人出牌情况下</param> private void FinalOutCdsCheck(bool isgetcdsWithoutCompare) { //经过智能检索后最后检查一遍抬出的牌是否合法----start--- var finalType = PokerRuleUtil.GetCdsType(HdCdctrlInstance.GetUpCdList().ToArray()); if (finalType != CardType.None && finalType != CardType.Exception) { //如果选出的牌型不是那种单牌,或者对子的小牌型,就先关闭智能选牌 if (isgetcdsWithoutCompare && finalType != CardType.C1 && finalType != CardType.C2) { _onoffIchosecCds = false; } else if (!isgetcdsWithoutCompare) { _onoffIchosecCds = false; } DDzUtil.ActiveBtn(ChuPaiBtn, DisChuPaiBtn); } else { DDzUtil.DisableBtn(ChuPaiBtn, DisChuPaiBtn); } //------------end }
//---------------end-- /// <summary> /// 检测是否可以一手全出所有手牌,如果可以自动全出。 /// </summary> private bool CheckCanOutOneTime() { if (!_autoLastOut) { return(false); } var hdCds = HdCdsListTemp.ToArray(); var cdsType = PokerRuleUtil.GetCdsType(hdCds); if (cdsType == CardType.None || cdsType == CardType.Exception || cdsType == CardType.C411) { return(false); } //如果是飞机带单牌,查找是否含有炸弹,有则不自动出了 if (cdsType == CardType.C11122234) { var sotedCds = PokerRuleUtil.GetSortedValues(hdCds); var cdNum = 0; var curCd = -1; if (ExistC42(sotedCds)) { return(false); } foreach (var cd in sotedCds) { if (curCd != cd) { curCd = cd; if (cdNum >= 4) { return(false); } cdNum = 1; continue; } cdNum++; } if (cdNum >= 4) { return(false); } } //赖子代表的牌 var laiziRepCds = new[] { -1 }; App.GetRServer <DdzGameServer>().ThrowOutCard(hdCds, laiziRepCds, (int)cdsType); return(true); }
/// <summary> /// 获取牌型 /// </summary> /// <param name="data"></param> /// <returns></returns> CardType GetOutCardsType(ISFSObject data) { if (data.ContainsKey(RequestKey.KeyCardType)) { return((CardType)data.GetInt(RequestKey.KeyCardType)); } if (!data.ContainsKey(RequestKey.KeyCards)) { return(0); } var cards = data.GetIntArray(RequestKey.KeyCards); return(PokerRuleUtil.GetCdsType(cards)); }
//------------------------------------------------------------------------------------------------ /// <summary> /// 当上一次玩家出牌不是自己时 /// </summary> /// <param name="lastOutData">最后一次出牌的信息</param> /// <param name="isRejoin">标记是否是重连进入的</param> private void OnNotSelfOutCds(ISFSObject lastOutData, bool isRejoin = false) { //DDzUtil.ActiveBtn(BuYaoBtn, DisBuYaoBtn); DDzUtil.DisableBtn(ChuPaiBtn, DisChuPaiBtn); //玩家剩余最后4张牌,牌型三带一,最后一次出牌信息三带二,特殊改为玩家三带二计算(特殊情况) var lastcdType = CardType.None; lastcdType = PokerRuleUtil.GetCdsType(lastOutData.GetIntArray(RequestKey.KeyCards)); if (HdCdsListTemp.ToArray().Length == 4 && lastcdType == CardType.C32) { var sortedLastOutCd = PokerRuleUtil.GetSortedValues(HdCdsListTemp.ToArray()); var dictoNum = new Dictionary <int, int>(); foreach (var cd in sortedLastOutCd) { if (!dictoNum.ContainsKey(cd)) { dictoNum[cd] = 1; continue; } dictoNum[cd]++; } var dictoNumTwo = dictoNum; foreach (var cd in dictoNum.Keys.Where(cd => dictoNum[cd] == 1)) { dictoNumTwo[cd]++; break; } List <int> TempHdCdsListTemp = new List <int>(); foreach (var item in dictoNumTwo) { for (int i = 0; i < item.Value; i++) { TempHdCdsListTemp.Add(item.Key); } } endchupaiV(isRejoin, TempHdCdsListTemp, lastOutData); } else { endchupaiV(isRejoin, HdCdsListTemp, lastOutData); } var args = new HdCdCtrlEvtArgs(HdCdctrlInstance.GetUpCdList().ToArray()); OnHdCdsCtrlEvent(null, args); _onoffIchosecCds = true; }
void OutCard() { int[] cardArr = HdCdctrlInstance.GetUpCdList().ToArray(); //赖子代表的牌 var laiziRepCds = new[] { -1 }; //类型 int curRule = -1; var type = PokerRuleUtil.GetCdsType(cardArr); if (type != CardType.None && type != CardType.Exception) { curRule = (int)type; } App.GetRServer <DdzGameServer>().ThrowOutCard(cardArr, laiziRepCds, curRule); }
/// <summary> /// 发送出牌消息 /// </summary> /// <param name="handCardArr"></param> private void SendOutCdsRequest(int[] handCardArr) { //Debug.Log("<color=#0021FFFF>" + "发送出牌消息发送出牌消息发送出牌消息发送出牌消息发送出牌消息发送出牌消息" + "</color>"); //赖子代表的牌 var laiziRepCds = new int[] { -1 }; //类型 int curRule = -1; var type = PokerRuleUtil.GetCdsType(handCardArr); if (type != CardType.None && type != CardType.Exception) { curRule = (int)type; } else { curRule = (int)CheckCanOutCdsOneTime(new CdSplitStruct(handCardArr)); } GlobalData.ServInstance.ThrowOutCard(handCardArr, laiziRepCds, curRule); }
/// <summary> /// 有人出牌时,检查是否有炸弹火箭等,从而显示加倍 /// </summary> /// <param name="args"></param> private void OnTypeOutCard(DdzbaseEventArgs args) { var data = args.IsfObjData; var cards = data.GetIntArray(RequestKey.KeyCards); cards = HdCdsCtrl.SortCds(cards); var cdsType = PokerRuleUtil.GetCdsType(cards); if (cdsType == CardType.C4 || cdsType == CardType.C42 || cdsType == CardType.C5) { try { int mul = 2; //var curbeishu = int.Parse(BeiShuLabel.text); _beishu *= mul; BeiShuAnimAtion(mul); BeiShuLabel.text = _beishu.ToString(CultureInfo.InvariantCulture); } catch (Exception e) { YxDebug.LogError("BeiShuLabel有问题:" + e.Message); } } }
/// <summary> /// 先根据牌型进行声音名称的筛选 /// </summary> /// <param name="cards"></param> /// <param name="cardType"></param> /// <returns></returns> public static string GetAudioNameBytypeFirst(int[] cards, int cardType = -1) { CardType cdType; if (cardType == -1) { cdType = PokerRuleUtil.GetCdsType(cards); } else { cdType = (CardType)cardType; } var str = new string[cards.Length]; for (int i = 0; i < cards.Length; i++) { str[i] = cards[i].ToString("x").Substring(1, 1); } System.Array.Sort(str); switch (cards.Length) { case 1: if (cards[0] == 81) { return("xiaowang"); } if (cards[0] == 97) { return("dawang"); } return(str[0]); case 2: if (cards[0] == 97 || cards[1] == 97 || cards[0] == 81 || cards[1] == 81) { return("huojian"); } if (str[0] == str[1] || HaveMagic(cards)) { if (HaveMagic(cards)) { return("1dui" + str[1]); } return("1dui" + str[0]); } else { return("huojian"); } case 3: return("3zhang" + str[1]); case 4: if (cardType == (int)CardType.C1122) { return("shuangshun"); } if (HaveMagic(cards)) { if (str[1] == str[2] && str[2] == str[3]) { return("zhadan"); } } if (str[0] != str[3]) { return("3dai1"); } return("zhadan"); case 5: if (HaveMagic(cards)) { if (str[1] == str[2] && str[2] == str[3] && str[3] == str[4]) { return("zhadan"); } } if (str[0] != str[1] && str[2] != str[3]) { return("shunzi"); } bool cod0 = cardType == (int)CardType.C32; bool cod1 = (str[0] == str[1] && str[3] == str[4]); if (cod0 || cod1) { return("3dai2"); } return("4dai1"); case 6: if (str[0] != str[1] && str[1] != str[2] && str[2] != str[3]) { return("shunzi"); } if (str[0] == str[1] && str[2] == str[3] && str[4] == str[5] && str[1] != str[2] && str[3] != str[4]) { return("shuangshun"); } if (str[0] == str[1] && str[1] == str[2] && str[3] == str[4] && str[4] == str[5]) { return("feiji"); } return("4dai2"); case 8: //if (cardType == CardType.C1112223434) if (str[2] == str[3] && str[3] == str[4] && str[4] == str[5]) { return("4dai2dui"); } if (str[4] == str[5] && str[5] == str[6] && str[6] == str[7]) { return("4dai2dui"); } if (str[0] == str[1] && str[1] == str[2] && str[2] == str[3]) { return("4dai2dui"); } if (str[0] == str[1] && str[1] == str[2]) { return(FeijiDaiChibang); } if (str[0] != str[1]) { if (str[1] == str[2] && str[2] == str[3]) { return(FeijiDaiChibang); } } if (str[0] != str[1] && str[1] != str[2]) { if (str[2] == str[3] && str[2] == str[4]) { return(FeijiDaiChibang); } } if (str[0] == str[1] && str[2] == str[3] && str[0] != str[2]) { return("shuangshun"); } return("shunzi"); case 10: if (cdType == CardType.C1112223434) { return(FeijiDaiChibang); } if (str[0] == str[1] && str[1] == str[2]) { return(FeijiDaiChibang); } if (str[1] != str[2]) { if (str[2] == str[3] && str[2] == str[4]) { return(FeijiDaiChibang); } } if (str[7] == str[8] && str[7] == str[9]) { return(FeijiDaiChibang); } if (str[0] == str[1]) { return("shuangshun"); } return("shunzi"); default: if (str.Length % 2 == 0) { if (str[0] == str[1]) { return("shuangshun"); } else { return("shunzi"); } } else { if (str[0] == str[1] && str[0] == str[2]) { return("sanshun"); } else { return("shunzi"); } } } }
/// <summary> /// 检查出的牌,播放相应的粒子特效 /// </summary> /// <param name="outCds">已经排序好的扑克</param> private void CheckPartiCalPlay(int[] outCds) { CheckPartiCalPlay(PokerRuleUtil.GetCdsType(outCds)); }
/// <summary> /// 当玩家有对手牌进行点击操作时 /// </summary> /// <param name="args"></param> private void OnHdCdsCtrlEvent(HdCdCtrlEvtArgs args) { //如果不该自己行动 if (!_isMyTurn) { return; } //如果没有选牌 if (args.SelectedCds.Length == 0) { if (ChuPaiBtn.activeSelf) { SetBtnState(ChuPaiBtn, false); } _onoffIchosecCds = true; return; } var selectedCds = args.SelectedCds; var lastOutCds = _lastOutData.GetIntArray(RequestKey.KeyCards); //-----------------------start 智能选牌过程-------有赖子,或者开关关闭则不用智能选牌---------------------------- bool isgetcdsWithoutCompare = false; //标记是不是在自己出动出牌时做出的智能选牌 int[] mayOutCds = null; bool selCdshasLaizi = PokerRuleUtil.CheckHaslz(selectedCds); if (!selCdshasLaizi && _onoffIchosecCds) { if (_lastOutData.GetInt(RequestKey.KeySeat) == App.GetGameData <DdzGameData>().SelfSeat) { mayOutCds = _checkCardTool.GetcdsWithOutCompare(selectedCds, HdCdsListTemp.ToArray()); isgetcdsWithoutCompare = true; } else { SetBtnActive(BuYaoBtn, true); mayOutCds = _checkCardTool.ChkCanoutCdListWithLastCdList(selectedCds, _cardManager.GetTishiGroupDic, lastOutCds); } } //---------------------------------------------------------------------------------------end /* //---start---------------使智能选牌出了相同的牌型,不重复执行----------------------- * var haschosemayOutCds = DDzUtil.IsTwoArrayEqual(HdCdsCtrl.SortCds(_mayoutCdsTemp), HdCdsCtrl.SortCds(mayOutCds)); * _mayoutCdsTemp = mayOutCds; * //如果上次智能选牌和本次相同,则直接取消一次智能选牌 * if (haschosemayOutCds) * { * mayOutCds = null; * } * //----------------------------------------------------------------------------------end*/ if (mayOutCds == null || mayOutCds.Length == 0) { bool isMatch; //如果_lastOutData不是自己出牌 if (_lastOutData.GetInt(RequestKey.KeySeat) != App.GetGameData <DdzGameData>().SelfSeat) { var lastoutcds = new List <int>(); if (lastOutCds != null) { lastoutcds.AddRange(lastOutCds); } var cardTypeDic = _cardManager.GetAutoCardsList(selectedCds, selCdshasLaizi, lastoutcds.ToArray()); isMatch = cardTypeDic != null && cardTypeDic.Count > 0; } else { var cardTypeDic = _cardManager.GetAutoCardsList(selectedCds, selCdshasLaizi, null); isMatch = cardTypeDic != null && cardTypeDic.Count > 0; } if (isMatch) { HdCdctrlInstance.UpCdList(selectedCds); } else { if (ChuPaiBtn.activeSelf) { SetBtnState(ChuPaiBtn, false); } //DDzUtil.DisableBtn(ChuPaiBtn, DisChuPaiBtn); return; } } else { if (!ChooseMayOutCards(mayOutCds, selectedCds)) //如果选中的牌不能出 { if (ChuPaiBtn.activeSelf) { SetBtnState(ChuPaiBtn, false); } return; } } //经过智能检索后最后检查一遍抬出的牌是否合法----start--- var finalType = PokerRuleUtil.GetCdsType(HdCdctrlInstance.GetUpCdList().ToArray()); SetBtnState(ChuPaiBtn, true); //DDzUtil.ActiveBtn(ChuPaiBtn, DisChuPaiBtn); if (finalType != CardType.None && finalType != CardType.Exception) { //如果选出的牌型不是那种单牌,或者对子的小牌型,就先关闭智能选牌 if (isgetcdsWithoutCompare && finalType != CardType.C1 && finalType != CardType.C2) { _onoffIchosecCds = false; } else if (!isgetcdsWithoutCompare) { _onoffIchosecCds = false; } } //------------end }