module Settings {
    var debug = console.debug;
    var debugEmpty = () => {};

    export var hardDebug = false;
    export var sayTurnTime = true;

    export function setDebug (isDebug : boolean) {
        if (isDebug) {
            console.debug = debug;
        } else {
            console.debug = debugEmpty;
        }
    }

    export function isDebug () {
        return console.debug == debug;
    }

    export function setHardDebug (isHardDebug : boolean) {
        hardDebug = isHardDebug;
    }
}

//Settings.setDebug(false);
//Settings.sayTurnTime = true;

/**
 * Future notes on Performance Issues:
 * - It doesn't really matter if most of the code is optimized or not. CPUs are fast.
 * - It *does* matter if code that is run frequently is sub-optimized.
 * --- Biggest place to look at is at Every Turn Rules, particularly AI: these will run for every action the player does for every single NPC in the game.
 * - This being a text game, we have up to 100ms before the player "feels" the game isn't instantaneous.
 * - Beyond that, we have until about 250ms before the player starts getting legit pissed. These are both per turn.
 *
 * Being that all other code will run once and that's the end of it, the only portion of the game that CAN bring performance issues will be the AI.
 * Each NPC added increases time spent by AI by around ((n + 1)/n). Each rule added does the same.
 * Since NPCs will be added and more and more rules will keep getting added, AT SOME POINT we'll have problems.
 * Stress testing with Pick Shinies and NPCs suggests that we can have about 200 NPCs and about 800 rules before problems, but the testing is not ideal:
 * - Pick Shinies increases in complexity with the amount of things in a room. So the test made this rule particularly nasty, since all NPCs were going and coming from the same rooms.
 * - In a real game situation, it's expected for rooms to rarely have more than 5 things/people in them and for NPCs to be disperse.
 * We should never reach our 250ms limit on powerful CPUs.
 *
 * Regardless, if performance ever becomes an issue:
 * - Optimize AI trees so that Conditions don't have to be checked. Cook each NPC's Rulebook so that all rules that aren't his aren't ever looked at. This is the simplest, no-loss improvement, but only offers improvements if the NPC * RULES number is big.
 * - If the number of Rules * NPCs is not the issue, then figure out which specific rules are being a problem and optimize them specifically. In general, expensive rules should also be rare. This solution might not always be available and might not get all that much result.
 * - Slow down AI for NPCs away from the player. Possibilities: if an NPC is more than 20 rooms away, it only gets one action every 4 turns, then 3, then 2... until it's close enough to act every turn.
 * - Simply skip AI for NPCs in different regions. i.e.: if the player is inside the Obelisk, don't even bother with NPCs in the forest.
 *
 *
 * We also do a lot of debugging.
 * While disabling console.debug offers a substantial performance gain (around 50%) and is available as an Option,
 * entirely commenting out console.debug calls gives us an additional 20% gain on top of that, for a total of around 60% performance gain.
 * Considering debugging is not really useful for players, this should always be kept in mind.
 */