public int GetSeats(string cat) { cat = cat.ToUpper(); int nbSeats = Seats.Where(s => s.Category.Name == cat).Count(); return(nbSeats); }
private void NeedCard() { if (this.Auction == null) { throw new ObjectDisposedException("this.theAuction"); } if (this.Play == null) { throw new ObjectDisposedException("this.thePlay"); } Seats controller = this.Play.whoseTurn; if (this.Play.whoseTurn == this.Auction.Declarer.Partner()) { controller = this.Auction.Declarer; } int leadSuitLength = this.Distribution.Length(this.Play.whoseTurn, this.Play.leadSuit); //Log.Trace("BoardResultEventPublisher({2}).NeedCard from {0} by {1}", this.Play.whoseTurn, controller, this.Name); this.EventBus.HandleCardNeeded( controller , this.Play.whoseTurn , this.Play.leadSuit , this.Play.Trump , leadSuitLength == 0 && this.Play.Trump != Suits.NoTrump , leadSuitLength , this.Play.currentTrick ); }
public static List <Seats> GetAllSeats() { List <Seats> lSeat = new List <Seats>(); Seats seat; using (OracleConnection conn = new OracleConnection(ConString)) { if (conn.State != ConnectionState.Open) { conn.Open(); } using (OracleCommand cmd = new OracleCommand()) { cmd.Connection = conn; cmd.CommandText = "select * from seats"; cmd.CommandType = CommandType.Text; OracleDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { seat = new Seats(); seat.SeatId = reader.GetInt32(0); seat.SeatName = reader.GetString(1); seat.DistrictId = reader.GetInt32(2); lSeat.Add(seat); } conn.Close(); } } return(lSeat); }
public override void HandleBidDone(Seats source, Bid bid) { //Log.Trace("BoardResultEventPublisher.HandleBidDone: {0} bids {1}", source, bid); if (this.currentTournament != null && !this.currentTournament.AllowOvercalls && this.Auction.Opened && !source.IsSameDirection(this.Auction.Opener) && !bid.IsPass) { Log.Trace(1, "TournamentController overcall in bid contest: change to pass"); bid.SetPass(); bid.Explanation = ""; bid.HumanExplanation = ""; } base.HandleBidDone(source, bid); if (this.Auction.Ended) { //Log.Trace("BoardResultEventPublisher.HandleBidDone: auction finished"); if (this.Contract.Bid.IsRegular && !(this.currentTournament != null && this.currentTournament.BidContest) ) { this.EventBus.HandleAuctionFinished(this.Auction.Declarer, this.Play.Contract); this.NeedCard(); } else { //Log.Trace("BoardResultEventPublisher.HandleBidDone: all passed"); this.EventBus.HandlePlayFinished(this); } } else { //Log.Trace("BoardResultEventPublisher.HandleBidDone: next bid needed from {0}", this.Auction.WhoseTurn); this.EventBus.HandleBidNeeded(this.Auction.WhoseTurn, this.Auction.LastRegularBid, this.Auction.AllowDouble, this.Auction.AllowRedouble); } }
public override async void HandleExplanationDone(Seats source, Bid bid) { #if syncTrace Log.Trace(2, "TableManagerClient.{0}.HandleExplanationDone: {1}'s {2} means {3}", this.seat, source, bid, bid.Explanation); #endif await this.WriteProtocolMessageToRemoteMachine(bid.Explanation); }
private void GenerateRowNameColumn(Seat objSeat, bool isSelectAllColumn, bool isEnable = true) { try { Seats.Add(new SeatProperties() { CheckboxVisibility = isSelectAllColumn ? Visibility.Visible : (objSeat.FK_SeatStatus_ID != 0 ? Visibility.Visible : Visibility.Collapsed), Column = isSelectAllColumn ? 0 : objSeat.ColumnValue, ColumnText = isSelectAllColumn ? Convert.ToString(0) : (!string.IsNullOrEmpty(objSeat.RowText) ? Convert.ToString(objSeat.ColumnText) : string.Empty), DisplayText = isSelectAllColumn ? Convert.ToString(objSeat.RowText) : (!string.IsNullOrEmpty(objSeat.RowText) ? Convert.ToString(objSeat.ColumnText) : string.Empty), Id = objSeat.ID, IsChecked = !isSelectAllColumn && objSeat.IsReserved == 1, IsEnabled = isEnable, Row = objSeat.RowValue, RowNum = objSeat.RowValue, RowText = Convert.ToString(objSeat.RowText), ScreenClassId = objSeat.ScreenClassId, SeatColor = Helper.ReturnColor(objSeat.Color), SeatHeight = 25, SeatOrientation = Orientation.Horizontal, SeatWidth = isSelectAllColumn ? 50 : 20, TextVisibility = Visibility.Visible, TicketCost = objSeat.Price, VendorId = objSeat.VendorId }); } catch (Exception ex) { LogExceptions.LogException(ex); } }
//Create Seats for a new Flight public List <Seats> CreateSeatsForFlight(Flights Flight) { char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray(); //Check which airplane is used for this flight var airplaneid = Flight.AirplaneId; var airplane = _context.Airplanes .Where(s => s.Id == airplaneid) .FirstOrDefault(); //Initiate a list of seats for that flight List <Seats> seats = new List <Seats>(); for (int i = 0; i < airplane.Rows; i++) { for (int j = 0; j < airplane.Columns; j++) { Seats seat = new Seats { Id = Guid.NewGuid(), Row = i + 1, Column = alphabet[j], Available = true, FlightId = Flight.Id }; seats.Add(seat); } } return(seats); }
public void Reports_AddTo2020_Product(string input, long expected) { Seats s = new Seats(input); long occupied = s.OccupiedSeatsInStatis(); Assert.Equal(expected, occupied); }
//[ValidateAntiForgeryToken] // public ActionResult Create([Bind(Include = "ReservationFlightDetailID,SeatAssignment,Fare,Reservation,Flight,User")] ReservationFlightDetail reservationFlightDetail) public ActionResult Create(Seats SeatAssignment, Decimal Fare, int ReservationID, int FlightID, String id) { int fare = (int)Fare; Fare = CalculateFare(FlightID, id, SeatAssignment, fare); ReservationFlightDetail reservationFlightDetail = new ReservationFlightDetail(); reservationFlightDetail.SeatAssignment = SeatAssignment; reservationFlightDetail.Fare = Fare; reservationFlightDetail.Reservation = db.Reservations.First(r => r.ReservationID == ReservationID); reservationFlightDetail.Flight = db.Flights.First(f => f.FlightID == FlightID); reservationFlightDetail.User = db.Users.First(u => u.Id == id); ReservationViewModel FlightInfo = new ReservationViewModel(); FlightInfo.ReservationNumber = db.Reservations.First(r => r.ReservationID == ReservationID).ReservationNumber; //FlightInfo.RoundTrip = RoundTrip; //FlightInfo.AnotherFlight = AnotherFlight; //FlightInfo.NumberOfFliers = NumberOfFliers; FlightInfo.FlightID = FlightID; if (ModelState.IsValid) { db.ReservationFlightDetails.Add(reservationFlightDetail); db.SaveChanges(); return(RedirectToAction("Create", FlightInfo)); } //return View(reservationFlightDetail); return(View()); }
public override void HandlePlayFinished(BoardResultRecorder currentResult) { #if syncTrace Log.Trace(4, "HostBoardResult.HandlePlayFinished"); #endif base.HandlePlayFinished(currentResult); this.boardTime[Directions.NorthSouth] = this.ThinkTime[Directions.NorthSouth].Elapsed.Subtract(this.boardTime[Directions.NorthSouth]); this.boardTime[Directions.EastWest] = this.ThinkTime[Directions.EastWest].Elapsed.Subtract(this.boardTime[Directions.EastWest]); Threading.Sleep(20); this.BroadCast("Timing - N/S : this board {0:mm\\:ss}, total {1:h\\:mm\\:ss}. E/W : this board {2:mm\\:ss}, total {3:h\\:mm\\:ss}." , this.boardTime[Directions.NorthSouth].RoundToSeconds() , this.ThinkTime[Directions.NorthSouth].Elapsed.RoundToSeconds() , this.boardTime[Directions.EastWest].RoundToSeconds() , this.ThinkTime[Directions.EastWest].Elapsed.RoundToSeconds() ); this.boardTime[Directions.NorthSouth] = this.ThinkTime[Directions.NorthSouth].Elapsed; this.boardTime[Directions.EastWest] = this.ThinkTime[Directions.EastWest].Elapsed; for (Seats s = Seats.North; s <= Seats.West; s++) { this.clients[s].state = TableManagerProtocolState.WaitForStartOfBoard; this.clients[s].Pause = false; } this.OnHostEvent(this, HostEvents.BoardFinished, currentResult); }
void addNewItem_Click(object sender, EventArgs e) { switch (flag) { case "Buses": dgvBusStation.EndEdit(); Buses bus = (Buses)binSourceBusStation.Current; BusRepository rep = new BusRepository(); rep.Create(bus); Seats seat; SeatsRepository seatrep = new SeatsRepository(); for (int i = 0; i < bus.CountSeats; i++) { seat = new Seats(); seat.BusId = bus.BusId; seat.NumberSeat = i + 1; seatrep.Create(seat); } break; default: dgvBusStation.EndEdit(); T t = (T)binSourceBusStation.Current; repository.Create(t); break; } }
private void GenerateColumnSelection(int row, int column) { try { Seats.Add(new SeatProperties() { CheckboxVisibility = (row == 0) ? (ShowHeaderCheckBoxes ? Visibility.Visible : Visibility.Collapsed) : Visibility.Visible, Column = column, ColumnText = Convert.ToString(column), DisplayText = Convert.ToString(column), IsChecked = true, IsEnabled = (row == 0 && column == 0) ? false : true, Row = row, RowNum = row, RowText = Helper.IntToAA(row), SeatColor = (row == 0 && column == 1) ? Helper.ReturnColor("INACTIVE") : Helper.ReturnColor("ACTIVE"), SeatHeight = row == 0 ? 80 : 30, SeatOrientation = row == 0 ? Orientation.Vertical : Orientation.Horizontal, SeatWidth = 40, TextVisibility = (row == 0 ? Visibility.Visible : Visibility.Collapsed) }); } catch (Exception ex) { LogExceptions.LogException(ex); } }
private void RearrangeRowSeats(SeatProperties objSeat) { try { Seats.Where(w => w.Column == 0).ToList <SeatProperties>().ForEach(x => { x.IsChecked = false; x.RowNum = 0; x.DisplayText = x.RowText = string.Empty; }); int currentRow = 0; foreach (SeatProperties objSeatGroup in Seats.Where(w => w.Column == 0 && w.Row > currentRow).ToList <SeatProperties>()) { if (Seats.Where(w => w.Column > 0 && w.Row == objSeatGroup.Row && w.IsChecked).Count() > 0) { currentRow = currentRow + 1; objSeatGroup.IsChecked = true; objSeatGroup.RowNum = currentRow; objSeatGroup.DisplayText = Helper.IntToAA(objSeatGroup.RowNum); objSeatGroup.RowText = Helper.IntToAA(currentRow); } } RearrangeColumnSeats(objSeat); } catch (Exception ex) { LogExceptions.LogException(ex); } }
public void InitTable() { Cards = new string[0]; NbPlayed = 0; m_DealerSeat = Seats.SeatOfDealer(); foreach (var s in GetPlayersWhoNeedsToPutAntes()) { Bank.AddDebt(s.Player, Params.AnteAmount()); } foreach (var s in GetPlayersWhoNeedsToPutSmallBlind()) { s.AddAttribute(SeatAttributeEnum.SmallBlind); Bank.AddDebt(s.Player, Params.SmallBlindAmount()); } foreach (var s in GetPlayersWhoNeedsToPutBigBlind()) { s.AddAttribute(SeatAttributeEnum.BigBlind); Bank.AddDebt(s.Player, Params.BigBlindAmount()); } NewArrivals.Clear(); }
private void GenerateRowSelection(int row) { try { Seats.Add(new SeatProperties() { CheckboxVisibility = row > 0 ? Visibility.Visible : Visibility.Collapsed, Column = 0, ColumnText = Convert.ToString(0), DisplayText = Helper.IntToAA(row), IsChecked = true, IsEnabled = (row == 1) ? false : true, Row = row, RowNum = row, RowText = Helper.IntToAA(row), SeatColor = (row == 1) ? Helper.ReturnColor("INACTIVE") : Helper.ReturnColor("ACTIVE"), SeatHeight = row == 0 ? 90 : 30, SeatOrientation = row == 0 ? Orientation.Vertical : Orientation.Horizontal, SeatWidth = 80, TextVisibility = Visibility.Visible }); } catch (Exception ex) { LogExceptions.LogException(ex); } }
public SeatCollection() { for (Seats s = Seats.North; s <= Seats.West; s++) { this[s] = default(T); } }
public SeatingMap(IEnumerable <string> input, int tolerance = 4, bool searchFirstVisible = false) { //< Parse Width/Height this.Width = input.First().Length; this.Height = input.Count(); //< Assign the 'visible occupied seat tolerance' and how we search this.Tolerance = tolerance; this.SearchFirstVisible = searchFirstVisible; //< Make dat Grid in memory, boah this.Grid = new Seat[Width, Height]; this.Seats = new List <Seat>(); //< Populate them shits for (int y = 0; y < Height; y++) { string line = input.ElementAt(y); for (int x = 0; x < Width; x++) { Grid[x, y] = new Seat(x, y, line[x]); if (Grid[x, y].IsSeat()) { //< Retain list of all non-floor locations for later use Seats.Add(Grid[x, y]); } } } }
public override void HandleCardNeeded(Seats controller, Seats whoseTurn, Suits leadSuit, Suits trump, bool trumpAllowed, int leadSuitLength, int trick) { #if syncTrace Log.Trace(2, "{0}.HandleCardNeeded", this.Owner); #endif if (whoseTurn != this.Play.whoseTurn) { throw new InvalidOperationException("whoseTurn"); } if (controller == this.tmc.seat) { if (this.Play.man == 1) { this.tmc.ChangeState(TableManagerProtocolState.WaitForLead, true, false, new string[] { string.Format("{0} to lead", this.Play.whoseTurn == this.Play.Dummy ? "Dummy" : this.Play.whoseTurn.ToXMLFull()) }, ""); } } else { #if syncTrace //Log.Trace("{0}.HandleCardNeeded from {1}", this.Owner.seat, whoseTurn); #endif this.tmc.ChangeState(TableManagerProtocolState.WaitForCardPlay , false, false , new string[] { "" } , "{0} ready for {1}'s card to trick {2}", this.tmc.seat, (this.tmc.seat == this.Play.Dummy && this.tmc.seat == whoseTurn ? "dummy" : whoseTurn.ToString()), trick); } }
public override void HandleCardPlayed(Seats source, Suits suit, Ranks rank) { #if syncTrace Log.Trace(2, "{0}.HandleCardPlayed: {1} plays {3} of {2}", this.Owner, source, suit, rank); #endif var manForCurrentCard = this.Play.man; base.HandleCardPlayed(source, suit, rank); #if syncTrace Log.Trace(2, "{0}.HandleCardPlayed: next card by {1}", this.Owner, this.Play.whoseTurn); #endif if ((source == this.tmc.seat && this.tmc.seat != this.Play.Dummy) || (source == this.Play.Dummy && this.tmc.seat == this.Play.Dummy.Partner())) { var message = string.Format("{0} plays {2}{1}", // TM bug: TM does not recognize the phrase 'Dummy plays 8C', eventhough the protocol defines it //whoseTurn != this.seat ? "Dummy" : whoseTurn.ToString(), source, SuitHelper.ToXML(suit), rank.ToXML()); if (manForCurrentCard == 1) { this.tmc.ChangeState(TableManagerProtocolState.WaitForLead, false, false, new string[] { "" }, message); } else { this.tmc.ChangeState(this.tmc.state, false, this.Play.PlayEnded || (this.Play.man == 1 && (this.Play.whoseTurn == this.tmc.seat || (this.Play.whoseTurn == this.Play.Dummy && this.tmc.seat == this.Play.Contract.Declarer))), this.tmc.tableManagerExpectedResponse, message); } } }
public bool Equals(SeatsNotReserved other) { return(Customer == other.Customer && Seats.Count == other.Seats.Count && Seats.All((seat) => other.Seats.Contains(seat)) && Reason == other.Reason); }
public override void HandleCardPlayed(Seats source, Suits suit, Ranks rank) { #if syncTrace Log.Trace(4, "HostBoardResult.HandleCardPlayed {0} plays {2}{1}", source, suit.ToXML(), rank.ToXML()); #endif this.host.ThinkTime[source.Direction()].Stop(); //this.host.boardTime[source.Direction()] = this.host.boardTime[source.Direction()].Add(timer.Elapsed.Subtract(new TimeSpan(this.host.clients[source].communicationLag))); base.HandleCardPlayed(source, suit, rank); for (Seats s = Seats.North; s <= Seats.West; s++) { if ((s != source && !(s == this.Auction.Declarer && source == this.Play.Dummy)) || (s == source && source == this.Play.Dummy) ) { this.host.clients[s].WriteData("{0} plays {2}{1}", source, suit.ToXML(), rank.ToXML()); } if (this.Play.currentTrick == 1 && this.Play.man == 2) { // 1st card: need to send dummies cards #if syncTrace //Log.Trace("HostBoardResult.HandleCardPlayed 1st card to {0}", s); #endif var mustPause = s == this.Play.Dummy; lock (this.host.clients) this.host.clients[s].Pause = mustPause; this.host.clients[s].state = s == this.Play.Dummy ? TableManagerProtocolState.GiveDummiesCards : TableManagerProtocolState.WaitForDummiesCards; } } }
protected override void ExplainBid(Seats source, Bid bid) { if (bid.Equals(2, Suits.NoTrump)) { bid.NeedsAlert(); } }
public void TranslateSeatsDALtoSeatsContractData(Seats seatDAL, SeatsItemEntity seatContractData) { seatContractData.SeatNumber = seatDAL.seatNumber; seatContractData.SeatState = seatDAL.SeatState.stateName; seatContractData.TransportID = (int)seatDAL.transportId; }
public SeatInfo SitIn(PlayerInfo p, int preferedSeat = -1) { if (!Seats.RemainingSeatIds().Any()) { Logger.LogError("Not enough seats to join!"); return(null); } //if (!Params.IsValidBuyIn(p.MoneyAmnt)) //{ // Logger.LogError("Player Money ({0}) is not between Minimum ({1}) and Maximum ({2})", p.MoneyAmnt, Params.Lobby.MinimumBuyInAmount(Params.GameSize), Params.Lobby.MaximumBuyInAmount(Params.GameSize)); // return null; //} if (Seats.Players().ContainsPlayerWithSameName(p)) { Logger.LogError("Already someone seated with the same name! Is this you ?"); return(null); } var seat = preferedSeat; if (preferedSeat < 0 || preferedSeat >= Seats.Length || !Seats[preferedSeat].IsEmpty) { seat = Seats.RemainingSeatIds().First(); } HadPlayers = true; p.ChangeState(PlayerStateEnum.SitIn); p.NoSeat = seat; Seats[seat].Player = p; return(Seats[seat]); }
public void Reports_AddTo2020_Product(string input, long expected) { Seats s = new Seats(input); long id = s.MaxID(); Assert.Equal(expected, id); }
public async Task TableManager_2Tables_Test() { Log.Level = 1; var host1 = new TestHost(2002, new BridgeEventBus("Host1")); host1.OnHostEvent += Host_OnHostEvent; var vms = new SeatCollection <TestClient>(); Parallel.For(0, 4, (i) => { Seats s = (Seats)i; vms[s] = new TestClient(); vms[s].Connect(s, "localhost", 2002, 120, 1, "Robo" + (s == Seats.North || s == Seats.South ? "NS" : "EW"), false); }); var host2 = new TestHost(2003, new BridgeEventBus("Host2")); host2.OnHostEvent += Host_OnHostEvent; var vms2 = new SeatCollection <TestClient>(); Parallel.For(0, 4, (i) => { Seats s = (Seats)i; vms2[s] = new TestClient(); vms2[s].Connect(s, "localhost", 2003, 120, 1, "Robo" + (s == Seats.North || s == Seats.South ? "NS" : "EW"), false); }); await host1.WaitForCompletionAsync(); }
public static void ForEachSeat(Action <Seats> toDo) { for (Seats s = Seats.North; s <= Seats.West; s++) { toDo(s); } }
/// <summary> /// 清除本局全部座位游戏数据 /// </summary> private void ClearAllSeatInfo() { for (int i = 0; i < Seats.Count(); i++) { Seats[i].ClearSeatInfo(); } }
public SeatCollection(T[] initialValue) { for (Seats s = Seats.North; s <= Seats.West; s++) { this[s] = initialValue[(int)s]; } }
public async Task <IActionResult> Edit(int id, [Bind("SeatsId,Color")] Seats seats) { if (id != seats.SeatsId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(seats); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SeatsExists(seats.SeatsId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(seats)); }
void Awake() { if (isTimed) { myCountDownTimerRef = GameObject.Find("TimerLabel").GetComponent<CountDownTimer>(); } myLevelStatsRef = this.gameObject.GetComponent<LevelStats>(); // Automatic find game objects and references myDrinksContainerRef = GameObject.Find("_DrinksContainer").GetComponent<DrinksContainer>(); mySeatsRef = GameObject.Find("_Seats").GetComponent<Seats>(); drinkSpawner = GameObject.Find("DrinkSpawner").transform; }
void Awake () { // Gets a reference of Main Scripts inside the Game Objects mySeatReference = GameObject.Find("_Seats").GetComponent<Seats>(); myControlRef = GameObject.Find("_Control").GetComponent<Control>(); myDrinksContainerRef = GameObject.Find("_DrinksContainer").GetComponent<DrinksContainer>(); myDrinkAnimationRef = this.gameObject.GetComponent<DrinkAnimationScript>(); myCustomerTimerRef = baloon.GetComponent<CustomerTimer>(); //Gets reference of this game object components thisCustomer = this.gameObject; customer_Renderer = thisCustomer.GetComponent<SpriteRenderer>(); customer_Collision = thisCustomer.GetComponent<BoxCollider2D>(); //Initial Status of some elements thisCustomer.name = name; baloon.SetActive(false); }