dnd-exchange-rate
Version:
dungeons and dragons 5e coin conversion calculator
1 lines • 2.9 kB
JavaScript
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ExchangeRate=e()}}(function(){return function l(i,o,f){function p(r,e){if(!o[r]){if(!i[r]){var t="function"==typeof require&&require;if(!e&&t)return t(r,!0);if(u)return u(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var a=o[r]={exports:{}};i[r][0].call(a.exports,function(e){return p(i[r][1][e]||e)},a,a.exports,l,i,o,f)}return o[r].exports}for(var u="function"==typeof require&&require,e=0;e<f.length;e++)p(f[e]);return p}({1:[function(e,r,t){var n,a,b,s,g,o,i,v,d=(n={Client:{coin:{pp:{cp:{rate:1e3,label:"1000"},sp:{rate:100,label:"100"},ep:{rate:20,label:"20"},gp:{rate:10,label:"10"},pp:{rate:1,label:"1"}},gp:{cp:{rate:100,label:"100"},sp:{rate:10,label:"10"},ep:{rate:2,label:"2"},gp:{rate:1,label:"1"},pp:{rate:.1,label:"1/10"}},ep:{cp:{rate:50,label:"50"},sp:{rate:5,label:"5"},ep:{rate:1,label:"1"},gp:{rate:.5,label:"1/2"},pp:{rate:.05,label:"1/20"}},sp:{cp:{rate:10,label:"10"},sp:{rate:1,label:"1"},ep:{rate:.2,label:"1/5"},gp:{rate:.1,label:"1/10"},pp:{rate:.01,label:"1/100"}},cp:{cp:{rate:1,label:"1"},sp:{rate:.1,label:"1/10"},ep:{rate:.02,label:"1/50"},gp:{rate:.01,label:"1/100"},pp:{rate:.001,label:"1/1000"}}}}},(a={}).get=function(e){return function(e,r){for(var t=(r=(r=r.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),n=0,a=t.length;n<a;++n){var l=t[n];if(!(l in e))return;e=e[l]}return e}(n,e)},a),l=(b=function(e){return!isNaN(e)&&parseInt(Number(e))==e&&!isNaN(parseInt(e,10))},s=function(e){var r={};for(var t in d.get("Client.coin"))b(e[t])?r[t]=parseInt(e[t]):r[t]=0;return r},g=function(e,r,t){return r*d.get("Client.coin."+t+"."+e+".rate")},o=function(e,r,t){var n;return r%((n=d.get("Client.coin."+t+"."+e+".label")).includes("/")?parseInt(n.split("/")[1]):1)},i=function(e,r,t,n){var a=e;for(var l in d.get("Client.coin"))if(!(0<n.length&&-1==n.indexOf(l))){if(r===l)return void(t[r]+=a);var i=Math.floor(g(l,a,r));a=o(l,a,r),t[l]+=i}},{optimalExchange:v=function(e,r){null!=r&&null!=r||(r=[]);var t={};for(var n in d.get("Client.coin"))t[n]=0;var a=s(e);for(var l in a)0<a[l]&&i(a[l],l,t,r);return t},teamSplit:function(e,r,t){if(null!=t&&null!=t||(t=[]),b(e)&&e<=1)return[v(r)];for(var n=[],a=0;a<e;a++){var l={};for(var i in d.get("Client.coin"))l[i]=0;n.push(l)}var o=s(r),f=0,p=null;for(var i in d.get("Client.coin")){if(0<f)if("cp"===p)o[i]+=f;else if(i!==p){var u=g(i,f,p);o[i]+=u}var c=Math.floor(o[i]/e);for(a=0;a<e;a++)n[a][i]+=c;if(f=o[i]%e,"cp"===(p=i)&&0<f)for(a=0;a<f;a++)n[a][p]+=1}for(a=0;a<n.length;a++)n[a]=v(n[a],t);return n}});r.exports=l},{}],2:[function(e,r,t){r.exports=e("./exchange-rate")},{"./exchange-rate":1}]},{},[2])(2)});