var transition = {pid: '', port: '8080' }; // BERT Protocol var players = ["Gabrielo","Mustafa","Alina","Me"]; function handle_web_socket(body) { // console.log(dec(body).value[0][2].value); switch (dec(body).value[0][2].value) { case 'okey_game_info': var a = dec(body).value[0][3][0].value[0][1]; console.log("Players: " + a.length); for (var i=0;i'; slot.parentNode.replaceChild(svg(html),slot); } function rand(lo,hi) { return Math.floor((Math.random()*hi)+lo); } function loadScene() { reload("Kakaranet-7-Refined.svg", "Refined"); for (var i=1;i<16;i++) { empty_card(i,2); empty_card(i,1); } drawSampleCards(); } function findPlace() { for (var y=1;y<3;y++) for (var x=1;x<15;x++) { var e = document.getElementById(slotName(x,y)); if (e.childElementCount == 0) { var pos = e.attributes['id'].value.split("-")[1].split(","); console.log("Free"); console.log(pos[0]); console.log(pos[1]); return { y: pos[0], x: pos[1] }; } } } function findCardOnTable(c,v) { console.log("Find Card " + c + " " + v); for (var y=1;y<3;y++) for (var x=1;x<15;x++) { var e = document.getElementById(slotName(x,y)); if (e.childElementCount > 0) { var value = e.lastChild.textContent; var col = color.indexOf(e.lastChild.attributes['fill'].value) + 1; console.log(col + " " + value); if (c == col && v == value) return { 'x': x, 'y': y }; } } console.log("Card Not Found"); return ""; } // TODO: Rollout Monadic Chain here loadFile('templates/Card.svg', function() { loadFile('Kakaranet-7-Refined.svg', function() { loadScene(); loadFile('templates/PlayShow.svg', function() { document.getElementById("Play").appendChild( svg(localStorage.getItem("templates/PlayShow.svg"))); }); loadFile('templates/PlayHide.svg', function() { document.getElementById("Play").appendChild( svg(localStorage.getItem("templates/PlayHide.svg"))); }); loadFile('templates/CreateShow.svg', function() { document.getElementById("Create").appendChild( svg(localStorage.getItem("templates/CreateShow.svg"))); }); loadFile('templates/CreateHide.svg', function() { document.getElementById("Create").appendChild( svg(localStorage.getItem("templates/CreateHide.svg"))); }); document.getElementById("Right-Menu").setAttribute('onclick', 'onRightMenu(evt)'); document.getElementById("Play").setAttribute('onclick', 'onRightMenuDown(evt)'); document.getElementById("Create").setAttribute('onclick', 'onRightMenuDown(evt)'); }); }); function onRightMenu(evt) { ["PlayShow","CreateShow"].map(function (x) { document.getElementById(x).beginElement(); }); } function onRightMenuDown(evt) { ["PlayHide","CreateHide"].map(function (x) { document.getElementById(x).beginElement(); }); } // SVG Samples for svg.htm loadFile('templates/Mustafa-Persona.svg', null, "Mustafa-Persona-Sample"); loadFile('templates/Mustafa-Selection.svg', null, "Mustafa-Selection-Sample"); document.getElementById("MustafaSelection").addEventListener('click', function() { var style = document.getElementById("Mustafa-Selection-Sample").style; if (style.display == 'none') style.display = 'block'; else style.display = 'none'; }); function slotName1(x,y) { return "1Slot-"+y+","+x; } function drawSampleCards() { slotName = slotName1; for (var i=1;i<15;i++) { place_card(i,rand(1,2),rand(1,4),rand(1,13)); } slotName = slotNameDef; }