'use strict'; const fs=require('fs'),path=require('path'),vm=require('vm'); const ctx={console,Math,Date,JSON,Object,Array,Set,Map,Number,String,Boolean,RegExp,parseInt,parseFloat}; ctx.globalThis=ctx; vm.createContext(ctx); const dir=path.join(__dirname,'..','js'); for(const f of ['util.js','data.js','game.js','match.js']){ vm.runInContext(fs.readFileSync(path.join(dir,f),'utf8'),ctx,{filename:f}); } vm.runInContext(` Game.newWorld('normal'); Game.startWithTeam('t0'); G.calendar.forEach(e=>Game.registerEvent(e.id)); for(let d=0;d<26;d++){ const fx=Game.advanceOneDay(); if(fx){console.log('day',G.day,'USER FIXTURE vs',Game.team(fx.a===G.playerTeamId?fx.b:fx.a)?.tag); MatchEngine.simulate(fx,G.calendar.find(e=>e.id===fx.evId));} if(G.day>=14){ const ev=G.calendar[0]; console.log('day',G.day,'ev0:',ev.name,ev.status,'rounds:',ev.rounds.map(r=>r.name+'['+r.matches.map(m=>(m.a&&m.b?'AB':'..')+(m.winner?'W':'.')+':'+m.day).join(',')+']').join(' ')); } } `,ctx);