using Cute;

namespace Wizard;

public class GatheringRoomEnterVacancyRoomTask : BaseRoomBattleEnterRoomTask
{
	private GatheringInfo _gatheringInfo;

	public GatheringAutoJoinTaskInfo GatheringAutoJoinTaskInfo { get; private set; }

	public GatheringRoomEnterVacancyRoomTask(GatheringInfo gatheringInfo)
	{
		_gatheringInfo = gatheringInfo;
		base.type = ApiType.Type.GatheringRoomEnterVacancyRoom;
	}

	protected override int Parse()
	{
		if (base.ResponseData.TryGetValue("data", out var value) && value.IsObject && value.TryGetValue("is_owner", out var value2) && value2.ToInt() != 0 && value.Keys.Contains("result_reason"))
		{
			value["result_reason"] = "-1";
		}
		int num = base.Parse();
		if (num != 1)
		{
			return num;
		}
		GatheringAutoJoinTaskInfo = new GatheringAutoJoinTaskInfo(base.ResponseData, this, _gatheringInfo);
		if (GatheringAutoJoinTaskInfo.NeedsRetry)
		{
			return num;
		}
		if (GatheringAutoJoinTaskInfo.IsOwner)
		{
			CustomPreference.SetNodeServerURL(value["node_server_url"].ToString());
		}
		return num;
	}
}
