private static bool CanPlayerEnterRoom(Character.Models.Character player, Models.Room foundRoom, ItemRequirement itemReq = null, AttributeRequirement attrReq = null) { if (itemReq != null) { foreach (var item in player.CarriedItems) { if (item.ItemName == itemReq.RelevantItem.ItemName) { return(true); } } Console.WriteLine($"You need: <{itemReq.RequirementName}> to enter {foundRoom.RoomName}. \n", Color.DarkGoldenrod); } if (attrReq != null) { if (PlayerAttributeComparer.ComparePlayerTraitsToAttributeRequirement(player, attrReq)) { return(true); } Console.WriteLine($"You need: <{attrReq.RequirementName}> to enter {foundRoom.RoomName}. \n", Color.DarkGoldenrod); } return(false); }
public void MultipleUsersSelectAndDeselectMultipleCards() { Models.Room room = Hubs.RoomHub.Rooms[0]; UpdateConnectionId(); roomHub.JoinRoom(room.Id, "Jim Hopper"); UpdateConnectionId(); roomHub.JoinRoom(room.Id, "Jane Hopper"); UpdateConnectionId(); roomHub.JoinRoom(room.Id, "Joyce Byers"); UpdateConnectionId(); roomHub.JoinRoom(room.Id, "Jonathan Byers"); Models.User jimHopper = room.GetAllUsers().Find(x => x.Name == "Jim Hopper"); Models.User janeHopper = room.GetAllUsers().Find(x => x.Name == "Jane Hopper"); Models.User joyceByers = room.GetAllUsers().Find(x => x.Name == "Joyce Byers"); Models.User jonathanByers = room.GetAllUsers().Find(x => x.Name == "Jonathan Byers"); roomHub.SelectCard(room.Id, jimHopper.Id, 4); roomHub.SelectCard(room.Id, janeHopper.Id, 3); roomHub.SelectCard(room.Id, jonathanByers.Id, 5); roomHub.SelectCard(room.Id, joyceByers.Id, 2); roomHub.SelectCard(room.Id, janeHopper.Id, 5); roomHub.SelectCard(room.Id, jimHopper.Id, -1); Assert.AreEqual(-1, jimHopper.SelectedCard, "Jim Hopper should have card -1 selected"); Assert.AreEqual(5, janeHopper.SelectedCard, "Jane Hopper should have card 5 selected"); Assert.AreEqual(2, joyceByers.SelectedCard, "Joyce Byers should have card 2 selected"); Assert.AreEqual(5, jonathanByers.SelectedCard, "Jonathan Byers should have card 5 selected"); Assert.AreEqual(3, room.PlayedCards, $"Room {room.Id} should have 3 played cards"); }
// This is the logic for prompting the user for input continuously // until the user enters keywords to get to another room. // (Calls into a separate method to act on the input) public static Models.Room EnterRoom(Character.Models.Character player, Models.Room room) { Models.Room nextRoom = null; // Implement this while loop such that: // 1. It runs forever until the user enters a room keyword (one from a room connected to current room - RoomKeywords.cs) // 2. Prints the current room description to the console every time the loop runs // 3. Ask for user input, and calls PlayerActionHandler.HandlePlayerInput to handle the input // - Note that the PlayerActionHandler returns null, unless the input matches a room keyword (then it returns the next room) // 4. If the PlayerActionHandler returns null, the loop iterates again. Otherwise, returns the next room while (nextRoom == null) { // Print out the current Room's Room.InitialRoomDescription to the console if Room.RoomEntered is false, // Otherwise print Room.GenericRoomDescription to the console // E.C.: Use TypingAnimation.Animate to print to console // Now write to the console the ConsoleStrings.PlayerInputPrompt to ask the user for input // Call ReadLine to get the input from the user; store this in a variable //Set nextRoom to the return value of PlayerActionHandler.HandlePlayerInput (otherwise we loop forever!) } return(nextRoom); }
public void CreateNewRoom() { var room = new Models.Room("1,2,3,4,5,6"); string id = room.Id; Assert.IsTrue(Guid.TryParse(id, out _), "The room ID should be a GUID"); }
/// <summary> /// 得到一个对象实体 /// </summary> public Models.Room GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select *"); strSql.Append(" from tb_room"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Models.Room model = new Models.Room(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
// Add a getter here for each room that you want to exist in the game // Constructor: Add the reference to all the Room Objects here public RoomCreator() { YourBedroom = GameRooms.YourBedroom; // Set the getters from above this constructor to the actual GameRoom objects. // Hint: refer to the ItemCreator.cs for an example AddExitsToAllRooms(); }
public static void Add(Models.Room room) { using (CycloidContext context = new CycloidContext()) { context.Room.Add(room); context.SaveChanges(); } }
public static void Update(Models.Room room) { using (CycloidContext context = new CycloidContext()) { context.Entry(room).State = EntityState.Modified; context.SaveChanges(); } }
public async Task Refresh(Models.Room room) { await this.Groups.AddToGroupAsync(this.Context.ConnectionId, room.Name); var currentGame = await this.GameService.Current(room); await this.Clients.Group(room.Name).Refresh(room.Name, this.Map(currentGame)); }
// Room public static Entities.Room ToEntity(this Models.Room room) { return(new Entities.Room { RoomId = room.RoomId, Name = room.Name, MaxDesks = int.Parse(room.MaxDesks) }); }
public void RevealAllCards() { string roomId = roomHub.CreateRoom("1,2,3,4,5,6", false); Models.Room room = Hubs.RoomHub.Rooms.Find(x => x.Id == roomId); roomHub.RevealCards(roomId); Assert.IsTrue(room.CardsRevealed, $"The cards in room {room.Id} should be revealed"); }
public static Models.Room GetById(int id) { Models.Room room = new Models.Room(); using (CycloidContext context = new CycloidContext()) { room = context.Set <Models.Room>().Find(id); } return(room); }
public void Add() { var room = new Models.Room { Name = "Room 123", Building = "Korzplex", }; Console.WriteLine(EventsXdService.Rooms.Add(5577, room)); }
public async Task DeleteRoomAsync(Models.Room room) { try { await _roomRepository.DeleteRoomAsync(room.ToEntity()); } catch (System.Exception) { throw; } }
public void SingleUserSelectsSingleCard() { Models.Room room = Hubs.RoomHub.Rooms[0]; UpdateConnectionId(); roomHub.JoinRoom(room.Id, "Jim Hopper"); Models.User jimHopper = room.GetAllUsers().Find(x => x.Name == "Jim Hopper"); roomHub.SelectCard(room.Id, jimHopper.Id, 4); Assert.AreEqual(4, jimHopper.SelectedCard, "Jim Hopper should have card 4 selected"); Assert.AreEqual(1, room.PlayedCards, $"Room {room.Id} should have 1 played card"); }
public static DataAccessLayer.Entities.Room ModelRoomToEntityRoom(Models.Room modelRoom) { DataAccessLayer.Entities.Room entityRoom = new DataAccessLayer.Entities.Room() { Id = modelRoom.Id, Name = modelRoom.Name, IsDeleted = modelRoom.IsDeleted, }; return(entityRoom); }
public void Update() { var room = new Models.Room { Name = "Room 123", Building = "Korzplex", Id = "25190" }; Console.WriteLine(EventsXdService.Rooms.Update(5577, room)); }
//----------------------------------------ROOM------------------------------------------------------- public static Models.Room EntityRoomToModelRoom(DataAccessLayer.Entities.Room entityRoom) { Models.Room modelRoom = new Models.Room { Id = entityRoom.Id, Name = entityRoom.Name, IsDeleted = entityRoom.IsDeleted }; return(modelRoom); }
public async Task <bool> Post([FromBody] Models.Room room) { if (room.location_id == 0) { return(false); } context.rooms.Add(room); await context.SaveChangesAsync(); return(true); }
public void RemoveSingleUserFromRoom() { var room = new Models.Room("1,2,3,4,5,6"); var jimHopper = room.AddUser("Jim Hopper", "1"); room.AddUser("Jane Hopper", "2"); room.RemoveUser(jimHopper.Id); int actualUserCount = room.GetAllUsers().Count; Assert.AreEqual(1, actualUserCount, "The room should contain 1 user"); }
public static DTO.Room Convert(Models.Room room) { return(new DTO.Room { Name = room.Name, Host = ConvertPlayer(room.Host), TeamA = ConvertTeam(room.TeamA), TeamB = ConvertTeam(room.TeamB), Board = ConvertBoard(room.Board, room.TeamA, room.TeamB), HasGameStarted = room.HasGameStarted, Round = ConvertRound(room.Board.CurrentRound) }); }
public bool IsRoomExist(Models.Room room) { bool flag = false; foreach (DataRow dr in dt.Rows) { if (room.RoomName == dr[0].ToString()) { flag = true; break; } } return(flag); }
// Returns an item in a room matching by the users input keyword public static List <string> GetAllRoomItemKeywords(Models.Room currentRoom) { var keywords = new List <string>(); // Implement this helper method such that: // 1. Check if the currentRoom has InventoryItems // - Loop on all items, add KeywordsForPickup that are not null or empty to the keywords variable // 2. Check if the currentRoom has WeaponItems // - Loop on all weapons, add KeywordsForPickup that are not null or empty to the keywords variable // 3. Return the keywords list return(keywords); }
// Constructor: Add the reference to all the Room Objects here public RoomCreator() { // Your House YourBedroom = YourHouse.YourBedroom; YourLivingRoom = YourHouse.YourLivingRoom; YourKitchen = YourHouse.YourKitchen; YourFrontEntryway = YourHouse.YourFrontEntryway; YourBasement = YourHouse.YourBasement; YourFrontPorch = YourHouse.YourFrontPorch; YourDriveway = YourHouse.YourDriveway; YourShed = YourHouse.YourShed; RoadConnectingYourHouseToTown = YourHouse.RoadConnectingYourHouseToTown; // Forest ForestLake = Forest.ForestLake; ForestLakeTent = Forest.ForestLakeTent; EastForest = Forest.EastForest; EastForestLowerClearing = Forest.EastForestLowerClearing; EastForestUpperClearing = Forest.EastForestUpperClearing; DeepEastForest = Forest.DeepEastForest; DeepEastForestLowerRiver = Forest.DeepEastForestLowerRiver; DeepEastForestUpperRiver = Forest.DeepEastForestUpperRiver; DeepEastForestUpperRiverCave = Forest.DeepEastForestUpperRiverCave; EastForestCampground = Forest.EastForestCampground; PathBetweenCampAndEastRoad = Forest.PathBetweenCampAndEastRoad; EastRoadToTown = Forest.EastRoadToTown; // Town TownSouthEntrance = Town.TownSouthEntrance; TownNorthEntrance = Town.TownNorthEntrance; TownEastEntrance = Town.TownEastEntrance; TownWestEntrance = Town.TownWestEntrance; AshburySouthSquare = Town.AshburySouthSquare; AshburyNorthSquare = Town.AshburyNorthSquare; AshburyEastSquare = Town.AshburyEastSquare; AshburyWestSquare = Town.AshburyWestSquare; AshburySouthMainStreet = Town.AshburySouthMainStreet; AshburyNorthMainStreet = Town.AshburyNorthMainStreet; AshburyEastPlaza = Town.AshburyEastPlaza; AshburyWestPlaza = Town.AshburyWestPlaza; AshburyTownCenter = Town.AshburyTownCenter; AshburySouthSquareEastAlley = Town.AshburySouthSquareEastAlley; AshburySouthEastVeterinaryClinic = Town.AshburySouthEastVeterinaryClinic; AshburySouthEastCornerLot = Town.AshburySouthEastCornerLot; AshburySouthEastDurrowHouse = Town.AshburySouthEastDurrowHouse; AshburySouthEastAviary = Town.AshburySouthEastAviary; AshburySouthEastWell = Town.AshburySouthEastWell; AshburySouthSquareWestAlley = Town.AshburySouthSquareWestAlley; AddExitsToAllRooms(); }
public static Models.ValidationResult UpdateRoom(Models.Room room) { using (var uow = new DAL.UnitOfWork()) { var validationResult = ValidateRoom(room, false); if (validationResult.IsValid) { uow.RoomRepository.Update(room, room.Id); validationResult.IsValid = uow.Save(); } return(validationResult); } }
public static Models.ValidationResult AddRoom(Models.Room room) { using (var uow = new DAL.UnitOfWork()) { var validationResult = ValidateRoom(room, true); if (validationResult.IsValid) { uow.RoomRepository.Insert(room); validationResult.IsValid = uow.Save(); } return(validationResult); } }
public void AddUsersWithSameConnectionId() { var room = new Models.Room("1,2,3,4,5,6"); room.AddUser("Jim Hopper", "1"); room.AddUser("Jane Hopper", "1"); int actualUserCount = room.GetAllUsers().Count; Assert.AreEqual(1, actualUserCount, "The room should contain 1 user"); int actualConnectionCount = room.Connections.Count; Assert.AreEqual(1, actualConnectionCount, "The room should contain 1 connection"); }
// Returns a character in a room matching by the users input keyword public static List <string> GetAllRoomCharacterKeywords(Models.Room currentRoom) { var keywords = new List <string>(); if (currentRoom?.RoomCharacters != null) { foreach (var character in currentRoom.RoomCharacters) { keywords.AddRange(character.CharacterKeywords.Where(k => !string.IsNullOrEmpty(k))); } } return(keywords); }
public async Task <IActionResult> OnGet(int roomId) { if (roomId > 0) { await Task.Run(() => Room = _roomService.GetRoom(roomId, includeMessages: true)); } if (Room == null || !RoomPermissionHelper.CanViewRoom(_context.CurrentUser, Room)) { return(LocalRedirect(UrlHelper.GetAccessDeniedUrl())); } return(Page()); }
private void button1_Click(object sender, EventArgs e) { Models.Room room = new Models.Room(); room.BuildingName = this.comboBox1.Text; room.Floor = this.comboBox2.Text; room.Num = this.comboBox3.Text; textBox1.Text = room.RoomName; room.RoomType = comboBox4.Text; room.Memo = textBox2.Text; room.RoomStatus = comboBox5.Text; label8.Text = rd.AddRoom(room); dataGridView1.DataSource = DALS.DataWork.ds.Tables[0]; }
public void ImportRooms() { var mongoRooms = this.MongoDataManager.GetCollectionAsList<MongoModels.Room>("rooms"); foreach (var room in mongoRooms) { var roomEntity = new Models.Room { Name = room.Name }; this.Db.Set<Models.Room>().AddOrUpdate(x => x.Name, roomEntity); } this.Db.SaveChanges(); }