public class HideNSeekGameOptions : IGameOptions
{
- public const int LatestVersion = 7;
+ public const int LatestVersion = 8;
public HideNSeekGameOptions(byte version = LatestVersion)
{
/// <inheritdoc />
public GameModes GameMode => GameModes.HideNSeek;
+ /// <inheritdoc />
+ public SpecialGameModes SpecialMode { get; set; } = SpecialGameModes.None;
+
+ /// <inheritdoc />
+ public RulesPresets RulesPreset { get; set; } = RulesPresets.Custom;
+
/// <inheritdoc />
public byte MaxPlayers { get; set; } = 15;
public void Deserialize(IMessageReader reader)
{
+ if (Version >= 8)
+ {
+ SpecialMode = (SpecialGameModes)reader.ReadByte();
+ RulesPreset = (RulesPresets)reader.ReadByte();
+ }
+
MaxPlayers = reader.ReadByte();
Keywords = (GameKeywords)reader.ReadInt32();
Map = (MapTypes)reader.ReadByte();
MaxPingTime = reader.ReadSingle();
CrewmateTimeInVent = reader.ReadSingle();
- if (Version > 7)
+ if (Version > LatestVersion)
{
IGameOptions.ThrowUnknownVersion<HideNSeekGameOptions>(Version);
}
public void Serialize(IMessageWriter writer)
{
+ if (Version >= 8)
+ {
+ writer.Write((byte)SpecialMode);
+ writer.Write((byte)RulesPreset);
+ }
+
writer.Write(MaxPlayers);
writer.Write((uint)Keywords);
writer.Write((byte)Map);
writer.Write(MaxPingTime);
writer.Write(CrewmateTimeInVent);
- if (Version > 7)
+ if (Version > LatestVersion)
{
IGameOptions.ThrowUnknownVersion<HideNSeekGameOptions>(Version);
}
public byte Version { get; }
/// <summary>
- /// Gets the currently active gamemode.
+ /// Gets the currently active gamemode. This is currently used for the Normal and HideAndSeek gamemodes.
/// </summary>
public GameModes GameMode { get; }
+ /// <summary>
+ /// Gets the currently active special gamemode. This is currently used for the AprilFools gamemode.
+ /// </summary>
+ public SpecialGameModes SpecialMode { get; }
+
+ /// <summary>
+ /// Gets the rule preset.
+ /// </summary>
+ public RulesPresets RulesPreset { get; }
+
/// <summary>
/// Gets or sets the maximum amount of players for this lobby.
/// </summary>
public GameModes GameMode => GameModes.Normal;
+ /// <inheritdoc />
+ public SpecialGameModes SpecialMode { get; } = SpecialGameModes.None;
+
+ /// <inheritdoc />
+ public RulesPresets RulesPreset { get; } = RulesPresets.Custom;
+
/// <summary>
/// Gets or sets the maximum amount of players for this lobby.
/// </summary>
public class NormalGameOptions : IGameOptions
{
- public const int LatestVersion = 7;
+ public const int LatestVersion = 8;
public NormalGameOptions(byte version = LatestVersion)
{
/// <inheritdoc />
public GameModes GameMode => GameModes.Normal;
+ /// <inheritdoc />
+ public SpecialGameModes SpecialMode { get; set; } = SpecialGameModes.None;
+
+ /// <inheritdoc />
+ public RulesPresets RulesPreset { get; set; } = RulesPresets.Custom;
+
/// <inheritdoc />
public byte MaxPlayers { get; set; } = 10;
public void Deserialize(IMessageReader reader)
{
+ if (Version >= 8)
+ {
+ SpecialMode = (SpecialGameModes)reader.ReadByte();
+ RulesPreset = (RulesPresets)reader.ReadByte();
+ }
+
MaxPlayers = reader.ReadByte();
Keywords = (GameKeywords)reader.ReadUInt32();
Map = (MapTypes)reader.ReadByte();
RoleOptions.Deserialize(reader);
- if (Version > 7)
+ if (Version > LatestVersion)
{
IGameOptions.ThrowUnknownVersion<NormalGameOptions>(Version);
}
public void Serialize(IMessageWriter writer)
{
+ if (Version >= 8)
+ {
+ writer.Write((byte)SpecialMode);
+ writer.Write((byte)RulesPreset);
+ }
+
writer.Write(MaxPlayers);
writer.Write((uint)Keywords);
writer.Write((byte)Map);
RoleOptions.Serialize(writer);
- if (Version > 7)
+ if (Version > LatestVersion)
{
IGameOptions.ThrowUnknownVersion<NormalGameOptions>(Version);
}
--- /dev/null
+namespace Impostor.Api.Innersloth.GameOptions.RoleOptions;
+
+public class NoisemakerRoleOptions : IRoleOptions
+{
+ public NoisemakerRoleOptions(byte version)
+ {
+ Version = version;
+ }
+
+ public byte Version { get; }
+
+ public RoleTypes Type => RoleTypes.Noisemaker;
+
+ public bool ImpostorAlert { get; set; } = true;
+
+ public byte AlertDuration { get; set; } = 10;
+
+ public static NoisemakerRoleOptions Deserialize(IMessageReader reader, byte version)
+ {
+ var options = new NoisemakerRoleOptions(version);
+
+ options.AlertDuration = reader.ReadByte();
+ options.ImpostorAlert = reader.ReadBoolean();
+
+ return options;
+ }
+
+ public void Serialize(IMessageWriter writer)
+ {
+ writer.Write(AlertDuration);
+ writer.Write(ImpostorAlert);
+ }
+}
--- /dev/null
+namespace Impostor.Api.Innersloth.GameOptions.RoleOptions;
+
+public class PhantomRoleOptions : IRoleOptions
+{
+ public PhantomRoleOptions(byte version)
+ {
+ Version = version;
+ }
+
+ public byte Version { get; }
+
+ public RoleTypes Type => RoleTypes.Phantom;
+
+ public byte Cooldown { get; set; } = 15;
+
+ public byte Duration { get; set; } = 30;
+
+ public static PhantomRoleOptions Deserialize(IMessageReader reader, byte version)
+ {
+ var options = new PhantomRoleOptions(version);
+
+ options.Cooldown = reader.ReadByte();
+ options.Duration = reader.ReadByte();
+
+ return options;
+ }
+
+ public void Serialize(IMessageWriter writer)
+ {
+ writer.Write(Cooldown);
+ writer.Write(Duration);
+ }
+}
RoleTypes.Engineer => EngineerRoleOptions.Deserialize(roleOptionsReader, Version),
RoleTypes.GuardianAngel => GuardianAngelRoleOptions.Deserialize(roleOptionsReader, Version),
RoleTypes.Shapeshifter => ShapeshifterRoleOptions.Deserialize(roleOptionsReader, Version),
+ RoleTypes.Noisemaker => NoisemakerRoleOptions.Deserialize(roleOptionsReader, Version),
+ RoleTypes.Phantom => PhantomRoleOptions.Deserialize(roleOptionsReader, Version),
+ RoleTypes.Tracker => TrackerRoleOptions.Deserialize(roleOptionsReader, Version),
_ => throw new ArgumentOutOfRangeException(nameof(roleType), roleType, null),
};
--- /dev/null
+namespace Impostor.Api.Innersloth.GameOptions.RoleOptions;
+
+public class TrackerRoleOptions : IRoleOptions
+{
+ public TrackerRoleOptions(byte version)
+ {
+ Version = version;
+ }
+
+ public byte Version { get; }
+
+ public RoleTypes Type => RoleTypes.Tracker;
+
+ public byte Cooldown { get; set; } = 15;
+
+ public byte Duration { get; set; } = 30;
+
+ public byte Delay { get; set; } = 1;
+
+ public static TrackerRoleOptions Deserialize(IMessageReader reader, byte version)
+ {
+ var options = new TrackerRoleOptions(version);
+
+ options.Cooldown = reader.ReadByte();
+ options.Duration = reader.ReadByte();
+ options.Delay = reader.ReadByte();
+
+ return options;
+ }
+
+ public void Serialize(IMessageWriter writer)
+ {
+ writer.Write(Cooldown);
+ writer.Write(Duration);
+ writer.Write(Delay);
+ }
+}