public string AddGunToPlayer(string name) { if (this.gunRepository.Models.Count == 0) { return($"There are no guns in the queue!"); } IGun gunToAdd = gunRepository.Models.ElementAt(0); if (name == "Vercetti") { mainPlayer.GunRepository.Add(gunToAdd); gunRepository.Remove(gunToAdd); return($"Successfully added {gunToAdd.Name} to the Main Player: Tommy Vercetti"); } if (this.civilPlayers.All(p => p.Name != name)) { return($"Civil player with that name doesn't exists!"); } IPlayer playerToBeAddedGun = this.civilPlayers.First(p => p.Name == name); playerToBeAddedGun.GunRepository.Add(gunToAdd); gunRepository.Remove(gunToAdd); return($"Successfully added {gunToAdd.Name} to the Civil Player: {playerToBeAddedGun.Name}"); }
public string AddGunToPlayer(string name) { if (gunRepo.Models.Count == 0) { return("There are no guns in the queue!"); } IGun gun = gunRepo.Models.FirstOrDefault(); if (name == "Vercetti") { tommy.GunRepository.Add(gun); gunRepo.Remove(gun); return($"Successfully added {gun.Name} to the Main Player: Tommy Vercetti"); } var civilPlayer = civilPlayers.FirstOrDefault(x => x.Name == name); if (civilPlayer == null) { return("Civil player with that name doesn't exists!"); } civilPlayer.GunRepository.Add(gun); gunRepo.Remove(gun); return($"Successfully added {gun.Name} to the Civil Player: {civilPlayer.Name}"); }
public string AddGunToPlayer(string name) { if (gunRepository.Models.Count == 0) { return("There are no guns in the queue!"); } var gun = gunRepository.models[0]; if (name == "Vercetti") { gunRepository.Remove(gun); return($"Successfully added {gun.Name} to the Main Player: Tommy Vercetti"); } if (!civilPlayers.Any(x => x.Name == name)) { return("Civil player with that name doesn't exists!"); } gunRepository.Remove(gun); civilPlayers.FirstOrDefault(x => x.Name == name).GunRepository.Add(gun); return($"Successfully added {gun.Name} to the Civil Player: {name}"); }
public string AddGunToPlayer(string name) { IPlayer player = players.FirstOrDefault(p => p.Name == name && p.IsAlive == true); IGun gun = guns.Models.FirstOrDefault(g => g.CanFire); if (guns.Models.Count == 0) { return("There are no guns in the queue!"); } else if (name == "Vercetti") { mainPlayer.GunRepository.Add(gun); guns.Remove(gun); return($"Successfully added {gun.Name} to the Main Player: Tommy Vercetti"); } else if (!players.Any(p => p.Name == name)) { return("Civil player with that name doesn't exists!"); } else { player.GunRepository.Add(gun); guns.Remove(gun); return($"Successfully added {gun.Name} to the Civil Player: {player.Name}"); } }
public string AddGunToPlayer(string name) { var gun = gunRepository.Models.FirstOrDefault(x => x.CanFire); if (gun == null) { return("There are no guns in the queue!"); } if (name == "Vercetti") { var mainPlayer = players.FirstOrDefault(x => x.Name == "Tommy Vercetti"); mainPlayer.GunRepository.Add(gun); gunRepository.Remove(gun); return($"Successfully added {gun.Name} to the Main Player: Tommy Vercetti"); } else { var civilPlayer = players.FirstOrDefault(x => x.Name == name); if (civilPlayer == null) { return("Civil player with that name doesn't exists!"); } civilPlayer.GunRepository.Add(gun); gunRepository.Remove(gun); return($"Successfully added {gun.Name} to the Civil Player: {name}"); } }