// Copyright 2018 RED Software, LLC. All Rights Reserved.

using IgniteEngine;

namespace GameLogServer.Services
{
    internal static class GameLogService
	{
		internal static bool AddCreateAvatar(int nCharNo)
		{
			return AddGeneric(GameLogType.GAME_CREATE_AVATAR, nCharNo);
		}

		internal static bool AddDeleteAvatar(int nCharNo)
		{
			return AddGeneric(GameLogType.GAME_DELETE_AVATAR, nCharNo);
		}
		
		internal static bool AddDataType0(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nTargetCharNo, int nTargetID, long nItemKey, int nInt1, int nInt2, int nInt3, long nBigint1)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, nTargetCharNo, nTargetID, nItemKey, nInt1, nInt2, nInt3, nBigint1);
		}

		internal static bool AddDataType1(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ);
		}

		internal static bool AddDataType2(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nInt1, int nInt2)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, null, null, null, nInt1, nInt2);
		}

		internal static bool AddDataType3(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nTargetCharNo, int nTargetID, int nInt1)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, nTargetCharNo, nTargetID, null, nInt1);
		}

		internal static bool AddDataType4(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nInt1, int nInt2, int nInt3)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, null, null, null, nInt1, nInt2, nInt3);
		}

		internal static bool AddDataType5(GameLogType nType, int nCharNo, int nInt1, int nInt2)
		{
			return AddGeneric(nType, nCharNo, null, null, null, null, null, null, nInt1, nInt2);
		}

		internal static bool AddDataType6(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nInt1, long nBigint1)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, null, null, null, nInt1, null, null, nBigint1);
		}

		internal static bool AddDataType7(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nTargetCharNo, int nInt1, int nInt2)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, nTargetCharNo, null, null, nInt1, nInt2);
		}

		internal static bool AddDataType8(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nInt1)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, null, null, null, nInt1);
		}

		internal static bool AddDataType9(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, long nItemKey, int nInt1, int nInt2)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, null, null, nItemKey, nInt1, nInt2);
		}

		internal static bool AddDataTypeA(GameLogType nType, int nCharNo, int nTargetCharNo, int nTargetID, long nItemKey, int nInt1, int nInt2, int nInt3)
		{
			return AddGeneric(nType, nCharNo, null, null, null, null, nTargetCharNo, nTargetID, nItemKey, nInt1, nInt2, nInt3);
		}

		internal static bool AddDataTypeB(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nTargetCharNo, int nTargetID, long nItemKey, int nInt1, int nInt2, int nInt3)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, nTargetCharNo, nTargetID, nItemKey, nInt1, nInt2, nInt3);
		}

		internal static bool AddDataTypeC(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nTargetID, long nItemKey, int nInt1, int nInt2, int nInt3)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, null, nTargetID, nItemKey, nInt1, nInt2, nInt3);
		}

		internal static bool AddDataTypeD(GameLogType nType, int nCharNo, long nItemKey, int nInt1, int nInt2)
		{
			return AddGeneric(nType, nCharNo, null, null, null, null, null, null, nItemKey, nInt1, nInt2);
		}

		internal static bool AddDataTypeE(GameLogType nType, string sMap, int nMapX, int nMapY, int nMapZ, int nTargetID, long nItemKey, int nInt1, int nInt2)
		{
			return AddGeneric(nType, null, sMap, nMapX, nMapY, nMapZ, null, nTargetID, nItemKey, nInt1, nInt2);
		}

		internal static bool AddDataTypeF(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nTargetID, long nItemKey, int nInt1, int nInt2, int nInt3, long nBigint1)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, null, nTargetID, nItemKey, nInt1, nInt2, nInt3, nBigint1);
		}

		internal static bool AddDataTypeG(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nTargetID, long nItemKey, int nInt1, int nInt2, long nBigint1)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, null, nTargetID, nItemKey, nInt1, nInt2, null, nBigint1);
		}

		internal static bool AddDataTypeH(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nTargetCharNo)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, nTargetCharNo);
		}

		internal static bool AddDataTypeI(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nTargetCharNo, int nTargetID)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, nTargetCharNo, nTargetID);
		}

		internal static bool AddDataTypeJ(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nTargetID, long nItemKey, int nInt1, int nInt2)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, null, nTargetID, nItemKey, nInt1, nInt2);
		}

		internal static bool AddDataTypeK(GameLogType nType, int nCharNo, string sMap, int nMapX, int nMapY, int nMapZ, int nInt1, int nInt2, long nBigint1)
		{
			return AddGeneric(nType, nCharNo, sMap, nMapX, nMapY, nMapZ, null, null, null, nInt1, nInt2, null, nBigint1);
		}

		internal static bool AddDataTypeL(GameLogType nType, int nCharNo, int nTargetCharNo, int nTargetID, long nItemKey, int nInt1, int nInt2, int nInt3, long nBigint1)
		{
			return AddGeneric(nType, nCharNo, null, null, null, null, nTargetCharNo, nTargetID, nItemKey, nInt1, nInt2, nInt3, nBigint1);
		}

		private static bool AddGeneric(GameLogType nType, int? nCharNo, string sMap = null, int? nMapX = null, int? nMapY = null, int? nMapZ = null, int? nTargetCharNo = null, int? nTargetID = null, long? nItemKey = null, int? nInt1 = null, int? nInt2 = null, int? nInt3 = null, long? nBigint1 = null)
		{
			using (var p_GameLog_Add = new StoredProcedure("p_GameLog_Add", Program.AccountLogODBC))
			{
				p_GameLog_Add.AddParameter("nType", (int)nType);
				p_GameLog_Add.AddParameter("nCharNo", nCharNo);
				p_GameLog_Add.AddParameter("sMap", sMap, 16);
				p_GameLog_Add.AddParameter("nMapX", nMapX);
				p_GameLog_Add.AddParameter("nMapY", nMapY);
				p_GameLog_Add.AddParameter("nMapZ", nMapZ);
				p_GameLog_Add.AddParameter("nTargetCharNo", nTargetCharNo);
				p_GameLog_Add.AddParameter("nTargetID", nTargetID);
				p_GameLog_Add.AddParameter("nItemKey", nItemKey);
				p_GameLog_Add.AddParameter("nInt1", nInt1);
				p_GameLog_Add.AddParameter("nInt2", nInt2);
				p_GameLog_Add.AddParameter("nInt3", nInt3);
				p_GameLog_Add.AddParameter("nBigint", nBigint1);
				p_GameLog_Add.AddOutput<long>("nLogNo");

				return p_GameLog_Add.Run().GetOutput<long>("nLogNo") != 0;
			}
		}
	}
}
