Exemple #1
0
        /// <summary>
        /// 计算碰杠牌操作权重
        /// </summary>
        /// <param name="actPowerVO">权重VO</param>
        /// <param name="copyCanPutCards">可出的牌数组</param>
        /// <param name="passAddPower">是否增加过操作权重</param>
        private void CalculatePengGangPower(ActPowerVO actPowerVO, List <int> canPutCards, out bool passAddPower)
        {
            passAddPower = false;
            List <int> copyCanPutCards = new List <int>(canPutCards);

            copyCanPutCards.Remove(actPowerVO.actCard);
            copyCanPutCards.Remove(actPowerVO.actCard);
            copyCanPutCards.Remove(actPowerVO.actCard);
            copyCanPutCards.Remove(actPowerVO.actCard);
            copyCanPutCards.Sort();
            bool hasDouble = false;

            for (int i = 0; i < copyCanPutCards.Count; i++)
            {
                if (i > 0 && copyCanPutCards[i] == copyCanPutCards[i - 1])
                {
                    hasDouble = true;
                    break;
                }
            }
            if (hasDouble)
            {
                actPowerVO.power += 1000;
            }
            else
            {
                passAddPower = true;
            }
        }
Exemple #2
0
 /// <summary>
 /// 第一操作响应
 /// </summary>
 /// <param name="actPowerVO"></param>
 private void FirstActHandler(ActPowerVO actPowerVO)
 {
     if (actPowerVO.act == PlayerActType.PASS)
     {
         var actC2S = new GuoC2S();
         NetMgr.Instance.SendBuff(SocketType.BATTLE, MsgNoC2S.C2S_ROOM_PASS.GetHashCode(), 0, actC2S);
         chiPowerArr = null;
     }
     else if (actPowerVO.act == PlayerActType.PENG)
     {
         var actC2S = new PengC2S();
         actC2S.mahjongCode = actPowerVO.actCard;
         NetMgr.Instance.SendBuff(SocketType.BATTLE, MsgNoC2S.C2S_ROOM_PENG.GetHashCode(), 0, actC2S);
         chiPowerArr = null;
     }
     else if (actPowerVO.act == PlayerActType.CHI)
     {
         var actC2S = new ChiC2S();
         actC2S.mahjongCodes.AddRange(chiPowerArr[0].chiCards);
         actC2S.mahjongCodes.Add(chiPowerArr[0].chiCard);
         actC2S.forbitCards.AddRange(chiPowerArr[0].forbitCards);
         NetMgr.Instance.SendBuff(SocketType.BATTLE, MsgNoC2S.C2S_ROOM_PENG.GetHashCode(), 0, actC2S);
     }
     else if (actPowerVO.act == PlayerActType.SELF_HU)
     {
         var actC2S = new ZiMoHuC2S();
         NetMgr.Instance.SendBuff(SocketType.BATTLE, MsgNoC2S.C2S_ROOM_ZI_MO_HU.GetHashCode(), 0, actC2S);
         chiPowerArr = null;
     }
     else if (actPowerVO.act == PlayerActType.QIANG_AN_GANG_HU)
     {
         var actC2S = new QiangAnGangHuC2S();
         NetMgr.Instance.SendBuff(SocketType.BATTLE, MsgNoC2S.C2S_ROOM_QIANG_AN_GANG_HU.GetHashCode(), 0, actC2S);
         chiPowerArr = null;
     }
     else if (actPowerVO.act == PlayerActType.QIANG_PENG_GANG_HU)
     {
         var actC2S = new QiangPengGangHuC2S();
         NetMgr.Instance.SendBuff(SocketType.BATTLE, MsgNoC2S.C2S_ROOM_QIANG_PENG_GANG_HU.GetHashCode(), 0, actC2S);
         chiPowerArr = null;
     }
     else if (actPowerVO.act == PlayerActType.QIANG_ZHI_GANG_HU)
     {
         var actC2S = new QiangZhiGangHuC2S();
         NetMgr.Instance.SendBuff(SocketType.BATTLE, MsgNoC2S.C2S_ROOM_QIANG_ZHI_GANG_HU.GetHashCode(), 0, actC2S);
         chiPowerArr = null;
     }
     else if (actPowerVO.act == PlayerActType.CHI_HU)
     {
         var actC2S = new ChiHuC2S();
         NetMgr.Instance.SendBuff(SocketType.BATTLE, MsgNoC2S.C2S_ROOM_CHI_HU.GetHashCode(), 0, actC2S);
         chiPowerArr = null;
     }
     else if (actPowerVO.act == PlayerActType.COMMON_AN_GANG)
     {
         var actC2S = new CommonAnGangC2S();
         actC2S.mahjongCode = actPowerVO.actCard;
         NetMgr.Instance.SendBuff(SocketType.BATTLE, MsgNoC2S.C2S_ROOM_COMMON_AN_GANG.GetHashCode(), 0, actC2S);
         chiPowerArr = null;
     }
     else if (actPowerVO.act == PlayerActType.BACK_AN_GANG)
     {
         var actC2S = new BackAnGangC2S();
         actC2S.mahjongCode = actPowerVO.actCard;
         NetMgr.Instance.SendBuff(SocketType.BATTLE, MsgNoC2S.C2S_ROOM_BACK_AN_GANG.GetHashCode(), 0, actC2S);
         chiPowerArr = null;
     }
     else if (actPowerVO.act == PlayerActType.ZHI_GANG)
     {
         var actC2S = new ZhiGangC2S();
         actC2S.mahjongCode = actPowerVO.actCard;
         NetMgr.Instance.SendBuff(SocketType.BATTLE, MsgNoC2S.C2S_ROOM_ZHI_GANG.GetHashCode(), 0, actC2S);
         chiPowerArr = null;
     }
     else if (actPowerVO.act == PlayerActType.COMMON_PENG_GANG)
     {
         var actC2S = new CommonPengGangC2S();
         actC2S.mahjongCode = actPowerVO.actCard;
         NetMgr.Instance.SendBuff(SocketType.BATTLE, MsgNoC2S.C2S_ROOM_COMMON_PENG_GANG.GetHashCode(), 0, actC2S);
         chiPowerArr = null;
     }
     else if (actPowerVO.act == PlayerActType.BACK_PENG_GANG)
     {
         var actC2S = new BackPengGangC2S();
         actC2S.mahjongCode = actPowerVO.actCard;
         NetMgr.Instance.SendBuff(SocketType.BATTLE, MsgNoC2S.C2S_ROOM_BACK_PENG_GANG.GetHashCode(), 0, actC2S);
         chiPowerArr = null;
     }
 }
Exemple #3
0
        /// <summary>
        /// 计算吃操作的权重
        /// </summary>
        /// <param name="actPowerVO">权重VO</param>
        /// <param name="canPutCards">可出的牌数组</param>
        /// <param name="passAddPower">是否增加过操作权重</param>
        private void CalculateChiPower(ActPowerVO actPowerVO, List <int> canPutCards, out bool passAddPower)
        {
            List <List <int> > chiSelectArr = BattleAreaUtil.GetCanChiArr(actPowerVO.actCard);

            chiPowerArr = new List <ChiPowerVO>();
            for (int i = 0; i < chiSelectArr.Count; i++)
            {
                var        copyCanPutCards = new List <int>(canPutCards);
                List <int> forbitCards     = new List <int>();

                if (chiSelectArr[i][0] == actPowerVO.actCard + 1)
                {
                    if (Array.IndexOf(GlobalData.CardValues, actPowerVO.actCard + 3) != -1)
                    {
                        forbitCards.Add(actPowerVO.actCard + 3);
                    }
                }
                else if (chiSelectArr[i][0] == actPowerVO.actCard - 2)
                {
                    if (Array.IndexOf(GlobalData.CardValues, actPowerVO.actCard - 3) != -1)
                    {
                        forbitCards.Add(actPowerVO.actCard - 3);
                    }
                }
                ChiPowerVO addChiPowerVO = new ChiPowerVO(chiSelectArr[i], actPowerVO.actCard, forbitCards, 0);
                chiPowerArr.Add(addChiPowerVO);
                bool isBreakCard = false;
                for (int j = 0; j < chiSelectArr[i].Count; j++)
                {
                    List <int> listFind = copyCanPutCards.FindAll(delegate(int s) {
                        return(s == chiSelectArr[i][j]);
                    });
                    if (listFind.Count > 1)//需要拆对
                    {
                        isBreakCard = true;
                    }
                }
                if (!isBreakCard)
                {
                    addChiPowerVO.power += 1000;
                }

                for (int j = 0; j < chiSelectArr[i].Count; j++)
                {
                    copyCanPutCards.Remove(chiSelectArr[i][j]);
                }
                bool hasDouble = false;
                for (int j = 0; j < copyCanPutCards.Count; j++)
                {
                    if (j > 0 && copyCanPutCards[j] == copyCanPutCards[j - 1])
                    {
                        hasDouble = true;
                        break;
                    }
                }
                if (hasDouble)
                {
                    addChiPowerVO.power += 1000;
                }
            }
            chiPowerArr.Sort((ChiPowerVO chiPowerVO1, ChiPowerVO chiPowerVO2) =>
            {
                if (chiPowerVO1.power > chiPowerVO2.power)
                {
                    return(-1);
                }
                else
                {
                    return(1);
                }
            });
            if (chiPowerArr[0].power <= 0)
            {
                passAddPower = true;
            }
            else
            {
                passAddPower      = false;
                actPowerVO.power += 50;
            }
        }