package testutils;

import electrosphere.engine.Globals;
import electrosphere.engine.Main;
import electrosphere.engine.profiler.Profiler;
import electrosphere.net.NetUtils;

/**
 * Utils for testing the engine
 */
public class TestEngineUtils {
    
    /**
     * Initializes the engine
     */
    public static void initHeadlessEngine(){
        Globals.RUN_CLIENT = true;
        Globals.RUN_SERVER = true;
        Globals.RUN_AUDIO = false;
        Globals.HEADLESS = true;
        Profiler.PROFILE = false;
        NetUtils.setPort(0);
        Main.startUp();
    }

    /**
     * Initializes the engine
     */
    public static void initGraphicalEngine(){
        Globals.RUN_CLIENT = true;
        Globals.RUN_SERVER = true;
        Globals.RUN_AUDIO = false;
        Globals.HEADLESS = false;
        Profiler.PROFILE = false;
        NetUtils.setPort(0);
        Main.startUp();
    }

    /**
     * Prints a logging message
     * @param log the message to print
     */
    public static void log(String log){
        System.out.println(log);
    }

    /**
     * Simulates a certain number of frames
     * @param frameCount The number of frames to simulate
     */
    public static void simulateFrames(int frameCount){
        int i = 0;
        while(i < frameCount){
            Main.setFramestep(1);
            Main.mainLoop(1);
            i++;
        }
    }

}
