/// <summary> /// Adds a certain amount of fame (or disrepute) for a player, to their relationship with a faction. /// </summary> /// <param name="playerName">Name of the player to change reputation for</param> /// <param name="factionName">Faction with which reputation will be changed</param> /// <param name="amount">Amount by which reputation will change</param> public static OperationResult ChangeFactionStanding(string playerName, string factionName, int amount) { var result = new OperationResult(); var player = GetByName(playerName); if (player == null) { result.Message = $"Player {playerName} has no entry in the Penumbra database."; return(result); } var faction = FactionRepository.GetByName(factionName); if (faction == null) { result.Message = $"Faction {factionName} has no entry in the Penumbra database."; return(result); } var relevantReputation = player.Reputations.FirstOrDefault(r => r.Id == faction.Id); if (relevantReputation == null) { relevantReputation = new Reputation { PlayerId = player.Id, FactionId = faction.Id, Standing = amount }; ReputationRepository.Create(relevantReputation); } else { relevantReputation.Standing += amount; ReputationRepository.Update(relevantReputation); } return(result); }