const fs=require('fs'),vm=require('vm');function E(){return{innerHTML:'',textContent:'',children:[],appendChild(x){this.children.push(x)},prepend(){},remove(){},onclick:null,files:[]}}const els={};const ctx={console,Math,Date,Blob:function(){},URL:{createObjectURL(){return''}},FileReader:function(){},localStorage:{getItem(){return null},setItem(){}},document:{getElementById(id){return els[id]||(els[id]=E())},createElement(){return E()}},window:{}};ctx.window=ctx;vm.createContext(ctx);for(const f of ['data.js','tournaments.js','engine.js','game.js'])vm.runInContext(fs.readFileSync(__dirname+'/'+f,'utf8'),ctx);ctx.__promo=ctx.__FIFA_PROMO_QA.promotionRules;ctx.__rel=ctx.__FIFA_PROMO_QA.relegationRules;if(Object.keys(ctx.__promo).length<10)throw Error('promotion rules missing');if(Object.keys(ctx.__rel).length<10)throw Error('relegation rules missing');console.log('FIFA promotion/relegation QA OK',Object.keys(ctx.__promo).length,Object.keys(ctx.__rel).length);
