Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Trait and TraitMapper internal, reduce interface use #2361

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading