]> git.deb.at Git - rhonda/impostor.git/commitdiff
Add GameOptions V10
authorminiduikboot <mini@duikbo.at>
Tue, 9 Sep 2025 18:40:07 +0000 (20:40 +0200)
committerminiduikboot <mini@duikbo.at>
Tue, 9 Sep 2025 18:40:07 +0000 (20:40 +0200)
Manually added roles to RoleTypes, will clean up later

src/Impostor.Api/Innersloth/Data/enums/RoleTypes.json
src/Impostor.Api/Innersloth/GameOptions/HideNSeekGameOptions.cs
src/Impostor.Api/Innersloth/GameOptions/NormalGameOptions.cs
src/Impostor.Api/Innersloth/GameOptions/RoleOptions/DetectiveRoleOptions.cs [new file with mode: 0644]
src/Impostor.Api/Innersloth/GameOptions/RoleOptions/RoleOptionsCollection.cs
src/Impostor.Api/Innersloth/GameOptions/RoleOptions/ViperRoleOptions.cs [new file with mode: 0644]

index 8fe73d0b986a878ea09b76ce26e4fe9fce9df569..4045c25492bb91e27f23dab27f60b77ea55e1c19 100644 (file)
@@ -9,5 +9,7 @@
   "ImpostorGhost": 7,
   "Noisemaker": 8,
   "Phantom": 9,
-  "Tracker": 10
-}
\ No newline at end of file
+  "Tracker": 10,
+  "Detective": 12,
+  "Viper": 18
+}
index a3d494a89e0591b77a7e38d6ba362f11cb1ddd78..74b3fd1eef02d5745ee912419485a27c77d749be 100644 (file)
@@ -2,7 +2,7 @@ namespace Impostor.Api.Innersloth.GameOptions;
 
 public class HideNSeekGameOptions : IGameOptions
 {
-    public const int LatestVersion = 9;
+    public const int LatestVersion = 10;
 
     public HideNSeekGameOptions(byte version = LatestVersion)
     {
index 4488b1731f26afbe888c3359c1fc1294a4ff2c68..4055f826a998bed7d5399370abd28791a89c6eeb 100644 (file)
@@ -4,7 +4,7 @@ namespace Impostor.Api.Innersloth.GameOptions;
 
 public class NormalGameOptions : IGameOptions
 {
-    public const int LatestVersion = 9;
+    public const int LatestVersion = 10;
 
     public NormalGameOptions(byte version = LatestVersion)
     {
diff --git a/src/Impostor.Api/Innersloth/GameOptions/RoleOptions/DetectiveRoleOptions.cs b/src/Impostor.Api/Innersloth/GameOptions/RoleOptions/DetectiveRoleOptions.cs
new file mode 100644 (file)
index 0000000..4bd29b3
--- /dev/null
@@ -0,0 +1,29 @@
+namespace Impostor.Api.Innersloth.GameOptions.RoleOptions;
+
+public class DetectiveRoleOptions : IRoleOptions
+{
+    public DetectiveRoleOptions(byte version)
+    {
+        Version = version;
+    }
+
+    public byte Version { get; }
+
+    public RoleTypes Type => RoleTypes.Detective;
+
+    public byte DetectiveSuspectLimit { get; set; } = 3;
+
+    public static DetectiveRoleOptions Deserialize(IMessageReader reader, byte version)
+    {
+        var options = new DetectiveRoleOptions(version);
+
+        options.DetectiveSuspectLimit = reader.ReadByte();
+
+        return options;
+    }
+
+    public void Serialize(IMessageWriter writer)
+    {
+        writer.Write((byte)DetectiveSuspectLimit);
+    }
+}
index 91919d8fc24da5fa9d62f7bd5b73614e27a2893e..187987ba272509298e1a532dd1a818a2395f71d8 100644 (file)
@@ -32,6 +32,8 @@ public class RoleOptionsCollection
                 RoleTypes.Noisemaker => NoisemakerRoleOptions.Deserialize(roleOptionsReader, Version),
                 RoleTypes.Phantom => PhantomRoleOptions.Deserialize(roleOptionsReader, Version),
                 RoleTypes.Tracker => TrackerRoleOptions.Deserialize(roleOptionsReader, Version),
+                RoleTypes.Detective => DetectiveRoleOptions.Deserialize(roleOptionsReader, Version),
+                RoleTypes.Viper => ViperRoleOptions.Deserialize(roleOptionsReader, Version),
                 _ => throw new ArgumentOutOfRangeException(nameof(roleType), roleType, null),
             };
 
diff --git a/src/Impostor.Api/Innersloth/GameOptions/RoleOptions/ViperRoleOptions.cs b/src/Impostor.Api/Innersloth/GameOptions/RoleOptions/ViperRoleOptions.cs
new file mode 100644 (file)
index 0000000..56185ad
--- /dev/null
@@ -0,0 +1,29 @@
+namespace Impostor.Api.Innersloth.GameOptions.RoleOptions;
+
+public class ViperRoleOptions : IRoleOptions
+{
+    public ViperRoleOptions(byte version)
+    {
+        Version = version;
+    }
+
+    public byte Version { get; }
+
+    public RoleTypes Type => RoleTypes.Viper;
+
+    public byte ViperDissolveTime { get; set; } = 15;
+
+    public static ViperRoleOptions Deserialize(IMessageReader reader, byte version)
+    {
+        var options = new ViperRoleOptions(version);
+
+        options.ViperDissolveTime = reader.ReadByte();
+
+        return options;
+    }
+
+    public void Serialize(IMessageWriter writer)
+    {
+        writer.Write((byte)ViperDissolveTime);
+    }
+}