-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bookmark map with player titles displayed (#324) #minor
* DrawBookmarkMap test * Prepare BookmarkOutputter for displaying player countries * Draw bookmark map with player titles displayed * PR tweaks * Fix regression * Make countries on map semi-transparent * Determine province neighbors from provinces.png * Determine colorable impassables * Color some impassables * Create realm highlight file * Minor optimisation * Update title_map.txt * Calculate position for players on bookmark screen * Change provincePositionsPath * Update commonItems.NET * Calculate position of character on bookmark screen * Separate file for ProvincePosition * Separate files for classes * ReSharper tweaks for BookmarkOutputter * ID -> Id * ProvinceDefinitionTests * TestFiles, ProvinceDefinitionsTests * Create ProvincePositionTests.cs * MapDataTests * Tweaks for Codacy * Add vassals' counties to bookmark map * Actually do what the previous commit was supposed to * !!! * Check nonImpassableNeighborProvs for emptiness * Change thrown exception type * Change impassable coloring algorithm * Test tweaks * Make GetProvincesInCountry a Title method * Load MapData in CK3 World * Cleanup * Fix memory leak by using ImageSharp * Remove old rakaly files
- Loading branch information
1 parent
d25d6a6
commit 4b93e67
Showing
47 changed files
with
75,648 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using ImperatorToCK3.CK3.Map; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Xunit; | ||
|
||
namespace ImperatorToCK3.UnitTests.CK3.Map { | ||
[Collection("MapTests")] | ||
[CollectionDefinition("MapTests", DisableParallelization = true)] | ||
public class MapDataTests { | ||
private const string testCK3Path = "TestFiles/MapData/CK3_1_province_map"; | ||
[Fact] | ||
public void NeighborsDictDefaultsToEmpty() { | ||
var data = new MapData(testCK3Path); | ||
|
||
Assert.Empty(data.NeighborsDict); | ||
} | ||
[Fact] | ||
public void NeighborProvincesCanBeDetermined() { | ||
const string testCK3Path2 = "TestFiles/MapData/CK3_all_prov_defs"; | ||
const ulong byzantionId = 496; | ||
|
||
var data = new MapData(testCK3Path2); | ||
Assert.True(data.ProvinceDefinitions.ProvinceToColorDict.ContainsKey(byzantionId)); | ||
Assert.True(data.NeighborsDict.ContainsKey(byzantionId)); | ||
|
||
var byzantionNeighborProvs = data.NeighborsDict[byzantionId]; | ||
var expectedByzantionNeighborProvs = new HashSet<ulong> { | ||
3761, // Selymbria | ||
8668, // sea_bosporus | ||
947 // sea_marmara | ||
// There is also a dark grey circle in the middle of Byzantion, | ||
// but the color is not found in definition.csv, so there's no ID to add to neighbors. | ||
}; | ||
Assert.True(byzantionNeighborProvs.SetEquals(expectedByzantionNeighborProvs)); | ||
} | ||
|
||
[Fact] | ||
public void ProvinceNotFoundForColorIsLogged() { | ||
var output = new StringWriter(); | ||
Console.SetOut(output); | ||
|
||
const string testCK3Path2 = "TestFiles/MapData/CK3_all_prov_defs"; | ||
_ = new MapData(testCK3Path2); | ||
Assert.Contains("Province not found for color Rgb24(30, 30, 30)", output.ToString()); | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
ImperatorToCK3.UnitTests/CK3/Map/ProvinceDefinitionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using ImperatorToCK3.CK3.Map; | ||
using SixLabors.ImageSharp.PixelFormats; | ||
using System; | ||
using Xunit; | ||
|
||
namespace ImperatorToCK3.UnitTests.CK3.Map { | ||
[Collection("MapTests")] | ||
[CollectionDefinition("MapTests", DisableParallelization = true)] | ||
public class ProvinceDefinitionsTests { | ||
private const string testCK3Path = "TestFiles/CK3"; | ||
[Fact] | ||
public void DictionariesDefaultToEmpty() { | ||
var provDefs = new ProvinceDefinitions(testCK3Path); | ||
Assert.Collection(provDefs.ColorToProvinceDict, | ||
pair1 => { | ||
(Rgb24 key, ulong value) = pair1; | ||
Assert.Equal(new Rgb24(42, 3, 128), key); | ||
Assert.Equal((ulong)1, value); | ||
}, | ||
pair2 => { | ||
(Rgb24 key, ulong value) = pair2; | ||
Assert.Equal(new Rgb24(84, 6, 1), key); | ||
Assert.Equal((ulong)2, value); | ||
}, | ||
pair3 => { | ||
(Rgb24 key, ulong value) = pair3; | ||
Assert.Equal(new Rgb24(126, 9, 129), key); | ||
Assert.Equal((ulong)3, value); | ||
} | ||
); | ||
Assert.Collection(provDefs.ProvinceToColorDict, | ||
pair1 => { | ||
(ulong key, Rgb24 value) = pair1; | ||
Assert.Equal((ulong)1, key); | ||
Assert.Equal(new Rgb24(42, 3, 128), value); | ||
}, | ||
pair2 => { | ||
(ulong key, Rgb24 value) = pair2; | ||
Assert.Equal((ulong)2, key); | ||
Assert.Equal(new Rgb24(84, 6, 1), value); | ||
}, | ||
pair3 => { | ||
(ulong key, Rgb24 value) = pair3; | ||
Assert.Equal((ulong)3, key); | ||
Assert.Equal(new Rgb24(126, 9, 129), value); | ||
} | ||
); | ||
} | ||
|
||
[Fact] | ||
public void ExceptionIsThrownOnUnparseableLine() { | ||
const string ck3Path = "TestFiles/corruptedCK3"; | ||
// this definition.csv has a line with quoted province id | ||
Assert.Throws<FormatException>(() => _ = new ProvinceDefinitions(ck3Path)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using commonItems; | ||
using ImperatorToCK3.CK3.Map; | ||
using Xunit; | ||
|
||
namespace ImperatorToCK3.UnitTests.CK3.Map { | ||
[Collection("MapTests")] | ||
[CollectionDefinition("MapTests", DisableParallelization = true)] | ||
public class ProvincePositionTests { | ||
[Fact] | ||
public void PositionCanBeParsed() { | ||
const string blob = "{" + | ||
"id = 5 " + | ||
"position ={ 271.722198 0.000000 3950.798096 } " + | ||
"rotation ={ -0.000000 - 0.960029 - 0.000000 0.279900 } " + | ||
"scale ={ 1.000000 1.000000 1.000000 } " + | ||
"}"; | ||
var reader = new BufferedReader(blob); | ||
var pos = ProvincePosition.Parse(reader); | ||
Assert.Equal((ulong)5, pos.Id); | ||
Assert.Equal(271.722198, pos.X); | ||
Assert.Equal(3950.798096, pos.Y); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.