public string AddPlayer (string type, string username, int health, int armor, string gunName) { IGun gun = gunRepository.FindByName(gunName); if (gun == null) { throw new ArgumentException("Gun cannot be found!"); } if (type == "Terrorist") { Player newPlayer = new Terrorist(username, health, armor, gun); playerRepository.Add(newPlayer); } else if (type == "CounterTerrorist") { Player newPlayer = new CounterTerrorist(username, health, armor, gun); playerRepository.Add(newPlayer); } else { throw new ArgumentException("Invalid player type!"); } return($"Successfully added player {username}."); }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IGun playersGun = gunsRep.FindByName(gunName); if (playersGun == null) { throw new ArgumentException("Gun cannot be found!"); } if (type == "Terrorist" || type == "CounterTerrorist") { if (type == "Terrorist") { playerRep.Add(new Terrorist(username, health, armor, playersGun)); } else if (type == "CounterTerrorist") { playerRep.Add(new CounterTerrorist(username, health, armor, playersGun)); } } else { throw new ArgumentException("Invalid player type."); } return($"Successfully added player {username}."); }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IGun gun = gunRepository.FindByName(gunName); if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } IPlayer player; if (type == "Terrorist") { player = new Terrorist(username, health, armor, gun); playerRepository.Add(player); return($"Successfully added player {player.Username}."); } else if (type == "CounterTerrorist") { player = new CounterTerrorist(username, health, armor, gun); playerRepository.Add(player); return($"Successfully added gun {gun.Name}."); } else { throw new ArgumentException(ExceptionMessages.InvalidPlayerType); } }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IGun gun = guns.FindByName(gunName); if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } switch (type) { case "Terrorist": players.Add(new Terrorist(username, health, armor, gun)); break; case "CounterTerrorist": players.Add(new CounterTerrorist(username, health, armor, gun)); break; default: throw new ArgumentException(ExceptionMessages.InvalidPlayerType); } return(string.Format(OutputMessages.SuccessfullyAddedPlayer, username)); }
public void Should_be_able_to_add_player_rivalry_statistics() { var game = ObjectMother.CreateGame(); _gameRepository.Add(game); var player = ObjectMother.CreatePlayer(); var affectedPlayer = ObjectMother.CreatePlayer(); _playerRepository.Add(player); _playerRepository.Add(affectedPlayer); var hole = ObjectMother.CreateHole(Int32.MaxValue); _holeRepository.Add(hole); var shotType = ObjectMother.CreateShotType(); _shotTypeRepository.Add(shotType); var playerRivalryStatistics = ObjectMother.CreatePlayerRivalryStatistics(game, player, affectedPlayer, hole, shotType); _playerRivalryStatisticsRepository.Add(playerRivalryStatistics); Assert.AreNotEqual(0, playerRivalryStatistics.Id); }
public void Should_be_able_to_add_player() { var player = ObjectMother.CreatePlayer(); _repository.Add(player); Assert.AreNotEqual(0, player.Id); }
public void TestHighCardWinner() { IPlayerRepository playerRepository = new PlayerRepository(); IGameManager gameManager = new GameManager(); // Create test data playerRepository.Add(new Player { PlayerName = "Devin", Cards = new List <Card> { new Card { Rank = "A", Suit = "D" }, new Card { Rank = "2", Suit = "D" }, new Card { Rank = "3", Suit = "D" }, new Card { Rank = "7", Suit = "S" }, new Card { Rank = "10", Suit = "H" } } }); playerRepository.Add(new Player { PlayerName = "Maks", Cards = new List <Card> { new Card { Rank = "K", Suit = "H" }, new Card { Rank = "Q", Suit = "D" }, new Card { Rank = "10", Suit = "S" }, new Card { Rank = "9", Suit = "D" }, new Card { Rank = "7", Suit = "H" } } }); (var winners, var hand) = gameManager.GetWinners(playerRepository.GetAll()); // Assert that Devin won with the High Card Assert.AreEqual("Devin", winners.FirstOrDefault().PlayerName); Assert.AreEqual(HandTypes.HighCard, hand); }
public string AddPlayer(string type, string username) { if (type == "Beginner") { var player = new Beginner(new CardRepository(), username); playerRepository.Add(player); return($"Successfully added player of type {type} with username: {username}"); } else { var player = new Advanced(new CardRepository(), username); playerRepository.Add(player); return($"Successfully added player of type {type} with username: {username}"); } }
public void ShouldBeAbleToAddPlayerGameStatistics() { var game = ObjectMother.CreateGame(); _gameRepository.Add(game); var player = ObjectMother.CreatePlayer(); _playerRepository.Add(player); var playerGameStatistics = ObjectMother.CreatePlayerGameStatistics(game, player); _playerGameStatisticsRepository.Add(playerGameStatistics); Assert.AreNotEqual(0, playerGameStatistics.Id); }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { var gun = _guns.FindByName(gunName); if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } if (!Enum.TryParse(type, out PlayerType playerType)) { throw new ArgumentException(ExceptionMessages.InvalidGunType); } IPlayer player = null; switch (playerType) { case PlayerType.Terrorist: player = new Terrorist(username, health, armor, gun); break; case PlayerType.CounterTerrorist: player = new CounterTerrorist(username, health, armor, gun); break; } _players.Add(player); return(string.Format(OutputMessages.SuccessfullyAddedPlayer, username)); }
public void Handle(NetConnection sender, SNMessageData messageData) { if (!(sender.Tag is PlayerClient)) { return; } var client = (PlayerClient)sender.Tag; var selectCharacterMessageData = (SelectCharacterMessageData)messageData; if (!IsAccountCharacter(client.PersistentId, selectCharacterMessageData.CharacterId, out Character character)) { return; } var characterSelectedMessageData = new CharacterSelectedMessageData(); characterSelectedMessageData.Character = character; outgoingMessageService.Send(characterSelectedMessageData, sender); var player = new Player(client, character); playerRepository.Add(player); sender.Tag = player; // Send already connected players positions entitiesProcessor.NewPlayerConnected(player); }
public ActionResult Create(PlayerModel model) { try { // TODO: Add insert logic here PlayerRepository repository = new PlayerRepository(); model.UserId = User.Identity.GetUserId(); var player = repository.Add(model); if (Request.Files[0].ContentLength > 0) { HttpPostedFileBase postedFile = Request.Files[0]; string filename = player.Id + ".jpg"; var blobHelper = new StorageHelper.BlobHelper(); var container = blobHelper.GetContainer("playerspictures"); blobHelper.UploadToContainer(postedFile, container, filename); return RedirectToAction("Index"); } return RedirectToAction("Index"); } catch(Exception ex) { Trace.TraceError(ex.Message); throw; } }
private void PlayerCreateButton_Click(object sender, EventArgs e) { PlayerRepository repos = new PlayerRepository(); if (NewPlayerTextBox.Text != "") { if (freestats == 0) { if (!repos.IsExist(NewPlayerTextBox.Text)) { Player pl = new Player(NewPlayerTextBox.Text, str, agi, stm); repos.Add(pl); SwitchScene(Scene.Menu, pl); } else { MessageBox.Show("This name is already taken"); } } else { MessageBox.Show("Use all stats"); } } else { MessageBox.Show("Input name"); } }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IPlayer Player = null; IGun gun = null; gun = gunRepository.FindByName(gunName); if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } switch (type) { case "Terrorist": Player = new Terrorist(username, health, armor, gun); break; case "CounterTerrorist": Player = new CounterTerrorist(username, health, armor, gun); break; default: throw new ArgumentException(ExceptionMessages.InvalidPlayerType); // exc message-a se razlichava s tova ot faila } playerRepository.Add(Player); return(String.Format(OutputMessages.SuccessfullyAddedPlayer, username)); }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IPlayer player; IGun gun = gunRepository.FindByName(gunName); if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } if (type == "Terrorist") { player = new Terrorist(username, health, armor, gun); } else if (type == "CounterTerrorist") { player = new CounterTerrorist(username, health, armor, gun); } else { throw new ArgumentException(ExceptionMessages.InvalidPlayerType); } playerRepository.Add(player); return(string.Format(OutputMessages.SuccessfullyAddedPlayer, username)); }
protected override Event Persist() { if (Result.Resolution == EventResolutionType.Commit) { playerRepository.Add(_player); var dumpPlayerAt = new EnterLocationEvent(_id, _player.LoggedOutPosition); Engine.Instance.Push(dumpPlayerAt); } // TEMPORARY WORKAROUND TO ALWAYS SPAWN A MONSTER WHEN PLAYER SUBSCRIBES: //var monster = (Monster)ResourceLocator.Get(Id.FromString("M1111123")); //if (monster == null) //{ // monster = MonsterFactory.Create("A"); // ResourceLocator.Add(monster); // _player.Scene.Entities.Add(monster); //} //TODO: Look at this! We should be able to have one way references. //_player.Scene.Entities.Add(_player); //_player.Scene = todoScene; return(this); }
public void Post([FromBody] PlayerAddRequest players) { if (ModelState.IsValid) { playerRepository.Add(players); } }
public string AddPlayer(string type, string username) { IPlayer player; if (type == "Beginner") { player = new Beginner(new CardRepository(), username); playerRepository.Add(player); } else if (type == "Advanced") { player = new Advanced(new CardRepository(), username); playerRepository.Add(player); } return(result = string.Format(ConstantMessages.SuccessfullyAddedPlayer, type, username)); }
public string AddPlayer(string type, string username) { var player = playerFactory.CreatePlayer(type, username); playerRepository.Add(player); return($"Successfully added player of type {type} with username: {username}"); }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { if (type == nameof(Terrorist) || type == nameof(CounterTerrorist)) { IPlayer player; IGun gun; gun = guns.FindByName(gunName); if (type == nameof(Terrorist)) { if (gun == null) { throw new ArgumentException(String.Format(ExceptionMessages.GunCannotBeFound)); } else { player = new Terrorist(username, health, armor, gun); players.Add(player); } } else { if (gun == null) { throw new ArgumentException(String.Format(ExceptionMessages.GunCannotBeFound)); } else { player = new CounterTerrorist(username, health, armor, gun); players.Add(player); } } return(String.Format(OutputMessages.SuccessfullyAddedPlayer, player.Username)); } else { throw new ArgumentException(String.Format(ExceptionMessages.InvalidPlayerType)); } }
public void DoesNotAddDuplicatePlayer() { var player = new Player { FirstName = "First 1", LastName = "Last 1" }; var playerRepository = new PlayerRepository(_fixture.Context); playerRepository.Add(player); playerRepository.Add(player); var result = playerRepository.GetAll(); Assert.Equal(1, result.Count()); Assert.Equal(player, result.First()); }
public static void AddPlayerUsingRepository() { var playerRepo = new PlayerRepository(); var player = new Player { FirstName = "Emil", LastName = "Christensen", NickName = "HeatoN", CountryId = 1, BirthDate = new DateTime(1984, 5, 15), Status = "Retierd", Role = "Rifler" }; playerRepo.Add(player); playerRepo.Save(); }
public ActionResult Create(PlayerModel model) { if (ModelState.IsValid) { playerRepository.Add(PlayerModel.ToDatabaseModel(model)); return(RedirectToAction("Index")); } return(View(model)); }
private void CreatePlayer(Player player) { var playerRepo = new PlayerRepository(); Player existing = playerRepo.FindByExternalId(player.ExternalId); if (existing == null) { playerRepo.Add(player); } }
public void Should_be_able_to_add_ranking() { var player = ObjectMother.CreatePlayer(); _playerRepository.Add(player); var ranking = ObjectMother.CreateRanking(player); _rankingRepository.Add(ranking); Assert.AreNotEqual(0, ranking.Id); }
public void Should_be_able_to_add_player_statistics() { var player = ObjectMother.CreatePlayer(); _playerRepository.Add(player); var playerStatistics = ObjectMother.CreatePlayerStatistics(player); _playerStatisticsRepository.Add(playerStatistics); Assert.AreNotEqual(0, playerStatistics.Id); }
/// <summary>Saves this player.</summary> public override void Save() { // Save the player's basic info. var repository = new PlayerRepository(); if (this.ID == 0) { repository.Add(this.PlayerData); this.ID = this.PlayerData.ID; } else { repository.Update(this.PlayerData); } /* Disabling roles for now * // Deal with the player roles. * var roleRepository = new PlayerRoleRepository(); * ICollection<PlayerRoleRecord> existingRoles = roleRepository.FetchAllPlayerRoleRecordsForPlayer(this.Id); * * var toAdd = new List<PlayerRoleRecord>(); * * foreach (var roleRecord in this.RoleData) * { * var currRole = this.FindRole(roleRecord.ID, existingRoles); * * if (currRole == null) * { * // Add it to the list to add * toAdd.Add(currRole); * } * else * { * // Remove the role since there is nothing to do. * existingRoles.Remove(currRole); * } * } * * roleRepository.AddRolesToPlayer(toAdd); * * // Delete any roles still in the existing roles collection as they * // are no longer assigned to the person. * foreach (PlayerRoleRecord existingRole in existingRoles) * { * roleRepository.Remove(existingRole); * } */ // @@@ TODO: Need to do this with all the other custom lists and collections, like friends and inventory. }
public void AddPlayer() { var player = new Player { FirstName = "First 1", LastName = "Last 1" }; var playerRepository = new PlayerRepository(_fixture.Context); var result = playerRepository.Add(player); Assert.NotNull(result); Assert.Equal(player, result); }
public string AddPlayer(string type, string username) { var player = playerFactory.CreatePlayer(type, username); try { players.Add(player); } catch (Exception e) { return(e.Message); } return(ConstantMessages.SuccessfullyAddedPlayer .Replace("{0}", type) .Replace("{1}", username)); }
public void Should_be_able_to_add_player_hole_statistics() { var player = ObjectMother.CreatePlayer(); _playerRepository.Add(player); var hole = ObjectMother.CreateHole(Int32.MaxValue); _holeRepository.Add(hole); var playerHoleStatistics = ObjectMother.CreatePlayerHoleStatistics(player, hole); _playerHoleStatisticsRepository.Add(playerHoleStatistics); Assert.AreNotEqual(0, playerHoleStatistics.Id); }
public void SignUp(Registered player) { if (player == null) { throw new ArgumentNullException(nameof(player)); } if (string.IsNullOrEmpty(player.Name)) { throw new InvalidOperationException("Name must be provided."); } if (string.IsNullOrEmpty(player.Password)) { throw new InvalidOperationException("Password must be provided."); } _repository.Add(player); }