Exemplo n.º 1
0
 public void Deal(int playerId)
 {
     // if (IsChipinClose) {
     if (CurrentStage != EStage.CanChipIning)
     {
         NotifySinglePlayer(WebscoketSendObjs.RoomMessage(playerId, "不是押底阶段,不能发牌!"), playerId);
         return;
     }
     // if (JoinSeats.Count() != InningeGame.NotEmptySeats().Count()) {
     if (JoinSeats.Count() < 2)
     {
         NotifyRoomPlayers(WebscoketSendObjs.RoomMessage(0, "押底人数不足2人,不能发牌"));
         return;
     }
     CheckDateTime = DateTime.Now;
     //  IsChipinClose = true;//?
     PokerManager.Riffile();
     lock (this) {
         for (int i = 0; i < JoinSeats.Count(); i++)
         {
             ThreeCards threeCards = new ThreeCards(PokerManager.TackOut(3));
             JoinSeats[i].Pokers      = threeCards;
             JoinSeats[i].PreChipType = EChipinType.PlayerChipIn;
         }
         CurrentStage = EStage.Running;
     }
     CheckDateTime = DateTime.Now;
     NotifyRoomPlayers(new FreshGameFace(0));
     NotifyRoomPlayers(WebscoketSendObjs.RoomMessage(0, "发牌完毕,庄家开始下注"));
 }
Exemplo n.º 2
0
        public override void AfterPlayerLeave(object inningeGame, EventArgs e)
        {
            var notEmptySeatsCount = ((IInningeGame)inningeGame).NotEmptySeats().Count();

            if (notEmptySeatsCount > 0)
            {
                if (CurrentStage == EStage.Running && JoinSeats.Count() == 1)
                {
                    CompareAll();
                    NotifyRoomPlayers(WebscoketSendObjs.RoomMessage(0, "有玩家要离开,人数不足,自动结算"));
                }
                else if (notEmptySeatsCount == 1)
                {
                    CurrentStage = EStage.CanChipIning;
                    if (JoinSeats.Count() == 1)
                    {
                        var onlySeat = JoinSeats[0];
                        if (onlySeat.IsChipIned)
                        {
                            onlySeat.IsChipIned = false;
                            IsDecutMoneySuccess(onlySeat.IPlayer, -onlySeat.ChipinAmount);
                        }
                        onlySeat.IsGaveUp = false;
                        onlySeat.IsLooked = false;
                        NotifyRoomPlayers(WebscoketSendObjs.RoomMessage(0, "有玩家要离开,人数不足,退还你的押底"));
                    }
                    NotifyRoomPlayers(WebscoketSendObjs.RoomMessage(0, "有玩家要离开,人数不足,取消押底"));
                }
                base.AfterPlayerLeave(inningeGame, e);
                NotifyRoomPlayers(new FreshGameFace(0));
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 轮到下一个玩家表态
 /// </summary>
 private void MoveToNextSeat(decimal amount, bool isLook, int playerId, EChipinType chipinType = EChipinType.Nothing)
 {
     lock (this) {
         PreSeatAmount = amount;
         if (chipinType != EChipinType.GaveUp)
         {
             CurrentSeat.PreChipInAmount = amount;
             CurrentSeat.PreChipType     = chipinType;
             AddCurrentTotal(amount);
         }
         Seat tempSeat = CurrentSeat;
         do
         {
             tempSeat = GetNextJoinSeat(tempSeat);
         } while (tempSeat.IsGaveUp);
         CurrentSeat   = tempSeat;
         PreSeatIsLook = isLook;
         if (CurrentSeat == FirstSeat)
         {
             CurrentTurn++;
         }
         if (CurrentTurn > DefaultTurnCount)
         {
             NotifyRoomPlayers(WebscoketSendObjs.RoomMessage(0, "超过最大轮次,自动比牌"));
             CompareAll();
         }
         if (JoinSeats.Where(s => s.IsGaveUp == false).Count() == 1)
         {
             CompareAll();
         }
     }
     CheckDateTime = DateTime.Now;
     NotifyRoomPlayers(new ChipinAnimation(0, amount, playerId, chipinType));
     NotifyRoomPlayers(new FreshGameFace(0));
 }
Exemplo n.º 4
0
 /// <summary>
 /// 玩家押底入局
 /// </summary>
 /// <param name="seat"></param>
 private void AddPlaySeat(Seat seat)
 {
     if (JoinSeats.Exists(s => s.IPlayer.Id == seat.IPlayer.Id))
     {
         return;
     }
     JoinSeats.Add(seat);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 初始化每局公共信息
 /// </summary>c
 private void InitPublicInfo()
 {
     CurrentTotal = 0;             //初始化
     CurrentTurn  = 1;             //初始化轮次
     JoinSeats.Clear();            //次序控制
     PreSeatIsLook = false;        //上家是否看牌
     PreSeatAmount = ChipInAmount; //最近下注积分
     //  IsChipinClose = false;
     // IsWinnerStage = false;
     CurrentStage  = EStage.CanChipIning;
     WinnerSeat    = null;
     CheckDateTime = DateTime.Now;
 }
Exemplo n.º 6
0
 public override void Stoped(object inningeGame, EventArgs e)
 {
     //     if (!IsChipinClose) {
     if (CurrentStage == EStage.CanChipIning)
     {
         for (int i = 0; i < JoinSeats.Count(); i++)
         {
             var seat = JoinSeats[0];
             if (seat.IsChipIned)
             {
                 seat.IPlayer.DecutMoney(-seat.ChipinAmount);
             }
         }
     }
     InningeGame.GameOver();
     base.Stoped(inningeGame, e);
 }
Exemplo n.º 7
0
        /// <summary>
        /// 获得被开牌方座位
        /// </summary>
        /// <returns></returns>
        private Seat GetOnlyOpponentSeat()
        {
            List <Seat> seats          = JoinSeats.FindAll(s => s.IPlayer.Id != CurrentSeat.IPlayer.Id);
            List <Seat> notGaveupSeats = new List <Seat>();

            for (int i = 0; i < seats.Count; i++)
            {
                if (seats[i].IsGaveUp)
                {
                    continue;
                }
                notGaveupSeats.Add(seats[i]);
            }
            if (notGaveupSeats.Count != 1)
            {
                return(null);
            }
            return(seats[0]);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获得被开牌方座位
        /// </summary>
        /// <returns></returns>
        private Seat GetOnlyOpponentSeat(int playerId)
        {
            List <Seat> seats = JoinSeats.FindAll(s => s.IPlayer.Id != playerId && s.IsGaveUp != true);

            //List<Seat> notGaveupSeats = new List<Seat>();
            //for (int i = 0; i < seats.Count; i++) {
            //    if (seats[i].IsGaveUp) {
            //        continue;
            //    }
            //    notGaveupSeats.Add(seats[i]);
            //}
            //if (notGaveupSeats.Count != 1) {
            //    return null;
            //}
            if (seats.Count != 1)
            {
                return(null);
            }
            return(seats[0]);
        }
Exemplo n.º 9
0
 private void RemoveFromJoinSeats(Seat seat)
 {
     JoinSeats.Remove(seat);
 }
Exemplo n.º 10
0
        /// <summary>
        /// 没有放弃的玩家数量
        /// </summary>
        private int GetActiveSeatCount()
        {
            int count = JoinSeats.FindAll(s => s.IsGaveUp == false).Count();

            return(count);
        }
Exemplo n.º 11
0
 /// <summary>
 /// 返回每局参与玩家
 /// </summary>
 /// <returns></returns>
 private List <Seat> GetPlaySeats()
 {
     return(JoinSeats.FindAll(p => p.IsChipIned == true));
 }
Exemplo n.º 12
0
 /// <summary>
 /// 根据玩家Id获得对应座位
 /// </summary>
 /// <param name="playerId"></param>
 /// <returns></returns>
 private Seat GetJionSeatByPlayerId(int playerId)
 {
     return(JoinSeats.Find(s => s.IPlayer.Id == playerId));
 }