
// PRIVATE
//==============================================================================

function __cHandleChatMessage(message, receiver)
{
	if (!def(receiver))
	{
		receiver = ALLIES;
	}

	chat(message, receiver);
}
//==============================================================================

// PUBLIC
//==============================================================================

function eventChat(from, to, message)
{
	if (from === me)
	{
		if (message === "debug on")
		{
			setDebugFlag(true);
		}
		else if (message === "debug off")
		{
			setDebugFlag(false);
		}

		return; //Don't analyze our own messages further.
	}

	if (to === me)
	{
		var data;

		if (allianceExistsBetween(me, from))
		{
			var cpy;
			const COMMMAND = message.slice(0, -1);
			const PLAYER = message.slice(-1);

			if (PLAYER < 0 || PLAYER > maxPlayers)
			{
				debugMessage("eventChat. Player number does not exist.");
				return;
			}

			switch (COMMAND)
			{
				case "ratio group":
					cpy = enemyGroupRatio[PLAYER];
					data = "tanks: " + cpy.tank + " cyborg: " + cpy.cyborg + " vtol: " + cpy.vtol;
					break;
				case "ratio armor":
				case "ratio armour":
					cpy = enemyArmorRatio[PLAYER];
					data = "kinetic: " + cpy.kinetic + " thermal: " + cpy.thermal;
					break;
				case "ratio propulsion":
					cpy = enemyPropRatio[PLAYER];
					data = "land: " + cpy.land + " sea: " + cpy.sea + " air: " + cpy.air + " slow: " + cpy.slow + " fast: " + cpy.fast;
					break;
				case "ratio body":
					cpy = enemyBodyRatio[PLAYER];
					data = "small: " + cpy.small + " medium: " + cpy.medium + " heavy: " + cpy.heavy;
					break;
				case "ratio weapon":
					cpy = enemyWeapRatio[PLAYER];
					data = "tank: " + cpy.antiTank + " cyborg: " + cpy.antiCyborg + " vtol: " + cpy.antiVtol + "struct: " + cpy.antiStructure + "bunker: " + cpy.antiBunker + "EMP: " + cpy.electronic + " longhit: " + cpy.longHit + " short: " + cpy.shortHit;
					break;
				default:
					return; //Do nothing then.
			}

			__cHandleChatMessage(data, from);
		}
	}
}
//==============================================================================
