public override int GetHashCode() { int hash = 1; if (RoomId != 0) { hash ^= RoomId.GetHashCode(); } if (Seed != 0) { hash ^= Seed.GetHashCode(); } if (SelfId != 0) { hash ^= SelfId.GetHashCode(); } if (PlayerCount != 0) { hash ^= PlayerCount.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
// Get the partner's connections related to a specific private room, along with the active connections to the room private IEnumerable <ConnectionId> GetPartnerAndActiveConnections(RoomId roomId, UserId thisUserId, ConnectionId exceptConnection = null) { var roomConnIds = RoomsConnections.GetConnections(roomId, exceptConnection); var userConnIds = GetPartnerConnections(roomId, thisUserId); return(roomConnIds.Union(userConnIds).Where(c => c != exceptConnection)); }
private Room(IEnumerable <Amphipod> occupants, RoomId roomId, int initialSize) { this.occupants = new Stack <Amphipod>(occupants.Reverse()); this.roomId = roomId; this.initialSize = initialSize; }
internal IEnumerable <(HallId id, int distance)> HallsAvailableFrom(RoomId roomId) { int distance = 2; for (HallId left = HallId.L + (int)roomId; left >= HallId.LL; left--) { if (Positions[(int)left] != null) { break; } yield return(left, distance); distance += (left == HallId.L) ? 1 : 2; } distance = 2; for (HallId right = HallId.AB + (int)roomId; right <= HallId.RR; right++) { if (Positions[(int)right] != null) { break; } yield return(right, distance); distance += (right == HallId.R) ? 1 : 2; } }
internal bool IsRoomReachable(HallId hallId, RoomId roomId, out int distance) { HallId left = HallId.L + (int)roomId; HallId right = left + 1; distance = 2; while (hallId < left) { hallId++; distance += (hallId == HallId.L) ? 1 : 2; if (Positions[(int)hallId] != null) { distance = 0; return(false); } } while (hallId > right) { hallId--; distance += (hallId == HallId.R) ? 1 : 2; if (Positions[(int)hallId] != null) { distance = 0; return(false); } } return(true); }
public void DeserializeTextChatMessageWithoutUserIdNullTest() { RoomId roomId = "55-178"; FirstName firstName = "John"; LastName lastName = "Brawn"; string text = "Message text."; var jsonString = "{\"roomId\":\"55-178\",\"firstName\":\"John\",\"lastName\":\"Brawn\",\"text\":\"Message text.\"}"; var jsonTupleString = $"[{jsonString},10]"; ITextChatMessage deserializedMessage = JsonConvert.DeserializeObject <TextChatMessage>(jsonString); Assert.AreEqual(null, deserializedMessage.UserId); Assert.AreEqual(roomId, deserializedMessage.RoomId); Assert.AreEqual(firstName, deserializedMessage.FirstName); Assert.AreEqual(lastName, deserializedMessage.LastName); Assert.AreEqual(text, deserializedMessage.Text); Assert.AreEqual(null, deserializedMessage.UserId); Assert.AreEqual((string)roomId, (string)deserializedMessage.RoomId); Assert.AreEqual((string)firstName, (string)deserializedMessage.FirstName); Assert.AreEqual((string)lastName, (string)deserializedMessage.LastName); var deserializedTuple = JsonConvert.DeserializeObject <Tuple <TextChatMessage, UserId> >(jsonTupleString, new TupleJsonArrayConverter()); Assert.AreEqual(null, deserializedTuple.Item1.UserId); Assert.AreEqual(roomId, deserializedTuple.Item1.RoomId); Assert.AreEqual(firstName, deserializedTuple.Item1.FirstName); Assert.AreEqual(lastName, deserializedTuple.Item1.LastName); Assert.AreEqual(text, deserializedTuple.Item1.Text); Assert.AreEqual(new UserId(10), deserializedTuple.Item2); }
public void Remove(RoomId roomId) { if (_idIndex.TryRemove(roomId, out Room value)) { _codeIndex.TryRemove(value.RoomCode, out Room _); } }
public override int GetHashCode() { int hash = 1; if (Channel != 0) { hash ^= Channel.GetHashCode(); } if (RoomId != 0L) { hash ^= RoomId.GetHashCode(); } if (Message.Length != 0) { hash ^= Message.GetHashCode(); } if (From != 0L) { hash ^= From.GetHashCode(); } if (FromName.Length != 0) { hash ^= FromName.GetHashCode(); } if (To != 0L) { hash ^= To.GetHashCode(); } if (ToName.Length != 0) { hash ^= ToName.GetHashCode(); } return(hash); }
public IRoom GetRoomById(RoomId id) { if (_roomIndexById.ContainsKey(id)) { return(_roomIndexById[id]); } return(default);
public async Task BookRoom( BookingId bookingId, string guestId, RoomId roomId, StayPeriod period, Money price, string bookedBy, DateTimeOffset bookedAt, IsRoomAvailable isRoomAvailable ) { EnsureDoesntExist(); await EnsureRoomAvailable(roomId, period, isRoomAvailable); Apply( new RoomBooked( bookingId.Value, roomId.Value, guestId, period.CheckIn, period.CheckOut, price.Amount, price.Currency, bookedBy, bookedAt ) ); }
public void Join(RoomId room) { this.service.JoinRoomRequestChannel.Send(new JoinRoomRequest() { Room = room, }); }
public async Task Handle(RoomOccupationStarted @event, CancellationToken cancellationToken) { var room = await store.Load <Room, RoomId>(RoomId.CreateFor(@event.RoomId)) as Room; room.StartOccupation(@event.OccupationEndDate); await store.Save <Room, RoomId>(room); }
public void Create(RoomId withId = null) { if (withId == null) { withId = new RoomId() { GUID = Guid.NewGuid(), Name = "New Room", } } ; var controller = this.Server.Context.Services.Get <NetRoomControllerService>().CreateServerRoomController(withId); this.rooms.Add(withId.GUID, controller); this.RoomCreatedEvent?.Invoke(this, controller); this.RoomListUpdatedEvent?.Invoke(this, this); controller.RoomEndedEvent += (s, e) => { this.RoomEndedEvent?.Invoke(this, e); this.rooms.Remove(e.State.Id.GUID); this.RoomListUpdatedEvent?.Invoke(this, this); }; this.service.CreateRoomResponseChannel.Send(new Models.CreateRoomResponse() { Success = true, Id = controller.State.Id, }); }
void GameEvent.IEnterRoom.OnEnterRoom(RoomId id) { if (UiRoom.RoomId == id) { MoveCameraHere(); } }
RoomId GetNextDown(RoomId current) { var nextRoom = RoomId.Elevator0; switch (current) { case RoomId.Elevator0: nextRoom = RoomId.Elevator1; break; case RoomId.Elevator1: nextRoom = RoomId.Elevator2; break; case RoomId.Elevator2: nextRoom = RoomId.Elevator3; break; case RoomId.Elevator3: nextRoom = RoomId.Elevator2; break; } return(nextRoom); }
public override int GetHashCode() { int hash = 1; if (Error != 0) { hash ^= Error.GetHashCode(); } if (Succeed != false) { hash ^= Succeed.GetHashCode(); } if (RoomId != 0) { hash ^= RoomId.GetHashCode(); } if (RoomOwnerId != 0) { hash ^= RoomOwnerId.GetHashCode(); } hash ^= playersInfo_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void ListRooms(Dictionary <RoomId, List <object> > availableRooms) { mAvailableRooms = availableRooms; mMyRoomListScrollFrame.ClearChildWidgets(); //we need to procedurally populate the scroll frame with the names of the available rooms from the server foreach (KeyValuePair <RoomId, List <object> > room in availableRooms) { IGuiFrame roomListing = (IGuiFrame)mMyRoomListingFramePrototype.Clone(); RoomId newRoomId = new RoomId(room.Key); Button deleteRoomButton = roomListing.SelectSingleElement <Button>("DeleteRoomButton"); deleteRoomButton.AddOnPressedAction( delegate() { DeleteRoom(newRoomId); } ); Button joinRoomButton = roomListing.SelectSingleElement <Button>("JoinRoomButton"); joinRoomButton.AddOnPressedAction( delegate() { JoinRoom(newRoomId); } ); Label roomNameLabel = roomListing.SelectSingleElement <Label>("RoomName"); roomNameLabel.Text = room.Value + " - id: " + room.Key.ToString(); mMyRoomListScrollFrame.AddChildWidget(roomListing, new HorizontalAutoLayout()); } }
public NetClientRoomController CreateClientRoomController(RoomId roomId, UserState localUser) { var controller = new NetClientRoomController(localUser, roomId, this.Channels, Context.Services.Get <NetMatchControllerService>()); this.RoomMap.Add(roomId.GUID, controller); return(controller); }
/// <summary> /// Initializes a new instance of the RoomInstance class. /// </summary> public RoomInstance() : base("RoomInstance", "RoomInstance", "RoomInstance", "Magnetizing_FPG", "Magnetizing_FPG") { if (entranceIds == null) { entranceIds = new List <int>(); } RoomName = "Room " + RoomId.ToString(); RoomId = maxId++; allRoomInstances.Add(this); m_attributes = new RoomInstanceAttributes(this); // if (m_attributes is RoomInstanceAttributes) foreach (RoomInstance room in (m_attributes as RoomInstanceAttributes).targetObjectList) { (m_attributes as RoomInstanceAttributes).RemoveAdjacence(room as RoomInstance); } //(m_attributes as RoomInstanceAttributes).targetObjectList.Clear(); //(m_attributes as RoomInstanceAttributes).writerTargetObjectsListString = new string[0]; }
protected override async Task Handle(CreateRoomServiceRequest request, CancellationToken cancellationToken) { var room = await _roomRepository.GetById(request.RoomId); if (room == null) { throw new RoomNotFoundException($"RoomId {request.RoomId.ToString()} does not exist."); } var employee = await _employeeRepository.GetById(request.EmployeeId); if (employee == null) { throw new EmployeeNotFoundException($"Employee {request.EmployeeId.ToString()} does not exist."); } var roomService = RoomService.CreateFor(RoomId.CreateFor(request.RoomId), EmployeeId.CreateFor(request.EmployeeId)); await eventStore.Save <RoomService, RoomServiceId>(roomService); //We send the integration events after transaction is ok. foreach (var @event in roomService.GetChanges()) { await _mediator.Publish(@event); } }
private IEnumerable <Move> GetAvailableMoves() { for (RoomId roomId = 0; roomId != RoomId.Count; roomId++) { Room room = Rooms[(int)roomId]; if (room.CanMoveOut) { Amphipod occupant = room.Peek(); RoomId destinationRoomId = occupant.Home; Room destinationRoom = Rooms[(int)destinationRoomId]; if (destinationRoom.CanMoveIn && Hallway.IsRoomReachable(roomId, destinationRoomId, out int hallDistance)) { yield return(new Move() { FromRoom = roomId, ToRoom = destinationRoomId, Cost = (room.MoveOutDistance + destinationRoom.MoveInDistance + hallDistance) * occupant.MoveCost, }); } else { foreach ((HallId hallId, int distance) in Hallway.HallsAvailableFrom(roomId)) { yield return(new Move() { FromRoom = roomId, ToHall = hallId, Cost = (room.MoveOutDistance + distance) * occupant.MoveCost, }); } } } } for (HallId hallId = 0; hallId < HallId.Count; hallId++) { Amphipod?occupantNullable = Hallway.Positions[(int)hallId]; if (occupantNullable.HasValue) { Amphipod occupant = occupantNullable.Value; RoomId roomId = occupant.Home; Room room = Rooms[(int)roomId]; if (room.CanMoveIn && Hallway.IsRoomReachable(hallId, roomId, out int hallDistance)) { yield return(new Move() { FromHall = hallId, ToRoom = roomId, Cost = (hallDistance + room.MoveInDistance) * occupant.MoveCost, }); } } } }
public void MergeFrom(ReservationCheckInNotification other) { if (other == null) { return; } if (other.JWToken.Length != 0) { JWToken = other.JWToken; } if (other.reservation_ != null) { if (reservation_ == null) { reservation_ = new global::HOLMS.Types.Booking.Indicators.ReservationIndicator(); } Reservation.MergeFrom(other.Reservation); } if (other.checkInDate_ != null) { if (checkInDate_ == null) { checkInDate_ = new global::HOLMS.Types.Primitive.PbLocalDate(); } CheckInDate.MergeFrom(other.CheckInDate); } if (other.roomId_ != null) { if (roomId_ == null) { roomId_ = new global::HOLMS.Types.Operations.Rooms.RoomIndicator(); } RoomId.MergeFrom(other.RoomId); } if (other.guestId_ != null) { if (guestId_ == null) { guestId_ = new global::HOLMS.Types.CRM.Guests.GuestIndicator(); } GuestId.MergeFrom(other.GuestId); } if (other.averageRate_ != null) { if (averageRate_ == null) { averageRate_ = new global::HOLMS.Types.Primitive.MonetaryAmount(); } AverageRate.MergeFrom(other.AverageRate); } if (other.ReservationBookingNumber.Length != 0) { ReservationBookingNumber = other.ReservationBookingNumber; } if (other.KeepGuaranteeRequested != false) { KeepGuaranteeRequested = other.KeepGuaranteeRequested; } }
private void SwitchRoom(Guid sessionId, RoomId newRoomId, RoomId oldRoomId, Hangout.Shared.Action userJoinedRoomCallback) { if (oldRoomId != null) { LeaveRoom(sessionId, oldRoomId); } JoinRoom(sessionId, newRoomId, userJoinedRoomCallback); }
internal Room(string initial, RoomId roomId) { this.occupants = new Stack <Amphipod>( initial.Reverse().Select(ch => new Amphipod(ch))); this.roomId = roomId; this.initialSize = this.occupants.Count; }
public void Create(RoomId withId = null) { this.service.CreateRoomRequestChannel.Send(new CreateRoomRequest() { Id = withId, Creator = LocalUser, }); }
public static void DisableRoomService(AccountId accountId, RoomId roomId, System.Action <XmlDocument> disableRoomServiceCallback) { WebServiceRequest disableRoomInDatabaseService = new WebServiceRequest(StateServerConfig.WebServicesBaseUrl, "Rooms", "DisableRoom"); disableRoomInDatabaseService.AddParam(kRoomId, roomId.ToString()); disableRoomInDatabaseService.AddParam(kAccountId, accountId.ToString()); disableRoomInDatabaseService.GetWebResponseAsync(disableRoomServiceCallback); }
public ObjectRef(ObjectId id, string name, IEnumerable <string> tags, RoomId room, bool canGet = true) { this.Id = id; this.Name = name; this.Room = room; this.CanGet = canGet; this.tags = new HashSet <string>(tags); }
public int CompareTo(RoomInfo other) { if (UserCount == other.UserCount) { return(RoomId.CompareTo(other.RoomId)); } return(-UserCount.CompareTo(other.UserCount)); }
private void BeginRoomLoading(Message receivedMessage) { RoomId currentRoomId = CheckType.TryAssignType <RoomId>(receivedMessage.Data[0]); mCurrentRoomDistributedObjectId = CheckType.TryAssignType <DistributedObjectId>(receivedMessage.Data[1]); GameFacade.Instance.SendNotification(GameFacade.ROOM_LOADING_STARTED, currentRoomId); }
public List <ITextChatMessage> GetHistory(RoomId roomId, List <MessageVisibility> withVisibilities, int messageCount) { return(new List <ITextChatMessage> { Resources.Alice.Message, Resources.Bob.Message }); }