'use strict';

var graphicsModule = require('./graphics/graphicsbase.js');
var dataStructuresModule = require('./datastructures/datastructuresbase.js');
var consoleModule = require('./console/console.js');

// This is currently being attached to the window to allow non-modular
// JavaScript to have access to it. Once all libraries (Karel et al.)
// are ported to modules this will be redundant and can be simply
// replaced with a `require` in those files.
window.CodeHSGraphics = graphicsModule.CodeHSGraphics;
window.CodeHSConsole = consoleModule.CodeHSConsole;

// Quick fixes until Karel modules are ported.
window.Polygon = graphicsModule.Polygon;
window.WebImage = graphicsModule.WebImage;

// Use apply to pass CodeHSConsole to the function as `this`, rather than window
// which results as undefined.
var CodeHSConsole = new consoleModule.CodeHSConsole();
window.println = function() { CodeHSConsole.println.apply(CodeHSConsole, arguments) };
window.print = function() { CodeHSConsole.print.apply(CodeHSConsole, arguments) };
window.readInt = function() { CodeHSConsole.readInt.apply(CodeHSConsole, arguments) };
window.readBoolean = function() { CodeHSConsole.readBoolean.apply(CodeHSConsole, arguments) };
window.readFloat = function() { CodeHSConsole.readFloat.apply(CodeHSConsole, arguments) };
window.readLine = function() { CodeHSConsole.readLine.apply(CodeHSConsole, arguments) };

// The following are special cases, where namespaces are used but
// the objects are never constructed.
window.Randomizer = graphicsModule.Randomizer;
window.Color = graphicsModule.Color;
