/*
 * Main Loop
 *
 */

// prototypes
require('prototype.prototype');

// global methods
global.C            = require('constants');
global.cli          = require('util.cli');
global.utils        = new (require('util.utils'));
global.logger       = new (require('util.logger'));

var Kernel          = require('kernel');
var Logger = require('util.logger');

var logger = new Logger('[Main]');
logger.level = C.LOGLEVEL.DEBUG;

module.exports.loop = function () {
    var kernel = new Kernel;

    kernel.run();
}

/*
 * Main Loop
 *
 */

// prototypes
require('prototype.prototype');

// global methods
global.C            = require('constants');
global.cli          = require('util.cli');
global.utils        = new (require('util.utils'));
global.logger       = new (require('util.logger'));

var Director        = require('director.director');
var Queue           = require('queue.queue');
var Manage          = require('manage.manage');
var Role            = require('role.role');
var Task            = require('task.task');
var Work            = require('work.work');
var Mil             = require('mil.mil');
var Visuals         = require('util.visuals');

var Logger = require('util.logger');

var logger = new Logger('[Main]');
logger.level = C.LOGLEVEL.DEBUG;

module.exports.loop = function () {
    let cpuStart = Game.cpu.getUsed();

    Game.Director       = new Director;
    Game.Queue          = new Queue;
    Game.Role           = new Role;
    Game.Task           = new Task;
    Game.Work           = new Work;
    Game.Manage         = new Manage;
    Game.Mil            = new Mil;
    Game.Visuals        = new Visuals;

    Game.Visuals.addLog(undefined, {
        command: 'init',
        status: 'OK',
        cpu: Game.cpu.getUsed(),
        output: 'memory usage: ' + (JSON.stringify(RawMemory).length / 1024).toFixed(2) + ' KB',
    });


    Game.Visuals.addLog(undefined, {
        command: 'starting main',
    });

    Game.Queue.run();
    Game.Manage.run();
    Game.Director.run();
    Game.Mil.run();

    Game.Visuals.addLog(undefined, {
        command: 'main',
        status: 'OK',
        cpu: (Game.cpu.getUsed() - cpuStart),
    });

    Game.Visuals.run();

}

revert main