"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs-extra"));
const Factory_1 = require("../../src/Factory");
const FactoryDatabase_1 = require("../../src/FactoryDatabase");
const Trial_1 = require("../../src/Trial");
const Source_1 = require("../../src/Source");
const ModList_1 = require("../../src/ModList");
const Dataset_1 = require("../../src/Dataset");
const path_1 = __importDefault(require("path"));
require('dotenv').config();
function main() {
    return __awaiter(this, void 0, void 0, function* () {
        // startup factory
        yield Factory_1.Factory.initialize({
            hideConsole: false,
            updateInstall: true
        });
        yield FactoryDatabase_1.FactoryDatabase.initialize([
            {
                name: 'cache',
                type: 'postgres',
                host: process.env.PG_CACHE_HOST,
                port: parseInt(process.env.PG_CACHE_PORT),
                username: process.env.PG_CACHE_USER,
                password: process.env.PG_CACHE_PASS,
                poolSize: 4,
                synchronize: true,
                entities: [
                    Trial_1.Trial,
                    Source_1.Source,
                    ModList_1.ModList,
                    Dataset_1.GameFlowItemRecord,
                    Dataset_1.GameFlowElectricRecord,
                    Dataset_1.GameFlowCircuitRecord,
                    Dataset_1.GameFlowPollutionRecord,
                    Dataset_1.GameFlowSystemRecord
                ]
            }
        ]);
        console.log('Factory started! running trial');
        const bpFile = path_1.default.join(process.cwd(), 'factory/examples/1200spm_base.bp');
        const bpStr = yield fs.readFile(bpFile, 'utf8');
        // make a source, then run a trial with this source as well
        let source = new Source_1.Source({
            name: '1200spm_base',
            desc: 'Big science blueprint',
            variant: 'blueprint',
            text: bpStr
        });
        let t = new Trial_1.Trial({
            name: '1200spm_base',
            desc: 'Big base!',
            source: source,
            length: 108000,
            tickInterval: 300,
            initialBots: 150,
            recordItems: true,
            recordCircuits: true,
            recordPollution: true,
            recordSystem: true
        });
        yield FactoryDatabase_1.FactoryDatabase.saveTrial(t, true);
        // run trial
        yield Factory_1.Factory.analyzeTrial(t, true, true);
        console.log('trial done!');
    });
}
main().then((t) => {
    console.log('Worker Started!');
}).catch((e) => {
    console.error(e);
});
//# sourceMappingURL=runLocalFactoryTest.js.map