using System;
using System.Collections.Generic;

namespace QCRPG.Framework;

public static class PacketHelper
{
	public static PacketBase GetPacketTypeFromList(Type type, List<PacketBase> packets)
	{
		foreach (PacketBase packet in packets)
		{
			if (packet.GetType() == type)
			{
				return packet;
			}
		}
		throw new Exception("Packet type not found: " + type.ToString());
	}

	public static void RemoveTypeFromList(Type type, List<PacketBase> packets)
	{
		PacketBase packetBase = null;
		foreach (PacketBase packet in packets)
		{
			if (packet.GetType() == type)
			{
				packetBase = packet;
			}
		}
		if (packetBase == null)
		{
			throw new Exception("Packet type not found: " + type.ToString());
		}
		packets.Remove(packetBase);
	}
}
