using System;
using System.Text;

namespace TeslaConsole.RedPlanet;

[Serializable]
internal abstract class RPPlayer : RPParticipant
{
	private readonly string mName;

	private readonly string mVehicleKey;

	private readonly string mColorKey;

	private readonly string mBadgeKey;

	public string Name => mName;

	public string VehicleKey => mVehicleKey;

	public string ColorKey => mColorKey;

	public string BadgeKey => mBadgeKey;

	protected RPPlayer(string podHostAddress, string name, string vehicleKey, string colorKey, string badgeKey)
		: base(podHostAddress, HostType.GameMachineHostType)
	{
		if (podHostAddress == null)
		{
			throw new ArgumentNullException("podHostAddress");
		}
		if (name == null)
		{
			throw new ArgumentNullException("name");
		}
		if (vehicleKey == null)
		{
			throw new ArgumentNullException("vehicleKey");
		}
		if (colorKey == null)
		{
			throw new ArgumentNullException("colorKey");
		}
		if (badgeKey == null)
		{
			throw new ArgumentNullException("badgeKey");
		}
		mName = name;
		mVehicleKey = vehicleKey;
		mColorKey = colorKey;
		mBadgeKey = badgeKey;
	}

	protected sealed override void AppendParticipantSpecificData(int index, StringBuilder sb)
	{
		sb.Append("dropzone=one\n");
		sb.AppendFormat("name={0}\n", mName);
		sb.AppendFormat("bitmapindex={0}\n", index);
		sb.Append("loadzones=1\n");
		sb.AppendFormat("vehicle={0}\n", mVehicleKey);
		sb.AppendFormat("color={0}\n", mColorKey);
		sb.AppendFormat("badge={0}\n", mBadgeKey);
		AppendMissionSpecificPilot(index, sb);
	}

	protected abstract void AppendMissionSpecificPilot(int index, StringBuilder sb);
}
