Browse Source

calculate dmg for bolter

USRINGENICO\fmorel 3 years ago
parent
commit
804cd627d5

+ 3 - 12
.vs/VSWorkspaceState.json

@@ -1,21 +1,12 @@
 {
   "ExpandedNodes": [
     "",
-<<<<<<< HEAD
     "\\Dotnet",
     "\\Dotnet\\Warhammer",
-    "\\Dotnet\\Warhammer\\DAL",
-    "\\Dotnet\\Warhammer\\DAL\\Database",
     "\\Dotnet\\Warhammer\\Models",
-    "\\Dotnet\\Warhammer\\Models\\Enum",
-    "\\Dotnet\\Warhammer\\Views",
-    "\\Dotnet\\Warhammer\\Views\\Shared"
+    "\\Dotnet\\Warhammer\\Models\\Weapons",
+    "\\Dotnet\\Warhammer\\Service"
   ],
-  "SelectedNode": "\\Dotnet\\Warhammer\\Models\\Player.cs",
-=======
-    "\\Dotnet"
-  ],
-  "SelectedNode": "\\Dotnet\\Warhammer.sln",
->>>>>>> e358957dfb4f64810dea7162fe38a5820cb59cb1
+  "SelectedNode": "\\Dotnet\\Warhammer\\Models\\Weapons\\FlameThrower.cs",
   "PreviewInSolutionExplorer": false
 }

BIN
.vs/slnx.sqlite


+ 11 - 10
Dotnet/Warhammer/Models/Player.cs

@@ -28,16 +28,17 @@ namespace Warhammer.Models
         {
             return DiceService.RollDices(1, 10) + DiceService.Bonus(AG);
         }
-        public bool TestCC() { return DiceService.RollDices(100, 1) <= CC; }
-        public bool TestCT() { return DiceService.RollDices(100, 1) <= CT; }
-        public bool TestF() { return DiceService.RollDices(100, 1) <= F; }
-        public bool TestE() { return DiceService.RollDices(100, 1) <= E; }
-        public bool TestAG() { return DiceService.RollDices(100, 1) <= AG; }
-        public bool TestINT() { return DiceService.RollDices(100, 1) <= INT; }
-        public bool TestPER() { return DiceService.RollDices(100, 1) <= PER; }
-        public bool TestFM() { return DiceService.RollDices(100, 1) <= FM; }
-        public bool TestSOC() { return DiceService.RollDices(100, 1) <= SOC; }
-        public bool TestMF() { return DiceService.RollDices(100, 1) <= MF; }
+
+        public bool TestCC() { return DiceService.RollDices(1, 100) <= CC; }
+        public bool TestCT() { return DiceService.RollDices(1, 100) <= CT; }
+        public bool TestF() { return DiceService.RollDices(1, 100) <= F; }
+        public bool TestE() { return DiceService.RollDices(1, 100) <= E; }
+        public bool TestAG() { return DiceService.RollDices(1, 100) <= AG; }
+        public bool TestINT() { return DiceService.RollDices(1, 100) <= INT; }
+        public bool TestPER() { return DiceService.RollDices(1, 100) <= PER; }
+        public bool TestFM() { return DiceService.RollDices(1, 100) <= FM; }
+        public bool TestSOC() { return DiceService.RollDices(1, 100) <= SOC; }
+        public bool TestMF() { return DiceService.RollDices(1, 100) <= MF; }
 
         public IList Weapons { get; set; }
     }

+ 17 - 0
Dotnet/Warhammer/Models/Utilities.cs

@@ -0,0 +1,17 @@
+using System;
+
+namespace Warhammer.Models
+{
+    public static class Utilities
+    {
+        public static int Round(int value, int dividedBy)
+        {
+            if (value < 0)
+            {
+                return (int)Math.Floor(value / (double)dividedBy);
+            }
+
+            return 0;
+        }
+    }
+}

+ 28 - 3
Dotnet/Warhammer/Models/Weapons/Bolter.cs

@@ -1,11 +1,36 @@
-namespace Warhammer.Models.Weapons
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Warhammer.Service;
+
+namespace Warhammer.Models.Weapons
 {
     public class Bolter : Weapon
     {
-        public override int Shoot(string amo = null)
+        public override int DamageAmount(int successDegree)
         {
+            var throws = new List<int>();
+            for (int i = 0; i < successDegree; i++)
+            {
+                var currentThrow = DiceService.RollDices(3, 10);
+                throws.Add(currentThrow);
+            }
+            return throws.Sum() + 5 * successDegree;
+        }
 
-            return 0;
+        public override int Shoot(int bonusCt, int ct, string amo = null, bool? isHorde = null)
+        {
+            int successDegree;
+            var ctDice = ct - DiceService.RollDices(1, 100) + bonusCt;
+            if (ctDice > 0)
+            {
+                successDegree = 1 + Utilities.Round(ctDice, 10);
+            }
+            else
+            {
+                successDegree = 0;
+            }
+            return DamageAmount(successDegree);
         }
     }
 }

+ 20 - 2
Dotnet/Warhammer/Models/Weapons/FlameThrower.cs

@@ -1,10 +1,28 @@
-namespace Warhammer.Models.Weapons
+using System;
+using Warhammer.Service;
+
+namespace Warhammer.Models.Weapons
 {
     public class FlameThrower : Weapon
     {
-        public override int Shoot(string amo = null)
+        public FlameThrower()
         {
+            Range = 30;
+        }
+
+        public override int DamageAmount(int successDegree)
+        {
+            throw new NotImplementedException();
+        }
+
+        public override int Shoot(int bonusCt, int ct, string amo = null, bool? isHorde = null)
+        {
+            if (isHorde == true)
+            {
+                return DiceService.RollDices(1,5) + Utilities.Round(Range, 4);
+            }
             return 0;
         }
+
     }
 }

+ 11 - 1
Dotnet/Warhammer/Models/Weapons/Weapon.cs

@@ -1,4 +1,5 @@
 using Domain.BackOffice;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
 
 namespace Warhammer.Models.Weapons
 {
@@ -7,7 +8,16 @@ namespace Warhammer.Models.Weapons
         public int Damage;
         public int Range { get; set; }
         public string Name { get; set; }
+        public string GPE { get; set; }
+        public string Type { get; set; }
+        public int Pene { get; set; }
+        public string Mode { get; set; }
+        public string At { get; set; }
+        public string Rch { get; set; }
+        public string Attribute { get; set; }
+
+        public abstract int Shoot(int bonusCt, int ct, string amo = null, bool? isHorde = null);
+        public abstract int DamageAmount(int successDegree);
 
-        public abstract int Shoot(string amo = null);
     }
 }

+ 5 - 6
Dotnet/Warhammer/Service/DiceService.cs

@@ -9,13 +9,12 @@ namespace Warhammer.Service
     {
         public static Random Random = new Random();
 
-        public static int Bonus(double statValue)
+        public static int Bonus(int statValue)
         {
-            var bonus = statValue / 10;
-            return Convert.ToInt32(Math.Round(bonus, MidpointRounding.AwayFromZero));
+            return Utilities.Round(statValue, 10);
         }
 
-        public static int RollDices(int diceValue, int numberOfRoll)
+        public static int RollDices(int numberOfRoll, int diceValue)
         {
             var sum = 0;
 
@@ -27,7 +26,7 @@ namespace Warhammer.Service
             return sum;
         }
 
-      
+
         //public int flamethrower(bool hord = true)
         //{
         //    if (hord)
@@ -70,7 +69,7 @@ namespace Warhammer.Service
         //    return this.RollDices(1, 10) + 3 + this.MF;
         //}
 
-       
+
 
         //public virtual object fast_attack()
         //{