Skip to content

Commit

Permalink
Make Trait and TraitMapper internal, reduce interface use (#2361)
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored Dec 15, 2024
1 parent 1882b53 commit 75c0ff7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public CK3CharacterBuilder WithCultureMapper(CultureMapper cultureMapper) {
this.cultureMapper = cultureMapper;
return this;
}
public CK3CharacterBuilder WithTraitMapper(TraitMapper traitMapper) {
internal CK3CharacterBuilder WithTraitMapper(TraitMapper traitMapper) {
this.traitMapper = traitMapper;
return this;
}
Expand Down
4 changes: 2 additions & 2 deletions ImperatorToCK3.UnitTests/Mappers/Trait/TraitMapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace ImperatorToCK3.UnitTests.Mappers.Trait;
[Collection("Sequential")]
[CollectionDefinition("Sequential", DisableParallelization = true)]
public class TraitMapperTests {
public class TestTraitMapper : TraitMapper {
public TestTraitMapper(Dictionary<string, string> irToCK3TraitMap, IdObjectCollection<string, ImperatorToCK3.CK3.Characters.Trait> ck3Traits) {
internal class TestTraitMapper : TraitMapper {
internal TestTraitMapper(Dictionary<string, string> irToCK3TraitMap, IdObjectCollection<string, ImperatorToCK3.CK3.Characters.Trait> ck3Traits) {
ImperatorToCK3TraitMap = irToCK3TraitMap;
CK3Traits = ck3Traits;
}
Expand Down
7 changes: 3 additions & 4 deletions ImperatorToCK3/CK3/Characters/Trait.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
using commonItems;
using commonItems.Collections;
using System.Collections.Generic;
using System.Linq;

namespace ImperatorToCK3.CK3.Characters;
public sealed class Trait : IIdentifiable<string> {
internal sealed class Trait : IIdentifiable<string> {
public string Id { get; }
public ISet<string> Opposites { get; private set; } = new HashSet<string>();
public HashSet<string> Opposites { get; private set; } = [];

public Trait(string id) {
Id = id;
}
public Trait(string id, BufferedReader traitReader) : this(id) {
var parser = new Parser();
parser.RegisterKeyword("opposites", reader => Opposites = reader.GetStrings().ToHashSet());
parser.RegisterKeyword("opposites", reader => Opposites = [.. reader.GetStrings()]);
parser.RegisterRegex(CommonRegexes.Catchall, ParserHelpers.IgnoreItem);
parser.ParseStream(traitReader);
}
Expand Down
4 changes: 2 additions & 2 deletions ImperatorToCK3/Mappers/Trait/TraitMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace ImperatorToCK3.Mappers.Trait;

public class TraitMapper {
internal class TraitMapper {
protected IDictionary<string, string> ImperatorToCK3TraitMap = new Dictionary<string, string>();
protected IdObjectCollection<string, CK3.Characters.Trait> CK3Traits = [];

Expand Down Expand Up @@ -46,7 +46,7 @@ private void RegisterKeys(Parser parser) {
public string? GetCK3TraitForImperatorTrait(string impTrait) {
return ImperatorToCK3TraitMap.TryGetValue(impTrait, out var ck3Trait) ? ck3Trait : null;
}
public ISet<string> GetCK3TraitsForImperatorTraits(IEnumerable<string> irTraits) {
public HashSet<string> GetCK3TraitsForImperatorTraits(IEnumerable<string> irTraits) {
HashSet<string> ck3TraitsToReturn = [];
foreach (var irTrait in irTraits) {
var ck3Trait = GetCK3TraitForImperatorTrait(irTrait);
Expand Down

0 comments on commit 75c0ff7

Please sign in to comment.