Skip to content

Commit bd955ac

Browse files
authored
Merge pull request #127 from reubene/master
Basic save and load
2 parents fa13a81 + f5c3deb commit bd955ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1554
-1165
lines changed

.idea/.idea.Civ2clone/.idea/projectSettingsUpdater.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.Civ2clone/.idea/workspace.xml

Lines changed: 91 additions & 902 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Civ2/Civ2Interface.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Civ2.Dialogs.Scenario;
2121
using Civ2engine.OriginalSaves;
2222
using Model.Constants;
23+
using Model.Core;
2324
using Model.Core.Advances;
2425
using Model.Dialog;
2526

@@ -34,7 +35,7 @@ protected Civ2Interface(IMain main)
3435

3536
public bool CanDisplay(string? title)
3637
{
37-
return title == Title;
38+
return title != null && title.Contains(Title);
3839
}
3940

4041
public abstract InterfaceStyle Look { get; }
@@ -372,7 +373,7 @@ public IList<Ruleset> FindRuleSets(string[] searchPaths)
372373
public abstract bool IsButtonInOuterPanel { get; }
373374

374375
public int InterfaceIndex { get; set; }
375-
public IInterfaceAction HandleLoadGame(GameData gameData)
376+
public IInterfaceAction HandleLoadClassicGame(GameData gameData)
376377
{
377378
ExpectedMaps = gameData.MapNoSecondaryMaps + 1;
378379
Initialization.LoadGraphicsAssets(this);
@@ -487,4 +488,15 @@ public string GetScientistName(int epoch)
487488
{
488489
return Labels.For(epoch < 3 ? LabelIndex.wisemen : LabelIndex.scientists);
489490
}
491+
492+
public IInterfaceAction HandleLoadGame(IGame game, Civ2engine.Rules rules, Ruleset ruleset)
493+
{
494+
495+
ExpectedMaps = game.NoMaps;
496+
Initialization.LoadGraphicsAssets(this);
497+
Initialization.LoadGraphicsAssets(this);
498+
499+
Initialization.Start(game);
500+
return DialogHandlers[LoadOk.Title].Show(this);
501+
}
490502
}

Civ2/Dialogs/FileDialogs/LoadGame.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ public override ICivDialogHandler UpdatePopupData(Dictionary<string, PopupBox?>
2424
protected override IInterfaceAction HandleFileSelection(string fileName,
2525
Dictionary<string, ICivDialogHandler> civDialogHandlers, Civ2Interface civ2Interface)
2626
{
27-
var savDirectory = Path.GetDirectoryName(fileName);
28-
var root = Settings.SearchPaths.FirstOrDefault(p => savDirectory.StartsWith(p)) ?? Settings.SearchPaths[0];
29-
var savName = Path.GetFileName(fileName);
30-
GameData gameData = Read.ReadSavFile(savDirectory, savName);
31-
32-
var activeInterface = civ2Interface.MainApp.SetActiveRulesetFromFile(root, savDirectory, gameData.ExtendedMetadata);
33-
34-
return activeInterface.HandleLoadGame(gameData);
27+
return Civ2engine.SaveLoad.LoadGame.LoadFrom(fileName, civ2Interface.MainApp);
3528
}
3629
}

Civ2/Dialogs/FileDialogs/LoadScenario.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected override IInterfaceAction HandleFileSelection(string fileName, Diction
2929
var scnDirectory = Path.GetDirectoryName(fileName);
3030
var root = Settings.SearchPaths.FirstOrDefault(p => scnDirectory.StartsWith(p)) ?? Settings.SearchPaths[0];
3131
var scnName = Path.GetFileName(fileName);
32-
GameData gameData = Read.ReadSavFile(scnDirectory, scnName);
32+
GameData gameData = Read.ReadSavFile(File.ReadAllBytes(fileName));
3333

3434
var activeInterface = civ2Interface.MainApp.SetActiveRulesetFromFile(root, scnDirectory, gameData.ExtendedMetadata);
3535

Civ2/Rules/Initialization.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Civ2engine.Enums;
55
using Civ2engine.IO;
66
using Model;
7+
using Model.Core;
78

89
namespace Civ2.Rules;
910

@@ -22,9 +23,9 @@ private static GameInitializationConfig GetConfig()
2223

2324
public static GameInitializationConfig ClearInitializationConfig() => _config = null;
2425

25-
internal static Game GameInstance;
26+
internal static IGame GameInstance;
2627

27-
public static void Start(Game game)
28+
public static void Start(IGame game)
2829
{
2930
GameInstance = game;
3031
}
@@ -52,11 +53,7 @@ public static void CompleteConfig()
5253

5354
var civilizations = new List<Civilization>
5455
{
55-
new()
56-
{
57-
Adjective = Labels.Items[17], LeaderName = Labels.Items[18], Alive = true, Id = 0,
58-
PlayerType = PlayerType.Barbarians, Advances = new bool[ConfigObject.Rules.Advances.Length]
59-
},
56+
Barbarians.Civilization,
6057
ConfigObject.PlayerCiv
6158
};
6259

@@ -86,6 +83,7 @@ public static Civilization MakeCivilization(GameInitializationConfig config, Lea
8683
var gender = human ? config.Gender : ConfigObject.Random.Next(2);
8784
return new Civilization
8885
{
86+
TribeId = tribe.TribeId,
8987
Adjective = tribe.Adjective,
9088
Alive = true,
9189
Government = (int)GovernmentType.Despotism,
@@ -111,7 +109,7 @@ private static string GetLeaderTitle(GameInitializationConfig config, LeaderDefa
111109
return config.Gender == 0 ? govt.TitleMale : govt.TitleFemale;
112110
}
113111

114-
public static Game UpdateScenarioChoices()
112+
public static IGame UpdateScenarioChoices()
115113
{
116114
var config = ConfigObject;
117115
var instance = GameInstance;

Civ2Gold/Civ2GoldInterface.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ public override void Initialize()
216216
KeyboardKey.U),
217217
new MenuElement("&Game Profile", Shortcut.None, KeyboardKey.G),
218218
new MenuElement("Pick &Music", Shortcut.None, KeyboardKey.M),
219-
new MenuElement("&Save Game|Ctrl+S", new Shortcut(KeyboardKey.S, ctrl: true), KeyboardKey.S),
220-
new MenuElement("&Load Game|Ctrl+L", new Shortcut(KeyboardKey.L, ctrl: true), KeyboardKey.L),
219+
new MenuElement("&Save Game|Ctrl+S", new Shortcut(KeyboardKey.S, ctrl: true), KeyboardKey.S, commandId: SaveGame),
220+
new MenuElement("&Load Game|Ctrl+L", new Shortcut(KeyboardKey.L, ctrl: true), KeyboardKey.L, commandId: LoadGame),
221221
new MenuElement("&Join Game|Ctrl+J", new Shortcut(KeyboardKey.J, ctrl: true), KeyboardKey.J),
222222
new MenuElement("Set Pass&word|Ctrl+W", new Shortcut(KeyboardKey.W, ctrl: true), KeyboardKey.W),
223223
new MenuElement("Change &Timer|Ctrl+T", new Shortcut(KeyboardKey.T, ctrl: true), KeyboardKey.T),

Civ2TOT/TestOfTimeInterface.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ protected override IEnumerable<Ruleset> GenerateRulesets(string path, string tit
9191

9292
var original = "Original";
9393

94+
// TODO: This method looks really scrambled... why do we no longer look in the root or at these extra folders??? something is wrong here!!
9495
var other_default_game_modes = new[] { "SciFi", "Fantasy" };
9596

9697
var originalPath = Path.Combine(path, original);

Civ2clone.sln

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Engine\Core.csproj"
1919
EndProject
2020
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RaylibUtils", "RaylibUtils\RaylibUtils.csproj", "{987C570F-A83B-4A7E-88D2-9D32B5741FA0}"
2121
EndProject
22-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CivServer", "CivServer\CivServer.csproj", "{03C77E6C-F012-4343-9D33-F8F627668B75}"
23-
EndProject
2422
Global
2523
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2624
Debug|Any CPU = Debug|Any CPU
@@ -58,10 +56,6 @@ Global
5856
{987C570F-A83B-4A7E-88D2-9D32B5741FA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
5957
{987C570F-A83B-4A7E-88D2-9D32B5741FA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
6058
{987C570F-A83B-4A7E-88D2-9D32B5741FA0}.Release|Any CPU.Build.0 = Release|Any CPU
61-
{03C77E6C-F012-4343-9D33-F8F627668B75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
62-
{03C77E6C-F012-4343-9D33-F8F627668B75}.Debug|Any CPU.Build.0 = Debug|Any CPU
63-
{03C77E6C-F012-4343-9D33-F8F627668B75}.Release|Any CPU.ActiveCfg = Release|Any CPU
64-
{03C77E6C-F012-4343-9D33-F8F627668B75}.Release|Any CPU.Build.0 = Release|Any CPU
6559
EndGlobalSection
6660
GlobalSection(SolutionProperties) = preSolution
6761
HideSolutionNode = FALSE

Civ2clone.sln.DotSettings.user

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AArray_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa0741529c8554d199992ef9e50684668d82800_003F0d_003Fe6bdac62_003FArray_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
3+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFileMode_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa0741529c8554d199992ef9e50684668d82800_003Fcd_003Fded6e3af_003FFileMode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
4+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFile_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa0741529c8554d199992ef9e50684668d82800_003Fbb_003Ffb5eabec_003FFile_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
5+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonConverter_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F94125f469e4d403caa9218894df9d5f0191800_003F23_003F9a30c93f_003FJsonConverter_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
6+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASafeFileHandle_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa0741529c8554d199992ef9e50684668d82800_003F7d_003F20e2dcf4_003FSafeFileHandle_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
7+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AStreamReader_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa0741529c8554d199992ef9e50684668d82800_003F8c_003F217db297_003FStreamReader_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
8+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F30d7ac0f7a7a48b7a3c557c4413de4c090c00_003Fcd_003F03329e0a_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
9+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F94125f469e4d403caa9218894df9d5f0191800_003F79_003F202d9a9b_003FThrowHelper_002Ecs_002Fz_003A2_002D1/@EntryIndexedValue">ForceIncluded</s:String>
10+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F94125f469e4d403caa9218894df9d5f0191800_003F79_003F202d9a9b_003FThrowHelper_002Ecs_002Fz_003A3_002D1/@EntryIndexedValue">ForceIncluded</s:String>
11+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa0741529c8554d199992ef9e50684668d82800_003Fb0_003Fc4e925fd_003FThrowHelper_002Ecs_002Fz_003A3_002D2/@EntryIndexedValue">ForceIncluded</s:String>
12+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F30d7ac0f7a7a48b7a3c557c4413de4c090c00_003F3a_003Fa6cb82a7_003FThrowHelper_002Ecs_002Fz_003A2_002D1/@EntryIndexedValue">ForceIncluded</s:String>
13+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F94125f469e4d403caa9218894df9d5f0191800_003F1e_003F0b90832d_003FThrowHelper_002Ecs_002Fz_003A4_002D3/@EntryIndexedValue">ForceIncluded</s:String>
14+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa0741529c8554d199992ef9e50684668d82800_003Ffb_003F1ad0a4b4_003FThrowHelper_002Ecs_002Fz_003A3_002D2/@EntryIndexedValue">ForceIncluded</s:String>
215
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;
316
&lt;Assembly Path="/Users/revans/.nuget/packages/raylib-cs/4.2.0.1/lib/net6.0/Raylib-cs.dll" /&gt;
417
&lt;/AssemblyExplorer&gt;</s:String>
5-
<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=24718bad_002Db4d0_002D43e9_002Dabfa_002D1176d54ff8ad_0023EtoFormsUI/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
18+
</wpf:ResourceDictionary>

Engine/Core.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
1515
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
1616
<PackageReference Include="NeoLua" Version="1.3.14" />
17-
<PackageReference Include="System.Drawing.Common" Version="5.0.0" />
1817
</ItemGroup>
1918

2019
<ItemGroup>
@@ -33,6 +32,9 @@
3332
<None Update="Scripts\game_setup.lua">
3433
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3534
</None>
35+
<None Update="Scripts\units.lua">
36+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
37+
</None>
3638
</ItemGroup>
3739

3840
<ItemGroup>

Engine/src/AdvanceFunctions.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private static void SetEpoch(Game game, Civilization civilization)
8181
{
8282
civilization.Epoch = game.Rules.Advances.Where(a => a.Effects.ContainsKey(Effects.EpochTech))
8383
.GroupBy(a => a.Effects[Effects.EpochTech])
84-
.Where(techs => techs.All(t => civilization.Advances[t.Index])).Select(t => t.Key)
84+
.Where(techs => techs.All(t => t.Index < civilization.Advances.Length && civilization.Advances[t.Index])).Select(t => t.Key)
8585
.DefaultIfEmpty(0).Max();
8686
}
8787

@@ -156,6 +156,12 @@ private static void ApplyCivAdvance(Game game, int advanceIndex, Civilization ci
156156
}
157157
}
158158

159+
if (civilization.Advances.Length < advanceIndex)
160+
{
161+
var advances = new bool[game.Rules.Advances.Length];
162+
Array.Copy(civilization.Advances, advances.Length, advances, 0, advances.Length);
163+
civilization.Advances = advances;
164+
}
159165
civilization.Advances[advanceIndex] = true;
160166

161167
var orders = ProductionOrder.GetAll(game.Rules);
@@ -189,7 +195,7 @@ public static int CalculateScienceCost(Game game, Civilization civ)
189195
baseCost += _mapSizeAdjustment;
190196
}
191197

192-
return baseCost * ourAdvances;
198+
return baseCost * (ourAdvances +1);
193199

194200
}
195201

@@ -200,14 +206,14 @@ public static bool HasTech(Civilization civ, int tech)
200206
return tech == AdvancesConstants.Nil;
201207
}
202208

203-
return civ.Advances[tech];
209+
return tech < civ.Advances.Length && civ.Advances[tech];
204210
}
205211

206212
public static List<Advance> CalculateAvailableResearch(Game game, Civilization activeCiv)
207213
{
208214
var allAvailable = game.Rules.Advances.Where(a =>
209215
activeCiv.AllowedAdvanceGroups[a.AdvanceGroup] == AdvanceGroupAccess.CanResearch &&
210-
HasTech(activeCiv, a.Prereq1) && HasTech(activeCiv, a.Prereq1) && !activeCiv.Advances[a.Index]).ToList();
216+
HasTech(activeCiv, a.Prereq1) && HasTech(activeCiv, a.Prereq1) && (activeCiv.Advances.Length < a.Index || !activeCiv.Advances[a.Index])).ToList();
211217

212218
//TODO: cull list based on difficulty
213219
return allAvailable.ToList();

Engine/src/Barbarians.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace Civ2engine;
4+
5+
public class Barbarians
6+
{
7+
public static readonly Civilization Civilization = new()
8+
{
9+
Adjective = Labels.Items[17], LeaderName = Labels.Items[18], Alive = true, Id = 0, TribeId = -1,
10+
PlayerType = PlayerType.Barbarians, Advances = []
11+
};
12+
}

Engine/src/Date.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace Civ2engine;
66

77
public class Date : IGameDate
88
{
9-
public readonly int StartingYear;
10-
public readonly int TurnYearIncrement;
9+
public int StartingYear { get; }
10+
public int TurnYearIncrement { get; }
1111
private readonly bool _monthlyTurnIncrement;
1212
private readonly bool _defaultTurnIncrement;
1313
private readonly int _difficulty;
@@ -46,7 +46,7 @@ private int GameYear(int turnNo)
4646
return gameYear;
4747
}
4848

49-
public string GameYearString(int turnNo)
49+
public string GameYearString(int turnNo, string separator = " ")
5050
{
5151
int gameYear = GameYear(turnNo);
5252

@@ -72,13 +72,14 @@ public string GameYearString(int turnNo)
7272
10 => Labels.For(LabelIndex.Nov),
7373
_ => Labels.For(LabelIndex.Dec),
7474
};
75-
return string.Join(" ", month, Math.Abs(Nyear));
75+
return string.Join(separator, month, Math.Abs(Nyear));
7676
}
7777
else
7878
{
7979
return gameYear < 0 ?
80-
string.Join(" ", Math.Abs(gameYear).ToString(), Labels.For(LabelIndex.BC)) :
81-
string.Join(" ", Labels.For(LabelIndex.AD), gameYear.ToString());
80+
string.Join(separator, Math.Abs(gameYear).ToString(), Labels.For(LabelIndex.BC)) :
81+
string.Join(separator, Labels.For(LabelIndex.AD), gameYear.ToString());
8282
}
8383
}
84+
8485
}

0 commit comments

Comments
 (0)