SaveDataFilter
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
namespace ParadoxSaveParser.WebAPI.SaveDataFilters;
|
||||
|
||||
public interface ISaveDataFilter
|
||||
{
|
||||
public string SearchString { get; }
|
||||
public ISearchExpression SearchExpression { get; }
|
||||
|
||||
public void Apply(Dictionary<string, List<object>> data);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System.Linq;
|
||||
using ParsedDict = System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<object>>;
|
||||
|
||||
namespace ParadoxSaveParser.WebAPI.SaveDataFilters;
|
||||
|
||||
public class SaveDataFilterEU4 : ISaveDataFilter
|
||||
{
|
||||
public string SearchString { get; }
|
||||
public ISearchExpression SearchExpression { get; }
|
||||
|
||||
public SaveDataFilterEU4()
|
||||
{
|
||||
SearchString =
|
||||
"""
|
||||
(
|
||||
active_war|
|
||||
previous_war|
|
||||
income_statistics|
|
||||
nation_size_statistics|
|
||||
inflation_statistics|
|
||||
countries.(
|
||||
---.~|REB.~|PIR.~|NAT.~|
|
||||
*.(
|
||||
flags.~|hidden_flags.~|variables.~|estate.~|active_agenda.~|
|
||||
power_projection.~|ai.~|history.~|navy.~|army.~|mercenary_company.~|
|
||||
active_relations.~|border_pct.~|border_sit.~|border_provinces.~|
|
||||
neighbours.~|home_neighbours.~|core_neighbours.~|inflation_history.~|
|
||||
opinion_cache.~|owned_provinces.~|controlled_provinces.~|core_provinces.~|
|
||||
claim_provinces.~|leader.~|*
|
||||
)
|
||||
)
|
||||
)
|
||||
"""
|
||||
.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(" ", "");
|
||||
SearchExpression = SearchExpressionCompiler.Compile(SearchString);
|
||||
}
|
||||
|
||||
|
||||
public void Apply(ParsedDict data)
|
||||
{
|
||||
var countries = (ParsedDict)data["countries"][0];
|
||||
var countries_filtered = countries.Where(pair
|
||||
=> pair.Value.Count > 0
|
||||
&& ((ParsedDict)pair.Value[0]).TryGetValue("raw_development", out var raw_development)
|
||||
&& (double)raw_development[0] > 0
|
||||
).ToDictionary();
|
||||
data["countries"][0] = countries_filtered;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
countries
|
||||
filter:
|
||||
always: exists (has raw_development && raw_development != 0)
|
||||
optional: is player (was_player == yes)
|
||||
exclude:
|
||||
flags
|
||||
hidden_flags
|
||||
variables
|
||||
estate
|
||||
active_agenda
|
||||
power_projection
|
||||
ai
|
||||
history
|
||||
navy
|
||||
army
|
||||
mercenary_company
|
||||
active_relations
|
||||
border_pct
|
||||
border_sit
|
||||
border_provinces
|
||||
neighbours
|
||||
home_neighbours
|
||||
core_neighbours
|
||||
inflation_history
|
||||
opinion_cache
|
||||
owned_provinces
|
||||
controlled_provinces
|
||||
core_provinces
|
||||
claim_provinces
|
||||
leader
|
||||
query:
|
||||
countries.(---.~|REB.~|PIR.~|NAT.~|*.(flags.~|hidden_flags.~|variables.~|estate.~|active_agenda.~|power_projection.~|ai.~|history.~|navy.~|army.~|mercenary_company.~|active_relations.~|border_pct.~|border_sit.~|border_provinces.~|neighbours.~|home_neighbours.~|core_neighbours.~|inflation_history.~|opinion_cache.~|owned_provinces.~|controlled_provinces.~|core_provinces.~|claim_provinces.~|leader.~|*))
|
||||
|
||||
active_war
|
||||
filter:
|
||||
optional: only player wars
|
||||
previous_war
|
||||
filter:
|
||||
optional: only player wars
|
||||
always: not fictive (has losses and lasts long)
|
||||
income_statistics
|
||||
nation_size_statistics
|
||||
inflation_statistics
|
||||
Reference in New Issue
Block a user