コード例 #1
0
 private IFutureValue <Occupation> GetSeatEvent(ISeat seat, DateTime watchPoint)
 {
     return(Session.CreateQuery("from SeatEvent s where s.Seat =:seat and s.Start <=:watchPoint and s.End >:watchPoint")
            .SetGuid("seat", seat.Id)
            .SetDateTime("watchPoint", watchPoint)
            .SetMaxResults(1).FutureValue <Occupation>());
 }
コード例 #2
0
ファイル: SeatArrangement.cs プロジェクト: Mrding/Ribbon
 public SeatArrangement( ISimpleEmployee agent, DateTime start, DateTime end, ISeat seat)
 {
     Agent = agent;
     Start = start;
     End = end;
     this.Seat = seat;
 }
コード例 #3
0
ファイル: SeatArrangement.cs プロジェクト: agamat/Ribbon-1
 public SeatArrangement(ISimpleEmployee agent, DateTime start, DateTime end, ISeat seat)
 {
     Agent     = agent;
     Start     = start;
     End       = end;
     this.Seat = seat;
 }
コード例 #4
0
        public SeatPopup(IViewsManager viewsManager)
        {
            InitializeComponent();
            ISeat seat = viewsManager.SeatsView.Value.Selected;

            this.textEditSeatNum.DataBindings.Add(
                new Binding("EditValue", seat, "SeatNum", true, DataSourceUpdateMode.OnPropertyChanged));
        }
コード例 #5
0
        public void PlayerSetDown_PlayerExist()
        {
            ISeat seat = _ISeatCreator();

            seat.PlayerSitDown(_player);

            Assert.Throws <Exception>(() => seat.PlayerSitDown(_player2));
        }
コード例 #6
0
        public void GetUp()
        {
            ISeat seat = _inngeGame.GetSeatByPlayerId(player.Id);

            if (seat != null)
            {
                seat.PlayLeave();
            }
        }
コード例 #7
0
        public void PlayerSitDown()
        {
            IInningeGame inningeGame = _IInningeGameCreator();

            inningeGame.AddSet(1);
            ISeat emptySeat = inningeGame.GetOneEmptySeat();

            Assert.NotNull(emptySeat);
        }
コード例 #8
0
        public void PlayerSetDown_()
        {
            ISeat seat = _ISeatCreator();

            seat.PlayerSitDown(_player);

            Assert.True(seat.IsEmpty == false);
            Assert.True(seat.IPlayer == _player, "座位玩家Id不对");
        }
コード例 #9
0
        private void ColumView_CustomColumnDisplayText(object sender, CustomColumnDisplayTextEventArgs e)
        {
            ISeat seat = e.Value as ISeat;

            if (seat != null)
            {
                e.DisplayText = seat.SeatNum.ToString();
            }
        }
コード例 #10
0
        public void PlayerSeatDow_yes()
        {
            ISeat seat = _ISeatCreator();

            seat.DCheckSitDown += delegate { return(true); };
            seat.PlayerSitDown(_player);

            Assert.True(seat.IPlayer == _player);
        }
コード例 #11
0
        public void PlayerLeaveSeat()
        {
            ISeat seat = _ISeatCreator();

            seat.PlayerSitDown(_player);
            seat.PlayLeave();

            Assert.True(seat.IsEmpty == true);
            Assert.True(seat.IPlayer == null, "座位玩家Id=0");
        }
コード例 #12
0
        public void PlayerSeatDow_no()
        {
            ISeat seat = _ISeatCreator();

            seat.DCheckSitDown += delegate { return(false); };
            seat.PlayerSitDown(_player);

            Assert.False(seat.IPlayer == _player);
            Assert.True(seat.IsEmpty);
        }
コード例 #13
0
        /// <summary>
        /// 添加座位坐下
        /// </summary>
        /// <param name="player">玩家</param>
        /// <returns>座位</returns>
        public ISeat PlaySitDown(IPlayerJoinRoom player)
        {
            ISeat seat = GetOneEmptySeat();

            if (seat == null)
            {
                seat = AddSet(1);
            }
            seat.PlayerSitDown(player);
            return(seat);
        }
コード例 #14
0
        public void Update(IBaseModel model)
        {
            ISeat seat = (ISeat)model;

            this.Id         = seat.Id;
            this.SeatColumn = seat.SeatColumn;
            this.SeatNum    = seat.SeatNum;
            this.SeatRow    = seat.SeatRow;
            this.IsActive   = seat.IsActive;
            this.SeatType   = seat.SeatType;
            this.FloorId    = seat.FloorId;
        }
コード例 #15
0
        public void PlayerSeatDown_beforEvent()
        {
            ISeat seat = _ISeatCreator();
            bool  beforSitDownEvent_ = false;
            bool  afterSitDownEvent_ = false;

            seat.BeforSitDownHandler += delegate { beforSitDownEvent_ = true; };
            seat.AfterSitDownHandler += delegate { afterSitDownEvent_ = true; };
            seat.PlayerSitDown(_player);

            Assert.True(beforSitDownEvent_);
            Assert.True(afterSitDownEvent_);
        }
コード例 #16
0
        /// <summary>
        /// 出牌或出牌后比较大小
        /// </summary>
        /// <param name="playerId">玩家Id</param>
        /// <param name="card_">一张牌</param>
        /// <returns>获胜玩家座位</returns>
        public void PlayerPlayOutOnePoker(int playerId)
        {
            var    meSeat                = InningeGame.GetSeatByPlayerId(playerId);
            var    opponentId            = GetOpponentId(playerId);
            var    opponentSeat          = InningeGame.GetSeatByPlayerId(opponentId);
            var    opponentPayOut        = opponentSeat.GameDateObj["playOutPokers"];
            var    opponentCompareResult = opponentSeat.GameDateObj["compareResult"];
            object card = null;

            //var card = CheckCardExist(playerId, card_);
            if (meSeat.GameDateObj["getPokers"].Count == 0)
            {
                return;
            }
            var mePoker = meSeat.GameDateObj["getPokers"];

            card = mePoker[0];
            var   mePayOut        = meSeat.GameDateObj["playOutPokers"];
            var   meCompareResult = meSeat.GameDateObj["compareResult"];
            ISeat winPlayer       = null;

            if (card != null)
            {
                mePoker.Remove(card);
                mePayOut.Add(card);
                if (opponentPayOut.Count > 0)
                {
                    if (((ABCard)mePayOut[0]).ComparedValue > ((ABCard)opponentPayOut[0]).ComparedValue)
                    {
                        winPlayer = meSeat;
                    }
                    else
                    {
                        winPlayer = opponentSeat;
                    }
                    mePayOut.Remove(card);
                    meCompareResult.Add(card);
                    opponentCompareResult.Add(opponentPayOut[0]);
                    opponentPayOut.Clear();
                    winPlayer.IPlayer.DecutMoney(-ChipInAmount);
                    foreach (var item in InningeGame.NotEmptySeats())//通知全部客户端刷新
                    {
                        // Notify?.Invoke(item.IPlayer.Id, "FreshGameFace");
                        Notify?.Invoke(WebscoketSendObjs.FreshGameFace(item.IPlayer.Id));
                    }// ClearPayOut(opponentPayOut, mePayOut);
                }
                Notify?.Invoke(WebscoketSendObjs.FreshGameFace(playerId));
                return;
            }
            return;
        }
コード例 #17
0
        public void PlayerPlayOutOnePoker(int playerId)
        {
            Seat   meSeat                = GetSeatByPlayerId(playerId);
            int    opponentId            = GetOpponentId(playerId);
            Seat   opponentSeat          = GetSeatByPlayerId(opponentId);
            var    opponentPayOut        = opponentSeat.PlayOutPokers;
            var    opponentCompareResult = opponentSeat.CompareResult;
            ABCard card = null;

            if (null == meSeat.GetPoker)
            {
                return;
            }
            card = meSeat.GetPoker;
            var   meCompareResult = meSeat.CompareResult;
            ISeat winPlayer       = null;

            if (card != null)
            {
                lock (Locker)
                {
                    meSeat.GetPoker      = null;
                    meSeat.PlayOutPokers = card;
                    if (opponentPayOut != null)
                    {
                        if (meSeat.PlayOutPokers.ComparedValue > opponentSeat.PlayOutPokers.ComparedValue)
                        {
                            winPlayer = meSeat;
                        }
                        else
                        {
                            winPlayer = opponentSeat;
                        }
                        meSeat.PlayOutPokers       = null;
                        meSeat.CompareResult       = card;
                        opponentSeat.CompareResult = opponentSeat.PlayOutPokers;
                        opponentSeat.PlayOutPokers = null;
                        winPlayer.IPlayer.DecutMoney(-ChipInAmount);
                        foreach (var item in InningeGame.NotEmptySeats())//通知全部客户端刷新
                        {
                            NotifySinglePlayer(WebscoketSendObjs.FreshGameFace(item.IPlayer.Id), item.IPlayer.Id);
                        }
                    }
                    NotifySinglePlayer(WebscoketSendObjs.FreshGameFace(playerId), playerId);
                    return;
                }
            }
            return;
        }
コード例 #18
0
        private void GridViewSeats_Click(object sender, EventArgs e)
        {
            GridView view = sender as GridView;

            if (this.IsInCell(view, e))
            {
                ISeat seat = this.gridViewSeats.GetFocusedValue() as ISeat;
                if (seat != null)
                {
                    seat.IsActive = !seat.IsActive;
                }

                view.InvalidateRowCell(view.FocusedRowHandle, view.FocusedColumn);
            }
        }
コード例 #19
0
ファイル: Seat.cs プロジェクト: kierenholt/AME-C-
        public Seat init(ISeat iseat,
                         Group paramGroup,
                         byte paramSeatNum)
        {
            FirstName      = iseat.FirstName;
            LastName       = iseat.LastName;
            Email          = iseat.Email;
            AlternateEmail = iseat.AlternateEmail;

            SeatNum = paramSeatNum;
            Group   = paramGroup;
            GroupID = paramGroup.GroupID;

            return(this);
        }
コード例 #20
0
        /// <summary>
        /// 抽象工厂模式测试
        /// </summary>
        static void AbstractFactory()
        {
            ICarFactory cara = new CarAFactory();
            IEngine     e1   = cara.CreateEngine();
            ISeat       s1   = cara.CreateSeat();

            e1.Run();
            s1.Message();

            ICarFactory carab = new CarBFactory();
            IEngine     e2    = carab.CreateEngine();
            ISeat       s2    = carab.CreateSeat();

            e2.Run();
            s2.Message();
        }
コード例 #21
0
 private void MyAddSet(int n)
 {
     for (int i = 0; i < n; i++)
     {
         if (IGameProject.PlayerCountLimit == SeatCount)
         {
             break;
             // throw new Exception("座位已经达到游戏上限,不能再添加");
         }
         ISeat seat = null;
         if (DCreatSeat != null)
         {
             seat = DCreatSeat(this);
         }
         Seats.Add(seat);
     }
 }
コード例 #22
0
ファイル: Room.cs プロジェクト: yiluxiaozhan/appleGameSVN
        /// <summary>
        /// 玩家离开房间
        /// </summary>
        /// <param name="player_">玩家</param>
        public void RemovePlayer(IPlayerJoinRoom player_)
        {
            ISeat seat = InningGame.GetSeatByPlayerId(player_.Id);

            if (seat != null)
            {
                seat.PlayLeave();
            }
            var realPlayer = Players.Find(p => p.Id == player_.Id);

            Players.Remove(realPlayer);
            if (player_.Id == RoomManager.Id && Players.Count > 0)
            {
                ChanageManger(Players[0]);
            }
            RemovePlayer_SuccessEvent?.Invoke(this, new PlayerEventArgs(player_));
            CheckFull();
            InningGame.CheckSeatCountEnoughWhenRunning();
        }
コード例 #23
0
        // --- Private Method --- //
        private bool SetOccupationSeat(List <SeatArrangement> occupations, ISeat targetSeat)
        {
            if (occupations.Any(o => o.Seat != default(ISeat)) || !targetSeat.InUse)
            {
                return(false);
            }

            if (_isMatchingRank && occupations.Any(o => o.Agent.Rank < targetSeat.Rank))
            {
                return(false);
            }

            bool success = true;

            foreach (var occ in occupations)
            {
                DateTime extendStart = occ.Start.AddMinutes(-_bufferLength);
                DateTime extendEnd   = occ.End.AddMinutes(_bufferLength);

                if (!_seatOccupationRegister.ContainsKey(targetSeat))
                {
                    return(false);
                }

                foreach (var o in _seatOccupationRegister[targetSeat])
                {
                    if (extendStart < o.End && extendEnd > o.Start)
                    {
                        success = false;
                    }
                }
            }
            if (success)
            {
                foreach (var occ in occupations)
                {
                    _seatOccupationRegister[targetSeat].Add(occ);
                    occ.Seat = targetSeat;
                }
            }
            return(success);
        }
コード例 #24
0
        public int Compare(ISeat left, ISeat right)
        {
            if (IsNull(left) && IsNull(right))
            {
                return(Equal);
            }

            if (IsNull(left) && IsNotNull(right))
            {
                return(PreferRight);
            }

            if (IsNotNull(left) && IsNull(right))
            {
                return(PreferLeft);
            }

            // ReSharper disable PossibleNullReferenceException
            return(right.Table.Seats.Count(s => s.IsOccupied) - left.Table.Seats.Count(s => s.IsOccupied));
            // ReSharper restore PossibleNullReferenceException
        }
コード例 #25
0
        public int CalculateScore(ISeat seat, SearchQuery query)
        {
            var unreservedSeatForDinerQuery = query as UnreservedSeatForDinerQuery;

            if (unreservedSeatForDinerQuery == null)
            {
                return(NoScore);
            }

            if (seat.Table.Seats.Where(s => s.IsOccupied).Any(s => SameFamily(s, unreservedSeatForDinerQuery)))
            {
                return(TableWithFamily);
            }

            if (seat.Table.IsEmpty)
            {
                return(EmptyTable);
            }

            return(TableWithStrangers);
        }
コード例 #26
0
ファイル: SeatingServiceModel.cs プロジェクト: Mrding/Ribbon
        // --- Private Method --- //
        private bool SetOccupationSeat(List<SeatArrangement> occupations, ISeat targetSeat)
        {
            if (occupations.Any(o => o.Seat != default(ISeat)) || !targetSeat.InUse)
                return false;

            if (_isMatchingRank && occupations.Any(o => o.Agent.Rank < targetSeat.Rank))
                return false;

            bool success = true;
            foreach (var occ in occupations)
            {
                DateTime extendStart = occ.Start.AddMinutes(-_bufferLength);
                DateTime extendEnd = occ.End.AddMinutes(_bufferLength);

                if (!_seatOccupationRegister.ContainsKey(targetSeat))
                    return false;

                foreach (var o in _seatOccupationRegister[targetSeat])
                {
                    if (extendStart < o.End && extendEnd > o.Start)
                        success = false;
                }
            }
            if (success)
            {
                foreach (var occ in occupations)
                {
                    _seatOccupationRegister[targetSeat].Add(occ);
                    occ.Seat = targetSeat;
                }

            }
            return success;
        }
コード例 #27
0
        public SeatArrangement GetPlannedSeatArrangement(ISeat seat, DateTime watchPoint)
        {
            var result = default(SeatArrangement);
            var seatId = seat.Id.ToString();

            //const int maxLayerCount = 1;

            var terms = Session.CreateQuery("from Term t where t.Seat =:seatId and t.Start <=:watchPoint order by t.End desc, t.Level desc")
                        .SetString("seatId", seatId)
                        .SetMaxResults(1)
                        .SetDateTime("watchPoint", watchPoint)
                        .List <Term>();

            if (terms.Count > 0)
            {
                var term       = terms[0];
                var employeeId = term.GetSnapshotValue <Guid>("EmployeeId");

                var source    = default(Term);
                var startTime = default(DateTime);

                var watchPointIsInTheTerm = watchPoint.IsInTheRange(term);

                if (term is AssignmentBase)
                {
                    if (!watchPointIsInTheTerm)
                    {
                        return(null);
                    }

                    //find upper term
                    var upperLevelTerm = Session.CreateQuery("from Term t where t.Bottom is not null and t.Start <=:watchPoint and t.Start >=:parentStart and t.End <=:parentEnd and t.Seat is not null order by t.End desc, t.Level desc")
                                         .SetDateTime("parentStart", term.Start)
                                         .SetDateTime("parentEnd", term.End)
                                         .SetDateTime("watchPoint", watchPoint)
                                         .SetMaxResults(1)
                                         .UniqueResult <Term>();

                    if (upperLevelTerm == null || (upperLevelTerm.SeatIsEmpty() && upperLevelTerm.IsNeedSeat))
                    {
                        source    = term;
                        startTime = term.Start;
                    }
                    else if (!upperLevelTerm.SeatIsEmpty() && upperLevelTerm.Seat != seatId)
                    {
                        return(null);
                    }
                    else if (upperLevelTerm.Seat == term.Seat && !upperLevelTerm.IsNeedSeat)
                    {
                        source    = upperLevelTerm;
                        startTime = upperLevelTerm.End;
                    }
                }
                else
                {
                    //subevnet
                    if (term.IsNeedSeat)
                    {
                        if (watchPointIsInTheTerm)
                        {
                            source    = term;
                            startTime = term.Start;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        if (watchPointIsInTheTerm)
                        {
                            return(null);
                        }
                        else
                        {
                            if (!watchPoint.IsInTheRange(term.Bottom))
                            {
                                return(null);
                            }
                            else
                            {
                                source    = term;
                                startTime = term.End;
                            }
                        }
                    }
                }
                if (source == null || startTime == default(DateTime))
                {
                    return(null);
                }
                result = new SeatArrangement(Session.Get <Employee>(employeeId), startTime, watchPoint, source, seat);
            }
            return(result);
        }
コード例 #28
0
 private bool FilterSeats(ISeat seat)
 {
     return(this.floorsView.Selected != null && seat.FloorId == this.floorsView.Selected.Id);
 }
コード例 #29
0
ファイル: SeatArrangement.cs プロジェクト: Mrding/Ribbon
 public SeatArrangement(ISimpleEmployee agent, DateTime start, DateTime end, Term shift, ISeat seat)
     : this(shift, agent, start, end)
 {
     this.Seat = seat;
 }
コード例 #30
0
 private static bool SameFamily(ISeat s, UnreservedSeatForDinerQuery query)
 {
     return(s.Diner.LastName.Equals(query.DinerLastName, StringComparison.OrdinalIgnoreCase));
 }
コード例 #31
0
ファイル: SeatArrangement.cs プロジェクト: agamat/Ribbon-1
 public SeatArrangement(ISimpleEmployee agent, DateTime start, DateTime end, Term shift, ISeat seat)
     : this(shift, agent, start, end)
 {
     this.Seat = seat;
 }
コード例 #32
0
        public override bool Equals(object seat)
        {
            ISeat seatToCompare = seat as ISeat;

            return(seatToCompare != null && this.Id.Equals(seatToCompare.Id));
        }
コード例 #33
0
 public void Add(ISeat seat)
 {
     _context.Add(seat);
 }