Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/net standard 2.0 #38

Merged
merged 11 commits into from
Dec 23, 2024
24 changes: 12 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: microsoft/setup-msbuild@v1

- name: Setup NuGet
uses: NuGet/setup-nuget@v1.0.5
uses: NuGet/setup-nuget@v2
with:
nuget-api-key: ${{secrets.NUGET_API_KEY}}
nuget-version: 'latest'
Expand All @@ -29,37 +29,37 @@ jobs:
- name: Build
run: msbuild Conspiratio.Lib.sln /p:Configuration=Release

- name: nuget Pack
run: nuget pack Conspiratio.Lib\Conspiratio.Lib.csproj
- name: Pack
run: msbuild Conspiratio.Lib.sln /p:Configuration=Release -t:pack

- name: Upload Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Conspiratio.Lib
path: |
Conspiratio.Lib\bin\Release\*
*.nupkg
Conspiratio.Lib\bin\Release\netstandard2.0\*
Conspiratio.Lib\bin\Release\*.nupkg

- name: Publish the package to nuget.org
run: nuget push *.nupkg ${{secrets.NUGET_API_KEY}} -Source https://api.nuget.org/v3/index.json -SkipDuplicate
run: nuget push Conspiratio.Lib\bin\Release\*.nupkg ${{secrets.NUGET_API_KEY}} -Source https://api.nuget.org/v3/index.json -SkipDuplicate

- name: Get Version from AssemblyInfo
- name: Get Version from csproj file
id: get_version
uses: SirTobyB/assembly-info-version@v1.0.2
uses: kzrnm/get-net-sdk-project-versions-action@v2
with:
AI_PATH: Conspiratio.Lib\Properties\AssemblyInfo.cs # Filepath of the AssemblyInfo, relative to root of repository
proj-path: Conspiratio.Lib\Conspiratio.Lib.csproj

- name: Create release text with changelog link
run: |
$version = "${{ steps.get_version.outputs.ASSEMBLY_VERSION }}"
$version = "${{steps.get-version.outputs.package-version}}"
$version = $version.Replace(".","")
$text = "Changelog: https://github.com/Conspiratio/Conspiratio.Lib/blob/master/CHANGELOG.md#"+$version
echo "VERSION_TEXT=${text}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Create GitHub Release
uses: ncipollo/release-action@v1.7.3
with:
artifacts: 'Conspiratio.Lib\bin\Release\*,*.nupkg'
artifacts: 'Conspiratio.Lib\bin\Release\*,Conspiratio.Lib\bin\Release\*.nupkg'
body: ${{env.VERSION_TEXT}}
token: ${{ secrets.GITHUB_TOKEN }}
commit: master
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: microsoft/setup-msbuild@v1

- name: Setup NuGet
uses: NuGet/setup-nuget@v1.0.5
uses: NuGet/setup-nuget@v2
with:
nuget-api-key: ${{secrets.NUGET_API_KEY}}
nuget-version: 'latest'
Expand All @@ -32,13 +32,13 @@ jobs:
- name: Build
run: msbuild Conspiratio.Lib.sln /p:Configuration=Release

- name: nuget Pack
run: nuget pack Conspiratio.Lib\Conspiratio.Lib.csproj
- name: Pack
run: msbuild Conspiratio.Lib.sln /p:Configuration=Release -t:pack

- name: Upload Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Conspiratio.Lib
path: |
Conspiratio.Lib\bin\Release\*
*.nupkg
Conspiratio.Lib\bin\Release\netstandard2.0\*
Conspiratio.Lib\bin\Release\*.nupkg
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog Conspiratio.Lib

## 3.0.0

_23.12.2024_

**[DE]**
- Projekt auf .NET Standard 2.0 angehoben
- Neue Überladung für Methode "Initialisieren" ohne Interface Parameter hinzugefügt
- Neue Klasse "NewGameManager" hinzugefügt
- Methode "DauerPlusEins" der Klasse "AktiveSpionagen" geändert in "DauerReduzieren"

**[EN]**
- Changed Project to .NET Standard 2.0
- Added a new overload method for "Initialisieren" without interface parameters
- Added new class "NewGameManager"
- Changed method "DauerPlusEins" of class "AktiveSpionagen" in "DauerReduzieren"

## 2.3.0

_23.12.2023_
Expand Down
4 changes: 2 additions & 2 deletions Conspiratio.Lib.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Conspiratio.Lib", "Conspiratio.Lib\Conspiratio.Lib.csproj", "{98ACB1BC-6708-4119-A1DC-23E3DEF08007}"
EndProject
Expand Down
26 changes: 26 additions & 0 deletions Conspiratio.Lib/Allgemein/DialogResultGame.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace Conspiratio.Lib.Allgemein
{
/// <summary>
/// Unser eigener enum, als Vorlage diente `System.Windows.Forms.DialogResult´.
/// Da wir hier aber keine Abhängigkeit auf `System.Windows.Forms´ haben können und wollen, gibt es diesen eigenen Typ.
/// </summary>
public enum DialogResultGame
{
/// <summary>Nothing Das Dialogfeld zurück. Dies bedeutet, dass das modale Dialogfeld weiterhin ausgeführt wird.</summary>
None,
/// <summary>Das Dialogfeld Rückgabewert ist OK (üblicherweise von der Schaltfläche OK gesendet).</summary>
OK,
/// <summary>Das Dialogfeld Rückgabewert ist Cancel (in der Regel von der Schaltfläche Abbrechen gesendet).</summary>
Cancel,
/// <summary>Das Dialogfeld Rückgabewert ist Abort (in der Regel von der Schaltfläche Abbrechen gesendet).</summary>
Abort,
/// <summary>Das Dialogfeld Rückgabewert ist Retry (in der Regel von der Schaltfläche Wiederholen gesendet).</summary>
Retry,
/// <summary>Das Dialogfeld Rückgabewert ist Ignore (in der Regel von der Schaltfläche Ignorieren gesendet).</summary>
Ignore,
/// <summary>Das Dialogfeld Rückgabewert ist Yes (in der Regel von der Schaltfläche Ja gesendet).</summary>
Yes,
/// <summary>Das Dialogfeld Rückgabewert ist No (in der Regel von der Schaltfläche Nein gesendet).</summary>
No
}
}
9 changes: 0 additions & 9 deletions Conspiratio.Lib/Allgemein/IJaNeinFrage.cs

This file was deleted.

19 changes: 19 additions & 0 deletions Conspiratio.Lib/Allgemein/IYesNoQuestion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Threading.Tasks;

namespace Conspiratio.Lib.Allgemein
{
public interface IYesNoQuestion
{
/// <summary>
/// Displays a dialog window with the specified text and two buttons (usually Yes and No). The texts can be freely customized.
/// The return value is <see cref="DialogResultGame.Yes"/>, <see cref="DialogResultGame.No"/> or <see cref="DialogResultGame.Cancel"/> when closing the dialog (e.g. with right-click).
/// </summary>
/// <remarks>When called from the WinForms client, a synchronous variant is used and this internally uses the method "Form.ShowDialog()",
/// to display a modal dialog. Otherwise, an engine waits for the player to close the dialog via await.</remarks>
/// <param name="textQuestion">Text of the question</param>
/// <param name="textYes">OPTIONAL: Labeling of the left “Yes” button</param>
/// <param name="textNo">OPTIONAL: Labeling of the right “No” button</param>
/// <returns>Can return <see cref="DialogResultGame.Yes"/>, <see cref="DialogResultGame.No"/> and <see cref="DialogResultGame.Cancel"/> when closing the dialog (e.g. with right-click).</returns>
Task<DialogResultGame> ShowDialogText(string textQuestion, string textYes = "Ja", string textNo = "Nein");
}
}
66 changes: 66 additions & 0 deletions Conspiratio.Lib/Allgemein/NewGameManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System.IO;

using Conspiratio.Lib.Gameplay.Spielwelt;

namespace Conspiratio.Lib.Allgemein
{
public class NewGameManager
{
private string _savegamePath;

public NewGameManager(string savegamePath)
{
_savegamePath = savegamePath;
}

public bool CreateNewGame(string name, int playerCount, bool cheating, bool showDeaths, bool testmode, out string error)
{
if (!ValidateName(name, out error))
return false;

SW.Dynamisch.SpielName = SanitizeName(name);
SW.Dynamisch.SetAktivSpielerAnzahl(playerCount);
SW.Dynamisch.Cheatmodus = cheating;
SW.Dynamisch.TodesfaelleAnzeigen = showDeaths;
SW.Dynamisch.Testmodus = testmode;

return true;
}

public bool ValidateName(string name, out string error)
{
error = "Der Spielname muss aus mindestens drei Zeichen bestehen";

if (string.IsNullOrEmpty(name))
return false;

if (name.Length < 3)
return false;

error = "";
return true;
}

public string SanitizeName(string name)
{
string savegamePathWithFilename = Path.Combine(_savegamePath, "_1600.dat");
int savegamePathLength = savegamePathWithFilename.Length;
int maxlength = 256 - savegamePathLength;

if (maxlength < 0) // fallback from settings (standard: 12), if savegame path is longer then 256 chars
maxlength = SW.Statisch.GetMaxNameLength();

name = RemoveInvalidChars(name);

if (name.Length > maxlength)
return name.Substring(0, maxlength);

return name;
}

private string RemoveInvalidChars(string filename)
{
return string.Concat(filename.Split(Path.GetInvalidFileNameChars()));
}
}
}
6 changes: 3 additions & 3 deletions Conspiratio.Lib/Allgemein/UIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Conspiratio.Lib.Allgemein
{
public class UIHelper
{
public IJaNeinFrage JaNeinFrage { get; private set; }
public IYesNoQuestion YesNoQuestion { get; private set; }

public ITextAnzeigen TextAnzeigen { get; private set; }

Expand All @@ -22,11 +22,11 @@ public class UIHelper

public IUntergebeneDialog UntergebeneDialog { get; private set; }

public void Initialisieren(IJaNeinFrage jaNeinFrage, ITextAnzeigen textAnzeigen, IBeziehungPflegen beziehungPflegen, IBauwerkStiftenDialog bauwerkStiftenDialog,
public void Initialisieren(IYesNoQuestion yesNoQuestion, ITextAnzeigen textAnzeigen, IBeziehungPflegen beziehungPflegen, IBauwerkStiftenDialog bauwerkStiftenDialog,
IFestGebenDialog festGebenDialog, IPolitischeWeltkarteDialog politischeWeltkarteDialog, ITestamentAnzeigenDialog testamentAnzeigenDialog,
IProzentwertFestlegenDialog prozentwertFestlegenDialog, IUntergebeneDialog untergebeneDialog)
{
JaNeinFrage = jaNeinFrage;
YesNoQuestion = yesNoQuestion;
TextAnzeigen = textAnzeigen;
BeziehungPflegen = beziehungPflegen;
BauwerkStiftenDialog = bauwerkStiftenDialog;
Expand Down
Loading