• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ParadoxGameConverters / ImperatorToCK3 / 14599978051

22 Apr 2025 04:36PM UTC coverage: 45.651%. First build
14599978051

Pull #2474

github

web-flow
Merge e9a0f945d into acda5af5a
Pull Request #2474: [WIP] Conversion of treasures into artifacts

2098 of 5487 branches covered (38.24%)

Branch coverage included in aggregate %.

11 of 294 new or added lines in 15 files covered. (3.74%)

7842 of 16287 relevant lines covered (48.15%)

6043.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.74
/ImperatorToCK3/Mappers/Modifier/ModifierMapper.cs
1
using commonItems;
2
using System.Collections.Generic;
3

4
namespace ImperatorToCK3.Mappers.Modifier;
5

6
public sealed class ModifierMapper {
7
        private readonly Dictionary<string, KeyValuePair<string, double>> effectMap = new(); // imperator effect, <ck3 effect, factor>
6✔
8

9
        public ModifierMapper(string mappingsFilePath) {
12✔
10
                var parser = new Parser();
6✔
11
                parser.RegisterKeyword("link", mappingReader => {
23✔
12
                        string? ir = null;
17✔
13
                        string? ck3 = null;
17✔
14
                        double factor = 1;
17✔
15

6✔
16
                        var mappingParser = new Parser();
17✔
17
                        mappingParser.RegisterKeyword("ir", reader => ir = reader.GetString());
34✔
18
                        mappingParser.RegisterKeyword("ck3", reader => ck3 = reader.GetString());
34✔
19
                        mappingParser.RegisterKeyword("factor", reader => factor = reader.GetDouble());
34✔
20
                        mappingParser.RegisterRegex(CommonRegexes.Catchall, ParserHelpers.IgnoreAndLogItem);
17✔
21
                        mappingParser.ParseStream(mappingReader);
17✔
22
                        
6✔
23
                        if (ir is null) {
17!
NEW
24
                                Logger.Warn($"Modifier mapping {ir} {ck3} {factor} has no {nameof(ir)} entry!");
×
25
                        } else if (ck3 is null) {
17!
NEW
26
                                Logger.Warn($"Modifier mapping {ir} {ck3} {factor} has no {nameof(ck3)} entry!");
×
27
                        } else {
17✔
28
                                effectMap[ir] = new KeyValuePair<string, double>(ck3, factor);
17✔
29
                        }
17✔
30
                });
23✔
31
                parser.RegisterRegex(CommonRegexes.Catchall, ParserHelpers.IgnoreAndLogItem);
6✔
32
                parser.ParseFile(mappingsFilePath);
6✔
33
        }
6✔
34

35
        public KeyValuePair<string, double>? Match(string imperatorEffect, double imperatorValue) {
6✔
36
                if (!effectMap.TryGetValue(imperatorEffect, out var match)) {
8✔
37
                        return null;
2✔
38
                }
39

40
                var (ck3Effect, factor) = match;
4✔
41
                var ck3Value = imperatorValue * factor;
4✔
42
                return new KeyValuePair<string, double>(ck3Effect, ck3Value);
4✔
43
        }
6✔
44
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc