

const scriptsInEvents = {

	async GameEvent_Event2_Act3(runtime, localVars)
	{
		// We don't need to create a new handler since it's already created in api_template.js
		if (window.apiHandler) {
			console.log('API Handler already exists');
			await window.apiHandler.verifyTokenAtStart();
		} else {
			console.error('API Handler not found! Check if api_template.js is loaded properly');
		}
	},

	async GameEvent_Event24_Act8(runtime, localVars)
	{
		// Use window.apiHandler directly
		if (window.apiHandler) {
			const currentScore = runtime.globalVars.score;
			try {
				await window.apiHandler.submitScoreIfNeeded(currentScore);
				console.log('Score submission attempted for score:', currentScore);
			} catch (error) {
				console.error('Error submitting score:', error);
			}
		} else {
			console.error('API Handler not found when trying to submit score');
		}
	}
};

globalThis.C3.JavaScriptInEvents = scriptsInEvents;
