var M={}; M.parent=Game.Objects['Bank']; M.parent.minigame=M; M.launch=function() { var M=this; M.name=M.parent.minigameName; M.init=function(div) { //populate div with html and initialize values M.goods={ 'Farm':{ name:'Cereals', symbol:'CRL', company:'Old Mills', desc:'Old Mills is a trusted staple of the grain industry. Finding their roots in humble pioneer farms centuries ago and honing their know-how ever since, the Old Mills organic crops have reached a standard of quality that even yours struggle to equal.', }, 'Mine':{ name:'Chocolate', symbol:'CHC', company:'Cocoa Excavations', desc:'Cocoa Excavations is an international chocolate mining venture whose extraction sites always seem, somehow, to pop up in war-torn countries. Their high-grade chocolate is renowned the world over and has even been marketed, to some success, as suitable gems for engagement rings.', }, 'Factory':{ name:'Butter', symbol:'BTR', company:'Bovine Industries', desc:'Bovine Industries is a formerly-agricultural conglomerate that now deals in mechanized dairy mass production. Whistleblowers have drawn attention to the way the milk cows employed by this company are treated, describing it as "not quite cruel or anything, but definitely unusual".', }, 'Bank':{ name:'Sugar', symbol:'SUG', company:'Candy Trust', desc:'The Candy Trust is a corporate banking group backed by, and specialized in, the trade of high-grade sugar. The origin of said sugar is legally protected by an armada of lawyers, though some suspect they secretly scrape it off of the bank bills coming in before processing it.', }, 'Temple':{ name:'Nuts', symbol:'NUT', company:'Hazel Monastery', desc:'Hidden between hills and fog somewhere, the secretive Hazel Monastery has, for centuries, maintained nut crops of the highest quality. The monastery nuts are carefully tended to, harvested and shelled by its monks, who are all required to take a vow of nut allergy as a lifelong test of piety.', }, 'Wizard tower':{ name:'Salt', symbol:'SLT', company:'Wacky Reagants', desc:'Salt is a versatile substance, with properties both mundane and mystical. This is why the bearded crackpots at Wacky Reagants have perfected the art of turning magic powder into salt, which is then sold to anyone promising to put it to good use - whether it be warding off banshees and ghouls or seasoning a Sunday roast.', }, 'Shipment':{ name:'Vanilla', symbol:'VNL', company:'Cosmic Exports', desc:'After the news broke of vanilla not being native to Earth, Cosmic Exports was the first company to discover its true origin planet - and has struck an exclusive deal with its tentacled inhabitants to ship its valuable, unadulterated beans all over the local quadrant.', }, 'Alchemy lab':{ name:'Eggs', symbol:'EGG', company:'Organic Gnostics', desc:'At Organic Gnostics, an egg is seen as a promise. A promise of life and nourishment, of infinite potential, of calcium and protein. An egg can become many things... especially when you\'re properly funded and don\'t believe there\'s room in science for rules or ethics.', }, 'Portal':{ name:'Cinnamon', symbol:'CNM', company:'Dimensional Exchange', desc:'The Dimensional Exchange employs a vast team of ragtag daredevils to dive into dangerous underworlds in search of strange native spices. Chief among those is cinnamon, a powder so delicious its true nature can only be unspeakably abominable.', }, 'Time machine':{ name:'Cream', symbol:'CRM', company:'Precision Aging', desc:'Once specialized in cosmetics for the elderly, the eggheads at Precision Aging have repurposed their timeshift technology and developed a process allowing them to accelerate, slow down, and even reverse the various phase changes of milk. Their flagship offering, whole cream, is said to be within 0.002% of theoretical ripening optimums.', }, 'Antimatter condenser':{ name:'Jam', symbol:'JAM', company:'Pectin Research', desc:'Pectin Research is a military-backed laboratory initially created with the aim of enhancing and miniaturizing army rations, but now open for public bulk trading. It has recently made forays in the field of highly-concentrated fruit jams, available in a variety of flavors.', }, 'Prism':{ name:'White chocolate', symbol:'WCH', company:'Dazzle Corp Ltd.', desc:'What was once two college kids messing around with mirrors in their dad\'s garage is now a world-famous megacorporation. Dazzle Corp\'s groundbreaking experiments in photonic annealing have led to the creation years ago of a new kind of matter, once derided as impossible by physicists and cooks alike: white chocolate.', }, 'Chancemaker':{ name:'Honey', symbol:'HNY', company:'Prosperity Hive', desc:'The folks at Prosperity Hive deal in honey, and it\'s always worked for them. With a work culture so relaxed you\'re almost tempted to ditch the cookie business and join them, these people have little in common with the proverbial busy bee - though their rates do sting quite a bit.', }, 'Fractal engine':{ name:'Cookies', symbol:'CKI', company:'Selfmade Bakeries', desc:'Interesting. It appears there\'s still a company out there trying to sell cookies even with your stranglehold on the market. No matter - you figure Selfmade Bakeries\' largely inferior product will make decent fodder for the mouse traps in your factories.', }, 'Javascript console':{ name:'Recipes', symbol:'RCP', company:'Figments Associated', desc:'In a post-material world, the market of ideas is where value is created. Figments Associated understands that, and is the prime designer (and patenter) of baking recipes, ingredient nomenclature, custom cooking procedures, and other kitchen processes.', }, 'Idleverse':{ name:'Subsidiaries', symbol:'SBD', company:'Polyvalent Acquisitions', desc:'Avoid the uncouth nastiness of mass layoffs and hostile takeovers by delegating the purchase, management, and eventual dissolution of other companies to the boys at Polyvalent Acquisitions. Let \'em deal with it!', }, 'Cortex baker':{ name:'Publicists', symbol:'PBL', company:'Great Minds', desc:'Get those juices flowing: from market research to advertising, the think tanks at Great Minds will lend their talents to the highest bidder. It\'s intellectual property on tap.', }, 'You':{ name:'%1', symbol:'YOU', company:'%1\'s Bakery', desc:'That\'s right! Your transcendental business skills are so influential, so universally resounding, that you\'ve become a publicly traded good yourself - you\'re the best %1\'s Bakery has to offer. Don\'t disappoint your shareholders, there\'s a price on your head! Invest in yourself NOW!', }, }; M.goodsById=[];var n=0; for (var i in M.goods){var it=M.goods[i];it.id=n;it.hidden=false;it.active=false;it.last=0;it.building=Game.Objects[i];it.stock=0;it.mode=0;it.dur=0;it.prev=0;it.val=1;it.vals=[it.val];it.d=0;M.goodsById[n]=it;it.icon=[it.building.iconColumn,33];it.name=loc(FindLocStringByPart('STOCK '+(it.id+1)+' TYPE'));it.company=loc(FindLocStringByPart('STOCK '+(it.id+1)+' NAME'));it.symbol=loc(FindLocStringByPart('STOCK '+(it.id+1)+' LOGO'));n++;} M.goodTooltip=function(id) { return function(){ var me=M.goodsById[id]; var delta=M.goodDelta(id); var val=M.getGoodPrice(me) icon=me.icon||[0,0]; var name=me.name.replace('%1',Game.bakeryName); var str='
'+ '
'+ '
'+name+' ('+loc("from %1",''+me.company.replace('%1',Game.bakeryName)+'')+') '+me.symbol+' '+(delta+''+(delta==Math.floor(delta)?'.00':(delta*10)==Math.floor(delta*10)?'0':'')+'%')+'
'+ '
'+(EN?'
'+ ''+me.desc.replace('%1',Game.bakeryName)+''+ '
':'')+'
'+loc("%1: currently worth $%2 per unit.",[name,Beautify(val,2)])+'
• '+loc("You currently own %1 (worth $%2).",['
'+Beautify(me.stock)+'x '+name,Beautify(val*me.stock,2)])+'
• '+loc("Your warehouses can store up to %1.",'
'+Beautify(M.getGoodMaxStock(me))+'x '+name)+'
• '+loc("You may increase your storage space by upgrading your offices and by buying more %1. You also get %2 extra storage space per %3 level (currently: +%4).",['
'+me.building.plural,10,me.building.single,(me.building.level*10)])+'
• '+loc("The average worth of this stock and how high it can peak depends on the building it is tied to, along with the level of your %1.",'
'+Game.Objects['Bank'].plural)+'
'+ '
'+loc("%1 the hide button to toggle all other stocks.",loc("Shift-click"))+'
'+ '
'; return str; }; } M.tradeTooltip=function(id,n) { return function(){ var me=M.goodsById[id]; var icon=me.icon||[0,0]; var val=M.getGoodPrice(me) var cost=Game.cookiesPsRawHighest*val; var buyOrSell=n>0; var overhead=1; var stock=me.stock; var maxStock=M.getGoodMaxStock(me); if (buyOrSell) overhead*=1+0.01*(20*Math.pow(0.95,M.brokers)); cost*=overhead; if (n==10000) n=Math.floor(Game.cookies/cost); else if (n==-10000) n=me.stock; n=Math.abs(n); if (buyOrSell) n=Math.min(n,maxStock-stock); if (!buyOrSell) n=Math.min(n,stock); var str='
'+ '
'+cap(loc("stock:"))+' '+Beautify(stock)+'/=maxStock)?' class="red"':'')+'>'+Beautify(maxStock)+'
'+ (me.prev?('
'+ '
'+loc("last bought at
$%1 each",Beautify(me.prev,2))+'
'):'')+ '
'+ '
'+(buyOrSell?loc("Buy"):loc("Sell"))+' '+Beautify(n)+'x
'+me.name.replace('%1',Game.bakeryName)+'
'+ '
'+loc("for $%1 each",Beautify(val,2))+'
'+ (overhead>1?('
('+loc("+%1% overhead",Beautify((overhead-1)*100,2))+')
'):'')+ '
'+ '
'+(buyOrSell?loc("you spend:"):loc("you earn:"))+'
'+ '
'+Beautify(cost*n)+'
'+ (n>0?('
($'+Beautify(val*overhead*n,2)+')
'+ '
('+loc("%1 of CpS",Game.sayTime(val*overhead*n*Game.fps,-1))+')
'):'')+ (((me.last==1 && !buyOrSell) || (me.last==2 && buyOrSell))?'
'+loc("You cannot buy and sell this stock in the same tick.")+'
':'')+ '
'; return str; }; } M.goodDelta=function(id,back)//if back is 0 we get the current step; else get current step -back { var back=back||0; var me=M.goodsById[id]; var val=0; if (me.vals.length>=(2+back)) { val=me.vals[0+back]/me.vals[1+back]-1; } val=Math.floor(val*10000)/100; return val; } M.getGoodMaxStock=function(good) { var bonus=0; if (M.officeLevel>0) bonus+=25; if (M.officeLevel>1) bonus+=50; if (M.officeLevel>2) bonus+=75; if (M.officeLevel>3) bonus+=100; return Math.ceil(good.building.highest*(M.officeLevel>4?1.5:1)+bonus+good.building.level*10); } M.getGoodPrice=function(good) { return good.val; } M.buyGood=function(id,n) { var me=M.goodsById[id]; var costInS=M.getGoodPrice(me); var cost=Game.cookiesPsRawHighest*costInS; var overhead=1+0.01*(20*Math.pow(0.95,M.brokers)); cost*=overhead; if (n==10000) n=Math.floor(Game.cookies/cost); n=Math.min(n,M.getGoodMaxStock(me)-me.stock); if (n>0 && me.last!=2 && Game.cookies>=cost*n && me.stock+n<=M.getGoodMaxStock(me)) { if (costInS*overhead*n>=86400) Game.Win('Buy buy buy'); M.profit-=costInS*overhead*n; Game.Spend(cost*n); me.stock+=n; var min=10000; for (var i=0;i=1000) Game.Win('Full warehouses'); } if (min>=100) Game.Win('Rookie numbers'); if (min>=500) Game.Win('No nobility in poverty'); me.last=1; me.prev=costInS; PlaySound('snd/cashOut.mp3',0.4); return true; } return false; } M.sellGood=function(id,n) { var me=M.goodsById[id]; if (n==10000) n=me.stock; n=Math.min(n,me.stock); if (n>0 && me.last!=1 && me.stock>0) { var costInS=M.getGoodPrice(me); if (costInS*n>=86400) Game.Win('Make my day'); M.profit+=costInS*n; if (M.profit>0) Game.Win('Initial public offering'); if (M.profit>=10000000) Game.Win('Liquid assets'); if (M.profit>=31536000) Game.Win('Gaseous assets'); //Game.Earn(Game.cookiesPsRawHighest*costInS*n); Game.cookies+=Game.cookiesPsRawHighest*costInS*n; Game.cookiesEarned=Math.max(Game.cookies,Game.cookiesEarned); me.stock-=n; me.last=2; PlaySound('snd/cashIn.mp3',0.4); return true; } return false; } M.getRestingVal=function(id) { return 10+10*id+(Game.Objects['Bank'].level-1); } M.updateGoodStyle=function(id) { var me=M.goodsById[id]; if (me.active) { me.l.style.display='inline-block'; if (!me.hidden) { me.l.classList.remove('bankHidden'); me.graphIconL.style.display='block'; } else { me.l.classList.add('bankHidden'); me.graphIconL.style.display='none'; } } else { me.l.style.display='none'; me.graphIconL.style.display='none'; } } M.officeLevel=0; M.offices=[ {name:loc("Credit garage"),icon:[0,33],cost:[100,2],desc:EN?"This is your starting office.":loc("This is your office.")+'
'+loc("Upgrading will grant you:")+'
• '+loc("+%1 warehouse space for all goods",25)+''}, {name:loc("Tiny bank"),icon:[9,33],cost:[200,4],desc:loc("This is your office.")+'
'+loc("Upgrading will grant you:")+'
• '+loc("+1 loan slot")+'
• '+loc("+%1 warehouse space for all goods",50)+'
'}, {name:loc("Loaning company"),icon:[10,33],cost:[350,8],desc:loc("This is your office.")+'
'+loc("Upgrading will grant you:")+'
• '+loc("+%1 warehouse space for all goods",75)+''}, {name:loc("Finance headquarters"),icon:[11,33],cost:[500,10],desc:loc("This is your office.")+'
'+loc("Upgrading will grant you:")+'
• '+loc("+1 loan slot")+'
• '+loc("+%1 warehouse space for all goods",100)+'
'}, {name:loc("International exchange"),icon:[12,33],cost:[700,12],desc:loc("This is your office.")+'
'+loc("Upgrading will grant you:")+'
• '+loc("+1 loan slot")+'
• '+loc("+%1% base warehouse space for all goods",50)+'
'}, {name:loc("Palace of Greed"),icon:[18,33],cost:0,desc:loc("This is your office.")+'
'+loc("It is fully upgraded. Its lavish interiors, spanning across innumerable floors, are host to many a decadent party, owing to your nigh-unfathomable wealth.")}, ]; M.officeTooltip=function() { return function(){ var me=M.offices[M.officeLevel]; var icon=me.icon||[0,0]; var str='
'+ '
'+ '
'+me.name+' ['+loc("Level %1 offices",M.officeLevel+1)+']
'+ '
'+ me.desc+ '
'+ (me.cost?('
'+ '
'+ loc("Upgrading will cost you %1.",''+me.cost[0]+' '+Game.Objects['Cursor'].plural+'')+'
'+ loc("Upgrading requires %1.",''+loc("Level %1 %2",[me.cost[1],Game.Objects['Cursor'].plural])+'')+ '
'):'')+ '
'; return str; }; } M.brokers=0; M.getMaxBrokers=function(){return Math.ceil(Game.Objects['Grandma'].highest/10+Game.Objects['Grandma'].level);} M.getBrokerPrice=function(){return Game.cookiesPsRawHighest*60*20;} M.brokersTooltip=function() { return function(){ var icon=[1,33]; var str='
'+ '
'+ '
'+(EN?('Stockbrokers (you have '+Beautify(M.brokers)+')'):(loc("Brokers:")+' '+Beautify(M.brokers)))+'
'+ '
'+ loc("A nice broker to trade more cookies.")+'
'+ '• '+loc("Buying goods normally incurs overhead costs of %1% extra. Each broker you hire reduces that cost by %2%.",[20,5])+'
'+ '• '+loc("Current overhead costs thanks to your brokers: +%1%",Beautify(20*Math.pow(0.95,M.brokers),2))+'
'+ '• '+loc("Buying a broker costs %1 of CpS (that's $%2).",[''+loc("%1 minute",LBeautify(20))+'',1200])+'
'+ '• '+loc("Maximum number of brokers you can own: %1 (the highest amount of grandmas you've owned this run, divided by 10, plus your grandma level)",''+Beautify(M.getMaxBrokers())+'')+'
'+ ''+loc("Brokers are Wall Street-class grandmas versed in the ways of finance. Stockbroker grandmas work hard and play hard, and will fight telephone in hand to get your clients the best possible deals - with a sizeable profit margin for you, of course.")+''+ '
'+ loc("Hiring a new broker will cost you %1.",''+loc("%1 cookie",LBeautify(M.getBrokerPrice()))+'')+ '
'+ '
'+ '
'; return str; }; } M.loanTypes=[ //name, mult, duration, payback mult, duration, downpayment (as % of bank), quote [loc("a modest loan"),1.5,60*2,0.25,60*4,0.2,loc("Buy that vintage car you've always wanted. Just pay us back.")], [loc("a pawnshop loan"),2,0.67,0.1,40,0.4,loc("Bad credit? No problem. It's your money, and you need it now.")], [loc("a retirement loan"),1.2,60*24*2,0.8,60*24*5,0.5,loc("Finance your next house, boat, spouse, etc. You've earned it.")], ]; M.loanTooltip=function(id) { return function(){ var loan=M.loanTypes[id-1]; var str='
'+ '
'+loc("Take out %1",loan[0])+'
'+ '
'+ loc("By taking this loan, you will get %1 CpS for the next %2.",['+'+Math.round((loan[1]-1)*100)+'%',''+Game.sayTime(60*loan[2]*Game.fps)+''])+'
'+ loc("However, you will get %1 CpS for the next %2 after that.",[''+Math.round((loan[3]-1)*100)+'%',''+Game.sayTime(60*loan[4]*Game.fps)+''])+ loc("You must also pay an immediate downpayment of %1 (%2% of your current bank).",[''+Beautify(Game.cookies*loan[5])+'',(loan[5]*100)])+ ''+loan[6]+''+ '
'; return str; }; } M.takeLoan=function(id,interest) { var loan=M.loanTypes[id-1]; if (!interest) { if (Game.hasBuff('Loan '+id) || Game.hasBuff('Loan '+id+' (interest)')) return false; Game.Spend(Game.cookies*loan[5]); Game.gainBuff('loan '+id,loan[2]*60,loan[1]); } else { Game.gainBuff('loan '+id+' interest',loan[4]*60,loan[3]); Game.Notify(loc("Loan over"),loc("Your loan has expired, and you must now repay the interest."),[1,33]); } return true; } Game.takeLoan=M.takeLoan; M.getOppSlots=function() { var slots=0; if (M.officeLevel>0) slots++; if (M.officeLevel>2) slots++; if (M.officeLevel>4) slots++; return slots; } //note: opportunity system to be added later maybe M.oppTooltip=function() { return function(){ var str='
'+ '
Generate opportunity
'+ '
'+ 'Pressing this button gives you up to 3 possible actions to choose from, depending on your office level.
These actions will let you manipulate the stock market to some degree, though some are riskier than others.
You may only generate an opportunity once an hour, though this can be refreshed with a sugar lump.'+ '
'; return str; }; } M.refillTooltip=function(){ return '
'+loc("Click to refill your opportunity timer (and give a quick burst to your economy) for %1.",''+loc("%1 sugar lump",LBeautify(1))+'')+ (Game.canRefillLump()?'
('+loc("can be done once every %1",Game.sayTime(Game.getLumpRefillMax(),-1))+')':('
('+loc("usable again in %1",Game.sayTime(Game.getLumpRefillRemaining()+Game.fps,-1))+')'))+ '
'; }; var str=''; str+=''; str+='
'; str+='
'; str+='
'+ '
'+ '
'+(EN?'Profits: $0. All prices are in $econds of your highest raw cookies per second.':loc("Profits: %1. All prices are in $econds of your highest raw cookies per second.",'$0'))+'
'+ '
-
'+ '
'+(EN?'no brokers':loc("Brokers:")+' 0')+'
'+loc("Hire")+'
'+ '
'+ /*'
Generate opportunity
refresh
'+*/ '
'; var buyStr=loc("Buy"); var sellStr=loc("Sell"); for (var i=0;i'+ '
'+ '
'+ '
'+me.symbol+' -.--%
'+ '
'+ '
'+loc("value:")+' -
'+ '
'+loc("stock:")+' -/-
'+ '
'+ '
'+ '
'+buyStr+'
'+ '
1
'+ '
10
'+ '
100
'+ '
'+cap(loc("max"))+'
'+ '
'+ '
'+sellStr+'
'+ '
1
'+ '
10
'+ '
100
'+ '
'+cap(loc("all"))+'
'+ '
'+ '
'; } str+='
'; str+='
'; str+='
'; div.innerHTML=str; var str=''; str+='
'+ '
'+loc("Line style")+'
'+ '
'+loc("Color mode")+'
'+ (Game.sesame?'
'+loc("Toggle speed")+'
':'')+ '
'+ '
DOUGH JONES INDEX
'; for (var i=0;i
'; } l('bankGraphBox').innerHTML=str; var div=document.createElement('canvas'); div.id='bankGraph'; div.style.marginLeft='-14px'; div.width=64; div.height=64; l('bankGraphBox').appendChild(div); M.graph=div; M.graphCtx=M.graph.getContext('2d',{alpha:false}); AddEvent(l('bankGraphLines'),'click',function(e){ if (M.graphLines==0) M.graphLines=1; else M.graphLines=0; M.toRedraw=2; PlaySound('snd/tick.mp3'); }); AddEvent(l('bankGraphCols'),'click',function(e){ if (M.graphCols==0) M.graphCols=1; else M.graphCols=0; M.setCols(); M.toRedraw=2; PlaySound('snd/tick.mp3'); }); if (l('bankCheatSpeed')) { AddEvent(l('bankCheatSpeed'),'click',function(e){ if (M.secondsPerTick==60) M.secondsPerTick=1/10; else M.secondsPerTick=60; M.toRedraw=2; PlaySound('snd/tick.mp3'); }); } AddEvent(l('bankOfficeUpgrade'),'click',function(e){ var me=M.offices[M.officeLevel]; if (me.cost && Game.Objects['Cursor'].amount>=me.cost[0] && Game.Objects['Cursor'].level>=me.cost[1]) { Game.Objects['Cursor'].sacrifice(me.cost[0]); M.officeLevel+=1; if (M.officeLevel>=M.offices.length-1) Game.Win('Pyramid scheme'); PlaySound('snd/cashIn2.mp3',0.6); Game.SparkleOn(e.target); } }); AddEvent(l('bankBrokersBuy'),'click',function(e){ if (M.brokers=M.getBrokerPrice()) { Game.Spend(M.getBrokerPrice()); M.brokers+=1; PlaySound('snd/cashIn2.mp3',0.6); Game.SparkleOn(e.target); } }); AddEvent(l('bankLoan1'),'click',function(e){ if (M.takeLoan(1)) {PlaySound('snd/cashIn2.mp3',0.6);Game.SparkleOn(e.target);} }); AddEvent(l('bankLoan2'),'click',function(e){ if (M.takeLoan(2)) {PlaySound('snd/cashIn2.mp3',0.6);Game.SparkleOn(e.target);} }); AddEvent(l('bankLoan3'),'click',function(e){ if (M.takeLoan(3)) {PlaySound('snd/cashIn2.mp3',0.6);Game.SparkleOn(e.target);} }); for (var i=0;i=0;i--) { var id=i; var me=M.goodsById[id]; if (me.hidden || !me.active) continue; for (var iR=0;iR=(2+iR)) { var min=Math.max(me.vals[0+iR],me.vals[1+iR]); var max=Math.abs((me.vals[0+iR]-me.vals[1+iR])); if (x>=width-span*iR-span-2 && x<=width-span*iR+2 && y>=height-min*M.graphScale-6 && y<=height-min*M.graphScale+Math.max(3,max*M.graphScale)+6) { isOnLine=i; Game.tooltip.draw(0,'
'+me.name.replace('%1',Game.bakeryName)+'
'+loc("valued at %1",'$'+Beautify(me.vals[0+iR],2)+'')+'
'+loc("%1 ago",Game.sayTime((iR+1)*M.secondsPerTick*Game.fps))+'
','top'); break bankGraphMouseDetect; } } } } if (isOnLine!=M.hoverOnGood) { M.hoverOnGood=isOnLine; if (M.hoverOnGood!=-1) { M.graph.style.cursor='pointer'; } else { M.graph.style.cursor='auto'; Game.tooltip.shouldHide=1; } M.toRedraw=2; } }); AddEvent(M.graph,'mouseout',function(e){ M.graph.style.cursor='auto'; if (M.hoverOnGood!=-1) {M.hoverOnGood=-1;M.toRedraw=2;} Game.tooltip.shouldHide=1; }); M.reset(); } M.onResize=function() { M.graph.width=l('bankContent').offsetWidth-22; M.graph.height=300;//l('bankContent').offsetHeight; var ctx=M.graphCtx; ctx.fillStyle='#fff'; ctx.fillRect(0,0,M.graph.width,M.graph.height); M.checkGraphScale(); M.toRedraw=2; } M.save=function() { //output cannot use ",", ";" or "|" var str=''+ parseInt(M.officeLevel)+':'+ parseInt(M.brokers)+':'+ parseInt(M.graphLines)+':'+ parseFloat(M.profit)+':'+ parseInt(M.graphCols)+':'+ ' '; for (var iG=0;iG0) it.active=true; if (it.l) M.updateGoodStyle(it.id); } M.onResize(); var on=parseInt(spl[i++]||0);if (on && Game.ascensionMode!=1) M.parent.switchMinigame(1); } M.reset=function(hard) { M.tickT=0; M.toRedraw=0; M.officeLevel=0; M.brokers=0; if (hard) {M.graphLines=1;M.graphCols=0;}M.setCols(); M.hoverOnGood=-1; M.ticks=0; M.lastTickDrawn=0; M.profit=0; for (var i=0;i(100+(Game.Objects['Bank'].level-1)*3) && me.d>0) me.d*=0.9; me.val+=me.d; /*if (me.val<=0 && me.d<0) { me.d*=0.75; if (me.mode==4 && Math.random()<0.05) me.mode=2; } if (me.val<2) me.val+=(2-me.val)*0.1; me.val=Math.max(me.val,0.01);*/ /*var cutoff=5; var minvalue=1; if (me.val<=cutoff) { var s=Math.max(0,me.val)/cutoff; me.val=((2*minvalue-cutoff)*s+(2*cutoff-3*minvalue))*s*s+minvalue;//low soft-cap between 1 and 5 }*/ if (me.val<5) me.val+=(5-me.val)*0.5; if (me.val<5 && me.d<0) me.d*=0.95; me.val=Math.max(me.val,1); me.vals.unshift(me.val); if (me.vals.length>65) me.vals.pop(); me.dur--; //if (Math.random()<1/me.dur) if (me.dur<=0) { me.dur=Math.floor(10+Math.random()*(690-200*dragonBoost)); if (Math.random()'+loc("Supreme Intellect")+'
'+loc("The stock market is more chaotic.")+''; } M.tickT=0; M.logic=function() { //run each frame M.tickT++; if (M.tickT>=Game.fps*M.secondsPerTick) { M.tickT=0; M.tick(); } if (Game.T%10==0) { var doResize=false; for (var i=0;i0) {me.active=true;me.hidden=false;M.toRedraw=2;if (me.l){M.updateGoodStyle(me.id);doResize=true;}} } if (doResize) M.onResize(); } } M.hoverOnGood=-1; M.graphScale=10;//how many units 1 vertical pixel represents M.graphLines=1; M.graphCols=0; M.checkGraphScale=function() { //check if the height of the graph and the highest good value //if the scale is too narrow to accommodate all goods, zoom out //if the scale is too wide, zoom back in (but with a higher margin) //this is done in increments of 50 var currentSize=M.graph.height; if (!currentSize) return false; var maxVal=0; for (var i=0;i5 || dif<-5) { M.graphScale=newScale; M.toRedraw=2; } } M.colBases=[ {bg:'#fff',line1:'#eee',line2:'#ccc',low:'#ce2549',high:'#79c600',highlight:'#000'}, {bg:'#1f2836',line1:'#273545',line2:'#384b61',low:'#3153a3',high:'#c4971a',highlight:'#a6abad'}, ]; M.setCols=function() { if (!M.colBases[M.graphCols]) M.graphCols=0; M.cols=M.colBases[M.graphCols]; if (l('bankGraphBox')) { l('bankGraphBox').style.backgroundColor=M.cols.bg; l('bankGraphBox').style.color=M.cols.highlight; } if (M.graph) M.graph.style.backgroundColor=M.cols.bg; } M.setCols(); M.drawGraph=function(full) { /* what this does: scroll the graph left by (span) draw more graph data to the right if (full), do a full redraw instead */ var ctx=M.graphCtx; var width=M.graph.width; var span=Math.max(4,Math.ceil(width/65));//6; var height=M.graph.height; ctx.globalAlpha=1; if (!full) ctx.drawImage(M.graph,-span,0); ctx.fillStyle=M.cols.bg; if (full) ctx.fillRect(0,0,width,height); else ctx.fillRect(width-span,0,span,height); ctx.lineWidth=2; ctx.globalAlpha=1; var rows=(full?Math.ceil(width/span):1); for (var i=0;i=(2+iR)) { var delta=M.goodDelta(me.id,iR); if (M.graphLines==0) { var min=Math.max(me.vals[0+iR],me.vals[1+iR]); var max=Math.abs((me.vals[0+iR]-me.vals[1+iR])); var min2=Math.abs(Math.sin((M.ticks-iR)*11+id*137))*max*2; var max2=min2+Math.abs(Math.sin((M.ticks-iR)*13+id*139))*max*2; if (M.hoverOnGood==id) { ctx.fillStyle=M.cols.highlight; ctx.fillRect(width-span*iR-span-1,Math.floor(height-min*M.graphScale)-1,span+1,Math.max(3,Math.ceil(max*M.graphScale))+2); } ctx.fillStyle=delta>0?M.cols.high:M.cols.low; ctx.fillRect(width-span*iR-span,Math.floor(height-min*M.graphScale),span-1,Math.max(3,Math.ceil(max*M.graphScale))); ctx.fillRect(width-span*iR-span/2-1,Math.floor(height-(min+min2)*M.graphScale),1,Math.max(3,Math.ceil((max+max2)*M.graphScale))); } else { if (M.hoverOnGood==id) { ctx.lineWidth=4; ctx.strokeStyle=M.cols.highlight; ctx.beginPath(); ctx.moveTo(width-span*iR-span-1,Math.floor(height-me.vals[1+iR]*M.graphScale)+0.5); ctx.lineTo(width-span*iR-1,Math.floor(height-me.vals[0+iR]*M.graphScale)+0.5); ctx.stroke(); ctx.lineWidth=2; } ctx.strokeStyle=delta>0?M.cols.high:M.cols.low; ctx.beginPath(); ctx.moveTo(width-span*iR-span-1,Math.floor(height-me.vals[1+iR]*M.graphScale)+0.5); ctx.lineTo(width-span*iR-1,Math.floor(height-me.vals[0+iR]*M.graphScale)+0.5); ctx.stroke(); } } } } } M.draw=function() { //run each draw frame if (Game.drawT%2==0 && M.toRedraw>0 && M.graph && M.graphCtx) { if (M.lastTickDrawn=0) {me.symbolNumL.classList.add('bankSymbolUp');me.symbolNumL.classList.remove('bankSymbolDown');} else if (val<0) {me.symbolNumL.classList.remove('bankSymbolUp');me.symbolNumL.classList.add('bankSymbolDown');} else {me.symbolNumL.classList.remove('bankSymbolUp');me.symbolNumL.classList.remove('bankSymbolDown');} me.valL.innerHTML='$'+Beautify(me.val,2); me.stockL.innerHTML=Beautify(me.stock); //if (me.stock>0) me.stockL.style.color='#fff'; //else me.stockL.style.removeProperty('color'); if (me.stock>0) me.stockBoxL.classList.add('green'); else me.stockBoxL.classList.remove('green'); me.stockMaxL.innerHTML='/'+Beautify(M.getGoodMaxStock(me)); me.graphIconL.style.transform='translate(-8px,'+Math.floor((M.graph.height-me.vals[0]*M.graphScale))+'px) scale(0.5)'; } M.toRedraw=0; } if (Game.drawT%10==0) { var office=M.offices[M.officeLevel]; l('bankOfficeIcon').style.backgroundPosition=(-office.icon[0]*48)+'px '+(-office.icon[1]*48)+'px'; l('bankOfficeName').innerHTML=office.name; l('bankOfficeUpgrade').innerHTML=EN?'Upgrade ('+office.cost[0]+' cursors)':loc("Upgrade for %1",office.cost[0]+' '+Game.Objects['Cursor'].plural); if (!office.cost) l('bankOfficeUpgrade').style.display='none'; else { l('bankOfficeUpgrade').style.removeProperty('display'); if (Game.Objects['Cursor'].amount>=office.cost[0] && Game.Objects['Cursor'].level>=office.cost[1]) l('bankOfficeUpgrade').classList.remove('bankButtonOff'); else l('bankOfficeUpgrade').classList.add('bankButtonOff'); } l('bankBrokersText').innerHTML=EN?(M.brokers==0?'no brokers':M.brokers==1?'1 broker':(M.brokers+' brokers')):(loc("Brokers:")+' '+M.brokers); if (M.brokers=M.getBrokerPrice()) l('bankBrokersBuy').classList.remove('bankButtonOff'); else l('bankBrokersBuy').classList.add('bankButtonOff'); if (M.officeLevel<=1) l('bankLoan1').style.display='none'; else l('bankLoan1').style.removeProperty('display'); if (M.officeLevel<=3) l('bankLoan2').style.display='none'; else l('bankLoan2').style.removeProperty('display'); if (M.officeLevel<=4) l('bankLoan3').style.display='none'; else l('bankLoan3').style.removeProperty('display'); for (var id=1;id<4;id++) { if (Game.hasBuff('Loan '+id) || Game.hasBuff('Loan '+id+' (interest)')) l('bankLoan'+id).classList.add('bankButtonOff'); else l('bankLoan'+id).classList.remove('bankButtonOff'); } var it=l('bankBalance'); it.innerHTML=(M.profit<0?'-':'')+'$'+Beautify(Math.abs(M.profit),2); if (M.profit>0) {it.classList.add('bankSymbolUp');it.classList.remove('bankSymbolDown');} else if (M.profit<0) {it.classList.add('bankSymbolDown');it.classList.remove('bankSymbolUp');} l('bankNextTick').innerHTML=loc("Next tick in %1.",Game.sayTime((Game.fps*M.secondsPerTick)-M.tickT+30,-1)); } } M.init(l('rowSpecial'+M.parent.id)); } var M=0;