--- a/main.js +++ b/main.js @@ -85,12 +85,6 @@ gs.state=2; resetgame(); } - else - if ((x>=110) && (x<=325) && (y>=300) && (y<=380)) - { - // Decentralised game (using drand) - updatedrand(); - } break; case 3: // Finished @@ -198,7 +192,7 @@ gs.uictx.fillRect(0, 0, xmax, ymax); gs.uictx.fillStyle="black"; - // Draw PLAY and PLAY decentralised button + // Draw PLAY button var grd=gs.uictx.createLinearGradient(110, 100, 110, 180); grd.addColorStop(0, "#fceb08"); grd.addColorStop(0.5, "#f2137b"); @@ -212,25 +206,6 @@ gs.uictx.fillText("PLAY", 145, 160); gs.uictx.fillStyle="black"; - var grd2=gs.uictx.createLinearGradient(110, 300, 110, 380); - grd2.addColorStop(0, "#0b68a4"); - grd2.addColorStop(0.48, "#c1eaf8"); - grd2.addColorStop(0.5, "#ffffff"); - grd2.addColorStop(0.52, "#9b3c0a"); - grd2.addColorStop(0.75, "#fcca31"); - grd2.addColorStop(0.99, "#fbe69d"); - grd2.addColorStop(1, "#ffffff"); - - gs.uictx.fillStyle=grd2; - gs.uictx.fillRect(110, 300, 215, 80); - - gs.uictx.fillStyle="white"; - gs.uictx.font="bold 52px Arial"; - gs.uictx.fillText("PLAY", 145, 350); - gs.uictx.fillStyle="#f2137b"; - gs.uictx.font="bold 14px Arial"; - gs.uictx.fillText("decentralised", 165, 370); - gs.uictx.fillStyle="black"; break; case 2: // InPlay @@ -616,66 +591,6 @@ placeitem(2, 4); } -// Use a decentralised random number source for seeding prng -function updatedrand() -{ - // Stop using frame based advance of pRNG - gs.usingdrand=true; - - // Set up - return new Promise(function(resolve, reject) - { - var req = new XMLHttpRequest(); - - req.timeout=5000; - req.open('GET', 'https://api.drand.sh/public/latest', true); - - // AJAX request has changed state - req.onreadystatechange = function () - { - if (req.readyState === 4) // AJAX done - { - if (req.status == 200) // Good response - { - // Parse the result - try - { - var res = JSON.parse(req.responseText); - - // Extract 4 bytes of hex for each seed - rng.s1=parseInt(res.randomness.substr(0,4), 16); - rng.s2=parseInt(res.randomness.substr(4,4), 16); - rng.s3=parseInt(res.randomness.substr(8,4), 16); - } - - catch(e) - { - gs.usingdrand=false; - } - } - else - gs.usingdrand=false; - - gs.state=2; - resetgame(); - } - }; - - // Something went wrong - req.onerror = function() - { - // drand failed, so fallback to pRNG - gs.usingdrand=false; - - gs.state=2; - resetgame(); - }; - - // Fire off the AJAX call - req.send(); - }); -} - function resetgame() { gs.finished=false;