/// <summary> /// 检测能否出牌 /// </summary> /// <param name="toPokers"></param> /// <returns></returns> public bool CheckCanPlayPoker(List <Poker> toPokers) { if (toPokers == null) { return(false); } Debug.Log("检测能否出牌:"); for (int i = 0; i < toPokers.Count; i++) { Debug.Log("检测能否出牌:" + toPokers[i].ToChinese()); } if (PlayerSeat.CheckThree()) { if (!PaoDeKuaiHelper.CheckThree(toPokers)) { Debug.Log("第一手出的牌必须带有黑桃3"); return(false); } } //检测 CombinationPokersEntity combinationPokers = new CombinationPokersEntity(PlayerSeat.Pos, toPokers, PokersType.None, 0); PaoDeKuaiHelper.CheckPokerType(combinationPokers); Debug.Log("检测能否出牌:" + combinationPokers.PokersType.ToString()); if (combinationPokers.PokersType == PokersType.None) { return(false); } if (combinationPokers.PokersType == PokersType.Three && PlayerSeat.pokerList.Count > 3) { return(false); } if (CurrentRoom.RecentlyPlayPoker.Pokers.Count == 0) { //没有上家牌 return(true); } else { if (combinationPokers.PokersType == CurrentRoom.RecentlyPlayPoker.PokersType) { return(combinationPokers.CurrSize > CurrentRoom.RecentlyPlayPoker.CurrSize); } else { return(combinationPokers.PokersType == PokersType.Bomb); } } }
public void Execute() { //自动过 if (m_DataEntity.pos == RoomPaoDeKuaiProxy.Instance.PlayerSeat.Pos) { if (RoomPaoDeKuaiProxy.Instance.CurrentRoom.RecentlyPlayPoker.PokersType != PokersType.None) { } RoomPaoDeKuaiProxy.Instance.Currhint.Reset(); PaoDeKuaiHelper.HintPoker(RoomPaoDeKuaiProxy.Instance.Currhint, RoomPaoDeKuaiProxy.Instance.PlayerSeat.pokerList); //判断是否有比上家大的牌 if (RoomPaoDeKuaiProxy.Instance.Currhint.CurrHint.PokersType == PokersType.None) { //RoomPaoDeKuaiProxy.Instance.Currhint.Reset(); //过 PaoDeKuaiGameCtrl.Instance.ClientSendPass(); return; } } RoomPaoDeKuaiProxy.Instance.NoticeSeatOperate(m_DataEntity); if (PaoDeKuaiSceneCtrl.Instance != null) { PaoDeKuaiSceneCtrl.Instance.SeatOperateNotice(m_DataEntity.pos); } }
/// <summary> /// 出牌 /// </summary> /// <param name="proto"></param> public PokersType PlayPoker(PDK_OPERATE proto) { SeatEntity seat = GetSeatBySeatPos(proto.pos); if (seat == null) { return(PokersType.None); } CurrentRoom.OperateSeat = null; CurrentRoom.CurrAlreadyPlayPos = proto.pos; //CurrentRoom.RecentlyPlayPoker.Reset(); //CurrentRoom.CurrPlayPoker.Clear(); seat.Status = SeatEntity.SeatStatus.Wait; List <Poker> playPoker = new List <Poker>(); List <POKER_INFO> prPlayPokers = proto.getPokerInfoList(); for (int i = 0; i < prPlayPokers.Count; i++) { for (int j = 0; j < seat.pokerList.Count; ++j) { if (prPlayPokers[i].index == seat.pokerList[j].index) { seat.pokerList[j].SetPaker(prPlayPokers[i].size, prPlayPokers[i].color); playPoker.Add(seat.pokerList[j]); CurrentRoom.HistoryPoker.Add(seat.pokerList[j]);//已出牌 //CurrentRoom.CurrPlayPoker.Add(seat.pokerList[j]); seat.pokerList.RemoveAt(j); break; } } } PaoDeKuaiHelper.Sort(playPoker); CurrentRoom.RecentlyPlayPoker = new CombinationPokersEntity(proto.pos, playPoker, PokersType.None, 0); PaoDeKuaiHelper.CheckPokerType(CurrentRoom.RecentlyPlayPoker); Debug.Log(string.Format("出牌玩家:{0} 检测牌型:{1}", seat.PlayerId, CurrentRoom.RecentlyPlayPoker.PokersType.ToString())); //是自己出牌 Currhint.Reset(); if (proto.pos == PlayerSeat.Pos) { //清空上家牌 Currhint.Others.Reset(); } else { Currhint.Others = CurrentRoom.RecentlyPlayPoker; } if (seat == PlayerSeat) { SendOperateStateChangeNotify(seat); } SendSeatInfoChangeNotify(seat); SetCountDown(0, seat == PlayerSeat, seat.Index, true); HistoryPokerChanged(); return(CurrentRoom.RecentlyPlayPoker.PokersType); }
public CombinationPokersEntity(int pos, List <Poker> pokers, PokersType pokersType, int size) { this.m_Pos = pos; this.m_pokers = pokers; this.m_pokersType = pokersType; m_currSize = size; if (pokers != null && pokers.Count > 0) { PaoDeKuaiHelper.Sort(pokers); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.A)) { PaoDeKuaiHelper.HintPoker(hint, m_HandPoksers); Debug.Log("当前提示级别" + hint.CurrHintLevel.ToString()); Debug.Log("当前期望提示级别" + hint.ExpectHintLevel.ToString()); Debug.Log("提示牌型:" + hint.CurrHint.PokersType.ToString()); Debug.Log("提示大小:" + hint.CurrHint.CurrSize); Debug.Log("提示牌:"); for (int i = 0; i < hint.CurrHint.Pokers.Count; i++) { Debug.Log(hint.CurrHint.Pokers[i].ToChinese()); } } }
HintPokersEntity hint;//提示实体 // Use this for initialization void Start() { CreatePoker(); List <Poker> othersPokers = CreateOthers(); m_HandPoksers = CreateHandPoksers(); CombinationPokersEntity m_others = new CombinationPokersEntity(3, othersPokers, PokersType.None, 0);//上家出的牌 PaoDeKuaiHelper.CheckPokerType(m_others); Debug.Log(string.Format("测试的上家牌型为{0} 大小为{1}", m_others.PokersType, m_others.CurrSize)); hint = new HintPokersEntity(m_others); }
/// <summary> /// 提示 /// </summary> /// <returns></returns> public List <Poker> CheakHint() { //List<Poker> pokerList = PaoDeKuaiHelper.CopyPokerList(PlayerSeat.pokerList); PaoDeKuaiHelper.HintPoker(Currhint, PlayerSeat.pokerList); Debug.Log("本次提示牌:"); List <Poker> pokers = Currhint.CurrHint.Pokers; if (pokers != null) { for (int i = 0; i < pokers.Count; ++i) { Debug.Log(pokers[i].ToChinese()); } } return(Currhint.CurrHint.Pokers); }
//结束选牌 private void EndSelectedPoker() { for (int i = 0; i < m_CurrSelectedPoker.Count; ++i) { m_CurrSelectedPoker[i].SetSelected(false); } List <Poker> selectedPoker = new List <Poker>(); for (int i = 0; i < m_CurrSelectedPoker.Count; ++i) { selectedPoker.Add(m_CurrSelectedPoker[i].Poker); } List <Poker> straightInSelected = PaoDeKuaiHelper.GetPokersInStraight(selectedPoker); List <PokerCtrl> playerSeatPoker = PrefabManager.Instance.GetHand(RoomPaoDeKuaiProxy.Instance.PlayerSeat.Pos); if (straightInSelected != null) { for (int i = 0; i < playerSeatPoker.Count; ++i) { playerSeatPoker[i].SetHold(PaoDeKuaiHelper.PokerIsInList(playerSeatPoker[i].Poker, straightInSelected)); } } else { for (int i = 0; i < m_CurrSelectedPoker.Count; ++i) { m_CurrSelectedPoker[i].SetHold(); } } ResetDragPoker(); for (int i = 0; i < playerSeatPoker.Count; ++i) { if (playerSeatPoker[i].IsHold) { m_CurrLiftUpPoker.Add(playerSeatPoker[i].Poker); } } }
/// <summary> /// 开局发牌 /// </summary> public void Begin(PDK_BEGIN proto) { ++CurrentRoom.currentLoop; //黑桃3的座位 CurrentRoom.SpadesThreePos = proto.pos; List <SEAT_INFO> protoSeatList = proto.getSeatInfoList(); for (int i = 0; i < protoSeatList.Count; ++i) { SeatEntity seat = GetSeatBySeatPos(protoSeatList[i].pos); if (seat == null) { continue; } Debug.Log(string.Format("Pos:{0} Count:{1}", seat.Pos, protoSeatList[i].getPokerInfoList().Count)); seat.HandPockerNum = protoSeatList[i].HandPocker; ResetSeat(seat); seat.Status = proto.pos == seat.Pos ? SeatEntity.SeatStatus.Operate : SeatEntity.SeatStatus.Wait; List <POKER_INFO> prPokerList = protoSeatList[i].getPokerInfoList(); Debug.Log("发牌位置" + seat.Pos); //手牌 for (int j = 0; j < prPokerList.Count; ++j) { Debug.Log(string.Format("index:{0} size:{1} color:{2}", prPokerList[j].index, prPokerList[j].size, prPokerList[j].color)); seat.pokerList.Add(new Poker(prPokerList[j].index, prPokerList[j].size, prPokerList[j].color)); } PaoDeKuaiHelper.Sort(seat.pokerList); } CurrentRoom.Status = RoomEntity.RoomStatus.Begin; SendRoomInfoChangeNotify(); }
/// <summary> /// 排序手牌 /// </summary> /// <param name="seatPos"></param> public void SortHandPokers(int seatPos) { List <PokerCtrl> lst = GetHand(seatPos); //MahJongManager if (lst == null || lst.Count == 0 || lst[0].Poker.size == 0) { return; } string temp = "排序后的手牌为:"; for (int i = 0; i < lst.Count; ++i) { temp += lst[i].Poker.ToString() + " "; } List <Poker> pokers = new List <Poker>(); for (int i = 0; i < lst.Count; ++i) { pokers.Add(lst[i].Poker); } PaoDeKuaiHelper.Sort(pokers); for (int i = 0; i < pokers.Count; ++i) { for (int j = lst.Count - 1; j >= 0; --j) { if (lst[j].Poker == pokers[i]) { PokerCtrl poker = lst[j]; lst.Remove(poker); lst.Insert(i, poker); break; } } } }
///// <summary> ///// 当前游戏状态 ///// </summary> //public MahjongGameState CurrentState; ///// <summary> ///// 游戏规则 ///// </summary> //public MahjongRule Rule; #endregion #region InitRoom 初始化房间数据 public void InitRoom(ROOM_INFO protoRoom) { //ROOM_INFO protoRoom = proto.roomInfo; CurrentRoom = new RoomEntity() { //BaseScore = proto.baseScore, roomId = protoRoom.roomId, ownerId = protoRoom.ownerId, currentLoop = protoRoom.loop, //matchId = protoRoom.matchId,//比赛场ID Status = (RoomEntity.RoomStatus)protoRoom.roomStatus, maxLoop = protoRoom.maxLoop, DisbandStartTime = protoRoom.dismissTime, DisbandTime = protoRoom.dismissMaxTime, DisbandTimeMax = (int)(protoRoom.dismissMaxTime - protoRoom.dismissTime), }; CurrentRoom.HistoryPoker = new List <Poker>(); CurrentRoom.SeatList = new List <SeatEntity>(); //收到数据存到模型基类 CurrentRoom.Config.Clear(); for (int i = 0; i < protoRoom.settingIdCount(); ++i) { cfg_settingEntity settingEntity = cfg_settingDBModel.Instance.Get(protoRoom.getSettingId(i)); if (settingEntity != null) { CurrentRoom.Config.Add(settingEntity); } } //获得当前游戏模式 for (int i = 0; i < CurrentRoom.Config.Count; i++) { if (CurrentRoom.Config[i].tags.Equals("mode")) { //CurrentRoom.roomModel = (Room.RoomModel)CurrentRoom.Config[i].value; } } for (int i = 0; i < CurrentRoom.Config.Count; i++) { if (CurrentRoom.Config[i].tags.Equals("roomMode")) { //CurrentRoom.superModel = (Room.SuperModel)CurrentRoom.Config[i].value; //Debug.Log("服务器发送的房间 普通高级场模式为为:" + CurrentRoom.Config[i].value); } } Debug.Log("房间ID为:" + protoRoom.roomId); Debug.Log("服务器发送的房间座位长度为:" + protoRoom.getSeatInfoList().Count); CurrentRoom.SeatCount = protoRoom.getSeatInfoList().Count; CurrentRoom.SeatList = new List <SeatEntity>(); for (int i = 0; i < CurrentRoom.SeatCount; ++i) { SEAT_INFO protoSeat = protoRoom.getSeatInfo(i); SeatEntity seat = new SeatEntity(); //是否同意解散 if (protoSeat.hasSeatStatus()) { seat.DisbandState = (DisbandState)protoSeat.dismiss_status; } //庄 //seat.IsBanker = protoSeat.isBanker; //玩家ID seat.PlayerId = protoSeat.playerId; //房主 seat.isLandlord = seat.PlayerId == protoRoom.ownerId; //pos seat.Pos = protoSeat.pos; //昵称 seat.Nickname = protoSeat.nickname; //头像 seat.Avatar = protoSeat.avatar; //性别 seat.Gender = protoSeat.gender; //是否准备 seat.IsReady = protoSeat.isReady; //已有金币 seat.Gold = protoSeat.gold; //座位状态 seat.Status = (SeatEntity.SeatStatus)protoSeat.seatStatus; ////本局收益 //seat.Earnings = protoSeat.nn_earnings; ////是否是胜利者 //seat.Winner = protoSeat.isWiner; ////纬度 //if (protoSeat.hasLatitude()) seat.Latitude = protoSeat.latitude; ////经度 //if (protoSeat.hasLongitude()) seat.Longitude = protoSeat.longitude; //手牌类型 seat.pokerList = new List <Poker>(); //具体手牌 if (protoSeat.hasPokerInfo()) { List <POKER_INFO> prPokerList = protoSeat.getPokerInfoList(); Debug.Log("prPokerList:" + prPokerList.Count); for (int j = 0; j < prPokerList.Count; ++j) { seat.pokerList.Add(new Poker(prPokerList[j].index, prPokerList[j].size, prPokerList[j].color)); } seat.HandPockerNum = prPokerList.Count; } CurrentRoom.SeatList.Add(seat); if (seat.Status == SeatEntity.SeatStatus.Operate) { CurrentRoom.OperateSeat = seat; } } CalculateSeatIndex(); //上家出牌 List <Poker> recentlyPlayPoker = new List <Poker>(); List <POKER_INFO> leftPoker = new List <POKER_INFO>(); if (protoRoom.hasLeftPoker()) { leftPoker = protoRoom.leftPoker.getPokerInfoList(); } for (int i = 0; i < leftPoker.Count; ++i) { recentlyPlayPoker.Add(new Poker(leftPoker[i].index, leftPoker[i].size, leftPoker[i].color)); } int leftPokerPos = protoRoom.hasLeftPoker() ? protoRoom.leftPoker.pos : 0; CurrentRoom.CurrAlreadyPlayPos = leftPokerPos; CurrentRoom.RecentlyPlayPoker = new CombinationPokersEntity(leftPokerPos, recentlyPlayPoker, PokersType.None, 0); PaoDeKuaiHelper.CheckPokerType(CurrentRoom.RecentlyPlayPoker); Currhint = new HintPokersEntity(CurrentRoom.RecentlyPlayPoker); SeatEntity leftseat = GetSeatBySeatPos(leftPokerPos); if (leftseat != null) { if (recentlyPlayPoker.Count > 0) { leftseat.pokerList.AddRange(recentlyPlayPoker); } } SetSeatPass(CurrentRoom.RecentlyPlayPoker.Pos, CurrentRoom.OperateSeat); //if (proto.nn_room.hasUnixtime()) //{ // CurrentRoom.serverTime = proto.nn_room.unixtime;//(时间戳) //} }