Added missing checks in InnerShipStatus

This commit is contained in:
AeonLucid committed 2020-10-24 00:04:43 +02:00
1 parent 7c946525fc
commit dcb903b272
3 files changed
+40 -10

No files matched your search

@@ -0,0 +1,12 @@
using Impostor.Api.Innersloth.Net.Objects.Systems;
namespace Impostor.Api
{
public static class SystemTypesExtensions
{
public static string GetFriendlyName(this SystemTypes type)
{
return SystemTypeHelpers.Names[(int)type];
}
}
}
@@ -108,16 +108,15 @@ namespace Impostor.Api.Innersloth.Net.Objects
{
if (!sender.IsHost)
{
throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.SetInfected)} but was not a host.");
throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.Exiled)} but was not a host.");
}
if (target != null)
{
throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.SetInfected)} to a specific player instead of broadcast.");
throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.Exiled)} to a specific player instead of broadcast.");
}
Console.WriteLine(PlayerInfo.PlayerName + " was voted out.");
// TODO: Not hit?
Die(DeathReason.Exile);
break;
}
@@ -250,6 +249,11 @@ namespace Impostor.Api.Innersloth.Net.Objects
}
var player = reader.ReadNetObject<InnerPlayerControl>(_game);
if (!player.PlayerInfo.IsDead)
{
player.Die(DeathReason.Kill);
}
break;
}
@@ -48,24 +48,38 @@ namespace Impostor.Api.Innersloth.Net.Objects
{
case RpcCalls.CloseDoorsOfType:
{
if (target == null || !target.IsHost)
{
throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.CloseDoorsOfType)} to wrong destinition, must be host.");
}
if (!sender.Character.PlayerInfo.IsImpostor)
{
Console.WriteLine($"OOPS Fake Impostor: {sender.Character.PlayerInfo.PlayerName} did doors");
// throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.CloseDoorsOfType)} as crewmate.");
}
var systemType = (SystemTypes)reader.ReadByte();
break;
}
case RpcCalls.RepairSystem:
{
if (target == null || !target.IsHost)
{
throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.RepairSystem)} to wrong destinition, must be host.");
}
if (!sender.Character.PlayerInfo.IsImpostor)
{
// throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.RepairSystem)} as crewmate.");
}
var systemType = (SystemTypes)reader.ReadByte();
var player = reader.ReadNetObject<InnerPlayerControl>(_game);
var amount = reader.ReadByte();
if (systemType == SystemTypes.Sabotage && !player.PlayerInfo.IsImpostor)
{
Console.WriteLine($"OOPS Fake Impostor: {player.PlayerInfo.PlayerName} did {(SystemTypes) amount}");
}
// TODO: Modify data (?)
break;
}
@@ -80,7 +94,7 @@ namespace Impostor.Api.Innersloth.Net.Objects
public override bool Serialize(IMessageWriter writer, bool initialState)
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
public override void Deserialize(IClientPlayer sender, IMessageReader reader, bool initialState)