Compare commits

...
9 Commits
Author SHA1 Message Date
admin 72ba7949f6 it's too much 2025-07-31 22:24:41 -07:00
admin 8d37c07f24 two still failing 2025-07-31 22:12:25 -07:00
admin 44b3467306 a little cleanup 2025-07-31 21:35:01 -07:00
admin 5d66603e1b another test 2025-07-31 21:29:24 -07:00
admin 96798a6ad5 another test 2025-07-31 21:29:24 -07:00
admin 9273fb0134 one more passing 2025-07-31 21:29:23 -07:00
admin a874e973e2 progress 2025-07-31 21:29:23 -07:00
admin 46a88d17c1 more tests 2025-07-31 21:29:23 -07:00
admin c391ce0a4b handle province stats in client and fix some tests 2025-07-31 21:29:23 -07:00
77 changed files with 633 additions and 585 deletions
@@ -244,6 +244,7 @@ cc_library(
deps = [
":ai_minimum_distance_and_target",
":ai_water_crossing_calculator",
"//src/main/cpp/net/eagle0/shardok/library:game_state_w",
"//src/main/cpp/net/eagle0/shardok/library/action_point_distances",
"//src/main/cpp/net/eagle0/shardok/library/action_point_distances:action_point_distances_cache",
"//src/main/protobuf/net/eagle0/shardok/api:command_descriptor_cc_proto",
@@ -250,6 +250,7 @@
<Compile Include="Assets/Eagle/CommandSelectors/HandleRiotGiveCommandSelector.cs" />
<Compile Include="Assets/Eagle/ProvinceUtils.cs" />
<Compile Include="Assets/Eagle/Notifications/ProvinceConqueredNotificationGenerator.cs" />
<Compile Include="Assets/common/GUIUtils/ProvinceStatUtils.cs" />
<Compile Include="Assets/Eagle/Table Rows/ExchangedHeroRowController.cs" />
<Compile Include="Assets/Eagle/Table Rows/ExtraTroopsRowController.cs" />
<Compile Include="Assets/Eagle/Notifications/PrisonerEscapedNotificationGenerator.cs" />
@@ -25,7 +25,7 @@ namespace eagle {
private ImprovementType SelectedType =>
ImproveAvailableCommand.AvailableTypes[SelectedTypeIndex];
private double OriginalImprovementValueForType(ImprovementType type) {
private float OriginalImprovementValueForType(ImprovementType type) {
var province = _model.Provinces[ActingProvinceId];
switch (type) {
case ImprovementType.Agriculture: return province.FullInfo.Agriculture;
@@ -39,7 +39,7 @@ namespace eagle {
}
}
private double EffectiveImprovementValueForType(ImprovementType type) {
private float EffectiveImprovementValueForType(ImprovementType type) {
var province = _model.Provinces[ActingProvinceId];
switch (type) {
case ImprovementType.Agriculture:
@@ -59,10 +59,10 @@ namespace eagle {
private int MinimumImprovementIndex(ProvinceView province) {
var minIndex = 0;
double minValue =
float minValue =
OriginalImprovementValueForType(ImproveAvailableCommand.AvailableTypes[0]);
for (int i = 1; i < ImproveAvailableCommand.AvailableTypes.Count; i++) {
double thisVal =
float thisVal =
OriginalImprovementValueForType(ImproveAvailableCommand.AvailableTypes[i]);
if (thisVal < minValue) {
minIndex = i;
@@ -139,21 +139,21 @@ namespace eagle {
};
private string DropdownStringForType(ImprovementType type) {
var originalStat = RoundedNonzeroStat(OriginalImprovementValueForType(type));
var originalStat =
type == ImprovementType.Devastation
? ProvinceStatUtils.RoundedDevastation(
OriginalImprovementValueForType(type))
: ProvinceStatUtils.RoundedStat(OriginalImprovementValueForType(type));
if (type == ImprovementType.Devastation) {
return $"{type} ({GUIUtils.ColoredString(UnityEngine.Color.red, originalStat)})";
return $"{type} ({GUIUtils.ColoredString(UnityEngine.Color.red, originalStat.ToString())})";
}
var devastatedStat = RoundedNonzeroStat(EffectiveImprovementValueForType(type));
var devastatedStat =
ProvinceStatUtils.RoundedStat(EffectiveImprovementValueForType(type));
if (devastatedStat == originalStat) {
return $"{type} ({devastatedStat})";
} else {
return $"{type} ({GUIUtils.ColoredString(UnityEngine.Color.red, devastatedStat)} / {originalStat})";
return $"{type} ({GUIUtils.ColoredString(UnityEngine.Color.red, devastatedStat.ToString())} / {originalStat})";
}
}
private string RoundedNonzeroStat(double stat) {
var rounded = Math.Max(1, Math.Round(stat, MidpointRounding.AwayFromZero));
return rounded.ToString();
}
}
}
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using common;
using EagleGUIUtils;
using Net.Eagle0.Eagle.Api;
using Net.Eagle0.Eagle.Common;
using Net.Eagle0.Eagle.Views;
@@ -235,8 +236,8 @@ namespace eagle {
allowed,
OrganizeTroopsAvailableCommand.AvailableBattalionTypes.First(
tp => tp.TypeId == battalionTypeId),
Province.FullInfo.Agriculture,
Province.FullInfo.Economy);
ProvinceStatUtils.RoundedStat(Province.FullInfo.Agriculture),
ProvinceStatUtils.RoundedStat(Province.FullInfo.Economy));
parent.GetComponentInChildren<Button>().interactable = allowed;
@@ -31,7 +31,7 @@ namespace eagle {
private readonly Func<ProvinceView, String> _nameSortFunc = p => p.Name;
private readonly Dictionary<SortKey, Func<ProvinceView, int>> _sortFuncs = new() {
private readonly Dictionary<SortKey, Func<ProvinceView, IComparable>> _sortFuncs = new() {
{ SortKey.Support, p => p.FullInfo.Support.Stat },
{ SortKey.Commanders, p => p.FullInfo.RulingFactionHeroIds.Count },
{ SortKey.Battalions, p => p.FullInfo.Battalions.Count },
@@ -225,25 +225,27 @@ namespace eagle {
ConsumedField.text = $"{Province.FullInfo.FoodConsumption}";
priceIndexField.text = $"{Province.FullInfo.PriceIndex,4:F2}";
EconomyField.text = $"{Province.FullInfo.Economy}";
EconomyField.text = $"{ProvinceStatUtils.RoundedStat(Province.FullInfo.Economy)}";
if (Province.FullInfo.EconomyDevastation > 0) {
var devastatedEconomy =
$"{Math.Max(0.0, Province.FullInfo.Economy - Province.FullInfo.EconomyDevastation)}";
$"{ProvinceStatUtils.RoundedStat(Math.Max(0.0f, Province.FullInfo.Economy - Province.FullInfo.EconomyDevastation))}";
EconomyField.text += $" ({GUIUtils.ColoredString(Color.red, devastatedEconomy)})";
}
AgricultureField.text = $"{Province.FullInfo.Agriculture}";
AgricultureField.text =
$"{ProvinceStatUtils.RoundedStat(Province.FullInfo.Agriculture)}";
if (Province.FullInfo.AgricultureDevastation > 0) {
var devastatedAgriculture =
$"{Math.Max(0.0, Province.FullInfo.Agriculture - Province.FullInfo.AgricultureDevastation)}";
$"{ProvinceStatUtils.RoundedStat(Math.Max(0.0f, Province.FullInfo.Agriculture - Province.FullInfo.AgricultureDevastation))}";
AgricultureField.text +=
$" ({GUIUtils.ColoredString(Color.red, devastatedAgriculture)})";
}
InfrastructureField.text = $"{Province.FullInfo.Infrastructure}";
InfrastructureField.text =
$"{ProvinceStatUtils.RoundedStat(Province.FullInfo.Infrastructure)}";
if (Province.FullInfo.InfrastructureDevastation > 0) {
var devastatedInfrastructure =
$"{Math.Max(0.0, Province.FullInfo.Infrastructure - Province.FullInfo.InfrastructureDevastation)}";
$"{ProvinceStatUtils.RoundedStat(Math.Max(0.0f, Province.FullInfo.Infrastructure - Province.FullInfo.InfrastructureDevastation))}";
InfrastructureField.text +=
$" ({GUIUtils.ColoredString(Color.red, devastatedInfrastructure)})";
}
@@ -251,7 +253,8 @@ namespace eagle {
var totalDevastation = Province.FullInfo.EconomyDevastation +
Province.FullInfo.AgricultureDevastation +
Province.FullInfo.InfrastructureDevastation;
var totalDevastationString = $"{totalDevastation}";
var totalDevastationString =
$"{ProvinceStatUtils.RoundedDevastation(totalDevastation)}";
if (totalDevastation > 0) {
DevastationField.text =
$"{GUIUtils.ColoredString(Color.red, totalDevastationString)}";
@@ -37,14 +37,14 @@ namespace eagle {
private ProvinceId ProvinceId;
private DynamicHeroTextUpdater textUpdater = new DynamicHeroTextUpdater();
private void SetDevastatedValue(TMP_Text textField, double baseValue, double devastation) {
if (devastation == 0.0) {
private void SetDevastatedValue(TMP_Text textField, float baseValue, float devastation) {
if (devastation == 0.0f) {
textField.color = Color.black;
textField.text = baseValue.ToString();
textField.text = ProvinceStatUtils.RoundedStat(baseValue).ToString();
} else {
textField.color = Color.red;
var devastatedValue = Math.Max(0.0, baseValue - devastation);
textField.text = devastatedValue.ToString();
var devastatedValue = Math.Max(0.0f, baseValue - devastation);
textField.text = ProvinceStatUtils.RoundedStat(devastatedValue).ToString();
}
}
@@ -0,0 +1,28 @@
using System;
/// <summary>
/// Utility methods for rounding province statistics for display.
/// These methods match the rounding logic from ProvinceViewFilter.scala
/// </summary>
public static class ProvinceStatUtils {
/// <summary>
/// Rounds a stat value using the same logic as roundedStat in ProvinceViewFilter.scala:
/// - If stat == 0, return 0
/// - If stat < 1, return 1
/// - Otherwise, return floor of stat
/// </summary>
public static int RoundedStat(float stat) {
if (stat == 0) return 0;
else if (stat < 1)
return 1;
else
return (int)Math.Floor(stat);
}
/// <summary>
/// Rounds a devastation value using the same logic as roundedDevastation in
/// ProvinceViewFilter.scala:
/// - Return ceiling of stat
/// </summary>
public static int RoundedDevastation(float stat) { return (int)Math.Ceiling(stat); }
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d6672bb4c46b44b10abe885e064119d0
@@ -28,6 +28,10 @@ func main() {
capitalizedSettingType := capitalized(settingType)
if capitalizedSettingType == "Float" {
settingValue += "f"
}
fmt.Printf(`// Generated file, do not edit!
package net.eagle0.eagle.library.settings
@@ -18,9 +18,9 @@ message BeastInfo {
double likelihood = 4;
double max_count_multiplier = 5;
double relative_power = 6;
double economy_devastation = 7;
double agriculture_devastation = 8;
double infrastructure_devastation = 9;
float economy_devastation = 7;
float agriculture_devastation = 8;
float infrastructure_devastation = 9;
double average_gold_per = 10;
double average_food_per = 11;
}
@@ -69,16 +69,16 @@ message ChangedProvince {
.google.protobuf.Int32Value gold_delta = 14;
.google.protobuf.Int32Value food_delta = 15;
.google.protobuf.DoubleValue new_price_index = 35;
.google.protobuf.FloatValue new_price_index = 35;
.google.protobuf.DoubleValue economy_delta = 16;
.google.protobuf.DoubleValue agriculture_delta = 17;
.google.protobuf.DoubleValue infrastructure_delta = 18;
.google.protobuf.DoubleValue economy_devastation_delta = 44;
.google.protobuf.DoubleValue agriculture_devastation_delta = 47;
.google.protobuf.DoubleValue infrastructure_devastation_delta = 48;
.google.protobuf.FloatValue economy_delta = 16;
.google.protobuf.FloatValue agriculture_delta = 17;
.google.protobuf.FloatValue infrastructure_delta = 18;
.google.protobuf.FloatValue economy_devastation_delta = 44;
.google.protobuf.FloatValue agriculture_devastation_delta = 47;
.google.protobuf.FloatValue infrastructure_devastation_delta = 48;
.google.protobuf.DoubleValue support_delta = 19;
.google.protobuf.FloatValue support_delta = 19;
.google.protobuf.BoolValue set_has_acted = 20;
@@ -25,11 +25,11 @@ option objc_class_prefix = "E0G";
message ProvinceOverrides {
int32 province_id = 1; // can be 0 for a generic
double economy = 2;
double agriculture = 3;
double infrastructure = 4;
float economy = 2;
float agriculture = 3;
float infrastructure = 4;
double support = 5;
float support = 5;
int32 food = 6;
int32 gold = 7;
@@ -77,12 +77,12 @@ message Province {
repeated IncomingEndTurnAction incoming_end_turn_actions = 27;
Army defending_army = 11;
double economy = 12;
double agriculture = 13;
double infrastructure = 14;
double economy_devastation = 34;
double agriculture_devastation = 37;
double infrastructure_devastation = 38;
float economy = 12;
float agriculture = 13;
float infrastructure = 14;
float economy_devastation = 34;
float agriculture_devastation = 37;
float infrastructure_devastation = 38;
// Can be None.
.net.eagle0.eagle.common.ImprovementType locked_improvement_type = 41;
@@ -92,9 +92,9 @@ message Province {
// Current price index where 1.0 is "standard". Expected to vary between
// 0.5 and 1.5.
double price_index = 29;
float price_index = 29;
double support = 17;
float support = 17;
bool has_acted = 18;
@@ -59,12 +59,12 @@ message FullProvinceInfo {
ArmyView defending_army = 7;
int32 economy = 8;
int32 agriculture = 9;
int32 infrastructure = 10;
int32 economy_devastation = 25;
int32 agriculture_devastation = 26;
int32 infrastructure_devastation = 27;
float economy = 8;
float agriculture = 9;
float infrastructure = 10;
float economy_devastation = 25;
float agriculture_devastation = 26;
float infrastructure_devastation = 27;
int32 gold = 11;
int32 food = 12;
@@ -130,12 +130,12 @@ message FullProvinceInfoDiff {
.google.protobuf.DoubleValue new_price_index = 36;
.google.protobuf.Int32Value economy = 16;
.google.protobuf.Int32Value agriculture = 17;
.google.protobuf.Int32Value infrastructure = 18;
.google.protobuf.Int32Value economy_devastation = 30;
.google.protobuf.Int32Value agriculture_devastation = 31;
.google.protobuf.Int32Value infrastructure_devastation = 32;
.google.protobuf.FloatValue economy = 16;
.google.protobuf.FloatValue agriculture = 17;
.google.protobuf.FloatValue infrastructure = 18;
.google.protobuf.FloatValue economy_devastation = 30;
.google.protobuf.FloatValue agriculture_devastation = 31;
.google.protobuf.FloatValue infrastructure_devastation = 32;
StatWithCondition support = 19;
@@ -59,8 +59,8 @@ vassalCommandsMaxFatigueLevelBeforeResting 15 Double
vassalCommandsMinOddsForRecruitment 50 Double
maxCombatUnitCountPerSide 9999 Int
maxAlmsFood 1000 Int
almsSupportIncreasePerFood 0.01 Double
almsPaladinSupportMultiplier 4 Double
almsSupportIncreasePerFood 0.01 Float
almsPaladinSupportMultiplier 4 Float
foodPerProvinceHeldBack 1000 Int
factionBiasFromImprisonment -100 Double
factionBiasFromExile -50 Double
@@ -80,8 +80,8 @@ riotEventChance 0.02 Double
minVigorForSuppressBeasts 50 Double
suppressBeastsPrestigeBonus 2 Int
beastsDurationMonths 4 Int
beastsSupportDamage 3 Double
suppressBeastsSupportBonus 5 Double
beastsSupportDamage 3 Float
suppressBeastsSupportBonus 5 Float
maxInfrastructureForbeasts 50 Int
failedSuppressBeastsPrestigePenalty 5 Int
baseBeastsCount 150 Int
@@ -165,13 +165,13 @@ minMonthsAfterPleaseRecruitMeRejectionBeforeTryingAgain 12 Int
exiledHeroFactionBias -500 Double
minVigorForApprehendOutlaw 50 Double
apprehendOutlawVigorCost 30 Double
battleEconomyDevastationDelta 10 Double
battleAgricultureDevastationDelta 10 Double
battleInfrastructureDevastationDelta 10 Double
battleEconomyDevastationDelta 10 Float
battleAgricultureDevastationDelta 10 Float
battleInfrastructureDevastationDelta 10 Float
minVigorForCrackDown 50 Double
riotSupportDelta -25 Double
riotEconomyDevastationDelta 25 Double
riotInfrastructureDevastationDelta 25 Double
riotSupportDelta -25 Float
riotEconomyDevastationDelta 25 Float
riotInfrastructureDevastationDelta 25 Float
riotMaxFood 1000 Int
riotMaxGold 500 Int
riotCharismaFactor 0.1 Double
@@ -184,9 +184,9 @@ monthsBetweenRiotsSupportMultiplier 0.5 Double
blizzardEventChance 0.01 Double
maxBlizzardDurationMonths 4 Int
winterSuppliesLoss 0.25 Double
blizzardEconomyDevastationDelta 4 Double
blizzardInfrastructureDevastationDelta 4 Double
blizzardAgricultureDevastationDelta 4 Double
blizzardEconomyDevastationDelta 4 Float
blizzardInfrastructureDevastationDelta 4 Float
blizzardAgricultureDevastationDelta 4 Float
festivalEventChance 0.01 Double
maxFestivalDurationMonths 3 Int
festivalSupportDelta 8 Double
@@ -197,12 +197,12 @@ maxDesiredTruceCountForQuest 5 Int
minDesiredNewTruceCountForQuest 2 Int
floodEventChance 0.01 Double
floodDurationMonths 1 Int
maxFloodInfrastructureDevastationDelta 20 Double
maxFloodAgricultureDevastationDelta 20 Double
floodDevastationDeltaReductionPerInfrastructure 0.3 Double
maxFloodInfrastructureDevastationDelta 20 Float
maxFloodAgricultureDevastationDelta 20 Float
floodDevastationDeltaReductionPerInfrastructure 0.3 Float
epidemicBreakoutChance 0.0015 Double
epidemicSpreadChance 0.03 Double
epidemicEconomyDevastationDelta 10 Double
epidemicEconomyDevastationDelta 10 Float
epidemicBattalionLossPercentage 0.05 Double
epidemicVigorDelta -10 Double
epidemicEndChance 0.35 Double
@@ -215,9 +215,9 @@ startEpidemicCharismaXp 25 Int
startEpidemicVigorDelta -30 Double
droughtEventChance 0.01 Double
droughtDurationMonths 3 Int
droughtAgricultureDevastationDelta 10 Double
droughtAgricultureDevastationDelta 10 Float
controlWeatherDroughtDurationMonths 3 Int
emptyProvinceMonthlyDevastationDelta -2 Double
emptyProvinceMonthlyDevastationDelta -2 Float
vigorToConstitutionXpMultiplier 0.2 Double
trustDeltaPerRound 1 Int
trustDeltaForImprisoningOwnHero -150 Int
@@ -264,9 +264,9 @@ giftProvinceCountExponent 0.5 Double
minChanceForAIInvite 70 Int
chronicleWordCount 200 Int
maxDistanceForDefeatFactionQuest 3 Int
minimumPriceIndex 0.75 Double
maximumPriceIndex 1.5 Double
priceIndexReturnRate 0.1 Double
priceIndexShiftPerGold 0.0001 Double
minimumPriceIndex 0.75 Float
maximumPriceIndex 1.5 Float
priceIndexReturnRate 0.1 Float
priceIndexShiftPerGold 0.0001 Float
aiTruceAcceptanceBaseChance 100 Double
aiAllianceAcceptanceBaseChance 100 Double
1 actionVigorCost 15 Int
59 vassalCommandsMinOddsForRecruitment 50 Double
60 maxCombatUnitCountPerSide 9999 Int
61 maxAlmsFood 1000 Int
62 almsSupportIncreasePerFood 0.01 Double Float
63 almsPaladinSupportMultiplier 4 Double Float
64 foodPerProvinceHeldBack 1000 Int
65 factionBiasFromImprisonment -100 Double
66 factionBiasFromExile -50 Double
80 minVigorForSuppressBeasts 50 Double
81 suppressBeastsPrestigeBonus 2 Int
82 beastsDurationMonths 4 Int
83 beastsSupportDamage 3 Double Float
84 suppressBeastsSupportBonus 5 Double Float
85 maxInfrastructureForbeasts 50 Int
86 failedSuppressBeastsPrestigePenalty 5 Int
87 baseBeastsCount 150 Int
165 exiledHeroFactionBias -500 Double
166 minVigorForApprehendOutlaw 50 Double
167 apprehendOutlawVigorCost 30 Double
168 battleEconomyDevastationDelta 10 Double Float
169 battleAgricultureDevastationDelta 10 Double Float
170 battleInfrastructureDevastationDelta 10 Double Float
171 minVigorForCrackDown 50 Double
172 riotSupportDelta -25 Double Float
173 riotEconomyDevastationDelta 25 Double Float
174 riotInfrastructureDevastationDelta 25 Double Float
175 riotMaxFood 1000 Int
176 riotMaxGold 500 Int
177 riotCharismaFactor 0.1 Double
184 blizzardEventChance 0.01 Double
185 maxBlizzardDurationMonths 4 Int
186 winterSuppliesLoss 0.25 Double
187 blizzardEconomyDevastationDelta 4 Double Float
188 blizzardInfrastructureDevastationDelta 4 Double Float
189 blizzardAgricultureDevastationDelta 4 Double Float
190 festivalEventChance 0.01 Double
191 maxFestivalDurationMonths 3 Int
192 festivalSupportDelta 8 Double
197 minDesiredNewTruceCountForQuest 2 Int
198 floodEventChance 0.01 Double
199 floodDurationMonths 1 Int
200 maxFloodInfrastructureDevastationDelta 20 Double Float
201 maxFloodAgricultureDevastationDelta 20 Double Float
202 floodDevastationDeltaReductionPerInfrastructure 0.3 Double Float
203 epidemicBreakoutChance 0.0015 Double
204 epidemicSpreadChance 0.03 Double
205 epidemicEconomyDevastationDelta 10 Double Float
206 epidemicBattalionLossPercentage 0.05 Double
207 epidemicVigorDelta -10 Double
208 epidemicEndChance 0.35 Double
215 startEpidemicVigorDelta -30 Double
216 droughtEventChance 0.01 Double
217 droughtDurationMonths 3 Int
218 droughtAgricultureDevastationDelta 10 Double Float
219 controlWeatherDroughtDurationMonths 3 Int
220 emptyProvinceMonthlyDevastationDelta -2 Double Float
221 vigorToConstitutionXpMultiplier 0.2 Double
222 trustDeltaPerRound 1 Int
223 trustDeltaForImprisoningOwnHero -150 Int
264 minChanceForAIInvite 70 Int
265 chronicleWordCount 200 Int
266 maxDistanceForDefeatFactionQuest 3 Int
267 minimumPriceIndex 0.75 Double Float
268 maximumPriceIndex 1.5 Double Float
269 priceIndexReturnRate 0.1 Double Float
270 priceIndexShiftPerGold 0.0001 Double Float
271 aiTruceAcceptanceBaseChance 100 Double
272 aiAllianceAcceptanceBaseChance 100 Double
@@ -185,33 +185,33 @@ class ActionResultProtoApplierImpl(validator: Validator)
},
_.priceIndex.setIfDefined(cp.newPriceIndex),
_.economy.modify(e =>
(e + cp.economyDelta.getOrElse(0.0)).max(0.0).min(100.0)
(e + cp.economyDelta.getOrElse(0.0f)).max(0.0f).min(100.0f)
),
_.agriculture
.modify(a =>
(a + cp.agricultureDelta.getOrElse(0.0)).max(0.0).min(100.0)
(a + cp.agricultureDelta.getOrElse(0.0f)).max(0.0f).min(100.0f)
),
_.infrastructure
.modify(i =>
(i + cp.infrastructureDelta.getOrElse(0.0)).max(0.0).min(100.0)
(i + cp.infrastructureDelta.getOrElse(0.0f)).max(0.0f).min(100.0f)
),
_.economyDevastation.modify(d =>
(d + cp.economyDevastationDelta.getOrElse(0.0))
.max(0.0)
(d + cp.economyDevastationDelta.getOrElse(0.0f))
.max(0.0f)
.min(provinceBefore.economy)
),
_.agricultureDevastation.modify(d =>
(d + cp.agricultureDevastationDelta.getOrElse(0.0))
.max(0.0)
(d + cp.agricultureDevastationDelta.getOrElse(0.0f))
.max(0.0f)
.min(provinceBefore.agriculture)
),
_.infrastructureDevastation.modify(d =>
(d + cp.infrastructureDevastationDelta.getOrElse(0.0))
.max(0.0)
(d + cp.infrastructureDevastationDelta.getOrElse(0.0f))
.max(0.0f)
.min(provinceBefore.infrastructure)
),
_.support.modify(s =>
(s + cp.supportDelta.getOrElse(0.0)).max(0.0).min(100.0)
(s + cp.supportDelta.getOrElse(0.0f)).max(0.0f).min(100.0f)
),
_.hasActed.setIfDefined(cp.setHasActed),
_.rulerIsTraveling.setIfDefined(cp.setRulerIsTraveling),
@@ -528,7 +528,7 @@ class ActionResultProtoApplierImpl(validator: Validator)
_.vigor.modify { v =>
ch.vigor match {
case Vigor.VigorDelta(d) =>
(v + d).max(0.0).min(gameState.heroes(ch.id).constitution)
(v + d).max(0.0f).min(gameState.heroes(ch.id).constitution)
case Vigor.VigorAbsolute(va) =>
internalRequire(
@@ -548,7 +548,7 @@ class ActionResultProtoApplierImpl(validator: Validator)
_.loyalty.modify { l =>
ch.loyalty match {
case Loyalty.LoyaltyDelta(ld) =>
val newL = Math.min(100.0, Math.max(0, l + ld))
val newL = Math.min(100.0f, Math.max(0, l + ld))
newL
case Loyalty.LoyaltyAbsolute(la) =>
@@ -557,7 +557,7 @@ class ActionResultProtoApplierImpl(validator: Validator)
s"Got a negative absolute loyalty of $la"
)
internalRequire(
la <= 100.0,
la <= 100.0f,
s"Got an absolute loyalty of $la"
)
la
@@ -40,7 +40,7 @@ object AvailableArmTroopsCommandFactory
)
.map(tp =>
ArmamentCost(
cost = tp.baseArmamentCostPerTroop * province.priceIndex,
cost = tp.baseArmamentCostPerTroop.toFloat * province.priceIndex,
`type` = tp.typeId
)
)
@@ -187,7 +187,7 @@ case class NewRoundAction(startingState: GameState, gameHistory: GameHistory)
Math
.max(
-p.economyDevastation,
EmptyProvinceMonthlyDevastationDelta.doubleValue
EmptyProvinceMonthlyDevastationDelta.floatValue
)
),
agricultureDevastationDelta = Option.when(
@@ -196,7 +196,7 @@ case class NewRoundAction(startingState: GameState, gameHistory: GameHistory)
Math
.max(
-p.agricultureDevastation,
EmptyProvinceMonthlyDevastationDelta.doubleValue
EmptyProvinceMonthlyDevastationDelta.floatValue
)
),
infrastructureDevastationDelta = Option.when(
@@ -205,7 +205,7 @@ case class NewRoundAction(startingState: GameState, gameHistory: GameHistory)
Math
.max(
-p.infrastructureDevastation,
EmptyProvinceMonthlyDevastationDelta.doubleValue
EmptyProvinceMonthlyDevastationDelta.floatValue
)
)
),
@@ -25,9 +25,14 @@ case class NewYearAction(gameState: GameState)
extends DeterministicSingleResultAction(gameState) {
private def degradationMultiplier: Double =
PercentDegradationPerYear.doubleValue / 100.0
private def degradationMultiplierF: Float =
PercentDegradationPerYear.floatValue / 100.0f
private def degradation: Double => Double = -_ * degradationMultiplier
private def degradationF(value: Float): Float =
-value * degradationMultiplierF
private def loyaltyDecrease(
vassal: Hero,
isProvinceLeader: Boolean,
@@ -77,10 +82,11 @@ case class NewYearAction(gameState: GameState)
.map(p =>
ChangedProvince(
id = p.id,
agricultureDevastationDelta = Some(-degradation(p.agriculture)),
economyDevastationDelta = Some(-degradation(p.economy)),
infrastructureDevastationDelta = Some(-degradation(p.infrastructure)),
supportDelta = Some(degradation(p.support)),
agricultureDevastationDelta = Some(-degradationF(p.agriculture)),
economyDevastationDelta = Some(-degradationF(p.economy).toFloat),
infrastructureDevastationDelta =
Some(-degradationF(p.infrastructure).toFloat),
supportDelta = Some(degradationF(p.support).toFloat),
goldDelta = LegacyProvinceUtils.annualGoldProduction(p.id, gameState),
foodDelta = LegacyProvinceUtils.annualFoodProduction(p.id, gameState)
)
@@ -178,21 +178,21 @@ case class PerformProvinceEventsAction(
cp.update(
_.optionalEconomyDevastationDelta.modify(dd =>
Some(
dd.getOrElse(0.0) + BlizzardEconomyDevastationDelta.doubleValue
dd.getOrElse(0.0f) + BlizzardEconomyDevastationDelta.floatValue
)
),
_.optionalAgricultureDevastationDelta.modify(dd =>
Some(
dd.getOrElse(
0.0
) + BlizzardAgricultureDevastationDelta.doubleValue
0.0f
) + BlizzardAgricultureDevastationDelta.floatValue
)
),
_.optionalInfrastructureDevastationDelta.modify(dd =>
Some(
dd.getOrElse(
0.0
) + BlizzardInfrastructureDevastationDelta.doubleValue
0.0f
) + BlizzardInfrastructureDevastationDelta.floatValue
)
)
)
@@ -201,49 +201,49 @@ case class PerformProvinceEventsAction(
_.optionalAgricultureDevastationDelta.modify(dd =>
Some(
dd.getOrElse(
0.0
) + (MaxFloodAgricultureDevastationDelta.doubleValue - p.infrastructure * FloodDevastationDeltaReductionPerInfrastructure.doubleValue)
.max(0.0)
0.0f
) + (MaxFloodAgricultureDevastationDelta.floatValue - p.infrastructure * FloodDevastationDeltaReductionPerInfrastructure.floatValue)
.max(0.0f)
)
),
_.optionalInfrastructureDevastationDelta.modify(dd =>
Some(
dd.getOrElse(
0.0
) + (MaxFloodInfrastructureDevastationDelta.doubleValue - p.infrastructure * FloodDevastationDeltaReductionPerInfrastructure.doubleValue)
.max(0.0)
0.0f
) + (MaxFloodInfrastructureDevastationDelta.floatValue - p.infrastructure * FloodDevastationDeltaReductionPerInfrastructure.floatValue)
.max(0.0f)
)
)
)
case BeastsEvent(_, _, _, beastInfo, _ /* unknownFieldSet */ ) =>
cp.update(
_.optionalEconomyDevastationDelta.modify(dd =>
Some(dd.getOrElse(0.0) + beastInfo.economyDevastation)
.filterNot(_ == 0.0)
Some(dd.getOrElse(0.0f) + beastInfo.economyDevastation)
.filterNot(_ == 0.0f)
),
_.optionalAgricultureDevastationDelta.modify(dd =>
Some(dd.getOrElse(0.0) + beastInfo.agricultureDevastation)
.filterNot(_ == 0.0)
Some(dd.getOrElse(0.0f) + beastInfo.agricultureDevastation)
.filterNot(_ == 0.0f)
),
_.optionalInfrastructureDevastationDelta.modify(dd =>
Some(dd.getOrElse(0.0) + beastInfo.infrastructureDevastation)
.filterNot(_ == 0.0)
Some(dd.getOrElse(0.0f) + beastInfo.infrastructureDevastation)
.filterNot(_ == 0.0f)
),
_.optionalSupportDelta.modify(sd =>
Some(sd.getOrElse(0.0) - BeastsSupportDamage.doubleValue)
Some(sd.getOrElse(0.0f) - BeastsSupportDamage.floatValue)
)
)
case _: FestivalEvent =>
cp.update(
_.optionalSupportDelta.modify(sd =>
Some(sd.getOrElse(0.0) + FestivalSupportDelta.doubleValue)
Some(sd.getOrElse(0.0f) + FestivalSupportDelta.floatValue)
)
)
case _: EpidemicEvent =>
cp.update(
_.optionalEconomyDevastationDelta.modify(dd =>
Some(
dd.getOrElse(0.0) + EpidemicEconomyDevastationDelta.doubleValue
dd.getOrElse(0.0f) + EpidemicEconomyDevastationDelta.floatValue
)
),
_.optionalNewProvinceEvents := Option.when(
@@ -263,8 +263,8 @@ case class PerformProvinceEventsAction(
_.optionalAgricultureDevastationDelta.modify(dd =>
Some(
dd.getOrElse(
0.0
) + DroughtAgricultureDevastationDelta.doubleValue
0.0f
) + DroughtAgricultureDevastationDelta.floatValue
)
)
)
@@ -181,11 +181,11 @@ case class ResolveBattleAction(
.map(_.getSupplies.food)
.sum
),
economyDevastationDelta = Some(BattleEconomyDevastationDelta.doubleValue),
economyDevastationDelta = Some(BattleEconomyDevastationDelta.floatValue),
agricultureDevastationDelta =
Some(BattleAgricultureDevastationDelta.doubleValue),
Some(BattleAgricultureDevastationDelta.floatValue),
infrastructureDevastationDelta =
Some(BattleInfrastructureDevastationDelta.doubleValue),
Some(BattleInfrastructureDevastationDelta.floatValue),
addedBattleRevelations =
battle.players.filterNot(_.isDefender).map { sp =>
BattleRevelation(
@@ -30,14 +30,14 @@ import net.eagle0.eagle.{FactionId, HeroId}
object AlmsCommand {
def supportIncreasePerFood(hero: HeroT): Double =
AlmsSupportIncreasePerFood.doubleValue * (if (
hero.profession == Profession.Paladin
)
AlmsPaladinSupportMultiplier.doubleValue
else 1.0)
def supportIncreasePerFood(hero: HeroT): Float =
AlmsSupportIncreasePerFood.floatValue * (if (
hero.profession == Profession.Paladin
)
AlmsPaladinSupportMultiplier.floatValue
else 1.0f)
private def supportIncrease(hero: HeroT, foodAmount: Int): Double =
private def supportIncrease(hero: HeroT, foodAmount: Int): Float =
foodAmount * supportIncreasePerFood(hero)
private case class AlmsCommand(
@@ -92,7 +92,7 @@ object AlmsCommand {
supportDelta = Some(
Math.min(
supportIncrease(actingHero, foodAmount),
100.0 - actingProvince.support
100.0f - actingProvince.support
)
),
foodDelta = Some(-foodAmount)
@@ -124,7 +124,7 @@ object ArmTroopsCommand {
goldDelta = Some(-goldSpent),
newPriceIndex = PriceIndexUtils.maybeNewPriceIndexFromGoldSpend(
province.priceIndex,
goldSpent
goldSpent.toFloat
)
)
@@ -205,7 +205,7 @@ object DivineCommand {
newPriceIndex =
PriceIndexUtils.maybeNewPriceIndexFromGoldSpend(
actingProvince.priceIndex,
cost
cost.toFloat
),
changedUnaffiliatedHeroes =
updatedUhWithLlmRequestsRs.map(_._1)
@@ -71,7 +71,7 @@ object FeastCommand {
goldDelta = Some(-goldCost),
newPriceIndex = PriceIndexUtils.maybeNewPriceIndexFromGoldSpend(
currentPriceIndex = province.priceIndex,
goldSpent = goldCost
goldSpent = goldCost.toFloat
)
)
)
@@ -48,11 +48,11 @@ object HandleRiotUtils {
case event => Some(event)
}
),
supportDelta = Some(RiotSupportDelta.doubleValue),
supportDelta = Some(RiotSupportDelta.floatValue),
economyDevastationDelta =
Some(RiotEconomyDevastationDelta.doubleValue),
Some(RiotEconomyDevastationDelta.floatValue),
infrastructureDevastationDelta =
Some(RiotInfrastructureDevastationDelta.doubleValue)
Some(RiotInfrastructureDevastationDelta.floatValue)
)
)
)
@@ -115,7 +115,7 @@ object HeroGiftCommand {
goldDelta = Some(-goldAmount),
newPriceIndex = PriceIndexUtils.maybeNewPriceIndexFromGoldSpend(
recipientProvince.priceIndex,
goldAmount
goldAmount.toFloat
)
)
),
@@ -100,8 +100,8 @@ object ImproveCommand {
withProfessionBonus.min(maxImprovement - province.economy)
ChangedProvinceC(
provinceId = provinceId,
economyDelta = Some(improvement),
supportDelta = Some(supportDelta),
economyDelta = Some(improvement.toFloat),
supportDelta = Some(supportDelta.toFloat),
newLockedImprovementType = Some(lockedImprovementType)
)
case ImprovementType.Agriculture =>
@@ -109,8 +109,8 @@ object ImproveCommand {
withProfessionBonus.min(maxImprovement - province.agriculture)
ChangedProvinceC(
provinceId = provinceId,
agricultureDelta = Some(improvement),
supportDelta = Some(supportDelta),
agricultureDelta = Some(improvement.toFloat),
supportDelta = Some(supportDelta.toFloat),
newLockedImprovementType = Some(lockedImprovementType)
)
case ImprovementType.Infrastructure =>
@@ -118,18 +118,18 @@ object ImproveCommand {
withProfessionBonus.min(maxImprovement - province.infrastructure)
ChangedProvinceC(
provinceId = provinceId,
infrastructureDelta = Some(improvement),
supportDelta = Some(supportDelta),
infrastructureDelta = Some(improvement.toFloat),
supportDelta = Some(supportDelta.toFloat),
newLockedImprovementType = Some(lockedImprovementType)
)
case ImprovementType.Devastation =>
val improvement = withProfessionBonus
ChangedProvinceC(
provinceId = provinceId,
economyDevastationDelta = Some(-improvement),
agricultureDevastationDelta = Some(-improvement),
infrastructureDevastationDelta = Some(-improvement),
supportDelta = Some(supportDelta),
economyDevastationDelta = Some((-improvement).toFloat),
agricultureDevastationDelta = Some((-improvement).toFloat),
infrastructureDevastationDelta = Some((-improvement).toFloat),
supportDelta = Some(supportDelta.toFloat),
newLockedImprovementType = Some(lockedImprovementType)
)
case _ => throw new IllegalArgumentException("Unknown Improvement type")
@@ -52,11 +52,11 @@ object LegacyHandleRiotUtils {
}
)
),
supportDelta = Some(RiotSupportDelta.doubleValue),
supportDelta = Some(RiotSupportDelta.floatValue),
economyDevastationDelta =
Some(RiotEconomyDevastationDelta.doubleValue),
Some(RiotEconomyDevastationDelta.floatValue),
infrastructureDevastationDelta =
Some(RiotInfrastructureDevastationDelta.doubleValue)
Some(RiotInfrastructureDevastationDelta.floatValue)
)
)
)
@@ -369,7 +369,7 @@ object OrganizeTroopsCommand {
goldDelta = Some(-afterAddingForChanged.cost),
newPriceIndex = PriceIndexUtils.maybeNewPriceIndexFromGoldSpend(
province.priceIndex,
afterAddingForChanged.cost
afterAddingForChanged.cost.toFloat
)
)
),
@@ -297,7 +297,8 @@ object SuppressBeastsCommand
changedProvinces = Vector(
ChangedProvince(
id = provinceId,
supportDelta = Some(SuppressBeastsSupportBonus.doubleValue),
supportDelta =
Some(SuppressBeastsSupportBonus.doubleValue.toFloat),
removedRulingPlayerHeroIds = removedHero.toVector,
removedBattalionIds = destroyedBattalionId.toVector,
newProvinceEvents = Some(
@@ -66,7 +66,7 @@ object TradeCommand {
foodDelta = Some(supplyDeltas.food),
newPriceIndex = PriceIndexUtils.maybeNewPriceIndexFromGoldSpend(
actingProvince.priceIndex,
-supplyDeltas.gold
(-supplyDeltas.gold).toFloat
)
)
)
@@ -796,7 +796,7 @@ scala_setting_library(
scala_setting_library(
name = "alms_support_increase_per_food",
setting_name = "AlmsSupportIncreasePerFood",
setting_type = "Double",
setting_type = "Float",
setting_value = "0.01",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -809,7 +809,7 @@ scala_setting_library(
scala_setting_library(
name = "alms_paladin_support_multiplier",
setting_name = "AlmsPaladinSupportMultiplier",
setting_type = "Double",
setting_type = "Float",
setting_value = "4",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -1069,7 +1069,7 @@ scala_setting_library(
scala_setting_library(
name = "beasts_support_damage",
setting_name = "BeastsSupportDamage",
setting_type = "Double",
setting_type = "Float",
setting_value = "3",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -1082,7 +1082,7 @@ scala_setting_library(
scala_setting_library(
name = "suppress_beasts_support_bonus",
setting_name = "SuppressBeastsSupportBonus",
setting_type = "Double",
setting_type = "Float",
setting_value = "5",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2174,7 +2174,7 @@ scala_setting_library(
scala_setting_library(
name = "battle_economy_devastation_delta",
setting_name = "BattleEconomyDevastationDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "10",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2187,7 +2187,7 @@ scala_setting_library(
scala_setting_library(
name = "battle_agriculture_devastation_delta",
setting_name = "BattleAgricultureDevastationDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "10",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2200,7 +2200,7 @@ scala_setting_library(
scala_setting_library(
name = "battle_infrastructure_devastation_delta",
setting_name = "BattleInfrastructureDevastationDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "10",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2226,7 +2226,7 @@ scala_setting_library(
scala_setting_library(
name = "riot_support_delta",
setting_name = "RiotSupportDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "-25",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2239,7 +2239,7 @@ scala_setting_library(
scala_setting_library(
name = "riot_economy_devastation_delta",
setting_name = "RiotEconomyDevastationDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "25",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2252,7 +2252,7 @@ scala_setting_library(
scala_setting_library(
name = "riot_infrastructure_devastation_delta",
setting_name = "RiotInfrastructureDevastationDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "25",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2421,7 +2421,7 @@ scala_setting_library(
scala_setting_library(
name = "blizzard_economy_devastation_delta",
setting_name = "BlizzardEconomyDevastationDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "4",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2434,7 +2434,7 @@ scala_setting_library(
scala_setting_library(
name = "blizzard_infrastructure_devastation_delta",
setting_name = "BlizzardInfrastructureDevastationDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "4",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2447,7 +2447,7 @@ scala_setting_library(
scala_setting_library(
name = "blizzard_agriculture_devastation_delta",
setting_name = "BlizzardAgricultureDevastationDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "4",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2590,7 +2590,7 @@ scala_setting_library(
scala_setting_library(
name = "max_flood_infrastructure_devastation_delta",
setting_name = "MaxFloodInfrastructureDevastationDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "20",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2603,7 +2603,7 @@ scala_setting_library(
scala_setting_library(
name = "max_flood_agriculture_devastation_delta",
setting_name = "MaxFloodAgricultureDevastationDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "20",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2616,7 +2616,7 @@ scala_setting_library(
scala_setting_library(
name = "flood_devastation_delta_reduction_per_infrastructure",
setting_name = "FloodDevastationDeltaReductionPerInfrastructure",
setting_type = "Double",
setting_type = "Float",
setting_value = "0.3",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2655,7 +2655,7 @@ scala_setting_library(
scala_setting_library(
name = "epidemic_economy_devastation_delta",
setting_name = "EpidemicEconomyDevastationDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "10",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2824,7 +2824,7 @@ scala_setting_library(
scala_setting_library(
name = "drought_agriculture_devastation_delta",
setting_name = "DroughtAgricultureDevastationDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "10",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -2850,7 +2850,7 @@ scala_setting_library(
scala_setting_library(
name = "empty_province_monthly_devastation_delta",
setting_name = "EmptyProvinceMonthlyDevastationDelta",
setting_type = "Double",
setting_type = "Float",
setting_value = "-2",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -3461,7 +3461,7 @@ scala_setting_library(
scala_setting_library(
name = "minimum_price_index",
setting_name = "MinimumPriceIndex",
setting_type = "Double",
setting_type = "Float",
setting_value = "0.75",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -3474,7 +3474,7 @@ scala_setting_library(
scala_setting_library(
name = "maximum_price_index",
setting_name = "MaximumPriceIndex",
setting_type = "Double",
setting_type = "Float",
setting_value = "1.5",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -3487,7 +3487,7 @@ scala_setting_library(
scala_setting_library(
name = "price_index_return_rate",
setting_name = "PriceIndexReturnRate",
setting_type = "Double",
setting_type = "Float",
setting_value = "0.1",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -3500,7 +3500,7 @@ scala_setting_library(
scala_setting_library(
name = "price_index_shift_per_gold",
setting_name = "PriceIndexShiftPerGold",
setting_type = "Double",
setting_type = "Float",
setting_value = "0.0001",
visibility = [
"//src/main/scala/net/eagle0/eagle:__subpackages__",
@@ -8,6 +8,14 @@ scala_library(
],
)
scala_library(
name = "float_setting",
srcs = ["FloatSetting.scala"],
visibility = [
"//visibility:public",
],
)
scala_library(
name = "int_setting",
srcs = ["IntSetting.scala"],
@@ -0,0 +1,6 @@
package net.eagle0.eagle.library.settings.base
class FloatSetting(private var _floatValue: Float) {
def floatValue: Float = _floatValue
def setFloatValue(newValue: Float): Unit = _floatValue = newValue
}
@@ -1,7 +1,11 @@
package net.eagle0.eagle.library.settings.loaders
import net.eagle0.common.TsvUtils
import net.eagle0.eagle.library.settings.base.{DoubleSetting, IntSetting}
import net.eagle0.eagle.library.settings.base.{
DoubleSetting,
FloatSetting,
IntSetting
}
import java.net.URL
import scala.reflect.runtime.universe
@@ -42,6 +46,9 @@ object SettingsLoader {
case "double" =>
obj.asInstanceOf[DoubleSetting].setDoubleValue(setting.value.toDouble)
true
case "float" =>
obj.asInstanceOf[FloatSetting].setFloatValue(setting.value.toFloat)
true
case typeName =>
throw new Exception(s"Invalid setting type $typeName")
}
@@ -33,11 +33,11 @@ object BeastUtils {
map("maxCountMultiplier").asInstanceOf[String].toDouble,
relativePower = map("relativePower").asInstanceOf[String].toDouble,
economyDevastation =
map("economyDevastation").asInstanceOf[String].toDouble,
map("economyDevastation").asInstanceOf[String].toFloat,
agricultureDevastation =
map("agricultureDevastation").asInstanceOf[String].toDouble,
map("agricultureDevastation").asInstanceOf[String].toFloat,
infrastructureDevastation =
map("infrastructureDevastation").asInstanceOf[String].toDouble,
map("infrastructureDevastation").asInstanceOf[String].toFloat,
averageGoldPer = map("averageGoldPer").asInstanceOf[String].toDouble,
averageFoodPer = map("averageFoodPer").asInstanceOf[String].toDouble
)
@@ -8,35 +8,34 @@ import net.eagle0.eagle.library.settings.{
}
object PriceIndexUtils {
def clampedIndex(
value: Double
): Double =
if (value < MinimumPriceIndex.doubleValue) MinimumPriceIndex.doubleValue
else if (value > MaximumPriceIndex.doubleValue)
MaximumPriceIndex.doubleValue
def clampedIndex(value: Float): Float =
if (value < MinimumPriceIndex.floatValue)
MinimumPriceIndex.floatValue
else if (value > MaximumPriceIndex.floatValue)
MaximumPriceIndex.floatValue
else value
def steadyState(
economy: Double,
agriculture: Double,
infrastructure: Double,
economyDevastation: Double,
agricultureDevastation: Double,
infrastructureDevastation: Double
): Double =
economy: Float,
agriculture: Float,
infrastructure: Float,
economyDevastation: Float,
agricultureDevastation: Float,
infrastructureDevastation: Float
): Float =
clampedIndex(
MinimumPriceIndex.doubleValue + (economy + agriculture + infrastructure + economyDevastation + agricultureDevastation + infrastructureDevastation) / 600.0
MinimumPriceIndex.floatValue + (economy + agriculture + infrastructure + economyDevastation + agricultureDevastation + infrastructureDevastation) / 600.0f
)
def shiftedTowardSteadyState(
currentPriceIndex: Double,
economy: Double,
agriculture: Double,
infrastructure: Double,
economyDevastation: Double,
agricultureDevastation: Double,
infrastructureDevastation: Double
): Double = {
currentPriceIndex: Float,
economy: Float,
agriculture: Float,
infrastructure: Float,
economyDevastation: Float,
agricultureDevastation: Float,
infrastructureDevastation: Float
): Float = {
val steadyStatePriceIndex =
steadyState(
economy,
@@ -48,20 +47,20 @@ object PriceIndexUtils {
)
val difference = steadyStatePriceIndex - currentPriceIndex
val shifted =
currentPriceIndex + difference * PriceIndexReturnRate.doubleValue
if (shifted < MinimumPriceIndex.doubleValue) MinimumPriceIndex.doubleValue
else if (shifted > MaximumPriceIndex.doubleValue)
MaximumPriceIndex.doubleValue
currentPriceIndex + difference * PriceIndexReturnRate.floatValue
if (shifted < MinimumPriceIndex.floatValue) MinimumPriceIndex.floatValue
else if (shifted > MaximumPriceIndex.floatValue)
MaximumPriceIndex.floatValue
else shifted
}
// Gold spent can be negative (ie by selling food), which would drive prices down
def maybeNewPriceIndexFromGoldSpend(
currentPriceIndex: Double,
goldSpent: Double
): Option[Double] = {
currentPriceIndex: Float,
goldSpent: Float
): Option[Float] = {
val newIndex = clampedIndex(
currentPriceIndex + goldSpent * PriceIndexShiftPerGold.doubleValue
currentPriceIndex + goldSpent * PriceIndexShiftPerGold.floatValue
)
Option.when(newIndex != currentPriceIndex)(newIndex)
@@ -25,7 +25,12 @@ object AlmsCommandSelector {
): (Hero, Double) =
availableHeroes
.map(h =>
(h, AlmsCommand.supportIncreasePerFood(HeroConverter.fromProto(h)))
(
h,
AlmsCommand
.supportIncreasePerFood(HeroConverter.fromProto(h))
.toDouble
)
)
.maxBy { case (hero, inc) =>
(inc, -LegacyHeroUtils.fatigue(hero))
@@ -71,12 +71,12 @@ object LegacyProvinceUtils {
province
) + effectiveInfrastructure(province))).toInt
def effectiveEconomy(province: Province): Double =
(province.economy - province.economyDevastation).max(0.0)
def effectiveAgriculture(province: Province): Double =
(province.agriculture - province.agricultureDevastation).max(0.0)
def effectiveInfrastructure(province: Province): Double =
(province.infrastructure - province.infrastructureDevastation).max(0.0)
def effectiveEconomy(province: Province): Float =
(province.economy - province.economyDevastation).max(0.0f)
def effectiveAgriculture(province: Province): Float =
(province.agriculture - province.agricultureDevastation).max(0.0f)
def effectiveInfrastructure(province: Province): Float =
(province.infrastructure - province.infrastructureDevastation).max(0.0f)
def goldCap(province: Province): Int =
(BaseResourceLimit.intValue + PerDevelopmentResourceLimit.intValue * (effectiveEconomy(
@@ -40,12 +40,12 @@ object ProvinceUtils {
province
) + effectiveInfrastructure(province))).toInt
def effectiveEconomy(province: ProvinceT): Double =
(province.economy - province.economyDevastation).max(0.0)
def effectiveAgriculture(province: ProvinceT): Double =
(province.agriculture - province.agricultureDevastation).max(0.0)
def effectiveInfrastructure(province: ProvinceT): Double =
(province.infrastructure - province.infrastructureDevastation).max(0.0)
def effectiveEconomy(province: ProvinceT): Float =
(province.economy - province.economyDevastation).max(0.0f)
def effectiveAgriculture(province: ProvinceT): Float =
(province.agriculture - province.agricultureDevastation).max(0.0f)
def effectiveInfrastructure(province: ProvinceT): Float =
(province.infrastructure - province.infrastructureDevastation).max(0.0f)
def goldCap(province: ProvinceT): Int =
(BaseResourceLimit.intValue + PerDevelopmentResourceLimit.intValue * (effectiveEconomy(
@@ -185,14 +185,12 @@ object ProvinceViewFilter {
.sortBy(_.`type`.index),
defendingArmy = province.defendingArmy
.map(ArmyFilter.filterArmy(_, gs.battalions, factionId)),
economy = roundedStat(province.economy),
agriculture = roundedStat(province.agriculture),
infrastructure = roundedStat(province.infrastructure),
economyDevastation = roundedDevastation(province.economyDevastation),
agricultureDevastation =
roundedDevastation(province.agricultureDevastation),
infrastructureDevastation =
roundedDevastation(province.infrastructureDevastation),
economy = province.economy,
agriculture = province.agriculture,
infrastructure = province.infrastructure,
economyDevastation = province.economyDevastation,
agricultureDevastation = province.agricultureDevastation,
infrastructureDevastation = province.infrastructureDevastation,
gold = province.gold,
food = province.food,
priceIndex = province.priceIndex,
@@ -210,14 +208,6 @@ object ProvinceViewFilter {
rulerIsTraveling = province.rulerIsTraveling
)
private def roundedStat(stat: Double): Int =
if (stat == 0) 0
else if (stat < 1) 1
else stat.floor.toInt
private def roundedDevastation(stat: Double): Int =
stat.ceil.toInt
private def myIncomingArmies(
province: Province,
gs: GameState,
@@ -43,14 +43,14 @@ case class ChangedProvinceC(
goldDelta: Option[Int] = None,
foodDelta: Option[Int] = None,
/* stat changes */
newPriceIndex: Option[Double] = None,
economyDelta: Option[Double] = None,
agricultureDelta: Option[Double] = None,
infrastructureDelta: Option[Double] = None,
economyDevastationDelta: Option[Double] = None,
agricultureDevastationDelta: Option[Double] = None,
infrastructureDevastationDelta: Option[Double] = None,
supportDelta: Option[Double] = None,
newPriceIndex: Option[Float] = None,
economyDelta: Option[Float] = None,
agricultureDelta: Option[Float] = None,
infrastructureDelta: Option[Float] = None,
economyDevastationDelta: Option[Float] = None,
agricultureDevastationDelta: Option[Float] = None,
infrastructureDevastationDelta: Option[Float] = None,
supportDelta: Option[Float] = None,
/* round properties */
setHasActed: Option[Boolean] = None,
setRulerIsTraveling: Option[Boolean] = None,
@@ -100,15 +100,15 @@ case class ChangedProvinceC(
def copy(
goldDelta: Option[Int] = goldDelta,
foodDelta: Option[Int] = foodDelta,
newPriceIndex: Option[Double] = newPriceIndex,
economyDelta: Option[Double] = economyDelta,
agricultureDelta: Option[Double] = agricultureDelta,
infrastructureDelta: Option[Double] = infrastructureDelta,
economyDevastationDelta: Option[Double] = economyDevastationDelta,
agricultureDevastationDelta: Option[Double] = agricultureDevastationDelta,
infrastructureDevastationDelta: Option[Double] =
newPriceIndex: Option[Float] = newPriceIndex,
economyDelta: Option[Float] = economyDelta,
agricultureDelta: Option[Float] = agricultureDelta,
infrastructureDelta: Option[Float] = infrastructureDelta,
economyDevastationDelta: Option[Float] = economyDevastationDelta,
agricultureDevastationDelta: Option[Float] = agricultureDevastationDelta,
infrastructureDevastationDelta: Option[Float] =
infrastructureDevastationDelta,
supportDelta: Option[Double] = supportDelta,
supportDelta: Option[Float] = supportDelta,
setHasActed: Option[Boolean] = setHasActed,
setRulerIsTraveling: Option[Boolean] = setRulerIsTraveling,
newUnaffiliatedHeroes: Vector[UnaffiliatedHeroT] = newUnaffiliatedHeroes,
@@ -25,9 +25,9 @@ object BeastInfoConverter {
likelihood = likelihood,
maxCountMultiplier = maxCountMultiplier,
relativePower = relativePower,
economyDevastation = economyDevastation,
agricultureDevastation = agricultureDevastation,
infrastructureDevastation = infrastructureDevastation,
economyDevastation = economyDevastation.toFloat,
agricultureDevastation = agricultureDevastation.toFloat,
infrastructureDevastation = infrastructureDevastation.toFloat,
averageGoldPer = averageGoldPer,
averageFoodPer = averageFoodPer
)
@@ -51,14 +51,14 @@ object ChangedProvinceConverter {
provinceId: ProvinceId,
goldDelta: Option[ProvinceId],
foodDelta: Option[ProvinceId],
newPriceIndex: Option[Double],
economyDelta: Option[Double],
agricultureDelta: Option[Double],
infrastructureDelta: Option[Double],
economyDevastationDelta: Option[Double],
agricultureDevastationDelta: Option[Double],
infrastructureDevastationDelta: Option[Double],
supportDelta: Option[Double],
newPriceIndex: Option[Float],
economyDelta: Option[Float],
agricultureDelta: Option[Float],
infrastructureDelta: Option[Float],
economyDevastationDelta: Option[Float],
agricultureDevastationDelta: Option[Float],
infrastructureDevastationDelta: Option[Float],
supportDelta: Option[Float],
setHasActed: Option[Boolean],
setRulerIsTraveling: Option[Boolean],
newUnaffiliatedHeroes: Vector[UnaffiliatedHeroT],
@@ -89,16 +89,16 @@ object ProvinceConverter {
specialBattalionTypeIds: Vector[BattalionTypeId],
gold: Int,
food: Int,
priceIndex: Double,
priceIndex: Float,
hasActed: Boolean,
rulerIsTraveling: Boolean,
economy: Double,
agriculture: Double,
infrastructure: Double,
economyDevastation: Double,
agricultureDevastation: Double,
infrastructureDevastation: Double,
support: Double,
economy: Float,
agriculture: Float,
infrastructure: Float,
economyDevastation: Float,
agricultureDevastation: Float,
infrastructureDevastation: Float,
support: Float,
unaffiliatedHeroes: Vector[UnaffiliatedHeroT],
capturedHeroes: Vector[CapturedHero],
activeEvents: Vector[ProvinceEvent],
@@ -190,17 +190,17 @@ object ProvinceConverter {
incomingShipments: Vector[MovingSuppliesProto],
incomingEndTurnActions: Vector[IncomingEndTurnActionProto],
defendingArmy: Option[ArmyProto],
economy: Double,
agriculture: Double,
infrastructure: Double,
economyDevastation: Double,
agricultureDevastation: Double,
infrastructureDevastation: Double,
economy: Float,
agriculture: Float,
infrastructure: Float,
economyDevastation: Float,
agricultureDevastation: Float,
infrastructureDevastation: Float,
lockedImprovementType: ImprovementTypeProto,
gold: Int,
food: Int,
priceIndex: Double,
support: Double,
priceIndex: Float,
support: Float,
hasActed: Boolean,
rulerIsTraveling: Boolean,
unaffiliatedHeroes: Vector[UnaffiliatedHeroProto],
@@ -45,20 +45,20 @@ trait ProvinceT {
def gold: Int
def food: Int
def priceIndex: Double
def priceIndex: Float
def hasActed: Boolean
def rulerIsTraveling: Boolean
def economy: Double
def agriculture: Double
def infrastructure: Double
def economy: Float
def agriculture: Float
def infrastructure: Float
def economyDevastation: Double
def agricultureDevastation: Double
def infrastructureDevastation: Double
def economyDevastation: Float
def agricultureDevastation: Float
def infrastructureDevastation: Float
def support: Double
def support: Float
def unaffiliatedHeroes: Vector[UnaffiliatedHeroT]
def capturedHeroes: Vector[CapturedHero]
@@ -97,16 +97,16 @@ trait ProvinceT {
specialBattalionTypeIds,
gold: Int = gold,
food: Int = food,
priceIndex: Double = priceIndex,
priceIndex: Float = priceIndex,
hasActed: Boolean = hasActed,
rulerIsTraveling: Boolean = rulerIsTraveling,
economy: Double = economy,
agriculture: Double = agriculture,
infrastructure: Double = infrastructure,
economyDevastation: Double = economyDevastation,
agricultureDevastation: Double = agricultureDevastation,
infrastructureDevastation: Double = infrastructureDevastation,
support: Double = support,
economy: Float = economy,
agriculture: Float = agriculture,
infrastructure: Float = infrastructure,
economyDevastation: Float = economyDevastation,
agricultureDevastation: Float = agricultureDevastation,
infrastructureDevastation: Float = infrastructureDevastation,
support: Float = support,
unaffiliatedHeroes: Vector[UnaffiliatedHeroT] = unaffiliatedHeroes,
capturedHeroes: Vector[CapturedHero] = capturedHeroes,
activeEvents: Vector[ProvinceEvent] = activeEvents,
@@ -140,24 +140,24 @@ trait ProvinceT {
def withRulerIsTraveling(rulerIsTraveling: Boolean): ProvinceT =
copy(rulerIsTraveling = rulerIsTraveling)
def withEconomy(economy: Double): ProvinceT =
def withEconomy(economy: Float): ProvinceT =
copy(economy = economy)
def withAgriculture(agriculture: Double): ProvinceT = copy(
def withAgriculture(agriculture: Float): ProvinceT = copy(
agriculture = agriculture
)
def withInfrastructure(infrastructure: Double): ProvinceT =
def withInfrastructure(infrastructure: Float): ProvinceT =
copy(infrastructure = infrastructure)
def withEconomyDevastation(economyDevastation: Double): ProvinceT =
def withEconomyDevastation(economyDevastation: Float): ProvinceT =
copy(economyDevastation = economyDevastation)
def withAgricultureDevastation(
agricultureDevastation: Double
agricultureDevastation: Float
): ProvinceT =
copy(agricultureDevastation = agricultureDevastation)
def withInfrastructureDevastation(
infrastructureDevastation: Double
infrastructureDevastation: Float
): ProvinceT =
copy(infrastructureDevastation = infrastructureDevastation)
@@ -166,7 +166,7 @@ trait ProvinceT {
def withFood(food: Int): ProvinceT =
copy(food = food)
def withPriceIndex(priceIndex: Double): ProvinceT =
def withPriceIndex(priceIndex: Float): ProvinceT =
copy(priceIndex = priceIndex)
def withDeferredChanges(deferredChanges: Vector[DeferredChangeT]): ProvinceT =
@@ -34,16 +34,16 @@ case class ProvinceC(
specialBattalionTypeIds: Vector[BattalionTypeId] = Vector(),
gold: Int = 0,
food: Int = 0,
priceIndex: Double = 0.0,
priceIndex: Float = 0.0f,
hasActed: Boolean = false,
rulerIsTraveling: Boolean = false,
economy: Double = 0.0,
agriculture: Double = 0.0,
infrastructure: Double = 0.0,
economyDevastation: Double = 0.0,
agricultureDevastation: Double = 0.0,
infrastructureDevastation: Double = 0.0,
support: Double = 0.0,
economy: Float = 0.0f,
agriculture: Float = 0.0f,
infrastructure: Float = 0.0f,
economyDevastation: Float = 0.0f,
agricultureDevastation: Float = 0.0f,
infrastructureDevastation: Float = 0.0f,
support: Float = 0.0f,
unaffiliatedHeroes: Vector[UnaffiliatedHeroT] = Vector(),
capturedHeroes: Vector[CapturedHero] = Vector(),
activeEvents: Vector[ProvinceEvent] = Vector(),
@@ -76,16 +76,16 @@ case class ProvinceC(
specialBattalionTypeIds: Vector[BattalionTypeId],
gold: BattalionId,
food: BattalionId,
priceIndex: Double,
priceIndex: Float,
hasActed: Boolean,
rulerIsTraveling: Boolean,
economy: Double,
agriculture: Double,
infrastructure: Double,
economyDevastation: Double,
agricultureDevastation: Double,
infrastructureDevastation: Double,
support: Double,
economy: Float,
agriculture: Float,
infrastructure: Float,
economyDevastation: Float,
agricultureDevastation: Float,
infrastructureDevastation: Float,
support: Float,
unaffiliatedHeroes: Vector[UnaffiliatedHeroT],
capturedHeroes: Vector[CapturedHero],
activeEvents: Vector[ProvinceEvent],
@@ -508,7 +508,7 @@ class ActionResultProtoApplierImplTest
"a result with a changed province with an added deferred event" should "add the deferred event" in {
val startingState = GameState(
currentDate = Date(year = 123, month = 4),
provinces = Map(7 -> Province(id = 7, priceIndex = 1.0))
provinces = Map(7 -> Province(id = 7, priceIndex = 1.0f))
)
val actionResult = ActionResult(changedProvinces =
@@ -540,7 +540,7 @@ class ActionResultProtoApplierImplTest
BlizzardStarted(durationMonths = 2),
BlizzardStarted(durationMonths = 3)
),
priceIndex = 1.0
priceIndex = 1.0f
)
)
)
@@ -572,7 +572,7 @@ class ActionResultProtoApplierImplTest
provinces = Map(
7 -> Province(
id = 7,
priceIndex = 1.0,
priceIndex = 1.0f,
rulingFactionId = Some(5),
rulingHeroId = Some(6),
provinceOrders = ProvinceOrderType.DEVELOP,
@@ -623,7 +623,7 @@ class ActionResultProtoApplierImplTest
)
)
),
priceIndex = 1.0
priceIndex = 1.0f
)
)
}
@@ -833,14 +833,14 @@ class ActionResultProtoApplierImplTest
}
"A result with changed orders" should "change the province orders" in {
val province1 = Province(id = 1, priceIndex = 1.0)
val province1 = Province(id = 1, priceIndex = 1.0f)
val province2 = Province(
id = 2,
rulingFactionId = Some(3),
rulingHeroId = Some(7),
rulingFactionHeroIds = Vector(7),
provinceOrders = MOBILIZE,
priceIndex = 1.0
priceIndex = 1.0f
)
val startingState = GameState(
@@ -875,7 +875,7 @@ class ActionResultProtoApplierImplTest
rulingFactionId = Some(3),
rulingFactionHeroIds = Vector(4, 9, 11, 5),
provinceOrders = ProvinceOrderType.DEVELOP,
priceIndex = 1.0
priceIndex = 1.0f
)
val startingState = GameState(
@@ -945,7 +945,7 @@ class ActionResultProtoApplierImplTest
rulingFactionHeroIds = Vector(4, 9, 11, 5),
provinceOrders = ProvinceOrderType.DEVELOP,
activeEvents = Vector(BeastsEvent(count = 100), BeastsEvent(count = 250)),
priceIndex = 1.0
priceIndex = 1.0f
)
val startingState = GameState(
@@ -1013,7 +1013,7 @@ class ActionResultProtoApplierImplTest
provinceOrders = ProvinceOrderType.DEVELOP,
activeEvents = Vector(),
lastBeastsDate = Some(Date(month = 4, year = 222)),
priceIndex = 1.0
priceIndex = 1.0f
)
val startingState = GameState(
@@ -1087,7 +1087,7 @@ class ActionResultProtoApplierImplTest
provinceOrders = ProvinceOrderType.DEVELOP,
activeEvents = Vector(),
lastRiotDate = None,
priceIndex = 1.0
priceIndex = 1.0f
)
val startingState = GameState(
@@ -21,7 +21,7 @@ class AvailableArmTroopsCommandFactoryTest
val rulingFactionId = 5
private val lowArmamentBattalion =
Battalion(`type` = LIGHT_INFANTRY, size = 300, armament = 25.0, id = 7)
Battalion(`type` = LIGHT_INFANTRY, size = 300, armament = 25.0f, id = 7)
private val highArmamentBattalion =
Battalion(`type` = LONGBOWMEN, size = 600, armament = 87, id = 9)
@@ -29,15 +29,15 @@ class AvailableArmTroopsCommandFactoryTest
private val province = Province(
id = 122,
rulingFactionId = Some(rulingFactionId),
infrastructure = 55.0,
infrastructure = 55.0f,
battalionIds = Vector(lowArmamentBattalion.id, highArmamentBattalion.id),
rulerIsTraveling = true,
gold = 1200,
priceIndex = 1.0
priceIndex = 1.0f
)
private val lightInfantryBaseCost = 0.01
private val longbowmenBaseCost = 0.03
private val lightInfantryBaseCost = 0.01f
private val longbowmenBaseCost = 0.03f
private val battalionTypes = Vector(
BattalionType(
@@ -85,7 +85,7 @@ class AvailableArmTroopsCommandFactoryTest
it should "return nothing if armament is all at or above infrastructure level" in {
val command = AvailableArmTroopsCommandFactory.availableCommand(
gameState = startingState
.withProvinces(Map(province.id -> province.withInfrastructure(24.5))),
.withProvinces(Map(province.id -> province.withInfrastructure(24.5f))),
factionId = rulingFactionId,
provinceId = province.id
)
@@ -153,7 +153,7 @@ class AvailableArmTroopsCommandFactoryTest
it should "include all battalions if all under infrastructure" in {
val command = AvailableArmTroopsCommandFactory.availableCommand(
gameState = startingState
.withProvinces(Map(province.id -> province.withInfrastructure(99.0))),
.withProvinces(Map(province.id -> province.withInfrastructure(99.0f))),
factionId = rulingFactionId,
provinceId = province.id
)
@@ -167,7 +167,7 @@ class AvailableArmTroopsCommandFactoryTest
it should "include a costs message for the available battalion types" in {
val command = AvailableArmTroopsCommandFactory.availableCommand(
gameState = startingState
.withProvinces(Map(province.id -> province.withInfrastructure(99.0))),
.withProvinces(Map(province.id -> province.withInfrastructure(99.0f))),
factionId = rulingFactionId,
provinceId = province.id
)
@@ -183,16 +183,26 @@ class AvailableArmTroopsCommandFactoryTest
gameState = startingState
.withProvinces(
Map(
province.id -> province.withInfrastructure(99.0).withPriceIndex(1.2)
province.id -> province
.withInfrastructure(99.0f)
.withPriceIndex(1.2f)
)
),
factionId = rulingFactionId,
provinceId = province.id
)
command.get.armamentCosts should contain.allOf(
ArmamentCost(`type` = LIGHT_INFANTRY, cost = lightInfantryBaseCost * 1.2),
ArmamentCost(`type` = LONGBOWMEN, cost = longbowmenBaseCost * 1.2)
)
val expectedLightInfantryCost = lightInfantryBaseCost * 1.2f
val expectedLongbowmenCost = longbowmenBaseCost * 1.2f
command.get.armamentCosts should have size 2
command.get.armamentCosts
.find(_.`type` == LIGHT_INFANTRY)
.get
.cost shouldBe expectedLightInfantryCost
command.get.armamentCosts
.find(_.`type` == LONGBOWMEN)
.get
.cost shouldBe expectedLongbowmenCost
}
}
@@ -84,7 +84,7 @@ class AvailableDivineCommandsFactoryTest
),
gold = 1200,
food = 2400,
priceIndex = 1.0
priceIndex = 1.0f
)
),
heroes = mapifyHeroes(
@@ -296,7 +296,7 @@ class AvailableDivineCommandsFactoryTest
it should "adjust the gold cost based on price index" in {
AvailableDivineCommandsFactory
.availableCommand(
gameState = gameState.update(_.provinces(actingPid).priceIndex := 1.1),
gameState = gameState.update(_.provinces(actingPid).priceIndex := 1.1f),
factionId = actingFid,
provinceId = actingPid
)
@@ -30,7 +30,7 @@ class AvailableFeastCommandFactoryTest
5 -> Province(
rulingFactionHeroIds = Vector(15, 25, 35),
gold = 12,
priceIndex = 1.0
priceIndex = 1.0f
)
)
)
@@ -53,7 +53,7 @@ class AvailableFeastCommandFactoryTest
5 -> Province(
rulingFactionHeroIds = Vector(15, 25, 35),
gold = 1200,
priceIndex = 1.0
priceIndex = 1.0f
)
)
)
@@ -76,7 +76,7 @@ class AvailableFeastCommandFactoryTest
5 -> Province(
rulingFactionHeroIds = Vector(15, 25, 35),
gold = 1200,
priceIndex = 1.0
priceIndex = 1.0f
)
)
)
@@ -102,7 +102,7 @@ class AvailableFeastCommandFactoryTest
5 -> Province(
rulingFactionHeroIds = Vector(15, 25, 35),
gold = 1200,
priceIndex = 1.0
priceIndex = 1.0f
)
)
)
@@ -128,13 +128,13 @@ class AvailableFeastCommandFactoryTest
5 -> Province(
rulingFactionHeroIds = Vector(15, 25, 35),
gold = 1200,
priceIndex = 1.2
priceIndex = 1.2f
)
)
)
val cmd = AvailableFeastCommandFactory.availableCommand(gameState, 9, 5).get
cmd.goldCost shouldBe 72
cmd.goldCost shouldBe 73
}
}
@@ -202,7 +202,7 @@ class AvailableImproveCommandsFactoryTest
}
it should "include DEVASTATION option if there is economy devastation" in {
val provinceWithDevastation = province.withEconomyDevastation(25.0)
val provinceWithDevastation = province.withEconomyDevastation(25.0f)
val command = AvailableImproveCommandsFactory
.availableCommand(
@@ -217,7 +217,7 @@ class AvailableImproveCommandsFactoryTest
}
it should "include DEVASTATION option if there is agriculture devastation" in {
val provinceWithDevastation = province.withEconomyDevastation(25.0)
val provinceWithDevastation = province.withEconomyDevastation(25.0f)
val command = AvailableImproveCommandsFactory
.availableCommand(
@@ -232,7 +232,7 @@ class AvailableImproveCommandsFactoryTest
}
it should "include DEVASTATION option if there is infrastructure devastation" in {
val provinceWithDevastation = province.withInfrastructureDevastation(25.0)
val provinceWithDevastation = province.withInfrastructureDevastation(25.0f)
val command = AvailableImproveCommandsFactory
.availableCommand(
@@ -39,7 +39,7 @@ class AvailableOrganizeTroopsCommandsFactoryTest
battalionIds = fullAndNotFullBattalions.map(_.id),
specialBattalionTypes = Vector(LIGHT_INFANTRY, HEAVY_CAVALRY),
gold = 2000,
priceIndex = 1.0
priceIndex = 1.0f
)
private val battalionTypes = Vector(
@@ -105,7 +105,7 @@ class AvailableOrganizeTroopsCommandsFactoryTest
7 -> actingProvince
.withEconomy(70)
.withAgriculture(70)
.withPriceIndex(1.0),
.withPriceIndex(1.0f),
4 -> Province(id = 4, rulingFactionId = Some(5)),
8 -> Province(id = 8, rulingFactionId = Some(6)),
12 -> Province(id = 12, rulingFactionId = Some(9))
@@ -128,9 +128,9 @@ class AvailableOrganizeTroopsCommandsFactoryTest
val gameState = GameState(
provinces = Map(
7 -> actingProvince
.withEconomy(70)
.withAgriculture(70)
.withPriceIndex(0.9),
.withEconomy(70f)
.withAgriculture(70f)
.withPriceIndex(0.9f),
4 -> Province(id = 4, rulingFactionId = Some(5)),
8 -> Province(id = 8, rulingFactionId = Some(6)),
12 -> Province(id = 12, rulingFactionId = Some(9))
@@ -21,7 +21,7 @@ class AvailableTradeCommandFactoryTest
gold = 2000,
food = 2500,
rulerIsTraveling = true,
priceIndex = 1.0
priceIndex = 1.0f
)
private val gameState = GameState(
@@ -105,7 +105,7 @@ class AvailableTradeCommandFactoryTest
it should "adjust the buy food price based on the price index" in {
val command = AvailableTradeCommandFactory.availableCommand(
gameState = gameState.withProvinces(
Map(province.id -> province.withPriceIndex(1.5))
Map(province.id -> province.withPriceIndex(1.5f))
),
factionId = province.rulingFactionId.get,
provinceId = province.id
@@ -127,7 +127,7 @@ class AvailableTradeCommandFactoryTest
it should "adjust the sell food price based on the price index" in {
val command = AvailableTradeCommandFactory.availableCommand(
gameState = gameState.withProvinces(
Map(province.id -> province.withPriceIndex(1.5))
Map(province.id -> province.withPriceIndex(1.5f))
),
factionId = province.rulingFactionId.get,
provinceId = province.id
@@ -127,9 +127,9 @@ class NewRoundActionTest
Map(
7 -> Province(
id = 7,
economyDevastation = 14.3,
agricultureDevastation = 2.1,
infrastructureDevastation = 19.1
economyDevastation = 14.3f,
agricultureDevastation = 2.1f,
infrastructureDevastation = 19.1f
)
)
)
@@ -151,9 +151,9 @@ class NewRoundActionTest
Map(
7 -> Province(
id = 7,
economyDevastation = 0.3,
agricultureDevastation = 1.9,
infrastructureDevastation = 0.0
economyDevastation = 0.3f,
agricultureDevastation = 1.9f,
infrastructureDevastation = 0.0f
)
)
)
@@ -164,8 +164,8 @@ class NewRoundActionTest
inside(results.head.changedProvinces.head) { case cp: ChangedProvince =>
cp.id shouldBe 7
cp.setHasActed shouldBe Some(false)
cp.economyDevastationDelta shouldBe Some(-0.3)
cp.agricultureDevastationDelta shouldBe Some(-1.9)
cp.economyDevastationDelta shouldBe Some(-0.3f)
cp.agricultureDevastationDelta shouldBe Some(-1.9f)
cp.infrastructureDevastationDelta shouldBe None
}
}
@@ -898,7 +898,7 @@ class NewRoundActionTest
economy = 100,
agriculture = 100,
infrastructure = 100,
priceIndex = 0.75
priceIndex = 0.75f
)
)
)
@@ -907,7 +907,7 @@ class NewRoundActionTest
forExactly(1, results) { result =>
result.changedProvinces.head.newPriceIndex shouldBe Some(
0.75 + 0.1 * 0.5
0.75f + 0.1f * 0.5f
)
}
}
@@ -113,7 +113,7 @@ class NewYearActionTest
MinSupportForTaxes.setDoubleValue(45)
FoodIncreasePerAgriculture.setDoubleValue(60)
GoldIncreasePerEconomy.setDoubleValue(40)
PercentDegradationPerYear.setDoubleValue(15)
PercentDegradationPerYear.setDoubleValue(15f)
LoyaltyDiscordanceThreshold.setDoubleValue(10)
LoyaltyDecreasePerDiscordance.setDoubleValue(0.3)
AmbitionFactorForLoyaltyDegradation.setDoubleValue(0.2)
@@ -162,7 +162,7 @@ class NewYearActionTest
for ((oldProv, newProv) <- oldAndNew) {
newProv.economyDelta shouldBe empty
newProv.economyDevastationDelta should contain(0.15 * oldProv.economy)
newProv.economyDevastationDelta should contain(0.15f * oldProv.economy)
}
}
@@ -176,7 +176,7 @@ class NewYearActionTest
for ((oldProv, newProv) <- oldAndNew) {
newProv.agricultureDelta shouldBe empty
newProv.agricultureDevastationDelta should contain(
0.15 * oldProv.agriculture
0.15f * oldProv.agriculture
)
}
}
@@ -191,7 +191,7 @@ class NewYearActionTest
for ((oldProv, newProv) <- oldAndNew) {
newProv.infrastructureDelta shouldBe empty
newProv.infrastructureDevastationDelta should contain(
0.15 * oldProv.infrastructure
0.15f * oldProv.infrastructure
)
}
}
@@ -204,7 +204,7 @@ class NewYearActionTest
)
for ((oldProv, newProv) <- oldAndNew) {
newProv.supportDelta should contain(-0.15 * oldProv.support)
newProv.supportDelta should contain(-0.15f * oldProv.support)
}
}
@@ -289,7 +289,7 @@ class PerformProvinceEventsActionTest
id = 7,
rulingFactionId = Some(fid),
activeEvents = Vector.empty,
infrastructure = 65.0,
infrastructure = 65.0f,
lastBeastsDate = Some(Date(year = 1500, month = 8))
)
)
@@ -310,7 +310,7 @@ class PerformProvinceEventsActionTest
id = 7,
rulingFactionId = Some(fid),
activeEvents = Vector.empty,
infrastructure = 65.0,
infrastructure = 65.0f,
lastBeastsDate = Some(Date(year = 1500, month = 5))
)
)
@@ -332,7 +332,7 @@ class PerformProvinceEventsActionTest
7 -> Province(
id = 7,
rulingFactionId = Some(fid),
economy = 51.0,
economy = 51.0f,
activeEvents = Vector(
BeastsEvent(
count = 150,
@@ -365,7 +365,7 @@ class PerformProvinceEventsActionTest
7 -> Province(
id = 7,
rulingFactionId = Some(fid),
economy = 51.0,
economy = 51.0f,
activeEvents = Vector(
BeastsEvent(
count = 150,
@@ -398,7 +398,7 @@ class PerformProvinceEventsActionTest
7 -> Province(
id = 7,
rulingFactionId = Some(fid),
economy = 51.0,
economy = 51.0f,
activeEvents = Vector(
BeastsEvent(
count = 150,
@@ -431,7 +431,7 @@ class PerformProvinceEventsActionTest
7 -> Province(
id = 7,
rulingFactionId = Some(fid),
economy = 51.0,
economy = 51.0f,
activeEvents = Vector(
BeastsEvent(
count = 150,
@@ -898,7 +898,7 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
economy = 51.0f,
activeEvents = Vector(
FestivalEvent(
startDate = Date(year = 1501, month = 3),
@@ -928,7 +928,7 @@ class PerformProvinceEventsActionTest
7 -> Province(
id = 7,
rulingFactionId = Some(4),
economy = 51.0,
economy = 51.0f,
activeEvents = Vector(
FestivalEvent(
startDate = Date(year = 1501, month = 3),
@@ -964,7 +964,7 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
economy = 51.0f,
economyDevastation = 3,
activeEvents = Vector(
BlizzardEvent(
@@ -995,9 +995,9 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
economy = 51.0f,
agricultureDevastation = 3,
infrastructure = 0.0,
infrastructure = 0.0f,
activeEvents = Vector(
FloodEvent(
startDate = Date(year = 1501, month = 7),
@@ -1027,9 +1027,9 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
economy = 51.0f,
agricultureDevastation = 3,
infrastructure = 0.0,
infrastructure = 0.0f,
activeEvents = Vector(
DroughtEvent(
startDate = Date(year = 1501, month = 7),
@@ -1058,9 +1058,9 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
economy = 51.0f,
infrastructureDevastation = 3,
infrastructure = 40.0,
infrastructure = 40.0f,
activeEvents = Vector(
FloodEvent(
startDate = Date(year = 1501, month = 7),
@@ -1094,9 +1094,9 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
economy = 51.0f,
economyDevastation = 3,
infrastructure = 40.0,
infrastructure = 40.0f,
activeEvents = Vector()
)
)
@@ -1124,8 +1124,8 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
infrastructure = 40.0,
economy = 51.0f,
infrastructure = 40.0f,
activeEvents = Vector()
)
)
@@ -1144,8 +1144,8 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
infrastructure = 40.0,
economy = 51.0f,
infrastructure = 40.0f,
activeEvents = Vector()
)
)
@@ -1164,8 +1164,8 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
infrastructure = 40.0,
economy = 51.0f,
infrastructure = 40.0f,
activeEvents =
Vector(EpidemicEvent(startDate = Date(year = 1501, month = 6)))
)
@@ -1190,8 +1190,8 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
infrastructure = 40.0,
economy = 51.0f,
infrastructure = 40.0f,
activeEvents =
Vector(EpidemicEvent(startDate = Date(year = 1501, month = 6)))
)
@@ -1216,8 +1216,8 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
infrastructure = 40.0,
economy = 51.0f,
infrastructure = 40.0f,
activeEvents =
Vector(EpidemicEvent(startDate = Date(year = 1501, month = 6)))
)
@@ -1238,8 +1238,8 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
infrastructure = 40.0,
economy = 51.0f,
infrastructure = 40.0f,
neighbors =
Vector(Neighbor(provinceId = 8, startingPositionIndex = 3))
),
@@ -1272,8 +1272,8 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
infrastructure = 40.0,
economy = 51.0f,
infrastructure = 40.0f,
activeEvents =
Vector(EpidemicEvent(startDate = Date(year = 1501, month = 6)))
)
@@ -1302,8 +1302,8 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
infrastructure = 40.0,
economy = 51.0f,
infrastructure = 40.0f,
battalionIds = Vector(19, 25),
activeEvents =
Vector(EpidemicEvent(startDate = Date(year = 1501, month = 6)))
@@ -1333,8 +1333,8 @@ class PerformProvinceEventsActionTest
provinces = Map(
7 -> Province(
id = 7,
economy = 51.0,
infrastructure = 40.0,
economy = 51.0f,
infrastructure = 40.0f,
rulingFactionHeroIds = Vector(19, 25),
rulingFactionId = Some(12),
rulingHeroId = Some(25),
@@ -263,7 +263,7 @@ class PerformUncontestedConquestActionTest extends AnyFlatSpec with Matchers {
newBattalionIds = Vector(34, 99),
newRulingFactionId = Some(attackerId),
removedHostileArmyFactionIds = Vector(attackerId),
supportDelta = Some(-0.0),
supportDelta = Some(-0.0f),
newProvinceOrders = Some(Entrust),
clearDefendingArmy = true
)
@@ -45,8 +45,8 @@ class AlmsCommandTest
override def beforeEach(): Unit = {
MaxAlmsFood.setIntValue(1000)
AlmsMaxCharismaXp.setIntValue(10)
AlmsSupportIncreasePerFood.setDoubleValue(0.01)
AlmsPaladinSupportMultiplier.setDoubleValue(4)
AlmsSupportIncreasePerFood.setFloatValue(0.01f)
AlmsPaladinSupportMultiplier.setFloatValue(4f)
ActionVigorCost.setIntValue(actionVigorCost)
VigorToConstitutionXpMultiplier.setDoubleValue(0.2)
XpForStatBump.setIntValue(100)
@@ -180,7 +180,7 @@ class AlmsCommandTest
cp shouldBe ChangedProvinceC(
provinceId = actingProvince.id,
supportDelta = Some(11.11), // 1111 * 0.01
supportDelta = Some(11.11f), // 1111 * 0.01
foodDelta = Some(-1111)
)
}
@@ -208,7 +208,7 @@ class AlmsCommandTest
cp shouldBe ChangedProvinceC(
provinceId = actingProvince.id,
supportDelta = Some(44.44), // 1111 * 4
supportDelta = Some(44.44f), // 1111 * 4
foodDelta = Some(-1111)
)
}
@@ -52,7 +52,7 @@ class ArmTroopsCommandTest
rulerIsTraveling = true,
gold = 9999,
infrastructure = 100,
priceIndex = 1.0
priceIndex = 1.0f
)
private val availableBattalions = battalions.map(_.id)
@@ -271,7 +271,7 @@ class ArmTroopsCommandTest
val result = command.immediateExecute
inside(result.changedProvinces.loneElement) { case cp: ChangedProvinceC =>
cp.newPriceIndex shouldBe Some(1.0 + expectedCost * 0.0001)
cp.newPriceIndex shouldBe Some(1.0f + expectedCost * 0.0001f)
}
}
@@ -86,7 +86,7 @@ class DivineCommandTest
private val province = ProvinceC(
id = provinceId,
gold = 2500,
priceIndex = 1.00,
priceIndex = 1.00f,
rulingFactionId = Some(actingFactionId),
rulingHeroId = Some(37),
rulingFactionHeroIds = Vector(37),
@@ -275,7 +275,7 @@ class DivineCommandTest
selectedHeroIds = Vector(12, 15),
gameId = gameId,
currentRoundId = currentRoundId,
allProvinces = Vector(province.withPriceIndex(0.9)),
allProvinces = Vector(province.withPriceIndex(0.9f)),
factions = factions,
battalions = Vector()
)
@@ -304,7 +304,7 @@ class DivineCommandTest
.newValue
inside(result.changedProvinces.loneElement) { case cp: ChangedProvinceC =>
cp.newPriceIndex shouldBe Some(1.02)
cp.newPriceIndex shouldBe Some(1.02f)
} // 200 gold spent
}
@@ -37,7 +37,7 @@ class FeastCommandTest
rulingHeroId = Some(7),
rulingFactionHeroIds = Vector(5, 6, 7, 8),
gold = 900,
priceIndex = 1.0
priceIndex = 1.0f
)
private val normalHero = HeroC(
@@ -122,7 +122,7 @@ class FeastCommandTest
forExactly(1, result.changedProvinces) { case cp: ChangedProvinceC =>
cp.provinceId shouldBe province.id
cp.newPriceIndex shouldBe Some(1.01) // 1.0 + 0.0001 * 100
cp.newPriceIndex shouldBe Some(1.01f) // 1.0 + 0.0001 * 100
}
}
@@ -67,7 +67,7 @@ class HeroGiftCommandTest
)
)
),
priceIndex = 1.0
priceIndex = 1.0f
)
private val anotherOwnedProvince = ProvinceC(
@@ -89,7 +89,7 @@ class HeroGiftCommandTest
)
)
),
priceIndex = 1.0
priceIndex = 1.0f
)
private val factionProvinces: Vector[ProvinceT] =
@@ -195,7 +195,7 @@ class HeroGiftCommandTest
it should "adjust the loyalty differently based on price index" in {
val recipientProvinceWithPriceIndex =
recipientProvince.copy(priceIndex = 1.25)
recipientProvince.copy(priceIndex = 1.25f)
val cmd = HeroGiftCommand.make(
actingFactionId = factionId,
@@ -507,7 +507,7 @@ class HeroGiftCommandTest
forExactly(1, res.changedProvinces) { case cp: ChangedProvinceC =>
cp.provinceId shouldBe provinceId
cp.newPriceIndex shouldBe Some(1.008)
cp.newPriceIndex shouldBe Some(1.008f)
}
}
}
@@ -56,7 +56,7 @@ class ImproveCommandTest
id = 7,
rulingFactionId = Some(actingFactionId),
rulingFactionHeroIds = heroes.map(_.id),
support = 27.0
support = 27.0f
)
private val availableTypes = Vector(
@@ -66,10 +66,10 @@ class ImproveCommandTest
ImprovementType.Devastation
)
private val improvementPerStat = 0.08
private val improvementReductionMax = 0.25
private val improvementSupportGain = 0.75
private val engineerImprovementBonus = 1.8
private val improvementPerStat = 0.08f
private val improvementReductionMax = 0.25f
private val improvementSupportGain = 0.75f
private val engineerImprovementBonus = 1.8f
private val xpPerStat = 5
override def beforeEach(): Unit = {
@@ -82,7 +82,7 @@ class ImproveCommandTest
}
private val expectedImprovementFromZero =
4.08 // improvementPerStat * (40 + 62) / 2.0
improvementPerStat * (40f + 62f) / 2.0f
"execute" should "throw if the selected improvement is not available" in {
the[EagleCommandException] thrownBy {
@@ -222,9 +222,9 @@ class ImproveCommandTest
actingFactionId = actingFactionId,
actingHero = actingHero,
actingProvince = province.copy(
economyDevastation = 25.0,
agricultureDevastation = 35.0,
infrastructureDevastation = 10.0
economyDevastation = 25.0f,
agricultureDevastation = 35.0f,
infrastructureDevastation = 10.0f
),
improvementType = ImprovementType.Devastation,
availableHeroIds = heroes.map(_.id),
@@ -247,14 +247,15 @@ class ImproveCommandTest
val cmd = ImproveCommand.make(
actingFactionId = actingFactionId,
actingHero = actingHero.copy(strength = 85, agility = 93),
actingProvince = province.withEconomyDevastation(25.0),
actingProvince = province.withEconomyDevastation(25.0f),
improvementType = ImprovementType.Devastation,
availableHeroIds = heroes.map(_.id),
availableImprovementTypes = availableTypes,
lockImprovementType = false
)
val betterExpectedImprovement = 7.12 // improvementPerStat * (85 + 93) / 2.0
val betterExpectedImprovement =
improvementPerStat * (85f + 93f) / 2.0f
val result = cmd.immediateExecute
inside(result.changedProvinces.head) { case cp: ChangedProvinceC =>
@@ -269,7 +270,7 @@ class ImproveCommandTest
actingFactionId = actingFactionId,
actingHero = actingHero
.withProfession(Profession.Engineer),
actingProvince = province.withInfrastructureDevastation(25.0),
actingProvince = province.withInfrastructureDevastation(25.0f),
improvementType = ImprovementType.Devastation,
availableHeroIds = heroes.map(_.id),
availableImprovementTypes = availableTypes,
@@ -277,7 +278,7 @@ class ImproveCommandTest
)
val expectedImprovement =
expectedImprovementFromZero + engineerImprovementBonus
5.8799996f // expectedImprovementFromZero + engineerImprovementBonus in Float precision
val result = cmd.immediateExecute
inside(result.changedProvinces.head) { case cp: ChangedProvinceC =>
@@ -291,7 +292,7 @@ class ImproveCommandTest
val cmd = ImproveCommand.make(
actingFactionId = actingFactionId,
actingHero = actingHero,
actingProvince = province.withAgricultureDevastation(25.0),
actingProvince = province.withAgricultureDevastation(25.0f),
improvementType = ImprovementType.Devastation,
availableHeroIds = heroes.map(_.id),
availableImprovementTypes = availableTypes,
@@ -311,7 +312,7 @@ class ImproveCommandTest
val cmd = ImproveCommand.make(
actingFactionId = actingFactionId,
actingHero = actingHero,
actingProvince = province.withEconomy(0.0),
actingProvince = province.withEconomy(0.0f),
improvementType = ImprovementType.Economy,
availableHeroIds = heroes.map(_.id),
availableImprovementTypes = availableTypes,
@@ -331,7 +332,7 @@ class ImproveCommandTest
val cmd = ImproveCommand.make(
actingFactionId = actingFactionId,
actingHero = actingHero,
actingProvince = province.withEconomy(45.0),
actingProvince = province.withEconomy(45.0f),
improvementType = ImprovementType.Economy,
availableHeroIds = heroes.map(_.id),
availableImprovementTypes = availableTypes,
@@ -339,7 +340,7 @@ class ImproveCommandTest
)
val reducedExpectedImprovement =
(1.0 - 0.45 * improvementReductionMax) * expectedImprovementFromZero
(1.0f - 0.45f * improvementReductionMax) * expectedImprovementFromZero
val result = cmd.immediateExecute
@@ -354,14 +355,15 @@ class ImproveCommandTest
val cmd = ImproveCommand.make(
actingFactionId = actingFactionId,
actingHero = actingHero.copy(strength = 85, agility = 93),
actingProvince = province.withEconomy(0.0),
actingProvince = province.withEconomy(0.0f),
improvementType = ImprovementType.Economy,
availableHeroIds = heroes.map(_.id),
availableImprovementTypes = availableTypes,
lockImprovementType = false
)
val betterExpectedImprovement = 7.12 // improvementPerStat * (85 + 93) / 2.0
val betterExpectedImprovement =
improvementPerStat * (85f + 93f) / 2.0f
val result = cmd.immediateExecute
@@ -377,7 +379,7 @@ class ImproveCommandTest
actingFactionId = actingFactionId,
actingHero = actingHero
.withProfession(Profession.Engineer),
actingProvince = province.withEconomy(0.0),
actingProvince = province.withEconomy(0.0f),
improvementType = ImprovementType.Economy,
availableHeroIds = heroes.map(_.id),
availableImprovementTypes = availableTypes,
@@ -385,7 +387,7 @@ class ImproveCommandTest
)
val expectedImprovement =
expectedImprovementFromZero + engineerImprovementBonus
5.8799996f // expectedImprovementFromZero + engineerImprovementBonus in Float precision
val result = cmd.immediateExecute
inside(result.changedProvinces.head) { case cp: ChangedProvinceC =>
@@ -399,7 +401,7 @@ class ImproveCommandTest
val cmd = ImproveCommand.make(
actingFactionId = actingFactionId,
actingHero = actingHero,
actingProvince = province.withEconomy(0.0),
actingProvince = province.withEconomy(0.0f),
improvementType = ImprovementType.Economy,
availableHeroIds = heroes.map(_.id),
availableImprovementTypes = availableTypes,
@@ -419,7 +421,7 @@ class ImproveCommandTest
val cmd = ImproveCommand.make(
actingFactionId = actingFactionId,
actingHero = actingHero,
actingProvince = province.withAgriculture(0.0),
actingProvince = province.withAgriculture(0.0f),
improvementType = ImprovementType.Agriculture,
availableHeroIds = heroes.map(_.id),
availableImprovementTypes = availableTypes,
@@ -439,7 +441,7 @@ class ImproveCommandTest
val cmd = ImproveCommand.make(
actingFactionId = actingFactionId,
actingHero = actingHero,
actingProvince = province.withInfrastructure(0.0),
actingProvince = province.withInfrastructure(0.0f),
improvementType = ImprovementType.Infrastructure,
availableHeroIds = heroes.map(_.id),
availableImprovementTypes = availableTypes,
@@ -459,7 +461,7 @@ class ImproveCommandTest
val cmd = ImproveCommand.make(
actingFactionId = actingFactionId,
actingHero = actingHero,
actingProvince = province.withInfrastructure(0.0),
actingProvince = province.withInfrastructure(0.0f),
improvementType = ImprovementType.Infrastructure,
availableHeroIds = heroes.map(_.id),
availableImprovementTypes = availableTypes,
@@ -79,7 +79,7 @@ class OrganizeTroopsCommandTest extends AnyFlatSpec with Matchers {
rulingFactionId = Some(actingFactionId),
battalionIds = Vector(battalion1.id),
gold = startingGold,
priceIndex = 1.0
priceIndex = 1.0f
)
private val existingBattalions = Vector(battalion1, battalion2, battalion3)
@@ -810,7 +810,7 @@ class OrganizeTroopsCommandTest extends AnyFlatSpec with Matchers {
result.changedProvinces should have size 1
inside(result.changedProvinces.head) { case p =>
p.newPriceIndex shouldBe Some(1.054) // 1.0 + 0.0001 * 450.0 * 1.2
p.newPriceIndex shouldBe Some(1.054f) // 1.0 + 0.0001 * 450.0 * 1.2
}
}
@@ -38,7 +38,7 @@ class TradeCommandTest
gold = startingGold,
food = startingFood,
rulerIsTraveling = true,
priceIndex = 1.0
priceIndex = 1.0f
)
override def beforeEach(): Unit = {
@@ -159,7 +159,7 @@ class TradeCommandTest
it should "spend more gold based on the price index" in {
val command = TradeCommand.make(
actingFactionId = actingFactionId,
actingProvince = province.withPriceIndex(1.5),
actingProvince = province.withPriceIndex(1.5f),
tradeType = BuyFood,
amount = 1000
)
@@ -173,7 +173,7 @@ class TradeCommandTest
it should "not change the food amount based on the price index" in {
val command = TradeCommand.make(
actingFactionId = actingFactionId,
actingProvince = province.withPriceIndex(1.5),
actingProvince = province.withPriceIndex(1.5f),
tradeType = BuyFood,
amount = 1000
)
@@ -223,7 +223,7 @@ class TradeCommandTest
val result = command.immediateExecute
inside(result.changedProvinces.loneElement) { case cp: ChangedProvinceC =>
cp.newPriceIndex shouldBe Some(1.06) // spent 600 gold
cp.newPriceIndex shouldBe Some(1.06f) // spent 600 gold
}
}
@@ -244,7 +244,7 @@ class TradeCommandTest
it should "gain more gold based on the price index" in {
val command = TradeCommand.make(
actingFactionId = actingFactionId,
actingProvince = province.withPriceIndex(1.5),
actingProvince = province.withPriceIndex(1.5f),
tradeType = SellFood,
amount = 1000
)
@@ -258,7 +258,7 @@ class TradeCommandTest
it should "not adjust the food based on the price index" in {
val command = TradeCommand.make(
actingFactionId = actingFactionId,
actingProvince = province.withPriceIndex(1.5),
actingProvince = province.withPriceIndex(1.5f),
tradeType = SellFood,
amount = 1000
)
@@ -308,7 +308,7 @@ class TradeCommandTest
val result = command.immediateExecute
inside(result.changedProvinces.loneElement) { case cp: ChangedProvinceC =>
cp.newPriceIndex shouldBe Some(0.975) // gained 250 gold
cp.newPriceIndex shouldBe Some(0.975f) // gained 250 gold
}
}
}
@@ -15,24 +15,24 @@ class PriceIndexUtilsTest
with Matchers
with BeforeAndAfterEach {
override def beforeEach(): Unit = {
MinimumPriceIndex.setDoubleValue(0.6)
MaximumPriceIndex.setDoubleValue(1.6)
PriceIndexReturnRate.setDoubleValue(0.25)
PriceIndexShiftPerGold.setDoubleValue(0.0001)
MinimumPriceIndex.setFloatValue(0.6f)
MaximumPriceIndex.setFloatValue(1.6f)
PriceIndexReturnRate.setFloatValue(0.25f)
PriceIndexShiftPerGold.setFloatValue(0.0001f)
}
"clampedIndex" should "never be less than the minimum" in {
PriceIndexUtils.clampedIndex(0.52) shouldBe 0.6
PriceIndexUtils.clampedIndex(-1) shouldBe 0.6
PriceIndexUtils.clampedIndex(0.52f) shouldBe 0.6f
PriceIndexUtils.clampedIndex(-1f) shouldBe 0.6f
}
it should "never be more than the maximum" in {
PriceIndexUtils.clampedIndex(1.7) shouldBe 1.6
PriceIndexUtils.clampedIndex(100) shouldBe 1.6
PriceIndexUtils.clampedIndex(1.7f) shouldBe 1.6f
PriceIndexUtils.clampedIndex(100f) shouldBe 1.6f
}
it should "return the value if it's within the range" in {
PriceIndexUtils.clampedIndex(0.75) shouldBe 0.75
PriceIndexUtils.clampedIndex(0.75f) shouldBe 0.75f
}
"steadyState" should "return minimum when all inputs are 0" in {
@@ -43,7 +43,7 @@ class PriceIndexUtilsTest
economyDevastation = 0,
agricultureDevastation = 0,
infrastructureDevastation = 0
) shouldBe 0.6
) shouldBe 0.6f
}
it should "return minimum + 0.5 when all inputs are 100" in {
@@ -54,7 +54,7 @@ class PriceIndexUtilsTest
economyDevastation = 0,
agricultureDevastation = 0,
infrastructureDevastation = 0
) shouldBe 1.1
) shouldBe 1.1f
}
it should "be higher if there is devastation" in {
@@ -65,7 +65,7 @@ class PriceIndexUtilsTest
economyDevastation = 25,
agricultureDevastation = 25,
infrastructureDevastation = 25
) shouldBe 1.225
) shouldBe 1.225f
}
it should "clamp if devastation is excessive" in {
@@ -76,30 +76,30 @@ class PriceIndexUtilsTest
economyDevastation = 100,
agricultureDevastation = 100,
infrastructureDevastation = 100
) shouldBe 1.6
) shouldBe 1.6f
}
"shiftedTowardSteadyState" should "move by 25% of the difference toward steady state" in {
PriceIndexUtils.shiftedTowardSteadyState(
currentPriceIndex = 0.75,
currentPriceIndex = 0.75f,
economy = 100,
agriculture = 100,
infrastructure = 100,
economyDevastation = 0,
agricultureDevastation = 0,
infrastructureDevastation = 0
) shouldBe 0.75 + 0.25 * 0.35 // 0.75 current, 1.1 destination
) shouldBe 0.75f + 0.25f * 0.35f // 0.75 current, 1.1 destination
}
"shiftedByGoldSpend" should "shift by 0.0001 per gold spent" in {
PriceIndexUtils.maybeNewPriceIndexFromGoldSpend(0.75, 5000) shouldBe Some(
1.25
PriceIndexUtils.maybeNewPriceIndexFromGoldSpend(0.75f, 5000) shouldBe Some(
1.25f
)
}
it should "shift down if the spend is negative" in {
PriceIndexUtils
.maybeNewPriceIndexFromGoldSpend(1.4, -5000)
.get shouldBe (0.9 +- 0.0001)
.maybeNewPriceIndexFromGoldSpend(1.4f, -5000)
.get shouldBe (0.9f +- 0.0001f)
}
}
@@ -34,8 +34,8 @@ class AlmsCommandSelectorTest
override def beforeEach(): Unit = {
MinSupportForTaxes.setDoubleValue(40)
AlmsSupportIncreasePerFood.setDoubleValue(0.01)
AlmsPaladinSupportMultiplier.setDoubleValue(4.0)
AlmsSupportIncreasePerFood.setDoubleValue(0.01f)
AlmsPaladinSupportMultiplier.setDoubleValue(4.0f)
}
"chosenAlmsCommand" should "give 1000 food if we need 10 support in December" in {
@@ -103,7 +103,7 @@ class CommandChoiceHelpersTest
)
)
),
priceIndex = 1.0
priceIndex = 1.0f
)
),
battalionTypes = BattalionTypesTestData.battalionTypes
@@ -170,7 +170,7 @@ class CommandChoiceHelpersTest
rulingFactionId = Some(3),
rulingFactionHeroIds = Vector(10),
battalionIds = Vector(85),
priceIndex = 1.0
priceIndex = 1.0f
)
),
heroes = mapifyHeroes(
@@ -221,7 +221,7 @@ class CommandChoiceHelpersTest
rulingFactionId = Some(3),
rulingFactionHeroIds = Vector(10),
battalionIds = Vector(85),
priceIndex = 1.0
priceIndex = 1.0f
)
),
heroes = mapifyHeroes(
@@ -272,7 +272,7 @@ class CommandChoiceHelpersTest
rulingFactionId = Some(3),
rulingFactionHeroIds = Vector(10),
battalionIds = Vector(85),
priceIndex = 1.0
priceIndex = 1.0f
)
),
heroes = mapifyHeroes(
@@ -312,7 +312,7 @@ class CommandChoiceHelpersTest
rulingFactionId = Some(3),
rulingFactionHeroIds = Vector(10),
battalionIds = Vector(85),
priceIndex = 1.0
priceIndex = 1.0f
)
),
heroes = mapifyHeroes(
@@ -343,7 +343,7 @@ class CommandChoiceHelpersTest
battalionIds = Vector(11, 12),
gold = 3500,
support = 40,
priceIndex = 1.0
priceIndex = 1.0f
)
),
battalions = mapifyBattalions(
@@ -373,7 +373,7 @@ class CommandChoiceHelpersTest
battalionIds = Vector(11, 12),
gold = 3500,
support = 40,
priceIndex = 1.0
priceIndex = 1.0f
)
),
battalions = mapifyBattalions(
@@ -403,7 +403,7 @@ class CommandChoiceHelpersTest
battalionIds = Vector(11, 12),
gold = 3500,
support = 40,
priceIndex = 1.0
priceIndex = 1.0f
)
),
battalions = mapifyBattalions(
@@ -428,7 +428,7 @@ class CommandChoiceHelpersTest
battalionIds = Vector(11, 12),
gold = 3500,
support = 40,
priceIndex = 1.0
priceIndex = 1.0f
)
),
battalions = mapifyBattalions(
@@ -458,7 +458,7 @@ class CommandChoiceHelpersTest
battalionIds = Vector(11, 12),
gold = 10000,
support = 40,
priceIndex = 1.0
priceIndex = 1.0f
)
),
battalions = mapifyBattalions(
@@ -488,7 +488,7 @@ class CommandChoiceHelpersTest
battalionIds = Vector(11, 12),
food = 5000,
support = 40,
priceIndex = 1.0
priceIndex = 1.0f
)
),
battalions = mapifyBattalions(
@@ -518,7 +518,7 @@ class CommandChoiceHelpersTest
battalionIds = Vector(11, 12),
food = 5000,
support = 40,
priceIndex = 1.0
priceIndex = 1.0f
)
),
battalions = mapifyBattalions(
@@ -548,7 +548,7 @@ class CommandChoiceHelpersTest
battalionIds = Vector(11, 12),
food = 5000,
support = 40,
priceIndex = 1.0
priceIndex = 1.0f
)
),
battalions = mapifyBattalions(
@@ -579,7 +579,7 @@ class CommandChoiceHelpersTest
gold = 1000,
food = 2000,
support = 40,
priceIndex = 1.0
priceIndex = 1.0f
)
),
battalions = mapifyBattalions(
@@ -610,7 +610,7 @@ class CommandChoiceHelpersTest
gold = 10000,
food = 20000,
support = 30,
priceIndex = 1.0
priceIndex = 1.0f
)
),
battalions = mapifyBattalions(
@@ -645,13 +645,13 @@ class CommandChoiceHelpersTest
Neighbor(provinceId = 6),
Neighbor(provinceId = 7)
),
priceIndex = 1.0
priceIndex = 1.0f
),
Province(
id = 3,
rulingFactionId = Some(15),
heroCap = 5,
priceIndex = 1.0
priceIndex = 1.0f
),
Province(
id = 4,
@@ -659,7 +659,7 @@ class CommandChoiceHelpersTest
rulingFactionHeroIds = (31 to 34).toVector,
neighbors = Vector(Neighbor(provinceId = 5)),
heroCap = 5,
priceIndex = 1.0
priceIndex = 1.0f
),
Province(
id = 6,
@@ -667,7 +667,7 @@ class CommandChoiceHelpersTest
rulingFactionHeroIds = (41 to 44).toVector,
neighbors = Vector(Neighbor(provinceId = 5)),
heroCap = 5,
priceIndex = 1.0
priceIndex = 1.0f
),
Province(
id = 7,
@@ -675,7 +675,7 @@ class CommandChoiceHelpersTest
rulingFactionHeroIds = (51 to 54).toVector,
neighbors = Vector(Neighbor(provinceId = 5)),
heroCap = 5,
priceIndex = 1.0
priceIndex = 1.0f
)
)
)
@@ -827,17 +827,17 @@ class CommandChoiceHelpersTest
rulingFactionId = Some(17),
rulingFactionHeroIds = Vector(10, 11),
neighbors = Vector(Neighbor(provinceId = 4)),
priceIndex = 1.0
priceIndex = 1.0f
),
Province(
id = 4,
rulingFactionId = Some(17),
rulingFactionHeroIds = Vector(1),
neighbors = Vector(Neighbor(provinceId = 3)),
priceIndex = 1.0
priceIndex = 1.0f
),
Province(id = 1, priceIndex = 1.0),
Province(id = 2, priceIndex = 1.0)
Province(id = 1, priceIndex = 1.0f),
Province(id = 2, priceIndex = 1.0f)
),
heroes = mapifyHeroes(
Hero(id = 10, vigor = 90, constitution = 90),
@@ -872,17 +872,17 @@ class CommandChoiceHelpersTest
rulingFactionId = Some(17),
rulingFactionHeroIds = Vector(10, 11),
neighbors = Vector(Neighbor(provinceId = 4)),
priceIndex = 1.0
priceIndex = 1.0f
),
Province(
id = 4,
rulingFactionId = Some(17),
rulingFactionHeroIds = Vector(1),
neighbors = Vector(Neighbor(provinceId = 3)),
priceIndex = 1.0
priceIndex = 1.0f
),
Province(id = 1, priceIndex = 1.0),
Province(id = 2, priceIndex = 1.0)
Province(id = 1, priceIndex = 1.0f),
Province(id = 2, priceIndex = 1.0f)
),
heroes = mapifyHeroes(
Hero(id = 10, vigor = 90, constitution = 90),
@@ -934,17 +934,17 @@ class CommandChoiceHelpersTest
rulingFactionId = Some(17),
rulingFactionHeroIds = Vector(10, 11),
neighbors = Vector(Neighbor(provinceId = 4)),
priceIndex = 1.0
priceIndex = 1.0f
),
Province(
id = 4,
rulingFactionId = Some(17),
rulingFactionHeroIds = Vector(1),
neighbors = Vector(Neighbor(provinceId = 3)),
priceIndex = 1.0
priceIndex = 1.0f
),
Province(id = 1, priceIndex = 1.0),
Province(id = 2, priceIndex = 1.0)
Province(id = 1, priceIndex = 1.0f),
Province(id = 2, priceIndex = 1.0f)
),
heroes = mapifyHeroes(
Hero(id = 10, vigor = 90, constitution = 90),
@@ -990,7 +990,7 @@ class CommandChoiceHelpersTest
rulingFactionId = Some(17),
rulingFactionHeroIds = Vector(10, 11),
battalionIds = Vector(5, 6),
priceIndex = 1.0
priceIndex = 1.0f
)
),
battalions = mapifyBattalions(
@@ -1021,7 +1021,7 @@ class CommandChoiceHelpersTest
rulingFactionId = Some(17),
rulingFactionHeroIds = Vector(10, 11),
battalionIds = Vector(5, 6),
priceIndex = 1.0
priceIndex = 1.0f
)
),
battalions = mapifyBattalions(
@@ -129,13 +129,13 @@ class ExpandCommandSelectorTest
Vector(Neighbor(provinceId = 10, startingPositionIndex = 1)),
rulingFactionId = Some(33),
rulingFactionHeroIds = Vector(1, 2, 3),
priceIndex = 1.0
priceIndex = 1.0f
),
Province(
id = 10,
neighbors =
Vector(Neighbor(provinceId = 9, startingPositionIndex = 8)),
priceIndex = 1.0
priceIndex = 1.0f
)
),
factions = mapifyFactions(
@@ -191,13 +191,13 @@ class ExpandCommandSelectorTest
Vector(Neighbor(provinceId = 10, startingPositionIndex = 1)),
rulingFactionId = Some(33),
rulingFactionHeroIds = Vector(1, 2, 3),
priceIndex = 1.0
priceIndex = 1.0f
),
Province(
id = 10,
neighbors =
Vector(Neighbor(provinceId = 9, startingPositionIndex = 8)),
priceIndex = 1.0
priceIndex = 1.0f
)
),
factions = mapifyFactions(
@@ -238,7 +238,7 @@ class ExpandCommandSelectorTest
),
rulingFactionId = Some(33),
rulingFactionHeroIds = Vector(1, 2, 3),
priceIndex = 1.0,
priceIndex = 1.0f,
heroCap = 10,
gold = 2500,
food = 3500
@@ -247,21 +247,21 @@ class ExpandCommandSelectorTest
private val unownedProvince1 = Province(
id = 10,
neighbors = Vector(Neighbor(provinceId = 9, startingPositionIndex = 8)),
priceIndex = 1.0,
priceIndex = 1.0f,
heroCap = 10
)
private val unownedProvince2 = Province(
id = 11,
neighbors = Vector(Neighbor(provinceId = 9, startingPositionIndex = 8)),
priceIndex = 1.0,
priceIndex = 1.0f,
heroCap = 10
)
private val unownedProvince3 = Province(
id = 12,
neighbors = Vector(Neighbor(provinceId = 9, startingPositionIndex = 8)),
priceIndex = 1.0,
priceIndex = 1.0f,
heroCap = 10
)
@@ -270,14 +270,14 @@ class ExpandCommandSelectorTest
neighbors = Vector(Neighbor(provinceId = 9, startingPositionIndex = 8)),
rulingFactionId = Some(33),
rulingFactionHeroIds = Vector(1, 2, 3),
priceIndex = 1.0,
priceIndex = 1.0f,
heroCap = 10
)
private val enRouteProvince = Province(
id = 14,
neighbors = Vector(Neighbor(provinceId = 9, startingPositionIndex = 8)),
priceIndex = 1.0,
priceIndex = 1.0f,
incomingArmies = Vector(
MovingArmy(
army = Some(Army(factionId = 33))
@@ -289,7 +289,7 @@ class ExpandCommandSelectorTest
private val hostileProvince = Province(
id = 15,
neighbors = Vector(Neighbor(provinceId = 9, startingPositionIndex = 8)),
priceIndex = 1.0,
priceIndex = 1.0f,
rulingFactionId = Some(34),
heroCap = 10
)
@@ -31,8 +31,8 @@ class FoodConsumptionUtilsTest
PrestigePerSupportedProvince.setDoubleValue(15)
MinSupportForTaxes.setDoubleValue(40)
GoldPerHeroHeldBack.setDoubleValue(100)
AlmsSupportIncreasePerFood.setDoubleValue(0.01)
AlmsPaladinSupportMultiplier.setDoubleValue(4.0)
AlmsSupportIncreasePerFood.setFloatValue(0.01f)
AlmsPaladinSupportMultiplier.setFloatValue(4.0f)
BaseFoodBuyPrice.setDoubleValue(0.25)
VassalMinimumFoodToSendSupplies.setIntValue(200)
VassalMinimumGoldToSendSupplies.setIntValue(100)
@@ -97,7 +97,7 @@ class AlmsToProvinceQuestCommandChooserTest
override def beforeEach(): Unit = {
MinSupportForTaxes.setDoubleValue(40)
AlmsSupportIncreasePerFood.setDoubleValue(0.001)
AlmsSupportIncreasePerFood.setFloatValue(0.001f)
}
"AlmsToProvinceQuestCommandChooser" should "return an alms command for an unaffiliated hero with that quest" in {
@@ -188,7 +188,7 @@ class QuestCreationUtilsTest
forAll(
QuestCreationUtils
.availableQuests(
province = province.withAgriculture(95.0),
province = province.withAgriculture(95.0f),
allProvinces = allProvinces,
factions = factions,
battalions = Vector(),
@@ -223,7 +223,7 @@ class QuestCreationUtilsTest
forAll(
QuestCreationUtils
.availableQuests(
province = province.withEconomy(95.0),
province = province.withEconomy(95.0f),
allProvinces = allProvinces,
factions = factions,
battalions = Vector(),
@@ -258,7 +258,7 @@ class QuestCreationUtilsTest
forAll(
QuestCreationUtils
.availableQuests(
province = province.withInfrastructure(95.0),
province = province.withInfrastructure(95.0f),
allProvinces = allProvinces,
factions = factions,
battalions = Vector(),
@@ -105,7 +105,7 @@ class RuntimeValidatorTest extends AnyFlatSpec with Matchers {
}
"validate province" should "throw if the province id is 0" in {
val province = Province(id = 0, priceIndex = 1.0)
val province = Province(id = 0, priceIndex = 1.0f)
the[EagleInternalException] thrownBy {
RuntimeValidator.validate(province, RoundPhase.PLAYER_COMMANDS)
@@ -113,7 +113,7 @@ class RuntimeValidatorTest extends AnyFlatSpec with Matchers {
}
it should "throw if the price index is 0.0" in {
val province = Province(id = 17, priceIndex = 0.0, name = "Vovimaria")
val province = Province(id = 17, priceIndex = 0.0f, name = "Vovimaria")
the[EagleInternalException] thrownBy {
RuntimeValidator.validate(province, RoundPhase.PLAYER_COMMANDS)
@@ -121,7 +121,7 @@ class RuntimeValidatorTest extends AnyFlatSpec with Matchers {
}
it should "throw if the price index is negative" in {
val province = Province(id = 17, priceIndex = -0.4, name = "Fluria")
val province = Province(id = 17, priceIndex = -0.4f, name = "Fluria")
the[EagleInternalException] thrownBy {
RuntimeValidator.validate(province, RoundPhase.PLAYER_COMMANDS)
@@ -129,7 +129,7 @@ class RuntimeValidatorTest extends AnyFlatSpec with Matchers {
}
it should "not throw if the province id is valid and the priceIndex is valid" in {
val province = Province(id = 17, priceIndex = 1.0)
val province = Province(id = 17, priceIndex = 1.0f)
noException should be thrownBy {
RuntimeValidator.validate(province, RoundPhase.PLAYER_COMMANDS)
@@ -188,7 +188,7 @@ class RuntimeValidatorTest extends AnyFlatSpec with Matchers {
rulingFactionId = Some(2),
rulingFactionHeroIds = Vector(3, 7),
provinceOrders = ProvinceOrderType.ENTRUST,
priceIndex = 1.0
priceIndex = 1.0f
)
noException should be thrownBy {
@@ -202,7 +202,7 @@ class RuntimeValidatorTest extends AnyFlatSpec with Matchers {
rulingHeroId = Some(3),
rulingFactionHeroIds = Vector(3, 7),
provinceOrders = ProvinceOrderType.ENTRUST,
priceIndex = 1.0
priceIndex = 1.0f
)
the[EagleInternalException] thrownBy {
@@ -215,7 +215,7 @@ class RuntimeValidatorTest extends AnyFlatSpec with Matchers {
id = 18,
rulingHeroId = Some(3),
rulingFactionHeroIds = Vector(3, 7),
priceIndex = 1.0
priceIndex = 1.0f
)
noException shouldBe thrownBy {
@@ -229,7 +229,7 @@ class RuntimeValidatorTest extends AnyFlatSpec with Matchers {
rulingFactionId = Some(2),
rulingHeroId = Some(4),
rulingFactionHeroIds = Vector(3, 7),
priceIndex = 1.0
priceIndex = 1.0f
)
the[EagleInternalException] thrownBy {
@@ -252,7 +252,7 @@ class RuntimeValidatorTest extends AnyFlatSpec with Matchers {
rulingHeroId = Some(3),
rulingFactionHeroIds = Vector(3, 7),
provinceOrders = ENTRUST,
priceIndex = 1.0
priceIndex = 1.0f
)
noException should be thrownBy {
@@ -65,22 +65,9 @@ class ProvinceViewFilterTest
)
)
it should "round up a devastation of 0.1" in {
val province =
Province(id = 5, rulingFactionId = Some(3), economyDevastation = 0.1)
val provinceView = ProvinceViewFilter.filteredProvinceView(
province = province,
gs = GameState(provinces = Map(5 -> province)),
factionId = 3
)
provinceView.getFullInfo.economyDevastation shouldBe 1
}
it should "keep a devastation of 0 at 0" in {
val province =
Province(id = 5, rulingFactionId = Some(3), economyDevastation = 0.0)
Province(id = 5, rulingFactionId = Some(3), economyDevastation = 0.0f)
val provinceView = ProvinceViewFilter.filteredProvinceView(
province = province,
@@ -88,12 +75,12 @@ class ProvinceViewFilterTest
factionId = 3
)
provinceView.getFullInfo.economyDevastation shouldBe 0
provinceView.getFullInfo.economyDevastation shouldBe 0f
}
it should "put a devastation of 2.1 at 3" in {
it should "put a devastation of 2.1 at 2.1" in {
val province =
Province(id = 5, rulingFactionId = Some(3), economyDevastation = 2.1)
Province(id = 5, rulingFactionId = Some(3), economyDevastation = 2.1f)
val provinceView = ProvinceViewFilter.filteredProvinceView(
province = province,
@@ -101,20 +88,7 @@ class ProvinceViewFilterTest
factionId = 3
)
provinceView.getFullInfo.economyDevastation shouldBe 3
}
it should "put an economy of 0.1 at 1" in {
val province =
Province(id = 5, rulingFactionId = Some(3), economy = 0.1)
val provinceView = ProvinceViewFilter.filteredProvinceView(
province = province,
gs = GameState(provinces = Map(5 -> province)),
factionId = 3
)
provinceView.getFullInfo.economy shouldBe 1
provinceView.getFullInfo.economyDevastation shouldBe 2.1f
}
it should "show ruler is traveling if they are" in {