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>()); }
public SeatArrangement( ISimpleEmployee agent, DateTime start, DateTime end, ISeat seat) { Agent = agent; Start = start; End = end; this.Seat = seat; }
public SeatArrangement(ISimpleEmployee agent, DateTime start, DateTime end, ISeat seat) { Agent = agent; Start = start; End = end; this.Seat = seat; }
public SeatPopup(IViewsManager viewsManager) { InitializeComponent(); ISeat seat = viewsManager.SeatsView.Value.Selected; this.textEditSeatNum.DataBindings.Add( new Binding("EditValue", seat, "SeatNum", true, DataSourceUpdateMode.OnPropertyChanged)); }
public void PlayerSetDown_PlayerExist() { ISeat seat = _ISeatCreator(); seat.PlayerSitDown(_player); Assert.Throws <Exception>(() => seat.PlayerSitDown(_player2)); }
public void GetUp() { ISeat seat = _inngeGame.GetSeatByPlayerId(player.Id); if (seat != null) { seat.PlayLeave(); } }
public void PlayerSitDown() { IInningeGame inningeGame = _IInningeGameCreator(); inningeGame.AddSet(1); ISeat emptySeat = inningeGame.GetOneEmptySeat(); Assert.NotNull(emptySeat); }
public void PlayerSetDown_() { ISeat seat = _ISeatCreator(); seat.PlayerSitDown(_player); Assert.True(seat.IsEmpty == false); Assert.True(seat.IPlayer == _player, "座位玩家Id不对"); }
private void ColumView_CustomColumnDisplayText(object sender, CustomColumnDisplayTextEventArgs e) { ISeat seat = e.Value as ISeat; if (seat != null) { e.DisplayText = seat.SeatNum.ToString(); } }
public void PlayerSeatDow_yes() { ISeat seat = _ISeatCreator(); seat.DCheckSitDown += delegate { return(true); }; seat.PlayerSitDown(_player); Assert.True(seat.IPlayer == _player); }
public void PlayerLeaveSeat() { ISeat seat = _ISeatCreator(); seat.PlayerSitDown(_player); seat.PlayLeave(); Assert.True(seat.IsEmpty == true); Assert.True(seat.IPlayer == null, "座位玩家Id=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); }
/// <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); }
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; }
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_); }
/// <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; }
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; }
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); } }
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); }
/// <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(); }
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); } }
/// <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(); }
// --- 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); }
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 }
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); }
// --- 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; }
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); }
private bool FilterSeats(ISeat seat) { return(this.floorsView.Selected != null && seat.FloorId == this.floorsView.Selected.Id); }
public SeatArrangement(ISimpleEmployee agent, DateTime start, DateTime end, Term shift, ISeat seat) : this(shift, agent, start, end) { this.Seat = seat; }
private static bool SameFamily(ISeat s, UnreservedSeatForDinerQuery query) { return(s.Diner.LastName.Equals(query.DinerLastName, StringComparison.OrdinalIgnoreCase)); }
public override bool Equals(object seat) { ISeat seatToCompare = seat as ISeat; return(seatToCompare != null && this.Id.Equals(seatToCompare.Id)); }
public void Add(ISeat seat) { _context.Add(seat); }