Exemplo n.º 1
0
 //玩家碰 明杠 暗杠
 public static bool PengOrMingGangOrAnGang(this FiveStarPlayer fiveStarPlayer, int card, int count, int operateType)
 {
     if (fiveStarPlayer.RemoveCardCount(card, count))
     {
         FiveStarOperateInfo fiveStarOperateInfo = FiveStarOperateInfoFactory.Create(card, operateType,
                                                                                     fiveStarPlayer.FiveStarRoom.CurrChuPaiIndex);
         fiveStarPlayer.OperateInfos.Add(fiveStarOperateInfo);
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        //托管的默认操作
        public static void CollocationAIOperate(this FiveStarPlayer fiveStarPlayer)
        {
            if (fiveStarPlayer.FiveStarRoom.CurrRoomStateType == RoomStateType.GameIn)
            {
                fiveStarPlayer.boolData = true;
                if (fiveStarPlayer.FiveStarRoom.IsDaPiaoBeing && (!fiveStarPlayer.IsAlreadyDaPiao)) //如果在打漂中 并且自己没有打漂就打漂
                {
                    if (fiveStarPlayer.IsAI)                                                        //如果是AI就随便漂
                    {
                        fiveStarPlayer.DaPiao(
                            RandomTool.Random(0, fiveStarPlayer.FiveStarRoom.RoomConfig.MaxPiaoNum + 1)); //随机打漂
                    }
                    else
                    {
                        fiveStarPlayer.DaPiao(0); //默认是不漂
                    }
                }
                else if (fiveStarPlayer.IsCanPlayCard)                                                   //如果可以出牌 直接出 最后摸到的牌
                {
                    if (fiveStarPlayer.IsAI)                                                             //如果是AI出牌 保留手牌中有多张相同的
                    {
                        fiveStarPlayer.Hands.Sort();                                                     //手牌排序
                        fiveStarPlayer.intData = fiveStarPlayer.Hands.IndexOf(fiveStarPlayer.MoEndHand); //获取摸到的牌 首次出现的位置

                        if (fiveStarPlayer.intData < fiveStarPlayer.Hands.Count - 2 && fiveStarPlayer.Hands[fiveStarPlayer.intData + 1] == fiveStarPlayer.MoEndHand)
                        {
                            fiveStarPlayer.AICollcationPlayCard(fiveStarPlayer.Hands[fiveStarPlayer.Hands.Count - 1]); //摸到的牌有相同的 出牌组里最后一张牌
                        }
                        else
                        {
                            fiveStarPlayer.AICollcationPlayCard(fiveStarPlayer.MoEndHand); //没有相同的出摸到的牌
                        }
                    }
                    else
                    {
                        fiveStarPlayer.AICollcationPlayCard(fiveStarPlayer.MoEndHand); //不是AI出牌直接出 最后摸到的牌
                    }
                }
                else if (fiveStarPlayer.FiveStarRoom.CanOperatePlayerIndex.Contains(fiveStarPlayer.SeatIndex)
                         ) //如果玩家可操作索引列表里面有自己 则直接操作
                {
                    FiveStarOperateInfo fiveStarOperateInfo;
                    if (fiveStarPlayer.canOperateLists.Contains(FiveStarOperateType.FangChongHu)) //如果可以胡 就胡
                    {
                        fiveStarOperateInfo = FiveStarOperateInfoFactory.Create(0, FiveStarOperateType.FangChongHu, 0);
                    }
                    else
                    {
                        fiveStarOperateInfo =
                            FiveStarOperateInfoFactory.Create(0, FiveStarOperateType.None, 0); //不能胡就放弃
                    }
                    if (fiveStarPlayer.IsAI)                                                   //如果是AI 就是能碰就碰 能杠就杠 因为发的牌会做特殊手脚
                    {
                        if (fiveStarPlayer.canOperateLists.Contains(FiveStarOperateType.Peng)) //如果可以胡 就胡
                        {
                            fiveStarOperateInfo.OperateType = FiveStarOperateType.Peng;
                        }
                        else if (fiveStarPlayer.canOperateLists.Contains(FiveStarOperateType.MingGang))
                        {
                            //杠牌 不仅需要传递 操作类型 还是传杠那张牌 之前记录亮了
                            foreach (var canGang in fiveStarPlayer.canGangCards)
                            {
                                fiveStarOperateInfo.Card        = canGang.Key;
                                fiveStarOperateInfo.OperateType = canGang.Value;
                            }
                        }
                    }
                    fiveStarPlayer.OperatePengGangHu(fiveStarOperateInfo); //执行操作
                    //不能销毁 fiveStarPlayer 因为多人操作会保留一段时间
                }
                else
                {
                    fiveStarPlayer.boolData = false;
                }
                if (fiveStarPlayer.boolData)
                {
                    fiveStarPlayer.SetCollocation(true); //如果进行了 托管操作 就进入托管
                }
            }
        }