SharkGame.PlayerResources={},SharkGame.PlayerIncomeTable={},SharkGame.Resources={INCOME_COLOR:"#808080",TOTAL_INCOME_COLOR:"#A0A0A0",UPGRADE_MULTIPLIER_COLOR:"#606060",BOOST_MULTIPLIER_COLOR:"#60A060",WORLD_MULTIPLIER_COLOR:"#6060A0",ARTIFACT_MULTIPLIER_COLOR:"#6F968A",specialMultiplier:null,rebuildTable:!1,init:function(){$.each(SharkGame.ResourceTable,(function(e,a){SharkGame.PlayerResources[e]={},SharkGame.PlayerResources[e].amount=0,SharkGame.PlayerResources[e].totalAmount=0,SharkGame.PlayerResources[e].incomeMultiplier=1})),$.each(SharkGame.ResourceTable,(function(e,a){SharkGame.PlayerIncomeTable[e]=0})),SharkGame.Resources.specialMultiplier=1},processIncomes:function(e){$.each(SharkGame.PlayerIncomeTable,(function(a,r){SharkGame.Resources.changeResource(a,r*e)}))},recalculateIncomeTable:function(e){var a=SharkGame.Resources,r=SharkGame.World;$.each(SharkGame.ResourceTable,(function(e,a){SharkGame.PlayerIncomeTable[e]=0}));var o=r.worldResources;$.each(SharkGame.ResourceTable,(function(e,r){var c=o[e];if(c.exists){SharkGame.PlayerResources[e];if(r.income){c&&c.incomeMultiplier;var t=1;r.forceIncome||$.each(r.income,(function(r,o){var c=a.getProductAmountFromGeneratorResource(e,r);if(c<0){var u=a.getResource(r);if(u+c<=0){var n=u/-c;t=n>=0&&n<1?Math.min(t,n):0}}})),$.each(r.income,(function(r,o){var c=a.getProductAmountFromGeneratorResource(e,r,t);SharkGame.World.doesResourceExist(r)&&(SharkGame.PlayerIncomeTable[r]+=c)}))}if(c){var u=c.income,n=o[e].boostMultiplier;SharkGame.PlayerIncomeTable[e]+=u*n*a.getSpecialMultiplier()}}}))},getProductAmountFromGeneratorResource:function(e,a,r){var o=SharkGame.Resources,c=SharkGame.World,t=SharkGame.PlayerResources[e];return"number"!=typeof r&&(r=1),SharkGame.ResourceTable[e].income[a]*o.getResource(e)*r*t.incomeMultiplier*c.getWorldIncomeMultiplier(e)*c.getWorldBoostMultiplier(a)*c.getArtifactMultiplier(e)*o.getSpecialMultiplier()},getSpecialMultiplier:function(){return Math.max(10*SharkGame.Resources.getResource("numen"),1)*SharkGame.Resources.specialMultiplier},getIncome:function(e){return SharkGame.PlayerIncomeTable[e]},getMultiplier:function(e){return SharkGame.PlayerResources[e].incomeMultiplier},setMultiplier:function(e,a){SharkGame.PlayerResources[e].incomeMultiplier=a,SharkGame.Resources.recalculateIncomeTable()},changeResource:function(e,a){if(!(Math.abs(a)0&&(r.totalAmount+=a),o0&&SharkGame.World.doesResourceExist(r)})),a},getCategoryOfResource:function(e){var a="";return $.each(SharkGame.ResourceCategories,(function(r,o){""===a&&$.each(o.resources,(function(o,c){""===a&&e==c&&(a=r)}))})),a},getResourcesInCategory:function(e){var a=[];return $.each(SharkGame.ResourceCategories[e].resources,(function(e,r){a.push(r)})),a},isCategory:function(e){return!(void 0===SharkGame.ResourceCategories[e])},isInCategory:function(e,a){return-1!==SharkGame.ResourceCategories[a].resources.indexOf(e)},getBaseOfResource:function(e){var a=null;return $.each(SharkGame.ResourceTable,(function(r,o){a||o.jobs&&$.each(o.jobs,(function(o,c){a||c===e&&(a=r)}))})),a},haveAnyResources:function(){var e=!1;return $.each(SharkGame.PlayerResources,(function(a,r){e||(e=r.totalAmount>0)})),e},checkResources:function(e,a){var r=!0;return $.each(SharkGame.ResourceTable,(function(o,c){var t;t=a?SharkGame.Resources.getTotalResource(o):SharkGame.Resources.getResource(o);var u=e[o];void 0===u&&(u=0),tSharkGame.EPSILON){var t=c>0?"+":"";$("#income-"+r).html(""+t+e.beautify(c)+"/s")}else $("#income-"+r).html("")}))},reconstructResourcesTable:function(){var e=$("#resourceTable"),a=(SharkGame.Main,SharkGame.Resources),r=SharkGame.World,o=$("#status");if(e.length<=0){o.prepend("

Stuff

");var c=$("
").attr("id","resourceTableContainer");c.append($("").attr("id","resourceTable")),o.append(c),e=$("#resourceTable")}e.empty();var t=!1;SharkGame.Settings.current.groupResources?$.each(SharkGame.ResourceCategories,(function(r,o){if(a.isCategoryVisible(o)){var c=$("").append($("");if(c.totalAmount>0){u.append($("
").attr("colSpan",3).append($("

").html(o.name)));e.append(c),$.each(o.resources,(function(r,o){if(a.getTotalResource(o)>0){var c=a.constructResourceTableRow(o);e.append(c),t=!0}}))}})):$.each(SharkGame.ResourceTable,(function(o,c){if(a.getTotalResource(o)>0&&r.doesResourceExist(o)){var u=a.constructResourceTableRow(o);e.append(u),t=!0}})),t?o.show():o.hide(),a.rebuildTable=!1},constructResourceTableRow:function(e){var a=SharkGame.Main,r=SharkGame.Resources,o=e,c=(SharkGame.ResourceTable[o],SharkGame.PlayerResources[o]),t=r.getIncome(o),u=$("

").attr("id","resource-"+o).html(SharkGame.Resources.getResourceName(o))),u.append($("").attr("id","amount-"+o).html(a.beautify(c.amount)));var n=$("").attr("id","income-"+o);if(u.append(n),Math.abs(t)>SharkGame.EPSILON){var s=t>0?"+":"";n.html(""+s+a.beautify(t)+"/s")}}return u},getResourceName:function(e,a,r){var o=SharkGame.ResourceTable[e],c=Math.floor(SharkGame.PlayerResources[e].amount)-1"+c+""}return c},resourceListToString:function(e,a){if($.isEmptyObject(e))return"";var r="";return $.each(SharkGame.ResourceTable,(function(o,c){var t=e[o];if(t>0&&SharkGame.World.doesResourceExist(o)){var u=Math.floor(t)-10&&a.income.push(r))})),$.each(SharkGame.HomeActions,(function(r,o){var c=o.effect.resource;c&&c[e]>0&&a.actions.push(r)})),a},giveMeSomeOfEverything:function(e){$.each(SharkGame.ResourceTable,(function(a,r){SharkGame.Resources.changeResource(a,e)}))},getResourceDependencyChains:function(e,a){var r=SharkGame.Resources,o=SharkGame.World,c=[];a||(a=[]);var t=r.getResourceSources(e);return $.each(t.actions,(function(e,r){var t=SharkGame.HomeActions[r].cost;$.each(t,(function(e,r){var t=r.resource;o.doesResourceExist(t)&&(c.push(t),a.push(t))}))})),$.each(t.income,(function(e,t){o.doesResourceExist(t)&&-1===a.indexOf(t)&&c.push(r.getResourceDependencyChains(t,a))})),c}};