From 4f6105590978ec3917e2f6f4f3a1350bcbea1448 Mon Sep 17 00:00:00 2001 From: jorsi Date: Tue, 2 Jun 2020 10:44:00 -0400 Subject: [PATCH] add enable god mode function --- script/engine.js | 111 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/script/engine.js b/script/engine.js index a994d30..1a9d870 100644 --- a/script/engine.js +++ b/script/engine.js @@ -823,6 +823,117 @@ return setTimeout(callback, timeout); + }, + + enableGodMode: function() { + // open up all section + if(!Outside.tab) { + Outside.init(); + } + + if(!Path.tab) { + Path.init(); + } + + if(!Ship.tab) { + Ship.init(); + } + + // add all remaining craftables and goods + var buildSection = $('#buildBtns'); + if (buildSection.length === 0) { + buildSection = $('
').attr({ 'id': 'buildBtns', 'data-legend': _('build:') }).css('opacity', 0); + buildSection.appendTo('div#roomPanel').animate({ opacity: 1 }, 300, 'linear'); + } + var craftSection = $('#craftBtns'); + if (craftSection.length === 0) { + craftSection = $('
').attr({ 'id': 'craftBtns', 'data-legend': _('craft:') }).css('opacity', 0); + craftSection.appendTo('div#roomPanel').animate({ opacity: 1 }, 300, 'linear'); + } + + var buySection = $('#buyBtns'); + if (buySection.length === 0) { + buySection = $('
').attr({ 'id': 'buyBtns', 'data-legend': _('buy:') }).css('opacity', 0); + buySection.appendTo('div#roomPanel').animate({ opacity: 1 }, 300, 'linear'); + } + + for (var k in Room.Craftables) { + craftable = Room.Craftables[k]; + if (craftable.button == null) { + var loc = Room.needsWorkshop(craftable.type) ? craftSection : buildSection; + craftable.button = new Button.Button({ + id: 'build_' + k, + cost: craftable.cost(), + text: _(k), + click: Room.build, + width: '80px', + ttPos: loc.children().length > 10 ? 'top right' : 'bottom right' + }).css('opacity', 0).attr('buildThing', k).appendTo(loc).animate({ opacity: 1 }, 300, 'linear'); + } + + var max = $SM.num(k, craftable) + 1 > craftable.maximum; + if (max) { + Button.setDisabled(craftable.button, true); + } else { + Button.setDisabled(craftable.button, false); + } + } + + for (var g in Room.TradeGoods) { + good = Room.TradeGoods[g]; + if (good.button == null) { + good.button = new Button.Button({ + id: 'build_' + g, + cost: good.cost(), + text: _(g), + click: Room.buy, + width: '80px', + ttPos: buySection.children().length > 10 ? 'top right' : 'bottom right' + }).css('opacity', 0).attr('buildThing', g).appendTo(buySection).animate({ opacity: 1 }, 300, 'linear'); + } + + var goodsMax = $SM.num(g, good) + 1 > good.maximum; + if (goodsMax) { + Button.setDisabled(good.button, true); + } else { + Button.setDisabled(good.button, false); + } + } + + // remove all cooldowns + $('.button').each(function (i, el) { + $(el).off('click'); + $(el).click(function() { + $(this).data("handler")($(this)); + }) + }); + + // set water/health + Path.DEFAULT_BAG_SPACE = 1000; + World.BASE_WATER = 1000; + World.BASE_HEALTH = 1000; + World.setHp(1000); + + // add all perks + for (var key in Engine.Perks) { + $SM.addPerk(key); + } + + // give 100000 of all stores + Prestige.storesMap.forEach(function (e) { + State.stores[e.store] = 100000; + }); + for (var key in Room.TradeGoods) { + State.stores[key] = 100000; + } + + // set world map mask to reveal entire map + for(var j = 0; j <= World.RADIUS * 2; j++) { + for(var i = 0; i <= World.RADIUS * 2; i++) { + State.game.world.mask[i][j] = true; + } + } + } };