Exemplo n.º 1
0
        private void CpgLogic(ISFSObject data)
        {
            mData.SetData(data);
            var cpgData = mData.CpgData;

            //如果是抓杠 改变类型
            if (cpgData.Type == EnGroupType.ZhuaGang)
            {
                CpgZhuaGang cpg = (CpgZhuaGang)cpgData;
                //抓杠时 会有两条数据回来 当消息为true 杠成功了
                if (cpg.Ok == false)
                {
                    return;
                }
                var cpgList = DataCenter.Players[mData.CurrOpChair].CpgDatas;
                for (int i = 0; i < cpgList.Count; i++)
                {
                    var cpgItem = cpgList[i];
                    if (cpgItem.Type == EnGroupType.Peng && cpgItem.Card == cpgData.Card)
                    {
                        cpgList[i] = cpgData;
                        break;
                    }
                }
                if (0 == mData.CurrOpChair && !mData.GangBao)
                {
                    //删除手牌数据
                    DataCenter.Players[mData.CurrOpChair].HardCards.Remove(cpgData.Card);
                }
            }
            else if (cpgData.Type == EnGroupType.AnGang && mData.GangBao)
            {
                if (0 == mData.CurrOpChair)
                {
                    int temp     = 0;
                    var tempList = cpgData.GetHardCards();
                    for (int i = 0; i < tempList.Count - 1; i++)
                    {
                        DataCenter.OneselfData.HardCards.Remove(tempList[i]);
                        temp++;
                    }
                }
            }
            else
            {
                //删除手牌数据
                if (0 == mData.CurrOpChair)
                {
                    var list = cpgData.GetHardCards();
                    for (int i = 0; i < list.Count; i++)
                    {
                        DataCenter.Players[mData.CurrOpChair].HardCards.Remove(list[i]);
                    }
                }
            }
            MahjongGroupsManager group = Game.MahjongGroups;

            //抓杠是特殊的 如果放回的消息ok 为false 证明正在确认是否有抢杠胡 为ture时表示 杠成功了
            if (cpgData.Type == EnGroupType.ZhuaGang)
            {
                CpgZhuaGang zhuanggang = (CpgZhuaGang)cpgData;
                if (!zhuanggang.Ok)
                {
                    group.PlayerToken = false;
                }
                else
                {
                    //如果是抓杠 移除手牌中抓的
                    group.MahjongHandWall[mData.CurrOpChair].RemoveMahjong(cpgData.Card);
                    //设置吃碰杠
                    group.MahjongCpgs[mData.CurrOpChair].SetCpg(cpgData);
                }
            }
            else
            {
                group.MahjongHandWall[mData.CurrOpChair].RemoveMahjong(cpgData.GetHardCards());
            }
            //如果是别人打出的牌
            if (cpgData.GetOutPutCard() != MiscUtility.DefValue)
            {
                group.MahjongThrow[mData.OldOpChair].PopMahjong(cpgData.Card);
                //隐藏箭头
                Game.TableManager.GetParts <MahjongOutCardFlag>(TablePartsType.OutCardFlag).Hide();
            }
            //排序麻将
            if (mData.CurrOpChair == 0)
            {
                group.PlayerHand.SortHandMahjong();
            }
            group.MahjongCpgs[mData.CurrOpChair].SetCpg(cpgData);
            //如果吃碰杠之后 cpg 加 手牌数量 大于 手牌数量 需要打牌设置最后一张
            if (group.MahjongCpgs[mData.CurrOpChair].GetHardMjCnt() + group.MahjongHandWall[mData.CurrOpChair].MahjongList.Count > DataCenter.Config.HandCardCount)
            {
                group.MahjongHandWall[mData.CurrOpChair].SetLastCardPos(MiscUtility.DefValue);
            }
            //麻将记录
            RecordMahjong(cpgData);
        }
Exemplo n.º 2
0
        public static CpgData CreateCpg(ISFSObject data)
        {
            CpgData     ret  = null;
            EnGroupType type = EnGroupType.None;

            if (data.ContainsKey(ProtocolKey.KeyTType))
            {
                type = (EnGroupType)(data.GetInt(ProtocolKey.KeyTType));
            }
            else if (data.ContainsKey(RequestKey.KeyType))
            {
                type = (EnGroupType)(data.GetInt(RequestKey.KeyType));
            }
            switch (type)
            {
            case EnGroupType.Chi:
                ret = new CpgChi();
                break;

            case EnGroupType.JueGang:
            case EnGroupType.Peng:
                ret = new CpgPeng();
                break;

            case EnGroupType.ZhuaGang:
                ret = new CpgZhuaGang();
                break;

            case EnGroupType.MingGang:
            case EnGroupType.AnGang:
            {
                if (data.ContainsKey("bao"))
                {
                    ret = new CpgSelfGangBao();
                }
                else
                {
                    ret = new CpgSelfGang();
                }
            }
            break;

            case EnGroupType.PengGang:
                ret = new CpgOtherGang();
                break;

            case EnGroupType.XFGang:
            case (EnGroupType)NetworkProtocol.MJRequestTypeXFG:
                ret = new CpgXFGang();
                break;

            case EnGroupType.XFDan:
            case EnGroupType.ZFBDan:
            case EnGroupType.YaoDan:
            case EnGroupType.JiuDan:
                ret = new CpgXfdGang();
                break;

            case EnGroupType.AnJueGang:
                ret = new CpgAnJueGang();
                break;
            }
            ret.ParseData(data);
            return(ret);
        }