papercats/public/bundle.js

2 lines
152 KiB
JavaScript
Raw Normal View History

2019-02-21 11:50:51 -05:00
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){var io=require("socket.io-client");var client=require("./src/game-client");var config=require("./config.json");client.allowAnimation=true;client.renderer=require("./src/user-mode");var mimiRequestAnimationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(callback){window.setTimeout(callback,1e3/30)};function run(){client.connectGame("//"+window.location.hostname+":"+config.ws_port,$("#name").val(),function(success,msg){if(success){$("#begin").fadeOut(1e3);$("#main-ui").fadeIn(1e3)}else{$("#error").text(msg)}})}$(function(){var error=$("#error");if(!window.WebSocket){error.text("Your browser does not support WebSockets!");return}error.text("Loading... Please wait");var socket=io("//"+window.location.hostname+":"+config.ws_port,{forceNew:true,upgrade:false,transports:["websocket"]});socket.on("connect",function(){socket.emit("pings")});socket.on("pongs",function(){socket.disconnect();error.text("All done, have fun!");$("#name").keypress(function(evt){if(evt.which===13)mimiRequestAnimationFrame(run)});$("#start").removeAttr("disabled").click(function(evt){mimiRequestAnimationFrame(run)})});socket.on("connect_error",function(){error.text("Cannot connect with server. This probably is due to misconfigured proxy server. (Try using a different browser)")})});$(document).keydown(function(e){var newHeading=-1;switch(e.which){case 38:newHeading=0;break;case 87:newHeading=0;break;case 39:newHeading=1;break;case 68:newHeading=1;break;case 40:newHeading=2;break;case 83:newHeading=2;break;case 37:newHeading=3;break;case 65:newHeading=3;break;default:return}client.changeHeading(newHeading)});$(document).on("touchmove",function(e){e.preventDefault()});$(document).on("touchstart",function(e1){var x1=e1.targetTouches[0].pageX;var y1=e1.targetTouches[0].pageY;$(document).one("touchend",function(e2){var x2=e2.changedTouches[0].pageX;var y2=e2.changedTouches[0].pageY;var deltaX=x2-x1;var deltaY=y2-y1;var newHeading=-1;if(deltaY<0&&Math.abs(deltaY)>Math.abs(deltaX))newHeading=0;else if(deltaX>0&&Math.abs(deltaY)<deltaX)newHeading=1;else if(deltaY>0&&Math.abs(deltaX)<deltaY)newHeading=2;else if(deltaX<0&&Math.abs(deltaX)>Math.abs(deltaY))newHeading=3;client.changeHeading(newHeading)})})},{"./config.json":2,"./src/game-client":52,"./src/user-mode":53,"socket.io-client":32}],2:[function(require,module,exports){module.exports={hostname:"0.0.0.0",http_port:8080,ws_port:8081,bots:[],consts:{GRID_SIZE:80,CELL_WIDTH:40,SPEED:5,BORDER_WIDTH:20,MAX_PLAYERS:81,PREFIXES:"Angry Baby Crazy Diligent Excited Fat Greedy Hungry Interesting Japanese Kind Little Magic Naïve Old Powerful Quiet Rich Superman THU Undefined Valuable Wifeless Xiangbuchulai Young Zombie",NAMES:"Alice Bob Carol Dave Eve Francis Grace Hans Isabella Jason Kate Louis Margaret Nathan Olivia Paul Queen Richard Susan Thomas Uma Vivian Winnie Xander Yasmine Zach"}}},{}],3:[function(require,module,exports){module.exports=after;function after(count,callback,err_cb){var bail=false;err_cb=err_cb||noop;proxy.count=count;return count===0?callback():proxy;function proxy(err,result){if(proxy.count<=0){throw new Error("after called too many times")}--proxy.count;if(err){bail=true;callback(err);callback=err_cb}else if(proxy.count===0&&!bail){callback(null,result)}}}function noop(){}},{}],4:[function(require,module,exports){module.exports=function(arraybuffer,start,end){var bytes=arraybuffer.byteLength;start=start||0;end=end||bytes;if(arraybuffer.slice){return arraybuffer.slice(start,end)}i