2 커밋 7ef3906490 ... 5ab9a2b7d7

작성자 SHA1 메시지 날짜
  Florian 5ab9a2b7d7 add console app 3 년 전
  Florian 4ee7d744d9 add console app 3 년 전

+ 4 - 0
.gitignore

@@ -18,3 +18,7 @@ __pycache__
 /Dotnet/Services/bin/Debug/net6.0
 /Dotnet/Services/obj
 /Dotnet/Warhammer/bin/Debug/net6.0
+/Dotnet/.vs/ProjectEvaluation
+/Dotnet/DeathwatchConsoleApp/bin/Debug/net6.0
+/Dotnet/DeathwatchConsoleApp/obj/Debug/net6.0
+/Dotnet/DeathwatchConsoleApp/obj

+ 17 - 0
Dotnet/DeathwatchConsoleApp/DeathwatchConsoleApp.csproj

@@ -0,0 +1,17 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net6.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\DataLayer\DataLayer.csproj" />
+    <ProjectReference Include="..\Domain\Domain.csproj" />
+    <ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
+    <ProjectReference Include="..\Services\Services.csproj" />
+  </ItemGroup>
+
+</Project>

+ 93 - 0
Dotnet/DeathwatchConsoleApp/Program.cs

@@ -0,0 +1,93 @@
+// See https://aka.ms/new-console-template for more information
+using Domain;
+using Infrastructure;
+using System.ComponentModel;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+Console.WriteLine("Hello, World!");
+Player perso = new Player();
+var fileName = $"C:/newCharacter.json";
+
+while (true)
+{
+    string? methodToExec = Console.ReadLine();
+    if (methodToExec != null)
+    {
+        switch (methodToExec.ToLower())
+        {
+            case "roll":
+                Console.WriteLine(RollInitialStat());
+                break;
+
+            case "createperso":
+                string jsonPerso = "";
+                object createPerso = await CreatePerso(perso, fileName, jsonPerso);
+                Console.Write(createPerso);
+                break;
+        }
+    }
+}
+
+static int RollInitialStat()
+{
+    var rollValue = DiceService.RollDices(1, 20);
+    rollValue += 30;
+    return rollValue;
+}
+
+static async Task<string> CreatePerso(Player perso, string fileName, string jsonPerso)
+{
+    perso = InitRandomStat();
+    jsonPerso = JsonSerializer.Serialize<Player>(perso);
+    //if (File.Exists(fileName))
+    //{
+    //    if (IsFileLocked(fileName))
+    //    {
+    //        Thread.Sleep(1000);
+    //    }
+    //    File.Delete(fileName);
+    //}
+    //if (IsFileLocked(fileName))
+    //{
+    //    Thread.Sleep(1000);
+    //}
+    //if (!File.Exists(fileName))
+    //    File.Create(fileName);
+    //await File.WriteAllTextAsync(fileName, jsonPerso);
+    return jsonPerso;
+}
+
+static Player InitRandomStat()
+{
+    return new Player
+    {
+        AG = RollInitialStat(),
+        CC = RollInitialStat(),
+        CT = RollInitialStat(),
+        E = RollInitialStat(),
+        F = RollInitialStat(),
+        FM = RollInitialStat(),
+        INT = RollInitialStat(),
+        MF = RollInitialStat(),
+        PER = RollInitialStat(),
+        SOC = RollInitialStat()
+    };
+}
+
+static bool IsFileLocked(string filePath)
+{
+    try
+    {
+        using (File.Open(filePath, FileMode.Open))
+        {
+            return true;
+        }
+    }
+    catch (IOException e)
+    {
+        Console.WriteLine("Exception occured while deleting the file, Exception is {e}", e);
+    }
+
+    return false;
+}

+ 3 - 1
Dotnet/Infrastructure/Infrastructure.csproj

@@ -7,7 +7,9 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <Folder Include="Interfaces\" />
+    <Compile Remove="Interfaces\**" />
+    <EmbeddedResource Remove="Interfaces\**" />
+    <None Remove="Interfaces\**" />
   </ItemGroup>
 
   <ItemGroup>

+ 10 - 4
Dotnet/Warhammer.sln

@@ -5,13 +5,15 @@ VisualStudioVersion = 17.1.32421.90
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Warhammer", "Warhammer\Warhammer.csproj", "{CAC4117F-9DAA-4631-8AFE-7CB1FE2183F6}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain\Domain.csproj", "{6513BB0B-4DC1-483F-887E-F40C8603FC2B}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Domain", "Domain\Domain.csproj", "{6513BB0B-4DC1-483F-887E-F40C8603FC2B}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Services", "Services\Services.csproj", "{8FA3AA34-0FC6-4C63-8D77-46A94C6BBB17}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Services", "Services\Services.csproj", "{8FA3AA34-0FC6-4C63-8D77-46A94C6BBB17}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "Infrastructure\Infrastructure.csproj", "{1EAD6FA9-441F-4386-AA6F-1FD40D77E2DC}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure", "Infrastructure\Infrastructure.csproj", "{1EAD6FA9-441F-4386-AA6F-1FD40D77E2DC}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataLayer", "DataLayer\DataLayer.csproj", "{7C05BF26-5E6B-4572-82DA-90E2876F1842}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataLayer", "DataLayer\DataLayer.csproj", "{7C05BF26-5E6B-4572-82DA-90E2876F1842}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeathwatchConsoleApp", "DeathwatchConsoleApp\DeathwatchConsoleApp.csproj", "{D5BBF8A5-0899-463C-BE7E-9297137C99B0}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -39,6 +41,10 @@ Global
 		{7C05BF26-5E6B-4572-82DA-90E2876F1842}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{7C05BF26-5E6B-4572-82DA-90E2876F1842}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{7C05BF26-5E6B-4572-82DA-90E2876F1842}.Release|Any CPU.Build.0 = Release|Any CPU
+		{D5BBF8A5-0899-463C-BE7E-9297137C99B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{D5BBF8A5-0899-463C-BE7E-9297137C99B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{D5BBF8A5-0899-463C-BE7E-9297137C99B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{D5BBF8A5-0899-463C-BE7E-9297137C99B0}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 20 - 0
Dotnet/Warhammer/Models/Players.cs

@@ -0,0 +1,20 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace Warhammer.Models
+{
+    public partial class Players
+    {
+        public int Id { get; set; }
+        public int Experience { get; set; }
+        public int CC { get; set; }
+        public int CT { get; set; }
+        public int F { get; set; }
+        public int E { get; set; }
+        public int AG { get; set; }
+        public int INT { get; set; }
+        public int PER { get; set; }
+        public int FM { get; set; }
+        public int SOC { get; set; }
+        public int MF { get; set; }
+    }
+}

+ 16 - 4
Dotnet/Warhammer/Warhammer.csproj

@@ -7,10 +7,22 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <Folder Include="DataLayer\Interfaces\" />
-    <Folder Include="Models\Enum\" />
-    <Folder Include="Models\Weapons\" />
-    <Folder Include="Service\" />
+    <Compile Remove="DataLayer\**" />
+    <Compile Remove="Models\Enum\**" />
+    <Compile Remove="Models\Weapons\**" />
+    <Compile Remove="Service\**" />
+    <Content Remove="DataLayer\**" />
+    <Content Remove="Models\Enum\**" />
+    <Content Remove="Models\Weapons\**" />
+    <Content Remove="Service\**" />
+    <EmbeddedResource Remove="DataLayer\**" />
+    <EmbeddedResource Remove="Models\Enum\**" />
+    <EmbeddedResource Remove="Models\Weapons\**" />
+    <EmbeddedResource Remove="Service\**" />
+    <None Remove="DataLayer\**" />
+    <None Remove="Models\Enum\**" />
+    <None Remove="Models\Weapons\**" />
+    <None Remove="Service\**" />
   </ItemGroup>
 
   <ItemGroup>