Skip to content

Instantly share code, notes, and snippets.

@kirbysayshi
Created November 8, 2013 06:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kirbysayshi/7367079 to your computer and use it in GitHub Desktop.
Save kirbysayshi/7367079 to your computer and use it in GitHub Desktop.
requirebin sketch
var Shuffle = require('shuffle');
var deckConfig = {
'Knight': {
description: "Move the robber, and steal a card from whomever borders the new robber location.",
count: 14
},
'Progress - Year of Plenty': {
description: "Immediately gain two resource cards of any type",
count: 2
},
'Progress - Monopoly': {
description: "",
count: 2
},
'Progress - Road Building': {
description: "",
count: 2
},
// TODO: make these collapsible somehow
'Victory Point - Chapel': {
display: 'Chapel',
description: "Gain one victory point immediately",
count: 1
},
'Victory Point - Library': {
display: 'Library',
description: "Gain one victory point immediately",
count: 1
},
'Victory Point - Marketplace': {
display: 'Marketplace',
description: "Gain one victory point immediately",
count: 1
},
'Victory Point - Palace': {
display: 'Palace',
description: "Gain one victory point immediately",
count: 1
},
'Victory Point - University': {
display: 'University',
description: "Gain one victory point immediately",
count: 1
}
};
function expand() {
}
var deck = Shuffle.shuffle({ deck: expand(deckConfig) });
function expand(){}require=function(e,t,n){function r(n,o){if(!t[n]){if(!e[n]){var s="function"==typeof require&&require;if(!o&&s)return s(n,!0);if(i)return i(n,!0);throw Error("Cannot find module '"+n+"'")}var a=t[n]={exports:{}};e[n][0].call(a.exports,function(t){var i=e[n][1][t];return r(i?i:t)},a,a.exports)}return t[n].exports}for(var i="function"==typeof require&&require,o=0;n.length>o;o++)r(n[o]);return r}({shuffle:[function(e,t){t.exports=e("SWUNsv")},{}],SWUNsv:[function(e,t){e("util");var n=e("./deck"),r=e("./playingCardDeck"),i=t.exports={},o={deck:(new r).cards,random:function(){return Math.random()}};i.playingCards=function(){return(new r).cards},i.shuffle=function(e){return e||(e=o),e.deck||(e.deck=o.deck),e.random||(e.random=o.random),new n(e.deck,e.random)}},{util:1,"./deck":2,"./playingCardDeck":3}],1:[function(e,t,n){function r(e){return e instanceof Array||Array.isArray(e)||e&&e!==Object.prototype&&r(e.__proto__)}function i(e){return e instanceof RegExp||"object"==typeof e&&"[object RegExp]"===Object.prototype.toString.call(e)}function o(e){if(e instanceof Date)return!0;if("object"!=typeof e)return!1;var t=Date.prototype&&a(Date.prototype),n=e.__proto__&&a(e.__proto__);return JSON.stringify(n)===JSON.stringify(t)}e("events"),n.isArray=r,n.isDate=function(e){return"[object Date]"===Object.prototype.toString.call(e)},n.isRegExp=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},n.print=function(){},n.puts=function(){},n.debug=function(){},n.inspect=function(e,t,u,c){function f(e,u){if(e&&"function"==typeof e.inspect&&e!==n&&(!e.constructor||e.constructor.prototype!==e))return e.inspect(u);switch(typeof e){case"undefined":return l("undefined","undefined");case"string":var c="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return l(c,"string");case"number":return l(""+e,"number");case"boolean":return l(""+e,"boolean")}if(null===e)return l("null","null");var h=s(e),d=t?a(e):h;if("function"==typeof e&&0===d.length){if(i(e))return l(""+e,"regexp");var v=e.name?": "+e.name:"";return l("[Function"+v+"]","special")}if(o(e)&&0===d.length)return l(e.toUTCString(),"date");var g,y,w;if(r(e)?(y="Array",w=["[","]"]):(y="Object",w=["{","}"]),"function"==typeof e){var m=e.name?": "+e.name:"";g=i(e)?" "+e:" [Function"+m+"]"}else g="";if(o(e)&&(g=" "+e.toUTCString()),0===d.length)return w[0]+g+w[1];if(0>u)return i(e)?l(""+e,"regexp"):l("[Object]","special");p.push(e);var _=d.map(function(t){var n,i;if(e.__lookupGetter__&&(e.__lookupGetter__(t)?i=e.__lookupSetter__(t)?l("[Getter/Setter]","special"):l("[Getter]","special"):e.__lookupSetter__(t)&&(i=l("[Setter]","special"))),0>h.indexOf(t)&&(n="["+t+"]"),i||(0>p.indexOf(e[t])?(i=null===u?f(e[t]):f(e[t],u-1),i.indexOf("\n")>-1&&(i=r(e)?i.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+i.split("\n").map(function(e){return" "+e}).join("\n"))):i=l("[Circular]","special")),n===void 0){if("Array"===y&&t.match(/^\d+$/))return i;n=JSON.stringify(""+t),n.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(n=n.substr(1,n.length-2),n=l(n,"name")):(n=n.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),n=l(n,"string"))}return n+": "+i});p.pop();var b=0,S=_.reduce(function(e,t){return b++,t.indexOf("\n")>=0&&b++,e+t.length+1},0);return _=S>50?w[0]+(""===g?"":g+"\n ")+" "+_.join(",\n ")+" "+w[1]:w[0]+g+" "+_.join(", ")+" "+w[1]}var p=[],l=function(e,t){var n={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},r={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[t];return r?"["+n[r][0]+"m"+e+"["+n[r][1]+"m":e};return c||(l=function(e){return e}),f(e,u===void 0?2:u)},n.log=function(){},n.pump=null;var s=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t},a=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.hasOwnProperty.call(e,n)&&t.push(n);return t},u=Object.create||function(e,t){var n;if(null===e)n={__proto__:null};else{if("object"!=typeof e)throw new TypeError("typeof prototype["+typeof e+"] != 'object'");var r=function(){};r.prototype=e,n=new r,n.__proto__=e}return t!==void 0&&Object.defineProperties&&Object.defineProperties(n,t),n};n.inherits=function(e,t){e.super_=t,e.prototype=u(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})};var c=/%[sdj%]/g;n.format=function(e){if("string"!=typeof e){for(var t=[],r=0;arguments.length>r;r++)t.push(n.inspect(arguments[r]));return t.join(" ")}for(var r=1,i=arguments,o=i.length,s=(e+"").replace(c,function(e){if("%%"===e)return"%";if(r>=o)return e;switch(e){case"%s":return i[r++]+"";case"%d":return Number(i[r++]);case"%j":return JSON.stringify(i[r++]);default:return e}}),a=i[r];o>r;a=i[++r])s+=null===a||"object"!=typeof a?" "+a:" "+n.inspect(a);return s}},{events:4}],2:[function(e,t){e("util"),t.exports=function(e,t){function n(e){var n=e.length;if(0===n)return!1;for(;--n;){var r=Math.floor(t()*(n+1)),i=e[n],o=e[r];e[n]=o,e[r]=i}}this.reset=function(){this.cards=e.slice(0),this.length=this.cards.length},this.shuffle=function(){n(this.cards)},this.reset(),this.shuffle(),this.deal=function(e,t){for(var n=0;e>n;n++)for(var r=0;t.length>r;r++)t[r].push(this.cards.pop());this.length=this.cards.length},this.draw=function(e){if(!e||1>=e)return this.length=this.cards.length-1,this.cards.pop();for(var t=[],n=0;e>n;n++)t.push(this.cards.pop());return this.length=this.cards.length,t},this.drawFromBottomOfDeck=function(e){if(!e||1>=e)return this.cards.shift();for(var t=[],n=0;e>n;n++)t.push(this.cards.shift());return this.length=this.cards.length,t},this.drawRandom=function(e){var n=function(){var e=Math.floor(t()*this.cards.length),n=this.cards[e];return this.cards.splice(e,1),this.length=this.cards.length,n};if(!e||1>=e)return n.apply(this);for(var r=[],i=0;e>i;i++)r.push(n.apply(this));return r},this.putOnTopOfDeck=function(e){if(!e instanceof Array)this.cards.push(e);else for(var t=0;e.length>t;t++)this.cards.push(e[t]);this.length=this.cards.length},this.putOnBottomOfDeck=function(e){if(!e instanceof Array)this.cards.unshift(e);else for(var t=0;e.length>t;t++)this.cards.unshift(e[t]);this.length=this.cards.length}}},{util:1}],5:[function(e,t){var n=t.exports={};n.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){if(e.source===window&&"process-tick"===e.data&&(e.stopPropagation(),n.length>0)){var t=n.shift();t()}},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(){throw Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw Error("process.chdir is not supported")}},{}],4:[function(e,t,n){(function(e){function t(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;e.length>n;n++)if(t===e[n])return n;return-1}e.EventEmitter||(e.EventEmitter=function(){});var r=n.EventEmitter=e.EventEmitter,i="function"==typeof Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},o=10;r.prototype.setMaxListeners=function(e){this._events||(this._events={}),this._events.maxListeners=e},r.prototype.emit=function(e){if("error"===e&&(!this._events||!this._events.error||i(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var t=this._events[e];if(!t)return!1;if("function"==typeof t){switch(arguments.length){case 1:t.call(this);break;case 2:t.call(this,arguments[1]);break;case 3:t.call(this,arguments[1],arguments[2]);break;default:var n=Array.prototype.slice.call(arguments,1);t.apply(this,n)}return!0}if(i(t)){for(var n=Array.prototype.slice.call(arguments,1),r=t.slice(),o=0,s=r.length;s>o;o++)r[o].apply(this,n);return!0}return!1},r.prototype.addListener=function(e,t){if("function"!=typeof t)throw Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",e,t),this._events[e])if(i(this._events[e])){if(!this._events[e].warned){var n;n=void 0!==this._events.maxListeners?this._events.maxListeners:o,n&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),console.trace())}this._events[e].push(t)}else this._events[e]=[this._events[e],t];else this._events[e]=t;return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){var n=this;return n.on(e,function r(){n.removeListener(e,r),t.apply(this,arguments)}),this},r.prototype.removeListener=function(e,n){if("function"!=typeof n)throw Error("removeListener only takes instances of Function");if(!this._events||!this._events[e])return this;var r=this._events[e];if(i(r)){var o=t(r,n);if(0>o)return this;r.splice(o,1),0==r.length&&delete this._events[e]}else this._events[e]===n&&delete this._events[e];return this},r.prototype.removeAllListeners=function(e){return 0===arguments.length?(this._events={},this):(e&&this._events&&this._events[e]&&(this._events[e]=null),this)},r.prototype.listeners=function(e){return this._events||(this._events={}),this._events[e]||(this._events[e]=[]),i(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]}})(e("__browserify_process"))},{__browserify_process:5}],3:[function(e,t){var n=e("./playingCard");t.exports=function(){this.cards=[new n("Club","Two",2),new n("Club","Three",3),new n("Club","Four",4),new n("Club","Five",5),new n("Club","Six",6),new n("Club","Seven",7),new n("Club","Eight",8),new n("Club","Nine",9),new n("Club","Ten",10),new n("Club","Jack",11),new n("Club","Queen",12),new n("Club","King",13),new n("Club","Ace",14),new n("Diamond","Two",2),new n("Diamond","Three",3),new n("Diamond","Four",4),new n("Diamond","Five",5),new n("Diamond","Six",6),new n("Diamond","Seven",7),new n("Diamond","Eight",8),new n("Diamond","Nine",9),new n("Diamond","Ten",10),new n("Diamond","Jack",11),new n("Diamond","Queen",12),new n("Diamond","King",13),new n("Diamond","Ace",14),new n("Heart","Two",2),new n("Heart","Three",3),new n("Heart","Four",4),new n("Heart","Five",5),new n("Heart","Six",6),new n("Heart","Seven",7),new n("Heart","Eight",8),new n("Heart","Nine",9),new n("Heart","Ten",10),new n("Heart","Jack",11),new n("Heart","Queen",12),new n("Heart","King",13),new n("Heart","Ace",14),new n("Spade","Two",2),new n("Spade","Three",3),new n("Spade","Four",4),new n("Spade","Five",5),new n("Spade","Six",6),new n("Spade","Seven",7),new n("Spade","Eight",8),new n("Spade","Nine",9),new n("Spade","Ten",10),new n("Spade","Jack",11),new n("Spade","Queen",12),new n("Spade","King",13),new n("Spade","Ace",14)]}},{"./playingCard":6}],6:[function(e,t){t.exports=function(e,t,n){this.suit=e,this.description=t,this.sort=n,this.toString=function(){return this.description+" of "+this.suit+"s"},this.toShortDisplayString=function(){var e,t=this.suit.substring(0,1);switch(this.sort){case 11:e="J";break;case 12:e="Q";break;case 13:e="K";break;case 14:e="A";break;default:e=this.sort}return e+t}}},{}]},{},[]);var Shuffle=require("shuffle"),deckConfig={Knight:{description:"Move the robber, and steal a card from whomever borders the new robber location.",count:14},"Progress - Year of Plenty":{description:"Immediately gain two resource cards of any type",count:2},"Progress - Monopoly":{description:"",count:2},"Progress - Road Building":{description:"",count:2},"Victory Point - Chapel":{display:"Chapel",description:"Gain one victory point immediately",count:1},"Victory Point - Library":{display:"Library",description:"Gain one victory point immediately",count:1},"Victory Point - Marketplace":{display:"Marketplace",description:"Gain one victory point immediately",count:1},"Victory Point - Palace":{display:"Palace",description:"Gain one victory point immediately",count:1},"Victory Point - University":{display:"University",description:"Gain one victory point immediately",count:1}},deck=Shuffle.shuffle({deck:expand(deckConfig)});
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; }
body, html { height: 100%; width: 100%; }</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment