· 9 years ago · Dec 20, 2016, 06:22 AM
1/*
2All this code is copyright Orteil, 2013-2016.
3 -with some help, advice and fixes by Nicholas Laux, Debugbro and Opti
4 -also includes a bunch of snippets found on stackoverflow.com
5Hello, and welcome to the joyous mess that is main.js. Code contained herein is not guaranteed to be good, consistent, or sane. Have a nice trip.
6Spoilers ahead.
7http://orteil.dashnet.org
8*/
9
10/*=====================================================================================
11MISC HELPER FUNCTIONS
12=======================================================================================*/
13function l(what) {return document.getElementById(what);}
14function choose(arr) {return arr[Math.floor(Math.random()*arr.length)];}
15
16function escapeRegExp(str){return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");}
17function replaceAll(find,replace,str){return str.replace(new RegExp(escapeRegExp(find),'g'),replace);}
18
19//disable sounds coming from soundjay.com (sorry)
20var realAudio=Audio;//backup real audio
21Audio=function(src){
22 if (src.indexOf('soundjay')>-1) {Game.Popup('Sorry, no sounds hotlinked from soundjay.com.');this.play=function(){};}
23 else return new realAudio(src);
24};
25
26if(!Array.prototype.indexOf) {
27 Array.prototype.indexOf = function(needle) {
28 for(var i = 0; i < this.length; i++) {
29 if(this[i] === needle) {return i;}
30 }
31 return -1;
32 };
33}
34
35function randomFloor(x) {if ((x%1)<Math.random()) return Math.floor(x); else return Math.ceil(x);}
36
37function shuffle(array)
38{
39 var counter = array.length, temp, index;
40 // While there are elements in the array
41 while (counter--)
42 {
43 // Pick a random index
44 index = (Math.random() * counter) | 0;
45
46 // And swap the last element with it
47 temp = array[counter];
48 array[counter] = array[index];
49 array[index] = temp;
50 }
51 return array;
52}
53
54var sinArray=[];
55for (var i=0;i<360;i++)
56{
57 //let's make a lookup table
58 sinArray[i]=Math.sin(i/360*Math.PI*2);
59}
60function quickSin(x)
61{
62 //oh man this isn't all that fast actually
63 //why do I do this. why
64 var sign=x<0?-1:1;
65 return sinArray[Math.round(
66 (Math.abs(x)*360/Math.PI/2)%360
67 )]*sign;
68}
69
70
71//Beautify and number-formatting adapted from the Frozen Cookies add-on (http://cookieclicker.wikia.com/wiki/Frozen_Cookies_%28JavaScript_Add-on%29)
72function formatEveryThirdPower(notations)
73{
74 return function (value)
75 {
76 var base = 0,
77 notationValue = '';
78 if (value >= 1000000 && isFinite(value))
79 {
80 value /= 1000;
81 while(Math.round(value) >= 1000)
82 {
83 value /= 1000;
84 base++;
85 }
86 if (base>=notations.length) {return 'Infinity';} else {notationValue = notations[base];}
87 }
88 return ( Math.round(value * 1000) / 1000 ) + notationValue;
89 };
90}
91
92function rawFormatter(value) {return Math.round(value * 1000) / 1000;}
93
94var numberFormatters =
95[
96 rawFormatter,
97 formatEveryThirdPower([
98 '',
99 ' million',
100 ' billion',
101 ' trillion',
102 ' quadrillion',
103 ' quintillion',
104 ' sextillion',
105 ' septillion',
106 ' octillion',
107 ' nonillion',
108 ' decillion',
109 ' undecillion',
110 ' duodecillion',
111 ' tredecillion',
112 ' quattuordecillion',
113 ' quindecillion'
114 ]),
115 formatEveryThirdPower([
116 '',
117 ' M',
118 ' B',
119 ' T',
120 ' Qa',
121 ' Qi',
122 ' Sx',
123 ' Sp',
124 ' Oc',
125 ' No',
126 ' Dc',
127 ' UnD',
128 ' DoD',
129 ' TrD',
130 ' QaD',
131 ' QiD'
132 ])
133];
134
135function Beautify(value,floats)
136{
137 var negative=(value<0);
138 var decimal='';
139 if (value<1000000 && floats>0 && Math.floor(value.toFixed(floats))!=value.toFixed(floats)) decimal='.'+(value.toFixed(floats).toString()).split('.')[1];
140 value=Math.floor(Math.abs(value));
141 var formatter=numberFormatters[Game.prefs.format?0:1];
142 var output=formatter(value).toString().replace(/\B(?=(\d{3})+(?!\d))/g,',');
143 return negative?'-'+output:output+decimal;
144}
145
146var beautifyInTextFilter=/(([\d]+[,]*)+)/g;//new regex
147var a=/\d\d?\d?(?:,\d\d\d)*/g;//old regex
148function BeautifyInTextFunction(str){return Beautify(parseInt(str.replace(/,/g,''),10));};
149function BeautifyInText(str) {return str.replace(beautifyInTextFilter,BeautifyInTextFunction);}//reformat every number inside a string
150function BeautifyAll()//run through upgrades and achievements to reformat the numbers
151{
152 var func=function(what){what.desc=BeautifyInText(what.baseDesc);}
153 Game.UpgradesById.forEach(func);
154 Game.AchievementsById.forEach(func);
155}
156
157function utf8_to_b64( str ) {
158 try{return Base64.encode(unescape(encodeURIComponent( str )));}
159 catch(err)
160 {return '';}
161}
162
163function b64_to_utf8( str ) {
164 try{return decodeURIComponent(escape(Base64.decode( str )));}
165 catch(err)
166 {return '';}
167}
168
169
170function CompressBin(arr)//compress a sequence like [0,1,1,0,1,0]... into a number like 54.
171{
172 var str='';
173 var arr2=arr.slice(0);
174 arr2.unshift(1);
175 arr2.push(1);
176 arr2.reverse();
177 for (var i in arr2)
178 {
179 str+=arr2[i];
180 }
181 str=parseInt(str,2);
182 return str;
183}
184
185function UncompressBin(num)//uncompress a number like 54 to a sequence like [0,1,1,0,1,0].
186{
187 var arr=num.toString(2);
188 arr=arr.split('');
189 arr.reverse();
190 arr.shift();
191 arr.pop();
192 return arr;
193}
194
195function CompressLargeBin(arr)//we have to compress in smaller chunks to avoid getting into scientific notation
196{
197 var arr2=arr.slice(0);
198 var thisBit=[];
199 var bits=[];
200 for (var i in arr2)
201 {
202 thisBit.push(arr2[i]);
203 if (thisBit.length>=50)
204 {
205 bits.push(CompressBin(thisBit));
206 thisBit=[];
207 }
208 }
209 if (thisBit.length>0) bits.push(CompressBin(thisBit));
210 arr2=bits.join(';');
211 return arr2;
212}
213
214function UncompressLargeBin(arr)
215{
216 var arr2=arr.split(';');
217 var bits=[];
218 for (var i in arr2)
219 {
220 bits.push(UncompressBin(parseInt(arr2[i])));
221 }
222 arr2=[];
223 for (var i in bits)
224 {
225 for (var ii in bits[i]) arr2.push(bits[i][ii]);
226 }
227 return arr2;
228}
229
230
231function pack(bytes) {
232 var chars = [];
233 var len=bytes.length;
234 for(var i = 0, n = len; i < n;) {
235 chars.push(((bytes[i++] & 0xff) << 8) | (bytes[i++] & 0xff));
236 }
237 return String.fromCharCode.apply(null, chars);
238}
239
240function unpack(str) {
241 var bytes = [];
242 var len=str.length;
243 for(var i = 0, n = len; i < n; i++) {
244 var char = str.charCodeAt(i);
245 bytes.push(char >>> 8, char & 0xFF);
246 }
247 return bytes;
248}
249
250//modified from http://www.smashingmagazine.com/2011/10/19/optimizing-long-lists-of-yesno-values-with-javascript/
251function pack2(/* string */ values) {
252 var chunks = values.match(/.{1,14}/g), packed = '';
253 for (var i=0; i < chunks.length; i++) {
254 packed += String.fromCharCode(parseInt('1'+chunks[i], 2));
255 }
256 return packed;
257}
258
259function unpack2(/* string */ packed) {
260 var values = '';
261 for (var i=0; i < packed.length; i++) {
262 values += packed.charCodeAt(i).toString(2).substring(1);
263 }
264 return values;
265}
266
267//file save function from https://github.com/eligrey/FileSaver.js
268var saveAs=saveAs||function(view){"use strict";if(typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var doc=view.document,get_URL=function(){return view.URL||view.webkitURL||view},save_link=doc.createElementNS("http://www.w3.org/1999/xhtml","a"),can_use_save_link="download"in save_link,click=function(node){var event=new MouseEvent("click");node.dispatchEvent(event)},is_safari=/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),webkit_req_fs=view.webkitRequestFileSystem,req_fs=view.requestFileSystem||webkit_req_fs||view.mozRequestFileSystem,throw_outside=function(ex){(view.setImmediate||view.setTimeout)(function(){throw ex},0)},force_saveable_type="application/octet-stream",fs_min_size=0,arbitrary_revoke_timeout=500,revoke=function(file){var revoker=function(){if(typeof file==="string"){get_URL().revokeObjectURL(file)}else{file.remove()}};if(view.chrome){revoker()}else{setTimeout(revoker,arbitrary_revoke_timeout)}},dispatch=function(filesaver,event_types,event){event_types=[].concat(event_types);var i=event_types.length;while(i--){var listener=filesaver["on"+event_types[i]];if(typeof listener==="function"){try{listener.call(filesaver,event||filesaver)}catch(ex){throw_outside(ex)}}}},auto_bom=function(blob){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)){return new Blob(["\ufeff",blob],{type:blob.type})}return blob},FileSaver=function(blob,name,no_auto_bom){if(!no_auto_bom){blob=auto_bom(blob)}var filesaver=this,type=blob.type,blob_changed=false,object_url,target_view,dispatch_all=function(){dispatch(filesaver,"writestart progress write writeend".split(" "))},fs_error=function(){if(target_view&&is_safari&&typeof FileReader!=="undefined"){var reader=new FileReader;reader.onloadend=function(){var base64Data=reader.result;target_view.location.href="data:attachment/file"+base64Data.slice(base64Data.search(/[,;]/));filesaver.readyState=filesaver.DONE;dispatch_all()};reader.readAsDataURL(blob);filesaver.readyState=filesaver.INIT;return}if(blob_changed||!object_url){object_url=get_URL().createObjectURL(blob)}if(target_view){target_view.location.href=object_url}else{var new_tab=view.open(object_url,"_blank");if(new_tab==undefined&&is_safari){view.location.href=object_url}}filesaver.readyState=filesaver.DONE;dispatch_all();revoke(object_url)},abortable=function(func){return function(){if(filesaver.readyState!==filesaver.DONE){return func.apply(this,arguments)}}},create_if_not_found={create:true,exclusive:false},slice;filesaver.readyState=filesaver.INIT;if(!name){name="download"}if(can_use_save_link){object_url=get_URL().createObjectURL(blob);setTimeout(function(){save_link.href=object_url;save_link.download=name;click(save_link);dispatch_all();revoke(object_url);filesaver.readyState=filesaver.DONE});return}if(view.chrome&&type&&type!==force_saveable_type){slice=blob.slice||blob.webkitSlice;blob=slice.call(blob,0,blob.size,force_saveable_type);blob_changed=true}if(webkit_req_fs&&name!=="download"){name+=".download"}if(type===force_saveable_type||webkit_req_fs){target_view=view}if(!req_fs){fs_error();return}fs_min_size+=blob.size;req_fs(view.TEMPORARY,fs_min_size,abortable(function(fs){fs.root.getDirectory("saved",create_if_not_found,abortable(function(dir){var save=function(){dir.getFile(name,create_if_not_found,abortable(function(file){file.createWriter(abortable(function(writer){writer.onwriteend=function(event){target_view.location.href=file.toURL();filesaver.readyState=filesaver.DONE;dispatch(filesaver,"writeend",event);revoke(file)};writer.onerror=function(){var error=writer.error;if(error.code!==error.ABORT_ERR){fs_error()}};"writestart progress write abort".split(" ").forEach(function(event){writer["on"+event]=filesaver["on"+event]});writer.write(blob);filesaver.abort=function(){writer.abort();filesaver.readyState=filesaver.DONE};filesaver.readyState=filesaver.WRITING}),fs_error)}),fs_error)};dir.getFile(name,{create:false},abortable(function(file){file.remove();save()}),abortable(function(ex){if(ex.code===ex.NOT_FOUND_ERR){save()}else{fs_error()}}))}),fs_error)}),fs_error)},FS_proto=FileSaver.prototype,saveAs=function(blob,name,no_auto_bom){return new FileSaver(blob,name,no_auto_bom)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(blob,name,no_auto_bom){if(!no_auto_bom){blob=auto_bom(blob)}return navigator.msSaveOrOpenBlob(blob,name||"download")}}FS_proto.abort=function(){var filesaver=this;filesaver.readyState=filesaver.DONE;dispatch(filesaver,"abort")};FS_proto.readyState=FS_proto.INIT=0;FS_proto.WRITING=1;FS_proto.DONE=2;FS_proto.error=FS_proto.onwritestart=FS_proto.onprogress=FS_proto.onwrite=FS_proto.onabort=FS_proto.onerror=FS_proto.onwriteend=null;return saveAs}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!=null){define([],function(){return saveAs})}
269
270
271//seeded random function, courtesy of http://davidbau.com/archives/2010/01/30/random_seeds_coded_hints_and_quintillions.html
272(function(a,b,c,d,e,f){function k(a){var b,c=a.length,e=this,f=0,g=e.i=e.j=0,h=e.S=[];for(c||(a=[c++]);d>f;)h[f]=f++;for(f=0;d>f;f++)h[f]=h[g=j&g+a[f%c]+(b=h[f])],h[g]=b;(e.g=function(a){for(var b,c=0,f=e.i,g=e.j,h=e.S;a--;)b=h[f=j&f+1],c=c*d+h[j&(h[f]=h[g=j&g+b])+(h[g]=b)];return e.i=f,e.j=g,c})(d)}function l(a,b){var e,c=[],d=(typeof a)[0];if(b&&"o"==d)for(e in a)try{c.push(l(a[e],b-1))}catch(f){}return c.length?c:"s"==d?a:a+"\0"}function m(a,b){for(var d,c=a+"",e=0;c.length>e;)b[j&e]=j&(d^=19*b[j&e])+c.charCodeAt(e++);return o(b)}function n(c){try{return a.crypto.getRandomValues(c=new Uint8Array(d)),o(c)}catch(e){return[+new Date,a,a.navigator.plugins,a.screen,o(b)]}}function o(a){return String.fromCharCode.apply(0,a)}var g=c.pow(d,e),h=c.pow(2,f),i=2*h,j=d-1;c.seedrandom=function(a,f){var j=[],p=m(l(f?[a,o(b)]:0 in arguments?a:n(),3),j),q=new k(j);return m(o(q.S),b),c.random=function(){for(var a=q.g(e),b=g,c=0;h>a;)a=(a+c)*d,b*=d,c=q.g(1);for(;a>=i;)a/=2,b/=2,c>>>=1;return(a+c)/b},p},m(c.random(),b)})(this,[],Math,256,6,52);
273
274function bind(scope,fn)
275{
276 //use : bind(this,function(){this.x++;}) - returns a function where "this" refers to the scoped this
277 return function() {fn.apply(scope,arguments);};
278}
279
280CanvasRenderingContext2D.prototype.fillPattern=function(img,X,Y,W,H,iW,iH,offX,offY)
281{
282 //for when built-in patterns aren't enough
283 if (img.alt!='blank')
284 {
285 var offX=offX||0;
286 var offY=offY||0;
287 if (offX<0) {offX=offX-Math.floor(offX/iW)*iW;} if (offX>0) {offX=(offX%iW)-iW;}
288 if (offY<0) {offY=offY-Math.floor(offY/iH)*iH;} if (offY>0) {offY=(offY%iH)-iH;}
289 for (var y=offY;y<H;y+=iH){for (var x=offX;x<W;x+=iW){this.drawImage(img,X+x,Y+y,iW,iH);}}
290 }
291}
292
293var OldCanvasDrawImage=CanvasRenderingContext2D.prototype.drawImage;
294CanvasRenderingContext2D.prototype.drawImage=function()
295{
296 //only draw the image if it's loaded
297 if (arguments[0].alt!='blank') OldCanvasDrawImage.apply(this,arguments);
298}
299
300
301if (!document.hasFocus) document.hasFocus=function(){return document.hidden;};//for Opera
302
303function AddEvent(html_element, event_name, event_function)
304{
305 if(html_element.attachEvent) //Internet Explorer
306 html_element.attachEvent("on" + event_name, function() {event_function.call(html_element);});
307 else if(html_element.addEventListener) //Firefox & company
308 html_element.addEventListener(event_name, event_function, false); //don't need the 'call' trick because in FF everything already works in the right way
309}
310
311function FireEvent(el, etype)
312{
313 if (el.fireEvent)
314 {el.fireEvent('on'+etype);}
315 else
316 {
317 var evObj=document.createEvent('Events');
318 evObj.initEvent(etype,true,false);
319 el.dispatchEvent(evObj);
320 }
321}
322
323var Loader=function()//asset-loading system
324{
325 this.loadingN=0;
326 this.assetsN=0;
327 this.assets=[];
328 this.assetsLoading=[];
329 this.assetsLoaded=[];
330 this.domain='';
331 this.loaded=0;//callback
332 this.doneLoading=0;
333
334 this.blank=document.createElement('canvas');
335 this.blank.width=8;
336 this.blank.height=8;
337 this.blank.alt='blank';
338
339 this.Load=function(assets)
340 {
341 for (var i in assets)
342 {
343 this.loadingN++;
344 this.assetsN++;
345 if (!this.assetsLoading[assets[i]] && !this.assetsLoaded[assets[i]])
346 {
347 var img=new Image();
348 img.src=this.domain+assets[i];
349 img.alt=assets[i];
350 img.onload=bind(this,this.onLoad);
351 this.assets[assets[i]]=img;
352 this.assetsLoading.push(assets[i]);
353 }
354 }
355 }
356 this.Replace=function(old,newer)
357 {
358 if (this.assets[old])
359 {
360 var img=new Image();
361 if (newer.indexOf('http')!=-1) img.src=newer;
362 else img.src=this.domain+newer;
363 img.alt=newer;
364 img.onload=bind(this,this.onLoad);
365 this.assets[old]=img;
366 }
367 }
368 this.onLoadReplace=function()
369 {
370 }
371 this.onLoad=function(e)
372 {
373 this.assetsLoaded.push(e.target.alt);
374 this.assetsLoading.splice(this.assetsLoading.indexOf(e.target.alt),1);
375 this.loadingN--;
376 if (this.doneLoading==0 && this.loadingN<=0 && this.loaded!=0)
377 {
378 this.doneLoading=1;
379 this.loaded();
380 }
381 }
382 this.getProgress=function()
383 {
384 return (1-this.loadingN/this.assetsN);
385 }
386}
387
388var Pic=function(what)
389{
390 if (Game.Loader.assetsLoaded.indexOf(what)!=-1) return Game.Loader.assets[what];
391 else if (Game.Loader.assetsLoading.indexOf(what)==-1) Game.Loader.Load([what]);
392 return Game.Loader.blank;
393}
394
395var Sounds=[];
396var PlaySound=function(url,vol)
397{
398 var volume=1;
399 if (vol!==undefined) volume=vol;
400 if (!Game.volume || volume==0) return 0;
401 if (!Sounds[url]) {Sounds[url]=new Audio(url);Sounds[url].onloadeddata=function(e){e.target.volume=Math.pow(volume*Game.volume/100,2);}}
402 else if (Sounds[url].readyState>=2) {Sounds[url].currentTime=0;Sounds[url].volume=Math.pow(volume*Game.volume/100,2);}
403 Sounds[url].play();
404}
405
406if (!Date.now){Date.now=function now() {return new Date().getTime();};}
407
408
409var debugStr='';
410var Debug=function(what)
411{
412 if (!debugStr) debugStr=what;
413 else debugStr+='; '+what;
414}
415
416var Timer={};
417Timer.t=Date.now();
418Timer.labels=[];
419Timer.smoothed=[];
420Timer.reset=function()
421{
422 Timer.labels=[];
423 Timer.t=Date.now();
424}
425Timer.track=function(label)
426{
427 if (!Game.sesame) return;
428 var now=Date.now();
429 if (!Timer.smoothed[label]) Timer.smoothed[label]=0;
430 Timer.smoothed[label]+=((now-Timer.t)-Timer.smoothed[label])*0.1;
431 Timer.labels[label]='<div style="padding-left:8px;">'+label+' : '+Math.round(Timer.smoothed[label])+'ms</div>';
432 Timer.t=now;
433}
434Timer.clean=function()
435{
436 if (!Game.sesame) return;
437 var now=Date.now();
438 Timer.t=now;
439}
440Timer.say=function(label)
441{
442 if (!Game.sesame) return;
443 Timer.labels[label]='<div style="border-top:1px solid #ccc;">'+label+'</div>';
444}
445
446
447/*=====================================================================================
448GAME INITIALIZATION
449=======================================================================================*/
450var Game={};
451
452Game.Launch=function()
453{
454 Game.version=2.002;
455 Game.beta=0;
456 if (window.location.href.indexOf('/beta')>-1) Game.beta=1;
457 Game.mobile=0;
458 Game.touchEvents=0;
459 if (Game.mobile) Game.touchEvents=1;
460
461 Game.baseSeason='';
462 var day=Math.floor((new Date()-new Date(new Date().getFullYear(),0,0))/(1000*60*60*24));
463 if (day>=41 && day<=46) Game.baseSeason='valentines';
464 else if (day>=90 && day<=92) Game.baseSeason='fools';
465 else if (day>=304-7 && day<=304) Game.baseSeason='halloween';
466 else if (day>=349 && day<=365) Game.baseSeason='christmas';
467 else
468 {
469
470 var easterDay=function(Y){var C = Math.floor(Y/100);var N = Y - 19*Math.floor(Y/19);var K = Math.floor((C - 17)/25);var I = C - Math.floor(C/4) - Math.floor((C - K)/3) + 19*N + 15;I = I - 30*Math.floor((I/30));I = I - Math.floor(I/28)*(1 - Math.floor(I/28)*Math.floor(29/(I + 1))*Math.floor((21 - N)/11));var J = Y + Math.floor(Y/4) + I + 2 - C + Math.floor(C/4);J = J - 7*Math.floor(J/7);var L = I - J;var M = 3 + Math.floor((L + 40)/44);var D = L + 28 - 31*Math.floor(M/4);return new Date(Y,M-1,D);}(new Date().getFullYear());
471 easterDay=Math.floor((easterDay-new Date(easterDay.getFullYear(),0,0))/(1000*60*60*24));
472 if (day>=easterDay-7 && day<=easterDay) Game.baseSeason='easter';
473 }
474
475 Game.updateLog=
476 '<div class="section">Info</div>'+
477 '</div><div class="subsection">'+
478 '<div class="title">About</div>'+
479 '<div class="listing">Cookie Clicker is a javascript game by <a href="http://orteil.dashnet.org" target="_blank">Orteil</a> and <a href="http://dashnet.org" target="_blank">Opti</a>.</div>'+
480 '<div class="listing">We have an <a href="http://forum.dashnet.org" target="_blank">official forum</a>; '+
481 'if you\'re looking for help, you may also want to visit the <a href="http://www.reddit.com/r/CookieClicker" target="_blank">subreddit</a> '+
482 'or the <a href="http://cookieclicker.wikia.com/wiki/Cookie_Clicker_Wiki" target="_blank">wiki</a>. We\'re also on <a href="http://forum.dashnet.org/discussion/277/irc-chat-channel/p1" target="_blank">IRC</a>.</div>'+
483 '<div class="listing">News and teasers are usually posted on my <a href="http://orteil42.tumblr.com/" target="_blank">tumblr</a> and <a href="http://twitter.com/orteil42" target="_blank">twitter</a>.</div>'+
484 '<div class="listing">We\'ve got some <a href="http://www.redbubble.com/people/dashnet" target="_blank">rad cookie shirts, hoodies and stickers</a> for sale!</div>'+
485 '<div class="listing warning">Note : if you find a new bug after an update and you\'re using a 3rd-party add-on, make sure it\'s not just your add-on causing it!</div>'+
486 '<div class="listing warning">Warning : clearing your browser cache or cookies <small>(what else?)</small> will result in your save being wiped. Export your save and back it up first!</div>'+
487
488 '</div><div class="subsection">'+
489 '<div class="title">Version history</div>'+
490
491 '</div><div class="subsection update small">'+
492 '<div class="title">24/07/2016 - golden cookies overhaul</div>'+
493 '<div class="listing">• golden cookies and reindeer now follow a new system involving explicitly defined buffs</div>'+
494 '<div class="listing">• a bunch of new golden cookie effects have been added</div>'+
495 '<div class="listing">• CpS gains from eggs are now multiplicative</div>'+
496 '<div class="listing">• shiny wrinklers are now saved</div>'+
497 '<div class="listing">• reindeer have been rebalanced ever so slightly</div>'+
498 '<div class="listing">• added a new cookie upgrade near the root of the heavenly upgrade tree; this is intended to boost early ascensions and speed up the game as a whole</div>'+
499 '<div class="listing">• due to EU legislation, implemented a warning message regarding browser cookies; do understand that the irony is not lost on us</div>'+
500
501 '</div><div class="subsection update">'+
502 '<div class="title">08/02/2016 - legacy</div>'+
503 '<div class="listing"><b>Everything that was implemented during the almost 2-year-long beta has been added to the live game. To recap :</b></div>'+
504 '<div class="listing">• 3 new buildings : banks, temples, and wizard towers; these have been added in-between existing buildings and as such, may disrupt some building-related achievements</div>'+
505 '<div class="listing">• the ascension system has been redone from scratch, with a new heavenly upgrade tree</div>'+
506 '<div class="listing">• mysterious new features such as angel-powered offline progression, challenge runs, and a cookie dragon</div>'+
507 '<div class="listing">• sounds have been added (can be disabled in the options)</div>'+
508 '<div class="listing">• heaps of rebalancing and bug fixes</div>'+
509 '<div class="listing">• a couple more upgrades and achievements, probably</div>'+
510 '<div class="listing">• fresh new options to further customize your cookie-clicking experience</div>'+
511 '<div class="listing">• quality-of-life improvements : better bulk-buy, better switches etc</div>'+
512 '<div class="listing">• added some <a href="http://en.wikipedia.org/wiki/'+choose(['Krzysztof_Arciszewski','Eustachy_Sanguszko','Maurycy_Hauke','Karol_Turno','Tadeusz_Kutrzeba','Kazimierz_Fabrycy','Florian_Siwicki'])+'" target="_blank">general polish</a></div>'+/* i liked this dumb pun too much to let it go unnoticed */
513 '<div class="listing">• tons of other little things we can\'t even remember right now</div>'+
514 '<div class="listing">Miss the old version? Your old save was automatically exported <a href="http://orteil.dashnet.org/cookieclicker/v10466/" target="_blank">here</a>!</div>'+
515
516 '</div><div class="subsection update small">'+
517 '<div class="title">05/02/2016 - legacy beta, more fixes</div>'+
518 '<div class="listing">• added challenge modes, which can be selected when ascending (only 1 for now : "Born again")</div>'+
519 '<div class="listing">• changed the way bulk-buying and bulk-selling works</div>'+
520 '<div class="listing">• more bugs ironed out</div>'+
521
522 '</div><div class="subsection update">'+
523 '<div class="title">03/02/2016 - legacy beta, part III</div>'+
524 '<div class="listing warning">• Not all bugs have been fixed, but everything should be much less broken.</div>'+
525 '<div class="listing">• Additions'+
526 '<div style="opacity:0.8;margin-left:12px;">'+
527 '-a few more achievements<br>'+
528 '-new option for neat, but slow CSS effects (disabled by default)<br>'+
529 '-new option for a less grating cookie sound (enabled by default)<br>'+
530 '-new option to bring back the boxes around icons in the stats screen<br>'+
531 '-new buttons for saving and loading your game to a text file<br>'+
532 '</div>'+
533 '</div>'+
534 '<div class="listing">• Changes'+
535 '<div style="opacity:0.8;margin-left:12px;">'+
536 '-early game should be a bit faster and very late game was kindly asked to tone it down a tad<br>'+
537 '-dragonflight should be somewhat less ridiculously overpowered<br>'+
538 '-please let me know if the rebalancing was too heavy or not heavy enough<br>'+
539 '-santa and easter upgrades now depend on Santa level and amount of eggs owned, respectively, instead of costing several minutes worth of CpS<br>'+
540 '-cookie upgrades now stack multiplicatively rather than additively<br>'+
541 '-golden switch now gives +50% CpS, and residual luck is +10% CpS per golden cookie upgrade (up from +25% and +1%, respectively)<br>'+
542 '-lucky cookies and cookie chain payouts have been modified a bit, possibly for the better, who knows!<br>'+
543 '-wrinklers had previously been reduced to a maximum of 8 (10 with a heavenly upgrade), but are now back to 10 (12 with the upgrade)<br>'+
544 /*'-all animations are now handled by requestAnimationFrame(), which should hopefully help make the game less resource-intensive<br>'+*/
545 '-an ascension now only counts for achievement purposes if you earned at least 1 prestige level from it<br>'+
546 '-the emblematic Cookie Clicker font (Kavoon) was bugged in Firefox, and has been replaced with a new font (Merriweather)<br>'+
547 '-the mysterious wrinkly creature is now even rarer, but has a shadow achievement tied to it<br>'+
548 '</div>'+
549 '</div>'+
550 '<div class="listing">• Fixes'+
551 '<div style="opacity:0.8;margin-left:12px;">'+
552 '-prestige now grants +1% CpS per level as intended, instead of +100%<br>'+
553 '-heavenly chips should no longer add up like crazy when you ascend<br>'+
554 '-upgrades in the store should no longer randomly go unsorted<br>'+
555 '-window can be resized to any size again<br>'+
556 '-the "Stats" and "Options" buttons have been swapped again<br>'+
557 '-the golden cookie sound should be somewhat clearer<br>'+
558 '-the ascend screen should be less CPU-hungry<br>'+
559 '</div>'+
560 '</div>'+
561
562 '</div><div class="subsection update">'+
563 '<div class="title">08/08/2013 - game launch</div>'+
564 '<div class="listing">• made the game in a couple hours, for laughs</div>'+
565 '<div class="listing">• kinda starting to regret it</div>'+
566 '<div class="listing">• ah well</div>'+
567 '</div>'
568 ;
569
570 Game.ready=0;
571
572 Game.Load=function()
573 {
574 //l('javascriptError').innerHTML='<div style="padding:64px 128px;"><div class="title">Loading...</div></div>';
575 Game.Loader=new Loader();
576 Game.Loader.domain='img/';
577 Game.Loader.loaded=Game.Init;
578 Game.Loader.Load(['filler.png']);
579 }
580 Game.ErrorFrame=function()
581 {
582 l('javascriptError').innerHTML=
583 '<div class="title">Oops. Wrong address!</div>'+
584 '<div>It looks like you\'re accessing Cookie Clicker from another URL than the official one.<br>'+
585 'You can <a href="http://orteil.dashnet.org/cookieclicker/" target="_blank">play Cookie Clicker over here</a>!<br>'+
586 '<small>(If for any reason, you are unable to access the game on the official URL, we are currently working on a second domain.)</small></div>';
587 }
588
589
590 Game.Init=function()
591 {
592 Game.ready=1;
593
594 /*=====================================================================================
595 VARIABLES AND PRESETS
596 =======================================================================================*/
597 Game.T=0;
598 Game.drawT=0;
599 Game.loopT=0;
600 Game.fps=30;
601
602 Game.season=Game.baseSeason;
603
604 Game.l=l('game');
605 Game.bounds=0;
606
607 if (Game.mobile==1)
608 {
609 l('wrapper').className='mobile';
610 }
611 Game.clickStr=Game.touchEvents?'ontouchend':'onclick';
612
613 Game.SaveTo='CookieClickerGame';
614 if (Game.beta) Game.SaveTo='CookieClickerGameBeta';
615 l('versionNumber').innerHTML='v. '+Game.version+(Game.beta?' <span style="color:#ff0;">beta</span>':'');
616
617 if (Game.beta) {var me=l('linkVersionBeta');me.parentNode.removeChild(me);}
618 else if (Game.version==1.0466) {var me=l('linkVersionOld');me.parentNode.removeChild(me);}
619 else {var me=l('linkVersionLive');me.parentNode.removeChild(me);}
620
621 //l('links').innerHTML=(Game.beta?'<a href="../" target="blank">Live version</a> | ':'<a href="beta" target="blank">Try the beta!</a> | ')+'<a href="http://orteil.dashnet.org/experiments/cookie/" target="blank">Classic</a>';
622 //l('links').innerHTML='<a href="http://orteil.dashnet.org/experiments/cookie/" target="blank">Cookie Clicker Classic</a>';
623
624 //latency compensator stuff
625 Game.time=Date.now();
626 Game.accumulatedDelay=0;
627 Game.catchupLogic=0;
628 Game.fpsStartTime=0;
629 Game.frameNumber=0;
630 Game.getFps=function()
631 {
632 Game.frameNumber++;
633 var currentTime=(Date.now()-Game.fpsStartTime )/1000;
634 var result=Math.floor((Game.frameNumber/currentTime));
635 if (currentTime>1)
636 {
637 Game.fpsStartTime=Date.now();
638 Game.frameNumber=0;
639 }
640 return result;
641 }
642
643 Game.cookiesEarned=0;
644 Game.cookies=0;
645 Game.cookiesd=0;
646 Game.cookiesPs=1;
647 Game.cookiesReset=0;
648 Game.cookieClicks=0;
649 Game.goldenClicks=0;
650 Game.goldenClicksLocal=0;
651 Game.missedGoldenClicks=0;
652 Game.handmadeCookies=0;
653 Game.milkProgress=0;
654 Game.milkH=Game.milkProgress/2;
655 Game.milkHd=0;
656 Game.milkType=0;
657 Game.backgroundType=0;
658 Game.chimeType=0;
659 Game.prestige=0;
660 Game.heavenlyChips=0;/
661 Game.heavenlyChipsDisplayed=0;
662 Game.heavenlyChipsSpent=0;
663 Game.heavenlyCookies=0;
664 Game.permanentUpgrades=[-1,-1,-1,-1,-1];
665 Game.ascensionMode=0;
666 Game.resets=0;
667
668 Game.volume=50;
669
670 Game.elderWrath=0;
671 Game.elderWrathOld=0;
672 Game.elderWrathD=0;
673 Game.pledges=0;
674 Game.pledgeT=0;
675 Game.researchT=0;
676 Game.nextResearch=0;
677 Game.cookiesSucked=0;
678 Game.cpsSucked=0;
679 Game.wrinklersPopped=0;
680 Game.santaLevel=0;
681 Game.reindeerClicked=0;
682 Game.seasonT=0;
683 Game.seasonUses=0;
684 Game.dragonLevel=0;
685 Game.dragonAura=0;
686 Game.dragonAura2=0;
687
688 Game.blendModesOn=(document.createElement('detect').style.mixBlendMode==='');
689
690 Game.bg='';
691 Game.bgFade='';//fading to background
692 Game.bgR=0;//ratio (0 - not faded, 1 - fully faded)
693 Game.bgRd=0;//ratio displayed
694
695 Game.windowW=window.innerWidth;
696 Game.windowH=window.innerHeight;
697
698 window.addEventListener('resize',function(event)
699 {
700 Game.windowW=window.innerWidth;
701 Game.windowH=window.innerHeight;
702 });
703
704 Game.startDate=parseInt(Date.now());//when we started playing
705 Game.fullDate=parseInt(Date.now());//when we started playing (carries over with resets)
706 Game.lastDate=parseInt(Date.now());
707
708 Game.prefs=[];
709 Game.DefaultPrefs=function()
710 {
711 Game.prefs.particles=1;//particle effects : falling cookies etc
712 Game.prefs.numbers=1;//numbers that pop up when clicking the cookie
713 Game.prefs.autosave=1;//save the game every minute or so
714 Game.prefs.autoupdate=1;//send an AJAX request to the server every 30 minutes (crashes the game when playing offline)
715 Game.prefs.milk=1;//display milk
716 Game.prefs.fancy=1;//CSS shadow effects (might be heavy on some browsers)
717 Game.prefs.warn=0;//warn before closing the window
718 Game.prefs.cursors=1;//display cursors
719 Game.prefs.focus=1;//make the game refresh less frequently when off-focus
720 Game.prefs.popups=0;//use old-style popups
721 Game.prefs.format=0;//shorten numbers
722 Game.prefs.notifs=0;//notifications fade faster
723 Game.prefs.animate=1;//animate buildings
724 Game.prefs.wobbly=1;//wobbly cookie
725 Game.prefs.monospace=0;//alt monospace font for cookies
726 Game.prefs.filters=0;//CSS filter effects (might be heavy on some browsers)
727 Game.prefs.cookiesound=1;//use new cookie click sound
728 Game.prefs.crates=0;//show crates around icons in stats
729 Game.prefs.altDraw=0;//use requestAnimationFrame to update drawing instead of fixed 30 fps setTimeout
730 }
731 Game.DefaultPrefs();
732
733 window.onbeforeunload=function(event)
734 {
735 if (Game.prefs.warn)
736 {
737 if (typeof event=='undefined') event=window.event;
738 if (event) event.returnValue='Are you sure you want to close Cookie Clicker?';
739 }
740 }
741
742 Game.Mobile=function()
743 {
744 if (!Game.mobile)
745 {
746 l('wrapper').className='mobile';
747 Game.mobile=1;
748 }
749 else
750 {
751 l('wrapper').className='';
752 Game.mobile=0;
753 }
754 }
755
756
757 /*=====================================================================================
758 MOD HOOKS (will be subject to change, probably shouldn't be used yet)
759 =======================================================================================*/
760 //really primitive custom mods support - might not be of any use at all (could theoretically be used for custom upgrades and achievements I guess?)
761 Game.customChecks=[];//push functions into this to add them to the "check for upgrade/achievement conditions" that happens every few seconds
762 Game.customInit=[];//add to the initialization call
763 Game.customLogic=[];//add to the logic calls
764 Game.customDraw=[];//add to the draw calls
765 Game.customSave=[];//add to the save write calls (save to your own localstorage key)
766 Game.customLoad=[];//add to the save load calls
767 Game.customReset=[];//add to the reset calls
768 Game.customTickers=[];//add to the random tickers (functions should return arrays of text)
769 Game.customCps=[];//add to the CpS computation (functions should return something to add to the multiplier ie. 0.1 for an addition of 10 to the CpS multiplier)
770 Game.customCpsMult=[];//add to the CpS multiplicative computation (functions should return something to multiply by the multiplier ie. 1.05 for a 5% increase of the multiplier)
771 Game.customMouseCps=[];//add to the cookies earned per click computation (functions should return something to add to the multiplier ie. 0.1 for an addition of 10 to the CpS multiplier)
772 Game.customMouseCpsMult=[];//add to the cookies earned per click multiplicative computation (functions should return something to multiply by the multiplier ie. 1.05 for a 5% increase of the multiplier)
773 Game.customCookieClicks=[];//add to the cookie click calls
774 Game.customCreate=[];//create your new upgrades and achievements in there
775
776 Game.LoadMod=function(url)
777 {
778 var js=document.createElement('script');
779 var id=url.split('/');id=id[id.length-1].split('.')[0];
780 js.setAttribute('type','text/javascript');
781 js.setAttribute('id','modscript_'+id);
782 js.setAttribute('src',url);
783 document.head.appendChild(js);
784 console.log('Loaded the mod '+url+', '+id+'.');
785 }
786
787
788
789
790
791 /*=====================================================================================
792 BAKERY NAME
793 =======================================================================================*/
794 Game.RandomBakeryName=function()
795 {
796 return (Math.random()>0.05?(choose(['Magic','Fantastic','Fancy','Sassy','Snazzy','Pretty','Cute','Pirate','Ninja','Zombie','Robot','Radical','Urban','Cool','Hella','Sweet','Awful','Double','Triple','Turbo','Techno','Disco','Electro','Dancing','Wonder','Mutant','Space','Science','Medieval','Future','Captain','Bearded','Lovely','Tiny','Big','Fire','Water','Frozen','Metal','Plastic','Solid','Liquid','Moldy','Shiny','Happy','Happy Little','Slimy','Tasty','Delicious','Hungry','Greedy','Lethal','Professor','Doctor','Power','Chocolate','Crumbly','Choklit','Righteous','Glorious','Mnemonic','Psychic','Frenetic','Hectic','Crazy','Royal','El','Von'])+' '):'Mc')+choose(['Cookie','Biscuit','Muffin','Scone','Cupcake','Pancake','Chip','Sprocket','Gizmo','Puppet','Mitten','Sock','Teapot','Mystery','Baker','Cook','Grandma','Click','Clicker','Spaceship','Factory','Portal','Machine','Experiment','Monster','Panic','Burglar','Bandit','Booty','Potato','Pizza','Burger','Sausage','Meatball','Spaghetti','Macaroni','Kitten','Puppy','Giraffe','Zebra','Parrot','Dolphin','Duckling','Sloth','Turtle','Goblin','Pixie','Gnome','Computer','Pirate','Ninja','Zombie','Robot']);
797 }
798 Game.GetBakeryName=function() {return Game.RandomBakeryName();}
799 Game.bakeryName=Game.GetBakeryName();
800 Game.bakeryNameL=l('bakeryName');
801 Game.bakeryNameL.innerHTML=Game.bakeryName+'\'s bakery';
802 Game.bakeryNameSet=function(what)
803 {
804 Game.bakeryName=what.replace(/\W+/g,' ');
805 Game.bakeryName=Game.bakeryName.substring(0,28);
806 Game.bakeryNameRefresh();
807 }
808 Game.bakeryNameRefresh=function()
809 {
810 var name=Game.bakeryName;
811 if (name.slice(-1).toLowerCase()=='s') name+='\' bakery'; else name+='\'s bakery';
812 Game.bakeryNameL.innerHTML=name;
813 name=Game.bakeryName.toLowerCase();
814 if (name=='orteil') Game.Win('God complex');
815 if (name.indexOf('saysopensesame',name.length-('saysopensesame').length)>0 && !Game.sesame) Game.OpenSesame();
816 Game.recalculateGains=1;
817 }
818 Game.bakeryNamePrompt=function()
819 {
820 Game.Prompt('<h3>Name your bakery</h3><div class="block" style="text-align:center;">What should your bakery\'s name be?</div><div class="block"><input type="text" style="text-align:center;width:100%;" id="bakeryNameInput" value="'+Game.bakeryName+'"/></div>',[['Confirm','if (l(\'bakeryNameInput\').value.length>0) {Game.bakeryNameSet(l(\'bakeryNameInput\').value);Game.Win(\'What\\\'s in a name\');Game.ClosePrompt();}'],['Random','Game.bakeryNamePromptRandom();'],'Cancel']);
821 l('bakeryNameInput').focus();
822 l('bakeryNameInput').select();
823 }
824 Game.bakeryNamePromptRandom=function()
825 {
826 l('bakeryNameInput').value=Game.RandomBakeryName();
827 }
828 AddEvent(Game.bakeryNameL,'click',Game.bakeryNamePrompt);
829
830 /*=====================================================================================
831 UPDATE CHECKER
832 =======================================================================================*/
833 Game.CheckUpdates=function()
834 {
835 ajax('server.php?q=checkupdate',Game.CheckUpdatesResponse);
836 }
837 Game.CheckUpdatesResponse=function(response)
838 {
839 var r=response.split('|');
840 var str='';
841 if (r[0]=='alert')
842 {
843 if (r[1]) str=r[1];
844 }
845 else if (parseFloat(r[0])>Game.version)
846 {
847 str='<b>New version available : v. '+r[0]+'!</b>';
848 if (r[1]) str+='<br><small>Update note : "'+r[1]+'"</small>';
849 str+='<br><b>Refresh to get it!</b>';
850 }
851 if (str!='')
852 {
853 l('alert').innerHTML=str;
854 l('alert').style.display='block';
855 }
856 }
857
858 Game.useLocalStorage=1;
859 //window.localStorage.clear();
860
861 /*=====================================================================================
862 SAVE
863 =======================================================================================*/
864 Game.ExportSave=function()
865 {
866 Game.Prompt('<h3>Export save</h3><div class="block">This is your save code.<br>Copy it and keep it somewhere safe!</div><div class="block"><textarea id="textareaPrompt" style="width:100%;height:128px;" readonly>'+Game.WriteSave(1)+'</textarea></div>',['All done!']);//prompt('Copy this text and keep it somewhere safe!',Game.WriteSave(1));
867 l('textareaPrompt').focus();l('textareaPrompt').select();
868 }
869 Game.ImportSave=function()
870 {
871 Game.Prompt('<h3>Import save</h3><div class="block">Please paste in the code that was given to you on save export.</div><div class="block"><textarea id="textareaPrompt" style="width:100%;height:128px;"></textarea></div>',[['Load','if (l(\'textareaPrompt\').value.length>0) {Game.ImportSaveCode(l(\'textareaPrompt\').value);Game.ClosePrompt();}'],'Nevermind']);//prompt('Please paste in the text that was given to you on save export.','');
872 l('textareaPrompt').focus();
873 }
874 Game.ImportSaveCode=function(save)
875 {
876 if (save && save!='') Game.LoadSave(save);
877 }
878
879 Game.FileSave=function()
880 {
881 var filename=Game.bakeryName.replace(/[^a-zA-Z0-9]+/g,'')+'Bakery';
882 var text=Game.WriteSave(1);
883 var blob=new Blob([text],{type:'text/plain;charset=utf-8'});
884 saveAs(blob,filename+'.txt');
885 }
886 Game.FileLoad=function(e)
887 {
888 if (e.target.files.length==0) return false;
889 var file=e.target.files[0];
890 var reader=new FileReader();
891 reader.onload=function(e)
892 {
893 Game.ImportSaveCode(e.target.result);
894 }
895 reader.readAsText(file);
896 }
897
898 Game.WriteSave=function(type)
899 {
900 //type : none is default, 1=return string only, 2=return uncompressed string, 3=return uncompressed, commented string
901 Game.lastDate=parseInt(Date.now());
902 var str='';
903 if (type==3) str+='\nGame version\n';
904 str+=Game.version+'|';
905 str+='|';//just in case we need some more stuff here
906 if (type==3) str+='\n\nRun details';
907 str+=//save stats
908 (type==3?'\n run start date : ':'')+parseInt(Game.startDate)+';'+
909 (type==3?'\n legacy start date : ':'')+parseInt(Game.fullDate)+';'+
910 (type==3?'\n date when we last opened the game : ':'')+parseInt(Game.lastDate)+';'+
911 (type==3?'\n bakery name : ':'')+(Game.bakeryName)+
912 '|';
913 if (type==3) str+='\n\nPacked preferences bitfield\n ';
914 var str2=//prefs
915 (Game.prefs.particles?'1':'0')+
916 (Game.prefs.numbers?'1':'0')+
917 (Game.prefs.autosave?'1':'0')+
918 (Game.prefs.autoupdate?'1':'0')+
919 (Game.prefs.milk?'1':'0')+
920 (Game.prefs.fancy?'1':'0')+
921 (Game.prefs.warn?'1':'0')+
922 (Game.prefs.cursors?'1':'0')+
923 (Game.prefs.focus?'1':'0')+
924 (Game.prefs.format?'1':'0')+
925 (Game.prefs.notifs?'1':'0')+
926 (Game.prefs.wobbly?'1':'0')+
927 (Game.prefs.monospace?'1':'0')+
928 (Game.prefs.filters?'1':'0')+
929 (Game.prefs.cookiesound?'1':'0')+
930 (Game.prefs.crates?'1':'0')+
931 '';
932 str2=pack2(str2);
933 str+=str2+'|';
934 if (type==3) str+='\n\nMisc game data';
935 str+=
936 (type==3?'\n cookies : ':'')+parseFloat(Game.cookies).toString()+';'+
937 (type==3?'\n total cookies earned : ':'')+parseFloat(Game.cookiesEarned).toString()+';'+
938 (type==3?'\n cookie clicks : ':'')+parseInt(Math.floor(Game.cookieClicks))+';'+
939 (type==3?'\n golden cookie clicks : ':'')+parseInt(Math.floor(Game.goldenClicks))+';'+
940 (type==3?'\n cookies made by clicking : ':'')+parseFloat(Game.handmadeCookies).toString()+';'+
941 (type==3?'\n golden cookies missed : ':'')+parseInt(Math.floor(Game.missedGoldenClicks))+';'+
942 (type==3?'\n background type : ':'')+parseInt(Math.floor(Game.backgroundType))+';'+
943 (type==3?'\n milk type : ':'')+parseInt(Math.floor(Game.milkType))+';'+
944 (type==3?'\n cookies from past runs : ':'')+parseFloat(Game.cookiesReset).toString()+';'+
945 (type==3?'\n elder wrath : ':'')+parseInt(Math.floor(Game.elderWrath))+';'+
946 (type==3?'\n pledges : ':'')+parseInt(Math.floor(Game.pledges))+';'+
947 (type==3?'\n pledge time left : ':'')+parseInt(Math.floor(Game.pledgeT))+';'+
948 (type==3?'\n currently researching : ':'')+parseInt(Math.floor(Game.nextResearch))+';'+
949 (type==3?'\n research time left : ':'')+parseInt(Math.floor(Game.researchT))+';'+
950 (type==3?'\n ascensions : ':'')+parseInt(Math.floor(Game.resets))+';'+
951 (type==3?'\n golden cookie clicks (this run) : ':'')+parseInt(Math.floor(Game.goldenClicksLocal))+';'+
952 (type==3?'\n cookies sucked by wrinklers : ':'')+parseFloat(Game.cookiesSucked).toString()+';'+
953 (type==3?'\n wrinkles popped : ':'')+parseInt(Math.floor(Game.wrinklersPopped))+';'+
954 (type==3?'\n santa level : ':'')+parseInt(Math.floor(Game.santaLevel))+';'+
955 (type==3?'\n reindeer clicked : ':'')+parseInt(Math.floor(Game.reindeerClicked))+';'+
956 (type==3?'\n season time left : ':'')+parseInt(Math.floor(Game.seasonT))+';'+
957 (type==3?'\n season switcher uses : ':'')+parseInt(Math.floor(Game.seasonUses))+';'+
958 (type==3?'\n current season : ':'')+(Game.season?Game.season:'')+';';
959 var wrinklers=Game.SaveWrinklers();
960 str+=
961 (type==3?'\n amount of cookies contained in wrinklers : ':'')+parseFloat(Math.floor(wrinklers.amount))+';'+
962 (type==3?'\n number of wrinklers : ':'')+parseInt(Math.floor(wrinklers.number))+';'+
963 (type==3?'\n prestige level : ':'')+parseFloat(Game.prestige).toString()+';'+
964 (type==3?'\n heavenly chips : ':'')+parseFloat(Game.heavenlyChips).toString()+';'+
965 (type==3?'\n heavenly chips spent : ':'')+parseFloat(Game.heavenlyChipsSpent).toString()+';'+
966 (type==3?'\n heavenly cookies : ':'')+parseFloat(Game.heavenlyCookies).toString()+';'+
967 (type==3?'\n ascension mode : ':'')+parseInt(Math.floor(Game.ascensionMode))+';'+
968 (type==3?'\n permanent upgrades : ':'')+parseInt(Math.floor(Game.permanentUpgrades[0]))+';'+parseInt(Math.floor(Game.permanentUpgrades[1]))+';'+parseInt(Math.floor(Game.permanentUpgrades[2]))+';'+parseInt(Math.floor(Game.permanentUpgrades[3]))+';'+parseInt(Math.floor(Game.permanentUpgrades[4]))+';'+
969 (type==3?'\n dragon level : ':'')+parseInt(Math.floor(Game.dragonLevel))+';'+
970 (type==3?'\n dragon aura : ':'')+parseInt(Math.floor(Game.dragonAura))+';'+
971 (type==3?'\n dragon aura 2 : ':'')+parseInt(Math.floor(Game.dragonAura2))+';'+
972 (type==3?'\n chime type : ':'')+parseInt(Math.floor(Game.chimeType))+';'+
973 (type==3?'\n volume : ':'')+parseInt(Math.floor(Game.volume))+';'+
974 (type==3?'\n number of shiny wrinklers : ':'')+parseInt(Math.floor(wrinklers.shinies))+';'+
975 (type==3?'\n amount of cookies contained in shiny wrinklers : ':'')+parseFloat(Math.floor(wrinklers.amountShinies))+';'+
976 '|';
977
978 if (type==3) str+='\n\nBuildings : amount, bought, cookies produced, special unlocked';
979 for (var i in Game.Objects)//buildings
980 {
981 var me=Game.Objects[i];
982 if (type==3) str+='\n '+me.name+' : ';
983 if (me.vanilla) str+=me.amount+','+me.bought+','+parseFloat(Math.floor(me.totalCookies))+','+(me.specialUnlocked?1:0)+';';
984 }
985 str+='|';
986 if (type==3) str+='\n\nPacked upgrades bitfield (unlocked and bought)\n ';
987 var toCompress=[];
988 for (var i in Game.UpgradesById)//upgrades
989 {
990 var me=Game.UpgradesById[i];
991 if (me.vanilla) toCompress.push(Math.min(me.unlocked,1),Math.min(me.bought,1));
992 };
993
994 toCompress=pack2(toCompress.join(''));//toCompress=pack(toCompress);//CompressLargeBin(toCompress);
995
996 str+=toCompress;
997 str+='|';
998 if (type==3) str+='\n\nPacked achievements bitfield (won)\n ';
999 var toCompress=[];
1000 for (var i in Game.AchievementsById)//achievements
1001 {
1002 var me=Game.AchievementsById[i];
1003 if (me.vanilla) toCompress.push(Math.min(me.won));
1004 }
1005 toCompress=pack2(toCompress.join(''));//toCompress=pack(toCompress);//CompressLargeBin(toCompress);
1006 str+=toCompress;
1007
1008 if (type==3) str+='\n';
1009
1010 for (var i in Game.customSave) {Game.customSave[i]();}
1011
1012 if (type==2 || type==3)
1013 {
1014 return str;
1015 }
1016 else if (type==1)
1017 {
1018 str=escape(utf8_to_b64(str)+'!END!');
1019 return str;
1020 }
1021 else
1022 {
1023 if (Game.useLocalStorage)
1024 {
1025 str=utf8_to_b64(str)+'!END!';
1026 if (str.length<10)
1027 {
1028 if (Game.prefs.popups) Game.Popup('Error while saving.<br>Purchasing an upgrade might fix this.');
1029 else Game.Notify('Saving failed!','Purchasing an upgrade and saving again might fix this.<br>This really shouldn\'t happen; please notify Orteil on his tumblr.');
1030 }
1031 else
1032 {
1033 str=escape(str);
1034 window.localStorage.setItem(Game.SaveTo,str);//aaand save
1035 if (!window.localStorage.getItem(Game.SaveTo))
1036 {
1037 if (Game.prefs.popups) Game.Popup('Error while saving.<br>Export your save instead!');
1038 else Game.Notify('Error while saving','Export your save instead!');
1039 }
1040 else if (document.hasFocus())
1041 {
1042 if (Game.prefs.popups) Game.Popup('Game saved');
1043 else Game.Notify('Game saved','','',1,1);
1044 }
1045 }
1046 }
1047 else//legacy system
1048 {
1049 var now=new Date();//we storin dis for 5 years, people
1050 now.setFullYear(now.getFullYear()+5);//mmh stale cookies
1051 str=utf8_to_b64(str)+'!END!';
1052 Game.saveData=escape(str);
1053 str=Game.SaveTo+'='+escape(str)+'; expires='+now.toUTCString()+';';
1054 document.cookie=str;//aaand save
1055 if (document.cookie.indexOf(Game.SaveTo)<0)
1056 {
1057 if (Game.prefs.popups) Game.Popup('Error while saving.<br>Export your save instead!');
1058 else Game.Notify('Error while saving','Export your save instead!','',0,1);
1059 }
1060 else if (document.hasFocus())
1061 {
1062 if (Game.prefs.popups) Game.Popup('Game saved');
1063 else Game.Notify('Game saved','','',1,1);
1064 }
1065 }
1066 }
1067 }
1068
1069 /*=====================================================================================
1070 LOAD
1071 =======================================================================================*/
1072 Game.LoadSave=function(data)
1073 {
1074 var str='';
1075 if (data) str=unescape(data);
1076 else
1077 {
1078 if (Game.useLocalStorage)
1079 {
1080 var local=window.localStorage.getItem(Game.SaveTo);
1081 if (!local)
1082 {
1083 if (document.cookie.indexOf(Game.SaveTo)>=0)
1084 {
1085 str=unescape(document.cookie.split(Game.SaveTo+'=')[1]);
1086 document.cookie=Game.SaveTo+'=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
1087 }
1088 else return false;
1089 }
1090 else
1091 {
1092 str=unescape(local);
1093 }
1094 }
1095 else//legacy system
1096 {
1097 if (document.cookie.indexOf(Game.SaveTo)>=0) str=unescape(document.cookie.split(Game.SaveTo+'=')[1]);//get cookie here
1098 else return false;
1099 }
1100 }
1101
1102 if (str!='')
1103 {
1104 var version=0;
1105 var oldstr=str.split('|');
1106 if (oldstr[0]<1) {}
1107 else
1108 {
1109 str=str.split('!END!')[0];
1110 str=b64_to_utf8(str);
1111 }
1112 if (str!='')
1113 {
1114 var spl='';
1115 str=str.split('|');
1116 version=parseFloat(str[0]);
1117
1118 if (isNaN(version) || str.length<5)
1119 {
1120 if (Game.prefs.popups) Game.Popup('Oops, looks like the import string is all wrong!');
1121 else Game.Notify('Error importing save','Oops, looks like the import string is all wrong!','',6,1);
1122 return false;
1123 }
1124 if (version>=1 && version>Game.version)
1125 {
1126 if (Game.prefs.popups) Game.Popup('Error : you are attempting to load a save from a future version (v. '+version+'; you are using v. '+Game.version+').');
1127 else Game.Notify('Error importing save','You are attempting to load a save from a future version (v. '+version+'; you are using v. '+Game.version+').','',6,1);
1128 return false;
1129 }
1130 if (version==1.0501)
1131 {
1132 setTimeout(function(){Game.Prompt('<h3>New beta</h3><div class="block">Hey there! Unfortunately, your old beta save won\'t work here anymore; you\'ll have to start fresh or import your save from the live version.<div class="line"></div>Thank you for beta-testing Cookie Clicker, we hope you\'ll enjoy it and find strange and interesting bugs!</div>',[['Alright then!','Game.ClosePrompt();']]);},200);
1133 return false;
1134 }
1135 else if (version<1.0501)
1136 {
1137 setTimeout(function(){Game.Prompt('<h3>Update</h3><div class="block"><b>Hey there!</b> Cookie Clicker just received a pretty substantial update, and you might notice that some things have been moved around. Don\'t panic!<div class="line"></div>Your building numbers may look strange, making it seem like you own buildings you\'ve never bought; this is because we\'ve added <b>3 new buildings</b> after factories (and swapped mines and factories), offsetting everything after them. Likewise, some building-related upgrades and achievements may look a tad shuffled around. This is all perfectly normal!<div class="line"></div>We\'ve also rebalanced Heavenly Chips amounts and behavior. Your amount of chips might be lower or higher than before.<br>You can now ascend through the <b>Legacy button</b> at the top!<div class="line"></div>Thank you for playing Cookie Clicker. We\'ve put a lot of work and care into this update and we hope you\'ll enjoy it!</div>',[['Neat!','Game.ClosePrompt();']]);},200);
1138 }
1139 if (version>=1)
1140 {
1141 spl=str[2].split(';');//save stats
1142 Game.startDate=parseInt(spl[0]);
1143 Game.fullDate=parseInt(spl[1]);
1144 Game.lastDate=parseInt(spl[2]);
1145 Game.bakeryName=spl[3]?spl[3]:Game.GetBakeryName();
1146 //prefs
1147 if (version<1.0503) spl=str[3].split('');
1148 else spl=unpack2(str[3]).split('');
1149 Game.prefs.particles=parseInt(spl[0]);
1150 Game.prefs.numbers=parseInt(spl[1]);
1151 Game.prefs.autosave=parseInt(spl[2]);
1152 Game.prefs.autoupdate=spl[3]?parseInt(spl[3]):1;
1153 Game.prefs.milk=spl[4]?parseInt(spl[4]):1;
1154 Game.prefs.fancy=parseInt(spl[5]);if (Game.prefs.fancy) Game.removeClass('noFancy'); else if (!Game.prefs.fancy) Game.addClass('noFancy');
1155 Game.prefs.warn=spl[6]?parseInt(spl[6]):0;
1156 Game.prefs.cursors=spl[7]?parseInt(spl[7]):0;
1157 Game.prefs.focus=spl[8]?parseInt(spl[8]):0;
1158 Game.prefs.format=spl[9]?parseInt(spl[9]):0;
1159 Game.prefs.notifs=spl[10]?parseInt(spl[10]):0;
1160 Game.prefs.wobbly=spl[11]?parseInt(spl[11]):0;
1161 Game.prefs.monospace=spl[12]?parseInt(spl[12]):0;
1162 Game.prefs.filters=parseInt(spl[13]);if (Game.prefs.filters) Game.removeClass('noFilters'); else if (!Game.prefs.filters) Game.addClass('noFilters');
1163 Game.prefs.cookiesound=spl[14]?parseInt(spl[14]):1;
1164 Game.prefs.crates=spl[15]?parseInt(spl[15]):0;
1165 BeautifyAll();
1166 spl=str[4].split(';');//cookies and lots of other stuff
1167 Game.cookies=parseFloat(spl[0]);
1168 Game.cookiesEarned=parseFloat(spl[1]);
1169 Game.cookieClicks=spl[2]?parseInt(spl[2]):0;
1170 Game.goldenClicks=spl[3]?parseInt(spl[3]):0;
1171 Game.handmadeCookies=spl[4]?parseFloat(spl[4]):0;
1172 Game.missedGoldenClicks=spl[5]?parseInt(spl[5]):0;
1173 Game.backgroundType=spl[6]?parseInt(spl[6]):0;
1174 Game.milkType=spl[7]?parseInt(spl[7]):0;
1175 Game.cookiesReset=spl[8]?parseFloat(spl[8]):0;
1176 Game.elderWrath=spl[9]?parseInt(spl[9]):0;
1177 Game.pledges=spl[10]?parseInt(spl[10]):0;
1178 Game.pledgeT=spl[11]?parseInt(spl[11]):0;
1179 Game.nextResearch=spl[12]?parseInt(spl[12]):0;
1180 Game.researchT=spl[13]?parseInt(spl[13]):0;
1181 Game.resets=spl[14]?parseInt(spl[14]):0;
1182 Game.goldenClicksLocal=spl[15]?parseInt(spl[15]):0;
1183 Game.cookiesSucked=spl[16]?parseFloat(spl[16]):0;
1184 Game.wrinklersPopped=spl[17]?parseInt(spl[17]):0;
1185 Game.santaLevel=spl[18]?parseInt(spl[18]):0;
1186 Game.reindeerClicked=spl[19]?parseInt(spl[19]):0;
1187 Game.seasonT=spl[20]?parseInt(spl[20]):0;
1188 Game.seasonUses=spl[21]?parseInt(spl[21]):0;
1189 Game.season=spl[22]?spl[22]:Game.baseSeason;
1190 var wrinklers={amount:spl[23]?parseFloat(spl[23]):0,number:spl[24]?parseInt(spl[24]):0};
1191 Game.prestige=spl[25]?parseFloat(spl[25]):0;
1192 Game.heavenlyChips=spl[26]?parseFloat(spl[26]):0;
1193 Game.heavenlyChipsSpent=spl[27]?parseFloat(spl[27]):0;
1194 Game.heavenlyCookies=spl[28]?parseFloat(spl[28]):0;
1195 Game.ascensionMode=spl[29]?parseInt(spl[29]):0;
1196 Game.permanentUpgrades[0]=spl[30]?parseInt(spl[30]):-1;Game.permanentUpgrades[1]=spl[31]?parseInt(spl[31]):-1;Game.permanentUpgrades[2]=spl[32]?parseInt(spl[32]):-1;Game.permanentUpgrades[3]=spl[33]?parseInt(spl[33]):-1;Game.permanentUpgrades[4]=spl[34]?parseInt(spl[34]):-1;
1197 //if (version<1.05) {Game.heavenlyChipsEarned=Game.HowMuchPrestige(Game.cookiesReset);Game.heavenlyChips=Game.heavenlyChipsEarned;}
1198 Game.dragonLevel=spl[35]?parseInt(spl[35]):0;
1199 Game.dragonAura=spl[36]?parseInt(spl[36]):0;
1200 Game.dragonAura2=spl[37]?parseInt(spl[37]):0;
1201 Game.chimeType=spl[38]?parseInt(spl[38]):0;
1202 Game.volume=spl[39]?parseInt(spl[39]):50;
1203 wrinklers.shinies=spl[40]?parseInt(spl[40]):0;
1204 wrinklers.amountShinies=spl[41]?parseFloat(spl[41]):0;
1205
1206 spl=str[5].split(';');//buildings
1207 Game.BuildingsOwned=0;
1208 for (var i in Game.ObjectsById)
1209 {
1210 var me=Game.ObjectsById[i];
1211 if (spl[i])
1212 {
1213 var mestr=spl[i].toString().split(',');
1214 me.amount=parseInt(mestr[0]);me.bought=parseInt(mestr[1]);me.totalCookies=parseFloat(mestr[2]);me.specialUnlocked=0;//parseInt(mestr[3]);
1215 Game.BuildingsOwned+=me.amount;
1216 }
1217 else
1218 {
1219 me.amount=0;me.unlocked=0;me.bought=0;me.totalCookies=0;
1220 }
1221 }
1222 if (version<1.035)//old non-binary algorithm
1223 {
1224 spl=str[6].split(';');//upgrades
1225 Game.UpgradesOwned=0;
1226 for (var i in Game.UpgradesById)
1227 {
1228 var me=Game.UpgradesById[i];
1229 if (spl[i])
1230 {
1231 var mestr=spl[i].split(',');
1232 me.unlocked=parseInt(mestr[0]);me.bought=parseInt(mestr[1]);
1233 if (me.bought && Game.CountsAsUpgradeOwned(me.pool)) Game.UpgradesOwned++;
1234 }
1235 else
1236 {
1237 me.unlocked=0;me.bought=0;
1238 }
1239 }
1240 if (str[7]) spl=str[7].split(';'); else spl=[];//achievements
1241 Game.AchievementsOwned=0;
1242 for (var i in Game.AchievementsById)
1243 {
1244 var me=Game.AchievementsById[i];
1245 if (spl[i])
1246 {
1247 var mestr=spl[i].split(',');
1248 me.won=parseInt(mestr[0]);
1249 }
1250 else
1251 {
1252 me.won=0;
1253 }
1254 if (me.won && me.pool!='shadow') Game.AchievementsOwned++;
1255 }
1256 }
1257 else if (version<1.0502)//old awful packing system
1258 {
1259 if (str[6]) spl=str[6]; else spl=[];//upgrades
1260 if (version<1.05) spl=UncompressLargeBin(spl);
1261 else spl=unpack(spl);
1262 Game.UpgradesOwned=0;
1263 for (var i in Game.UpgradesById)
1264 {
1265 var me=Game.UpgradesById[i];
1266 if (spl[i*2])
1267 {
1268 var mestr=[spl[i*2],spl[i*2+1]];
1269 me.unlocked=parseInt(mestr[0]);me.bought=parseInt(mestr[1]);
1270 if (me.bought && Game.CountsAsUpgradeOwned(me.pool)) Game.UpgradesOwned++;
1271 }
1272 else
1273 {
1274 me.unlocked=0;me.bought=0;
1275 }
1276 }
1277 if (str[7]) spl=str[7]; else spl=[];//achievements
1278 if (version<1.05) spl=UncompressLargeBin(spl);
1279 else spl=unpack(spl);
1280 Game.AchievementsOwned=0;
1281 for (var i in Game.AchievementsById)
1282 {
1283 var me=Game.AchievementsById[i];
1284 if (spl[i])
1285 {
1286 var mestr=[spl[i]];
1287 me.won=parseInt(mestr[0]);
1288 }
1289 else
1290 {
1291 me.won=0;
1292 }
1293 if (me.won && me.pool!='shadow') Game.AchievementsOwned++;
1294 }
1295 }
1296 else
1297 {
1298 if (str[6]) spl=str[6]; else spl=[];//upgrades
1299 spl=unpack2(spl).split('');
1300 Game.UpgradesOwned=0;
1301 for (var i in Game.UpgradesById)
1302 {
1303 var me=Game.UpgradesById[i];
1304 if (spl[i*2])
1305 {
1306 var mestr=[spl[i*2],spl[i*2+1]];
1307 me.unlocked=parseInt(mestr[0]);me.bought=parseInt(mestr[1]);
1308 if (me.bought && Game.CountsAsUpgradeOwned(me.pool)) Game.UpgradesOwned++;
1309 }
1310 else
1311 {
1312 me.unlocked=0;me.bought=0;
1313 }
1314 }
1315 if (str[7]) spl=str[7]; else spl=[];//achievements
1316 spl=unpack2(spl).split('');
1317 Game.AchievementsOwned=0;
1318 for (var i in Game.AchievementsById)
1319 {
1320 var me=Game.AchievementsById[i];
1321 if (spl[i])
1322 {
1323 var mestr=[spl[i]];
1324 me.won=parseInt(mestr[0]);
1325 }
1326 else
1327 {
1328 me.won=0;
1329 }
1330 if (me.won && me.pool!='shadow') Game.AchievementsOwned++;
1331 }
1332 }
1333
1334 for (var i in Game.ObjectsById)
1335 {
1336 var me=Game.ObjectsById[i];
1337 if (me.buyFunction) me.buyFunction();
1338 me.setSpecial(0);
1339 if (me.special && me.specialUnlocked==1) me.special();
1340 me.refresh();
1341 }
1342
1343 if (version<1.0503)
1344 {
1345 var me=Game.Upgrades['Persistent memory'];me.unlocked=0;me.bought=0;
1346 var me=Game.Upgrades['Season switcher'];me.unlocked=0;me.bought=0;
1347 }
1348
1349 if (Game.backgroundType==-1) Game.backgroundType=0;
1350 if (Game.milkType==-1) Game.milkType=0;
1351
1352
1353 //advance timers
1354 var framesElapsed=Math.ceil(((Date.now()-Game.lastDate)/1000)*Game.fps);
1355 if (Game.pledgeT>0) Game.pledgeT=Math.max(Game.pledgeT-framesElapsed,1);
1356 if (Game.seasonT>0) Game.seasonT=Math.max(Game.seasonT-framesElapsed,1);
1357 if (Game.researchT>0) Game.researchT=Math.max(Game.researchT-framesElapsed,1);
1358
1359
1360 Game.ResetWrinklers();
1361 Game.LoadWrinklers(wrinklers.amount,wrinklers.number,wrinklers.shinies,wrinklers.amountShinies);
1362
1363 //recompute season trigger prices
1364 if (Game.Has('Season switcher')) {for (var i in Game.seasons) {Game.Unlock(Game.seasons[i].trigger);}}
1365 Game.computeSeasonPrices();
1366
1367 //recompute prestige
1368 Game.prestige=Math.floor(Game.HowMuchPrestige(Game.cookiesReset));
1369 //if ((Game.heavenlyChips+Game.heavenlyChipsSpent)<Game.prestige)
1370 //{Game.heavenlyChips=Game.prestige;Game.heavenlyChipsSpent=0;}
1371
1372
1373
1374
1375 if (version==1.037 && Game.beta)//are we opening the new beta? if so, save the old beta to /betadungeons
1376 {
1377 window.localStorage.setItem('CookieClickerGameBetaDungeons',window.localStorage.getItem('CookieClickerGameBeta'));
1378 Game.Notify('Beta save data','Your beta save data has been safely exported to /betadungeons.',20);
1379 }
1380 else if (version==1.0501 && Game.beta)
1381 {
1382 window.localStorage.setItem('CookieClickerGameOld',window.localStorage.getItem('CookieClickerGameBeta'));
1383 //Game.Notify('Beta save data','Your beta save data has been safely exported to /oldbeta.',20);
1384 }
1385 if (version<=1.0466 && !Game.beta)//export the old 2014 version to /v10466
1386 {
1387 window.localStorage.setItem('CookieClickerGamev10466',window.localStorage.getItem('CookieClickerGame'));
1388 //Game.Notify('Beta save data','Your save data has been safely exported to /v10466.',20);
1389 }
1390 if (version==1.9)//are we importing from the 1.9 beta? remove all heavenly upgrades and refund heavenly chips
1391 {
1392 for (var i in Game.UpgradesById)
1393 {
1394 var me=Game.UpgradesById[i];
1395 if (me.bought && me.pool=='prestige')
1396 {
1397 me.unlocked=0;
1398 me.bought=0;
1399 }
1400 }
1401 Game.heavenlyChips=Game.prestige;
1402 Game.heavenlyChipsSpent=0;
1403
1404 setTimeout(function(){Game.Prompt('<h3>Beta patch</h3><div class="block">We\'ve tweaked some things and fixed some others, please check the update notes!<div class="line"></div>Of note : due to changes in prestige balancing, all your heavenly upgrades have been removed and your heavenly chips refunded; you\'ll be able to reallocate them next time you ascend.<div class="line"></div>Thank you again for beta-testing Cookie Clicker!</div>',[['Alright then!','Game.ClosePrompt();']]);},200);
1405 }
1406 if (version<=1.0466)
1407 {
1408 Game.heavenlyChips=Game.prestige;
1409 Game.heavenlyChipsSpent=0;
1410 }
1411
1412 if (Game.ascensionMode!=1)
1413 {
1414 if (Game.Has('Starter kit')) Game.Objects['Cursor'].free=10;
1415 if (Game.Has('Starter kitchen')) Game.Objects['Grandma'].free=5;
1416 }
1417
1418 Game.CalculateGains();
1419
1420 //compute cookies earned while the game was closed
1421 if (Game.mobile || Game.Has('Perfect idling') || Game.Has('Twin Gates of Transcendence'))
1422 {
1423 if (Game.Has('Perfect idling'))
1424 {
1425 var maxTime=60*60*24*1000000000;
1426 var percent=100;
1427 }
1428 else
1429 {
1430 var maxTime=60*60;
1431 if (Game.Has('Belphegor')) maxTime*=2;
1432 if (Game.Has('Mammon')) maxTime*=2;
1433 if (Game.Has('Abaddon')) maxTime*=2;
1434 if (Game.Has('Satan')) maxTime*=2;
1435 if (Game.Has('Asmodeus')) maxTime*=2;
1436 if (Game.Has('Beelzebub')) maxTime*=2;
1437 if (Game.Has('Lucifer')) maxTime*=2;
1438
1439 var percent=5;
1440 if (Game.Has('Angels')) percent+=10;
1441 if (Game.Has('Archangels')) percent+=10;
1442 if (Game.Has('Virtues')) percent+=10;
1443 if (Game.Has('Dominions')) percent+=10;
1444 if (Game.Has('Cherubim')) percent+=10;
1445 if (Game.Has('Seraphim')) percent+=10;
1446 if (Game.Has('God')) percent+=10;
1447
1448 if (Game.Has('Chimera')) {maxTime+=60*60*24*2;percent+=5;}
1449 }
1450
1451 var timeOffline=(Date.now()-Game.lastDate)/1000;
1452 var timeOfflineOptimal=Math.min(timeOffline,maxTime);
1453 var timeOfflineReduced=Math.max(0,timeOffline-timeOfflineOptimal);
1454 var amount=(timeOfflineOptimal+timeOfflineReduced*0.1)*Game.cookiesPs*(percent/100);
1455
1456 if (amount>0)
1457 {
1458 if (Game.prefs.popups) Game.Popup('Earned '+Beautify(amount)+' cookie'+(Math.floor(amount)==1?'':'s')+' while you were away');
1459 else Game.Notify('Welcome back!','You earned <b>'+Beautify(amount)+'</b> cookie'+(Math.floor(amount)==1?'':'s')+' while you were away.<br>('+Game.sayTime(timeOfflineOptimal*Game.fps)+' at '+Math.floor(percent)+'% CpS'+(timeOfflineReduced?', plus '+Game.sayTime(timeOfflineReduced*Game.fps)+' at '+(Math.floor(percent*10)/100)+'%':'')+'.)',[Math.floor(Math.random()*16),11]);
1460 Game.Earn(amount);
1461 }
1462 }
1463
1464
1465 Game.bakeryNameRefresh();
1466
1467 }
1468 else//importing old version save
1469 {
1470 Game.Notify('Error importing save','Sorry, you can\'t import saves from the old version anymore.','',6,1);
1471 return false;
1472 }
1473
1474
1475 Game.RebuildUpgrades();
1476
1477 Game.TickerAge=0;
1478
1479 Game.elderWrathD=0;
1480 Game.recalculateGains=1;
1481 Game.storeToRefresh=1;
1482 Game.upgradesToRebuild=1;
1483
1484 Game.buyBulk=1;Game.buyMode=1;Game.storeBulkButton(-1);
1485
1486 Game.specialTab='';
1487 Game.ToggleSpecialMenu(0);
1488
1489 Game.killShimmers();
1490
1491 if (Game.T>Game.fps*5 && Game.ReincarnateTimer==0)//fade out of black and pop the cookie
1492 {
1493 Game.ReincarnateTimer=1;
1494 Game.addClass('reincarnating');
1495 Game.BigCookieSize=0;
1496 }
1497
1498 if (Game.prefs.popups) Game.Popup('Game loaded');
1499 else Game.Notify('Game loaded','','',1,1);
1500 }
1501 }
1502 else return false;
1503 return true;
1504 }
1505
1506 /*=====================================================================================
1507 RESET
1508 =======================================================================================*/
1509 Game.Reset=function(hard)
1510 {
1511 var cookiesForfeited=Game.cookiesEarned;
1512 if (!hard)
1513 {
1514 if (cookiesForfeited>=1e6 Game.Win('Sacrifice');
1515 if (cookiesForfeited>=1e9) Game.Win('Oblivion');
1516 if (cookiesForfeited>=1e12) Game.Win('From scratch');
1517 if (cookiesForfeited>=1e15) Game.Win('Nihilism');
1518 if (cookiesForfeited>=1e18) Game.Win('Dematerialize');
1519 if (cookiesForfeited>=1e21) Game.Win('Nil zero zilch');
1520 if (cookiesForfeited>=1e24) Game.Win('Transcendence');
1521 if (cookiesForfeited>=1e27) Game.Win('Obliterate');
1522 if (cookiesForfeited>=1e30) Game.Win('Negative void');
1523 if (cookiesForfeited>=1e33) Game.Win('To crumbs, you say?');
1524 }
1525
1526 Game.cookiesReset+=Game.cookiesEarned;
1527 Game.cookies=0;
1528 Game.cookiesEarned=0;
1529 Game.cookieClicks=0;
1530 Game.goldenClicksLocal=0;
1531 //Game.goldenClicks=0;
1532 //Game.missedGoldenClicks=0;
1533 Game.handmadeCookies=0;
1534 if (hard)
1535 {
1536 Game.backgroundType=0;
1537 Game.milkType=0;
1538 Game.chimeType=0;
1539 }
1540 Game.pledges=0;
1541 Game.pledgeT=0;
1542 Game.elderWrath=0;
1543 Game.nextResearch=0;
1544 Game.researchT=0;
1545 Game.seasonT=0;
1546 Game.seasonUses=0;
1547 Game.season=Game.baseSeason;
1548 Game.computeSeasonPrices();
1549
1550 Game.startDate=parseInt(Date.now());
1551 Game.lastDate=parseInt(Date.now());
1552
1553 Game.cookiesSucked=0;
1554 Game.wrinklersPopped=0;
1555 Game.ResetWrinklers();
1556
1557 Game.santaLevel=0;
1558 Game.reindeerClicked=0;
1559
1560 Game.dragonLevel=0;
1561 Game.dragonAura=0;
1562 Game.dragonAura2=0;
1563
1564 if (Game.gainedPrestige>0) Game.resets++;
1565 Game.gainedPrestige=0;
1566
1567 for (var i in Game.ObjectsById)
1568 {
1569 var me=Game.ObjectsById[i];
1570 me.amount=0;me.bought=0;me.free=0;me.totalCookies=0;me.specialUnlocked=0;
1571 me.setSpecial(0);
1572 me.refresh();
1573 }
1574 for (var i in Game.UpgradesById)
1575 {
1576 var me=Game.UpgradesById[i];
1577 if (hard || me.pool!='prestige')
1578 {me.unlocked=0;me.bought=0;}
1579 }
1580
1581 Game.BuildingsOwned=0;
1582 Game.UpgradesOwned=0;
1583
1584 if (!hard)
1585 {
1586 if (Game.ascensionMode!=1)
1587 {
1588 for (var i in Game.permanentUpgrades)
1589 {
1590 if (Game.permanentUpgrades[i]!=-1)
1591 {Game.UpgradesById[Game.permanentUpgrades[i]].earn();}
1592 }
1593 if (Game.Has('Season switcher')) {for (var i in Game.seasons) {Game.Unlock(Game.seasons[i].trigger);}}
1594
1595 if (Game.Has('Starter kit')) Game.Objects['Cursor'].getFree(10);
1596 if (Game.Has('Starter kitchen')) Game.Objects['Grandma'].getFree(5);
1597 }
1598 }
1599
1600 /*for (var i in Game.AchievementsById)
1601 {
1602 var me=Game.AchievementsById[i];
1603 me.won=0;
1604 }*/
1605 //Game.DefaultPrefs();
1606 BeautifyAll();
1607
1608 Game.RebuildUpgrades();
1609 Game.TickerAge=0;
1610 Game.recalculateGains=1;
1611 Game.storeToRefresh=1;
1612 Game.upgradesToRebuild=1;
1613 Game.killShimmers();
1614
1615 Game.buyBulk=1;Game.buyMode=1;Game.storeBulkButton(-1);
1616
1617 l('toggleBox').style.display='none';
1618 l('toggleBox').innerHTML='';
1619 Game.choiceSelectorOn=-1;
1620 Game.specialTab='';
1621 Game.ToggleSpecialMenu(0);
1622
1623 for (var i in Game.customReset) {Game.customReset[i]();}
1624
1625 if (hard)
1626 {
1627 if (Game.T>Game.fps*5 && Game.ReincarnateTimer==0)//fade out of black and pop the cookie
1628 {
1629 Game.ReincarnateTimer=1;
1630 Game.addClass('reincarnating');
1631 Game.BigCookieSize=0;
1632 }
1633 if (Game.prefs.popups) Game.Popup('Game reset');
1634 else Game.Notify('Game reset','So long, cookies.',[21,6],6);
1635 }
1636 }
1637 Game.HardReset=function(bypass)
1638 {
1639 if (!bypass)
1640 {
1641 Game.Prompt('<h3>Wipe save</h3><div class="block">Do you REALLY want to wipe your save?<br><small>You will lose your progress, your achievements, and your heavenly chips!</small></div>',[['Yes!','Game.ClosePrompt();Game.HardReset(1);'],'No']);
1642 }
1643 else if (bypass==1)
1644 {
1645 Game.Prompt('<h3>Wipe save</h3><div class="block">Whoah now, are you really, <b><i>REALLY</i></b> sure you want to go through with this?<br><small>Don\'t say we didn\'t warn you!</small></div>',[['Do it!','Game.ClosePrompt();Game.HardReset(2);'],'No']);
1646 }
1647 else
1648 {
1649 for (var i in Game.AchievementsById)
1650 {
1651 var me=Game.AchievementsById[i];
1652 me.won=0;
1653 }
1654 Game.AchievementsOwned=0;
1655 Game.goldenClicks=0;
1656 Game.missedGoldenClicks=0;
1657 Game.Reset(1);
1658 Game.resets=0;
1659 Game.fullDate=parseInt(Date.now());
1660 Game.bakeryName=Game.GetBakeryName();
1661 Game.bakeryNameRefresh();
1662 Game.cookiesReset=0;
1663 Game.prestige=0;
1664 Game.heavenlyChips=0;
1665 Game.heavenlyChipsSpent=0;
1666 Game.heavenlyCookies=0;
1667 Game.permanentUpgrades=[-1,-1,-1,-1,-1];
1668 Game.ascensionMode=0;
1669 }
1670 }
1671
1672
1673 /*=====================================================================================
1674 TOOLTIP
1675 =======================================================================================*/
1676 Game.tooltip={text:'',x:0,y:0,origin:'',on:0,tt:l('tooltip'),tta:l('tooltipAnchor'),shouldHide:1,dynamic:0};
1677 Game.tooltip.draw=function(from,text,origin)
1678 {
1679 this.shouldHide=0;
1680 this.text=text;
1681 //this.x=x;
1682 //this.y=y;
1683 this.origin=origin;
1684 var tt=this.tt;
1685 var tta=this.tta;
1686 tt.style.left='auto';
1687 tt.style.top='auto';
1688 tt.style.right='auto';
1689 tt.style.bottom='auto';
1690 tt.innerHTML=typeof(this.text)=='function'?unescape(this.text()):unescape(this.text);
1691 tta.style.display='block';
1692 tta.style.visibility='hidden';
1693 Game.tooltip.update();
1694 tta.style.visibility='visible';
1695 this.on=1;
1696 }
1697 Game.tooltip.update=function()
1698 {
1699 var X=0;
1700 var Y=0;
1701 if (this.origin=='store')
1702 {
1703 X=Game.windowW-332-this.tt.clientWidth;
1704 Y=Game.mouseY-32;
1705 if (Game.onCrate) Y=Game.onCrate.getBoundingClientRect().top-42;
1706 Y=Math.max(0,Math.min(Game.windowH-this.tt.clientHeight-44,Y));
1707 /*this.tta.style.right='308px';//'468px';
1708 this.tta.style.left='auto';
1709 if (Game.onCrate) Y=Game.onCrate.getBoundingClientRect().top-2;
1710 this.tta.style.top=Math.max(0,Math.min(Game.windowH-this.tt.clientHeight-64,Y-48))+'px';*/
1711 }
1712 else
1713 {
1714 if (Game.onCrate)
1715 {
1716 var rect=Game.onCrate.getBoundingClientRect();
1717 rect={left:rect.left,top:rect.top,right:rect.right,bottom:rect.bottom};
1718 if (rect.left==0 && rect.top==0)//if we get that bug where we get stuck in the top-left, move to the mouse
1719 {rect.left=Game.mouseX-24;rect.right=Game.mouseX+24;rect.top=Game.mouseY-24;rect.bottom=Game.mouseY+24;}
1720 if (this.origin=='left')
1721 {
1722 X=rect.left-this.tt.clientWidth-16;
1723 Y=rect.top+(rect.bottom-rect.top)/2-this.tt.clientHeight/2-38;
1724 Y=Math.max(0,Math.min(Game.windowH-this.tt.clientHeight-19,Y));
1725 if (X<0) X=rect.right;
1726 }
1727 else
1728 {
1729 X=rect.left+(rect.right-rect.left)/2-this.tt.clientWidth/2-8;
1730 Y=rect.top-this.tt.clientHeight-48;
1731 X=Math.max(0,Math.min(Game.windowW-this.tt.clientWidth-16,X));
1732 if (Y<0) Y=rect.bottom-32;
1733 }
1734 }
1735 else if (this.origin=='bottom-right')
1736 {
1737 X=Game.mouseX+8;
1738 Y=Game.mouseY-32;
1739 X=Math.max(0,Math.min(Game.windowW-this.tt.clientWidth-16,X));
1740 Y=Math.max(0,Math.min(Game.windowH-this.tt.clientHeight-64,Y));
1741 }
1742 else
1743 {
1744 X=Game.mouseX-this.tt.clientWidth/2-8;
1745 Y=Game.mouseY-this.tt.clientHeight-32;
1746 X=Math.max(0,Math.min(Game.windowW-this.tt.clientWidth-16,X));
1747 Y=Math.max(0,Math.min(Game.windowH-this.tt.clientHeight-64,Y));
1748 }
1749 }
1750 this.tta.style.left=X+'px';
1751 this.tta.style.right='auto';
1752 this.tta.style.top=Y+'px';
1753 this.tta.style.bottom='auto';
1754 if (this.shouldHide) {this.hide();this.shouldHide=0;}
1755 if (Game.drawT%10==0 && typeof(this.text)=='function')
1756 {
1757 this.tt.innerHTML=unescape(this.text());
1758 }
1759 }
1760 Game.tooltip.hide=function()
1761 {
1762 this.tta.style.display='none';
1763 this.dynamic=0;
1764 this.on=0;
1765 }
1766 Game.getTooltip=function(text,origin,isCrate)
1767 {
1768 origin=(origin?origin:'middle');
1769 if (isCrate) return 'onMouseOut="Game.setOnCrate(0);Game.tooltip.shouldHide=1;" onMouseOver="if (!Game.mouseDown) {Game.setOnCrate(this);Game.tooltip.dynamic=0;Game.tooltip.draw(this,\''+escape(text)+'\',\''+origin+'\');Game.tooltip.wobble();}"';
1770 else return 'onMouseOut="Game.tooltip.shouldHide=1;" onMouseOver="Game.tooltip.dynamic=0;Game.tooltip.draw(this,\''+escape(text)+'\',\''+origin+'\');Game.tooltip.wobble();"';
1771 }
1772 Game.getDynamicTooltip=function(func,origin,isCrate)
1773 {
1774 origin=(origin?origin:'middle');
1775 if (isCrate) return 'onMouseOut="Game.setOnCrate(0);Game.tooltip.shouldHide=1;" onMouseOver="if (!Game.mouseDown) {Game.setOnCrate(this);Game.tooltip.dynamic=1;Game.tooltip.draw(this,'+'function(){return '+func+'();}'+',\''+origin+'\');Game.tooltip.wobble();}"';
1776 return 'onMouseOut="Game.tooltip.shouldHide=1;" onMouseOver="Game.tooltip.dynamic=1;Game.tooltip.draw(this,'+'function(){return '+func+'();}'+',\''+origin+'\');Game.tooltip.wobble();"';
1777 }
1778 Game.tooltip.wobble=function()
1779 {
1780 if (false)
1781 {
1782 this.tt.className='framed';
1783 this.tt.offsetWidth=this.tt.offsetWidth;
1784 this.tt.className='framed wobbling';
1785 }
1786 }
1787
1788 Game.onCrate=0;
1789 Game.setOnCrate=function(what)
1790 {
1791 Game.onCrate=what;
1792 }
1793 Game.crate=function(me,context,forceClickStr,id,asFunction)
1794 {
1795
1796 var classes='crate';
1797 var tags=[];
1798 var price='';
1799 var enabled=0;
1800 var noFrame=0;
1801 var attachment='top';
1802 var neuromancy=0;
1803 var mysterious=0;
1804 var clickStr='';
1805 var text=[];
1806
1807 if (me.type=='upgrade')
1808 {
1809 if (context=='stats' && me.bought==0 && !Game.Has('Neuromancy') && (!Game.sesame || me.pool!='debug')) return '';
1810 else if (context=='stats' && (Game.Has('Neuromancy') || (Game.sesame && me.pool=='debug'))) neuromancy=1;
1811 else if (context=='store' && !me.canBuy()) enabled=0;
1812 else if (context=='ascend' && me.bought==0) enabled=0;
1813 else enabled=1;
1814
1815 if (context=='stats' && !Game.prefs.crates) noFrame=1;
1816
1817 classes+=' upgrade';
1818
1819 if (me.pool=='prestige') {tags.push('Heavenly','#efa438');classes+=' heavenly';}
1820 else if (me.pool=='tech') tags.push('Tech','#36a4ff');
1821 else if (me.pool=='cookie') tags.push('Cookie',0);
1822 else if (me.pool=='debug') tags.push('Debug','#00c462');
1823 else if (me.pool=='toggle') tags.push('Switch',0);
1824 else tags.push('Upgrade',0);
1825
1826 if (me.tier!=0) tags.push('Tier : '+Game.Tiers[me.tier].name,Game.Tiers[me.tier].color);
1827
1828 if (me.bought>0)
1829 {
1830 if (me.pool=='tech') tags.push('Researched',0);
1831 else if (me.kitten) tags.push('Purrchased',0);
1832 else tags.push('Purchased',0);
1833 enabled=1;
1834 }
1835
1836 if (neuromancy && me.bought==0) tags.push('Click to learn!','#00c462');
1837 else if (neuromancy && me.bought>0) tags.push('Click to unlearn!','#00c462');
1838
1839 if (neuromancy) clickStr='Game.UpgradesById['+me.id+'].toggle();';
1840
1841 price='<div style="float:right;"><span class="price'+
1842 (me.pool=='prestige'?(Game.heavenlyChips>=me.getPrice()?' heavenly':' heavenly disabled'):'')+
1843 (context=='store'?(me.canBuy()?'':' disabled'):'')+
1844 '">'+Beautify(Math.round(me.getPrice()))+'</span></div>';
1845 }
1846 else if (me.type=='achievement')
1847 {
1848 if (context=='stats' && me.won==0 && me.pool!='normal') return '';
1849 else if (context!='stats') enabled=1;
1850
1851 if (context=='stats' && !Game.prefs.crates) noFrame=1;
1852
1853 classes+=' achievement';
1854 if (me.pool=='shadow') {tags.push('Shadow Achievement','#9700cf');classes+=' shadow';}
1855 else tags.push('Achievement',0);
1856 if (me.won>0) {tags.push('Unlocked',0);enabled=1;}
1857 else {tags.push('Locked',0);mysterious=1;}
1858 if (!enabled) clickStr='Game.AchievementsById['+me.id+'].click();';
1859 }
1860
1861 if (context=='store') attachment='store';
1862
1863 if (forceClickStr) clickStr=forceClickStr;
1864
1865 if (me.choicesFunction) classes+=' selector';
1866
1867 var tagsStr='';
1868 for (var i=0;i<tags.length;i+=2)
1869 {
1870 if (i%2==0) tagsStr+=' <div class="tag" style="color:'+(tags[i+1]==0?'#fff':tags[i+1])+';">['+tags[i]+']</div>';
1871 }
1872 tagsStr=tagsStr.substring(1);
1873
1874 var icon=me.icon;
1875 if (mysterious) icon=[0,7];
1876
1877 if (me.iconFunction) icon=me.iconFunction();
1878
1879 var desc=me.desc;
1880 if (me.bought && context=='store')
1881 {
1882 enabled=0;
1883 if (me.displayFuncWhenOwned) desc=me.displayFuncWhenOwned()+'<div class="line"></div>'+desc;
1884 }
1885
1886 if (enabled) classes+=' enabled';// else classes+=' disabled';
1887 if (noFrame) classes+=' noFrame';
1888
1889 if (Game.sesame)
1890 {
1891 if (Game.debuggedUpgradeCpS[me.name] || Game.debuggedUpgradeCpClick[me.name])
1892 {
1893 text.push('x'+Beautify(1+Game.debuggedUpgradeCpS[me.name],2));text.push(Game.debugColors[Math.floor(Math.max(0,Math.min(Game.debugColors.length-1,Math.pow(Game.debuggedUpgradeCpS[me.name]/2,0.5)*Game.debugColors.length)))]);
1894 text.push('x'+Beautify(1+Game.debuggedUpgradeCpClick[me.name],2));text.push(Game.debugColors[Math.floor(Math.max(0,Math.min(Game.debugColors.length-1,Math.pow(Game.debuggedUpgradeCpClick[me.name]/2,0.5)*Game.debugColors.length)))]);
1895 }
1896 if (Game.extraInfo) {text.push(Math.floor(me.order)+(me.power?'<br>P:'+me.power:''));text.push('#fff');}
1897 }
1898
1899 var textStr='';
1900 for (var i=0;i<text.length;i+=2)
1901 {
1902 textStr+='<div style="opacity:0.9;z-index:1000;padding:0px 2px;background:'+text[i+1]+';color:#000;font-size:10px;position:absolute;top:'+(i/2*10)+'px;left:0px;">'+text[i]+'</div>';
1903 }
1904
1905 if (asFunction)
1906 return function()
1907 {
1908 return '<div style="min-width:350px;">'+
1909 '<div class="icon" style="float:left;margin-left:-8px;margin-top:-8px;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div>'+
1910 (me.bought && context=='store'?'':price)+
1911 '<div class="name">'+(mysterious?'???':me.name)+'</div>'+
1912 tagsStr+
1913 '<div class="line"></div><div class="description">'+(mysterious?'???':desc)+'</div></div>';
1914 };
1915 else return '<div'+
1916 (clickStr!=''?(' '+Game.clickStr+'="'+clickStr+'"'):'')+
1917 ' class="'+classes+'" '+
1918 (context=='store'?
1919 Game.getDynamicTooltip(
1920 'Game.crate(Game.'+(me.type=='upgrade'?'Upgrades':'Achievements')+'ById['+me.id+'],'+(context?'\''+context+'\'':'')+',undefined,undefined,1)'
1921 ,attachment,true)+' '
1922 :
1923 Game.getTooltip(
1924 '<div style="min-width:350px;">'+
1925 '<div class="icon" style="float:left;margin-left:-8px;margin-top:-8px;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div>'+
1926 price+
1927 '<div class="name">'+(mysterious?'???':me.name)+'</div>'+
1928 tagsStr+
1929 '<div class="line"></div><div class="description">'+(mysterious?'???':desc)+'</div></div>'
1930 ,attachment,true)+' '
1931 )+
1932 (id?'id="'+id+'" ':'')+
1933 'style="'+(mysterious?
1934 'background-position:'+(-0*48)+'px '+(-7*48)+'px':
1935 (icon[2]?'background-image:url('+icon[2]+');':'')+'background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px')+';'+
1936 ((context=='ascend' && me.pool=='prestige')?'position:absolute;left:'+me.posX+'px;top:'+me.posY+'px;':'')+
1937 '">'+
1938 textStr+
1939 (me.choicesFunction?'<div class="selectorCorner"></div>':'')+
1940 '</div>';
1941 }
1942
1943
1944 /*=====================================================================================
1945 PRESTIGE
1946 =======================================================================================*/
1947
1948 Game.HCfactor=3;
1949 Game.HowMuchPrestige=function(cookies)
1950 {
1951 return Math.pow(cookies/1000000000000,1/Game.HCfactor);
1952 }
1953 Game.HowManyCookiesReset=function(chips)//how many cookies [chips] are worth
1954 {
1955 //this must be the inverse of the above function (ie. if cookies=chips^2, chips=cookies^(1/2) )
1956 return Math.pow(chips,Game.HCfactor)*1000000000000;
1957 }
1958 Game.gainedPrestige=0;
1959 Game.EarnHeavenlyChips=function(cookiesForfeited)
1960 {
1961 //recalculate prestige and chips owned
1962 var prestige=Math.floor(Game.HowMuchPrestige(Game.cookiesReset+cookiesForfeited));
1963 if (prestige>Game.prestige)//did we gain prestige levels?
1964 {
1965 var prestigeDifference=prestige-Game.prestige;
1966 Game.gainedPrestige=prestigeDifference;
1967 Game.heavenlyChips+=prestigeDifference;
1968 Game.prestige=prestige;
1969 if (Game.prefs.popups) Game.Popup('You gain '+Beautify(prestigeDifference)+' prestige level'+(prestigeDifference==1?'':'s')+'!');
1970 else Game.Notify('You forfeit your '+Beautify(cookiesForfeited)+' cookies.','You gain <b>'+Beautify(prestigeDifference)+'</b> prestige level'+(prestigeDifference==1?'':'s')+'!',[19,7]);
1971 }
1972 }
1973
1974 Game.GetHeavenlyMultiplier=function()
1975 {
1976 var heavenlyMult=0;
1977 if (Game.Has('Heavenly chip secret')) heavenlyMult+=0.05;
1978 if (Game.Has('Heavenly cookie stand')) heavenlyMult+=0.20;
1979 if (Game.Has('Heavenly bakery')) heavenlyMult+=0.25;
1980 if (Game.Has('Heavenly confectionery')) heavenlyMult+=0.25;
1981 if (Game.Has('Heavenly key')) heavenlyMult+=0.25;
1982 if (Game.hasAura('Dragon God')) heavenlyMult*=1.25;
1983 return heavenlyMult;
1984 }
1985
1986 Game.ascensionModes={
1987 0:{name:'None',desc:'No special modifiers.',icon:[10,0]},
1988 1:{name:'Born again',desc:'This run will behave as if you\'d just started the game from scratch. Prestige levels and heavenly upgrades will have no effect.<div class="line"></div>Some achievements are only available in this mode.',icon:[2,7]}/*,
1989 2:{name:'Trigger finger',desc:'In this run, scrolling your mouse wheel on the cookie counts as clicking it. Some upgrades introduce new clicking behaviors.<br>No clicking achievements may be obtained in this mode.<div class="line"></div>Reaching 1 quadrillion cookies in this mode unlocks a special heavenly upgrade.',icon:[12,0]}*/
1990 };
1991
1992 Game.ascendMeterPercent=0;
1993 Game.ascendMeterPercentT=0;
1994 Game.ascendMeterLevel=1e29;
1995 Game.ascendTooltip=l('ascendTooltip');
1996
1997 Game.nextAscensionMode=0;
1998 Game.UpdateAscensionModePrompt=function()
1999 {
2000 var icon=Game.ascensionModes[Game.nextAscensionMode].icon;
2001 var name=Game.ascensionModes[Game.nextAscensionMode].name;
2002 l('ascendModeButton').innerHTML=
2003 '<div class="crate noFrame enabled" '+Game.clickStr+'="Game.PickAscensionMode();" '+Game.getTooltip(
2004 '<div style="min-width:200px;text-align:center;font-size:11px;">Challenge mode for the next run :<br><b>'+name+'</b><div class="line"></div>Challenge modes apply special modifiers to your next ascension.<br>Click to change.</div>'
2005 ,'bottom-right')+' style="opacity:1;float:none;display:block;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div>';
2006 }
2007 Game.PickAscensionMode=function()
2008 {
2009 PlaySound('snd/tick.mp3');
2010 Game.tooltip.hide();
2011
2012 var str='';
2013 for (var i in Game.ascensionModes)
2014 {
2015 var icon=Game.ascensionModes[i].icon;
2016 str+='<div class="crate enabled'+(i==Game.nextAscensionMode?' highlighted':'')+'" id="challengeModeSelector'+i+'" style="opacity:1;float:none;display:inline-block;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;" '+Game.clickStr+'="Game.nextAscensionMode='+i+';Game.PickAscensionMode();PlaySound(\'snd/tick.mp3\');Game.choiceSelectorOn=-1;" onMouseOut="l(\'challengeSelectedName\').innerHTML=Game.ascensionModes[Game.nextAscensionMode].name;l(\'challengeSelectedDesc\').innerHTML=Game.ascensionModes[Game.nextAscensionMode].desc;" onMouseOver="l(\'challengeSelectedName\').innerHTML=Game.ascensionModes['+i+'].name;l(\'challengeSelectedDesc\').innerHTML=Game.ascensionModes['+i+'].desc;"'+
2017 '></div>';
2018 }
2019 Game.Prompt('<h3>Select a challenge mode</h3>'+
2020 '<div class="line"></div><div class="crateBox">'+str+'</div><h4 id="challengeSelectedName">'+Game.ascensionModes[Game.nextAscensionMode].name+'</h4><div class="line"></div><div id="challengeSelectedDesc" style="min-height:128px;">'+Game.ascensionModes[Game.nextAscensionMode].desc+'</div><div class="line"></div>'
2021 ,[['Confirm','Game.UpdateAscensionModePrompt();Game.ClosePrompt();']],0,'widePrompt');
2022 }
2023
2024 Game.UpdateLegacyPrompt=function()
2025 {
2026 if (!l('legacyPromptData')) return 0;
2027 var date=new Date();
2028 date.setTime(Date.now()-Game.startDate);
2029 var timeInSeconds=date.getTime()/1000;
2030 var startDate=Game.sayTime(timeInSeconds*Game.fps,2);
2031
2032 var ascendNowToGet=Math.floor(Game.HowMuchPrestige(Game.cookiesReset+Game.cookiesEarned)-Game.HowMuchPrestige(Game.cookiesReset));
2033 var cookiesToNext=Math.floor(Game.HowManyCookiesReset(Game.HowMuchPrestige(Game.cookiesReset+Game.cookiesEarned)+1)-Game.cookiesReset-Game.cookiesEarned);
2034 l('legacyPromptData').innerHTML=''+
2035 '<div class="icon" style="pointer-event:none;transform:scale(2);opacity:0.25;position:absolute;right:-8px;bottom:-8px;background-position:'+(-19*48)+'px '+(-7*48)+'px;"></div>'+
2036 '<div class="listing"><b>Run duration :</b> '+(startDate==''?'tiny':(startDate))+'</div>'+
2037 //'<div class="listing">Earned : '+Beautify(Game.cookiesEarned)+', Reset : '+Beautify(Game.cookiesReset)+'</div>'+
2038 '<div class="listing"><b>Prestige level :</b> '+Beautify(Game.prestige)+'</div>'+
2039 '<div class="listing"><b>Heavenly chips :</b> '+Beautify(Game.heavenlyChips)+'</div>'+
2040 (ascendNowToGet>=1?('<div class="listing"><b>Ascending now will produce :</b> '+Beautify(ascendNowToGet)+' heavenly chip'+((ascendNowToGet)==1?'':'s')+'</div>'):
2041 ('<div class="listing warning"><b>'+Beautify(cookiesToNext)+'</b> more cookie'+((cookiesToNext)==1?'':'s')+' for the next prestige level.<br>You may ascend now, but will gain no benefits.</div>'))+
2042 '';
2043 if (1 || ascendNowToGet>=1) l('promptOption0').style.display='inline-block'; else l('promptOption0').style.display='none';
2044 }
2045
2046 l('ascendOverlay').innerHTML=
2047 '<div id="ascendBox">'+
2048 '<div class="ascendData smallFramed prompt" '+Game.getTooltip(
2049 '<div style="min-width:200px;text-align:center;font-size:11px;">Each prestige level grants you a permanent +1% CpS.<br>The more levels you have, the more cookies they require.</div>'
2050 ,'bottom-right')+' style="margin-top:8px;"><h3 id="ascendPrestige"></h3></div>'+
2051 '<div class="ascendData smallFramed prompt" '+Game.getTooltip(
2052 '<div style="min-width:200px;text-align:center;font-size:11px;">Heavenly chips are used to buy heavenly upgrades.<br>You gain 1 chip every time you gain a prestige level.</div>'
2053 ,'bottom-right')+'><h3 id="ascendHCs"></h3></div>'+
2054 '<a id="ascendButton" class="option framed large red" '+Game.getTooltip(
2055 '<div style="min-width:200px;text-align:center;font-size:11px;">Click this once you\'ve bought<br>everything you need!</div>'
2056 ,'bottom-right')+' style="font-size:16px;margin-top:0px;"><span class="fancyText" style="font-size:20px;">Reincarnate</span></a>'+
2057 '<div id="ascendModeButton" style="position:absolute;right:34px;bottom:25px;display:none;"></div>'+
2058 '<input type="text" style="display:block;" id="upgradePositions"/></div>'+
2059
2060 '<div id="ascendInfo"><div class="ascendData smallFramed" style="margin-top:22px;width:40%;font-size:11px;">You are ascending.<br>Drag the screen around<br>or use arrow keys!<br>When you\'re ready,<br>click Reincarnate.</div></div>';
2061
2062 Game.UpdateAscensionModePrompt();
2063
2064 AddEvent(l('ascendButton'),'click',function(){
2065 PlaySound('snd/tick.mp3');
2066 Game.Reincarnate();
2067 });
2068
2069 Game.ascendl=l('ascend');
2070 Game.ascendContentl=l('ascendContent');
2071 Game.ascendZoomablel=l('ascendZoomable');
2072 Game.ascendUpgradesl=l('ascendUpgrades');
2073 Game.OnAscend=0;
2074 Game.AscendTimer=0;//how far we are into the ascend animation
2075 Game.AscendDuration=Game.fps*5;//how long the ascend animation is
2076 Game.AscendBreakpoint=Game.AscendDuration*0.5;//at which point the cookie explodes during the ascend animation
2077 Game.UpdateAscendIntro=function()
2078 {
2079 if (Game.AscendTimer==1) PlaySound('snd/charging.mp3');
2080 if (Game.AscendTimer==Math.floor(Game.AscendBreakpoint)) PlaySound('snd/thud.mp3');
2081 Game.AscendTimer++;
2082 if (Game.AscendTimer>Game.AscendDuration)//end animation and launch ascend screen
2083 {
2084 PlaySound('snd/cymbalRev.mp3',0.5);
2085 PlaySound('snd/choir.mp3');
2086 Game.EarnHeavenlyChips(Game.cookiesEarned);
2087 Game.AscendTimer=0;
2088 Game.OnAscend=1;Game.removeClass('ascendIntro');
2089 Game.addClass('ascending');
2090 Game.BuildAscendTree();
2091 Game.heavenlyChipsDisplayed=Game.heavenlyChips;
2092 Game.nextAscensionMode=0;
2093 Game.ascensionMode=0;
2094 Game.UpdateAscensionModePrompt();
2095 }
2096 }
2097 Game.ReincarnateTimer=0;//how far we are into the reincarnation animation
2098 Game.ReincarnateDuration=Game.fps*1;//how long the reincarnation animation is
2099 Game.UpdateReincarnateIntro=function()
2100 {
2101 if (Game.ReincarnateTimer==1) PlaySound('snd/pop'+Math.floor(Math.random()*3+1)+'.mp3',0.75);
2102 Game.ReincarnateTimer++;
2103 if (Game.ReincarnateTimer>Game.ReincarnateDuration)//end animation and launch regular game
2104 {
2105 Game.ReincarnateTimer=0;
2106 Game.removeClass('reincarnating');
2107 }
2108 }
2109 Game.Reincarnate=function(bypass)
2110 {
2111 if (!bypass) Game.Prompt('<h3>Reincarnate</h3><div class="block">Are you ready to return to the mortal world?</div>',[['Yes','Game.ClosePrompt();Game.Reincarnate(1);'],'No']);
2112 else
2113 {
2114 Game.ascendUpgradesl.innerHTML='';
2115 Game.ascensionMode=Game.nextAscensionMode;
2116 Game.nextAscensionMode=0;
2117 Game.Reset();
2118 if (Game.HasAchiev('Rebirth'))
2119 {
2120 if (Game.prefs.popups) Game.Popup('Reincarnated');
2121 else Game.Notify('Reincarnated','Hello, cookies!',[10,0],4);
2122 }
2123 if (Game.resets>=1000) Game.Win('Endless cycle');
2124 if (Game.resets>=100) Game.Win('Reincarnation');
2125 if (Game.resets>=10) Game.Win('Resurrection');
2126 if (Game.resets>=1) Game.Win('Rebirth');
2127 Game.removeClass('ascending');
2128 Game.OnAscend=0;
2129 //trigger the reincarnate animation
2130 Game.ReincarnateTimer=1;
2131 Game.addClass('reincarnating');
2132 Game.BigCookieSize=0;
2133 }
2134 }
2135 Game.GiveUpAscend=function(bypass)
2136 {
2137 if (!bypass) Game.Prompt('<h3>Give up</h3><div class="block">Are you sure? You\'ll have to start this run over and won\'t gain any heavenly chips!</div>',[['Yes','Game.ClosePrompt();Game.GiveUpAscend(1);'],'No']);
2138 else
2139 {
2140 if (Game.prefs.popups) Game.Popup('Game reset');
2141 else Game.Notify('Gave up','Let\'s try this again!',[0,5],4);
2142 Game.Reset();
2143 }
2144 }
2145 Game.Ascend=function(bypass)
2146 {
2147 if (!bypass) Game.Prompt('<h3>Ascend</h3><div class="block">Do you REALLY want to ascend?<div class="line"></div>You will lose your progress and start over from scratch.<div class="line"></div>All your cookies will be converted into prestige and heavenly chips.<div class="line"></div>You will keep your achievements.</div>',[['Yes!','Game.ClosePrompt();Game.Ascend(1);'],'No']);
2148 else
2149 {
2150 if (Game.prefs.popups) Game.Popup('Ascending');
2151 else Game.Notify('Ascending','So long, cookies.',[20,7],4);
2152 Game.OnAscend=0;Game.removeClass('ascending');
2153 Game.addClass('ascendIntro');
2154 //trigger the ascend animation
2155 Game.AscendTimer=1;
2156 Game.killShimmers();
2157 l('toggleBox').style.display='none';
2158 l('toggleBox').innerHTML='';
2159 Game.choiceSelectorOn=-1;
2160 Game.ToggleSpecialMenu(0);
2161 Game.AscendOffX=0;
2162 Game.AscendOffY=0;
2163 Game.AscendOffXT=0;
2164 Game.AscendOffYT=0;
2165 Game.AscendZoomT=1;
2166 Game.AscendZoom=0.2;
2167 }
2168 }
2169
2170 Game.DebuggingPrestige=0;
2171 Game.AscendDragX=0;
2172 Game.AscendDragY=0;
2173 Game.AscendOffX=0;
2174 Game.AscendOffY=0;
2175 Game.AscendZoom=1;
2176 Game.AscendOffXT=0;
2177 Game.AscendOffYT=0;
2178 Game.AscendZoomT=1;
2179 Game.AscendDragging=0;
2180 Game.AscendGridSnap=24;
2181 Game.heavenlyBounds={left:0,right:0,top:0,bottom:0};
2182 Game.UpdateAscend=function()
2183 {
2184 if (Game.keys[37]) Game.AscendOffXT+=16*(1/Game.AscendZoomT);
2185 if (Game.keys[38]) Game.AscendOffYT+=16*(1/Game.AscendZoomT);
2186 if (Game.keys[39]) Game.AscendOffXT-=16*(1/Game.AscendZoomT);
2187 if (Game.keys[40]) Game.AscendOffYT-=16*(1/Game.AscendZoomT);
2188
2189 if (Game.AscendOffXT>-Game.heavenlyBounds.left) Game.AscendOffXT=-Game.heavenlyBounds.left;
2190 if (Game.AscendOffXT<-Game.heavenlyBounds.right) Game.AscendOffXT=-Game.heavenlyBounds.right;
2191 if (Game.AscendOffYT>-Game.heavenlyBounds.top) Game.AscendOffYT=-Game.heavenlyBounds.top;
2192 if (Game.AscendOffYT<-Game.heavenlyBounds.bottom) Game.AscendOffYT=-Game.heavenlyBounds.bottom;
2193 Game.AscendOffX+=(Game.AscendOffXT-Game.AscendOffX)*0.5;
2194 Game.AscendOffY+=(Game.AscendOffYT-Game.AscendOffY)*0.5;
2195 Game.AscendZoom+=(Game.AscendZoomT-Game.AscendZoom)*0.25;
2196 if (Math.abs(Game.AscendZoomT-Game.AscendZoom)<0.005) Game.AscendZoom=Game.AscendZoomT;
2197
2198 if (Game.mouseDown && !Game.promptOn)
2199 {
2200 if (!Game.AscendDragging)
2201 {
2202 if (Game.DebuggingPrestige && !Game.SelectedHeavenlyUpgrade)
2203 {
2204 var dragFromX=(Game.mouseX-Game.ascendContentl.getBoundingClientRect().left-40);
2205 var dragFromY=(Game.mouseY-Game.ascendContentl.getBoundingClientRect().top-36);
2206 for (var i in Game.PrestigeUpgrades)
2207 {
2208 var me=Game.PrestigeUpgrades[i];
2209 if (Math.abs(dragFromX-me.posX)<32 && Math.abs(dragFromY-me.posY)<32) Game.SelectedHeavenlyUpgrade=me;
2210 }
2211 }
2212 Game.AscendDragX=Game.mouseX;
2213 Game.AscendDragY=Game.mouseY;
2214 }
2215 Game.AscendDragging=1;
2216
2217 if (Game.DebuggingPrestige)
2218 {
2219 if (Game.SelectedHeavenlyUpgrade)
2220 {
2221 Game.tooltip.hide();
2222 //drag upgrades around
2223 var me=Game.SelectedHeavenlyUpgrade;
2224 me.posX+=(Game.mouseX-Game.AscendDragX)*(1/Game.AscendZoomT);
2225 me.posY+=(Game.mouseY-Game.AscendDragY)*(1/Game.AscendZoomT);
2226 var posX=me.posX;//Math.round(me.posX/Game.AscendGridSnap)*Game.AscendGridSnap;
2227 var posY=me.posY;//Math.round(me.posY/Game.AscendGridSnap)*Game.AscendGridSnap;
2228 l('heavenlyUpgrade'+me.id).style.left=Math.floor(posX)+'px';
2229 l('heavenlyUpgrade'+me.id).style.top=Math.floor(posY)+'px';
2230 for (var ii in me.parents)
2231 {
2232 var origX=0;
2233 var origY=0;
2234 var targX=me.posX+28;
2235 var targY=me.posY+28;
2236 if (me.parents[ii]!=-1) {origX=me.parents[ii].posX+28;origY=me.parents[ii].posY+28;}
2237 var rot=-(Math.atan((targY-origY)/(origX-targX))/Math.PI)*180;
2238 if (targX<=origX) rot+=180;
2239 var dist=Math.floor(Math.sqrt((targX-origX)*(targX-origX)+(targY-origY)*(targY-origY)));
2240 //l('heavenlyLink'+me.id+'-'+ii).style='width:'+dist+'px;-webkit-transform:rotate('+rot+'deg);-moz-transform:rotate('+rot+'deg);-ms-transform:rotate('+rot+'deg);-o-transform:rotate('+rot+'deg);transform:rotate('+rot+'deg);left:'+(origX)+'px;top:'+(origY)+'px;';
2241 l('heavenlyLink'+me.id+'-'+ii).style='width:'+dist+'px;transform:rotate('+rot+'deg);left:'+(origX)+'px;top:'+(origY)+'px;';
2242 }
2243 }
2244 }
2245 if (!Game.SelectedHeavenlyUpgrade)
2246 {
2247 Game.AscendOffXT+=(Game.mouseX-Game.AscendDragX)*(1/Game.AscendZoomT);
2248 Game.AscendOffYT+=(Game.mouseY-Game.AscendDragY)*(1/Game.AscendZoomT);
2249 }
2250 Game.AscendDragX=Game.mouseX;
2251 Game.AscendDragY=Game.mouseY;
2252 }
2253 else
2254 {
2255 /*if (Game.SelectedHeavenlyUpgrade)
2256 {
2257 var me=Game.SelectedHeavenlyUpgrade;
2258 me.posX=Math.round(me.posX/Game.AscendGridSnap)*Game.AscendGridSnap;
2259 me.posY=Math.round(me.posY/Game.AscendGridSnap)*Game.AscendGridSnap;
2260 l('heavenlyUpgrade'+me.id).style.left=me.posX+'px';
2261 l('heavenlyUpgrade'+me.id).style.top=me.posY+'px';
2262 }*/
2263 Game.AscendDragging=0;
2264 Game.SelectedHeavenlyUpgrade=0;
2265 }
2266 if (Game.Click || Game.promptOn)
2267 {
2268 Game.AscendDragging=0;
2269 }
2270
2271 //Game.ascendl.style.backgroundPosition=Math.floor(Game.AscendOffX/2)+'px '+Math.floor(Game.AscendOffY/2)+'px';
2272 //Game.ascendl.style.backgroundPosition=Math.floor(Game.AscendOffX/2)+'px '+Math.floor(Game.AscendOffY/2)+'px,'+Math.floor(Game.AscendOffX/4)+'px '+Math.floor(Game.AscendOffY/4)+'px';
2273 //Game.ascendContentl.style.left=Math.floor(Game.AscendOffX)+'px';
2274 //Game.ascendContentl.style.top=Math.floor(Game.AscendOffY)+'px';
2275 Game.ascendContentl.style.webkitTransform='translate('+Math.floor(Game.AscendOffX)+'px,'+Math.floor(Game.AscendOffY)+'px)';
2276 Game.ascendContentl.style.msTransform='translate('+Math.floor(Game.AscendOffX)+'px,'+Math.floor(Game.AscendOffY)+'px)';
2277 Game.ascendContentl.style.oTransform='translate('+Math.floor(Game.AscendOffX)+'px,'+Math.floor(Game.AscendOffY)+'px)';
2278 Game.ascendContentl.style.mozTransform='translate('+Math.floor(Game.AscendOffX)+'px,'+Math.floor(Game.AscendOffY)+'px)';
2279 Game.ascendContentl.style.transform='translate('+Math.floor(Game.AscendOffX)+'px,'+Math.floor(Game.AscendOffY)+'px)';
2280 Game.ascendZoomablel.style.webkitTransform='scale('+(Game.AscendZoom)+','+(Game.AscendZoom)+')';
2281 Game.ascendZoomablel.style.msTransform='scale('+(Game.AscendZoom)+','+(Game.AscendZoom)+')';
2282 Game.ascendZoomablel.style.oTransform='scale('+(Game.AscendZoom)+','+(Game.AscendZoom)+')';
2283 Game.ascendZoomablel.style.mozTransform='scale('+(Game.AscendZoom)+','+(Game.AscendZoom)+')';
2284 Game.ascendZoomablel.style.transform='scale('+(Game.AscendZoom)+','+(Game.AscendZoom)+')';
2285
2286 //if (Game.Scroll!=0) Game.ascendContentl.style.transformOrigin=Math.floor(Game.windowW/2-Game.mouseX)+'px '+Math.floor(Game.windowH/2-Game.mouseY)+'px';
2287 if (Game.Scroll<0 && !Game.promptOn) {Game.AscendZoomT=0.5;}
2288 if (Game.Scroll>0 && !Game.promptOn) {Game.AscendZoomT=1;}
2289
2290 if (Game.T%2==0)
2291 {
2292 l('ascendPrestige').innerHTML='Prestige level :<br>'+Beautify(Game.prestige);
2293 l('ascendHCs').innerHTML='Heavenly chips :<br><span class="price heavenly">'+Beautify(Math.round(Game.heavenlyChipsDisplayed))+'</span>';
2294 if (Game.prestige>0) l('ascendModeButton').style.display='block';
2295 else l('ascendModeButton').style.display='none';
2296 }
2297 Game.heavenlyChipsDisplayed+=(Game.heavenlyChips-Game.heavenlyChipsDisplayed)*0.4;
2298
2299 if (Game.DebuggingPrestige && Game.T%10==0)
2300 {
2301 var str='';
2302 for (var i in Game.PrestigeUpgrades)
2303 {
2304 var me=Game.PrestigeUpgrades[i];
2305 str+=me.id+':['+Math.floor(me.posX)+','+Math.floor(me.posY)+'],';
2306 }
2307 l('upgradePositions').value='Game.UpgradePositions={'+str+'};';
2308 }
2309 //if (Game.T%5==0) Game.BuildAscendTree();
2310 }
2311 Game.AscendRefocus=function()
2312 {
2313 Game.AscendOffX=0;
2314 Game.AscendOffY=0;
2315 Game.ascendl.className='';
2316 }
2317
2318 Game.SelectedHeavenlyUpgrade=0;
2319 Game.PurchaseHeavenlyUpgrade=function(what)
2320 {
2321 //if (Game.Has('Neuromancy')) Game.UpgradesById[what].toggle(); else
2322 if (Game.UpgradesById[what].buy())
2323 {
2324 if (l('heavenlyUpgrade'+what)){var rect=l('heavenlyUpgrade'+what).getBoundingClientRect();Game.SparkleAt((rect.left+rect.right)/2,(rect.top+rect.bottom)/2-24);}
2325 //Game.BuildAscendTree();
2326 }
2327 }
2328 Game.BuildAscendTree=function()
2329 {
2330 var str='';
2331 Game.heavenlyBounds={left:0,right:0,top:0,bottom:0};
2332
2333 if (Game.DebuggingPrestige) l('upgradePositions').style.display='block'; else l('upgradePositions').style.display='none';
2334
2335 for (var i in Game.PrestigeUpgrades)
2336 {
2337 var me=Game.PrestigeUpgrades[i];
2338 me.canBePurchased=1;
2339 if (!me.bought && !Game.DebuggingPrestige)
2340 {
2341 for (var ii in me.parents)
2342 {
2343 if (me.parents[ii]!=-1 && !me.parents[ii].bought) me.canBePurchased=0;
2344 }
2345 }
2346 }
2347 str+='<div class="crateBox" style="filter:none;-webkit-filter:none;">';
2348 for (var i in Game.PrestigeUpgrades)
2349 {
2350 var me=Game.PrestigeUpgrades[i];
2351
2352 var ghosted=0;
2353 if (me.canBePurchased || Game.Has('Neuromancy'))
2354 {
2355 str+=Game.crate(me,'ascend','Game.PurchaseHeavenlyUpgrade('+me.id+');','heavenlyUpgrade'+me.id);
2356 }
2357 else
2358 {
2359 for (var ii in me.parents)
2360 {
2361 if (me.parents[ii]!=-1 && me.parents[ii].canBePurchased) ghosted=1;
2362 }
2363 if (ghosted)
2364 {
2365 //maybe replace this with Game.crate()
2366 str+='<div class="crate upgrade heavenly ghosted" id="heavenlyUpgrade'+me.id+'" style="position:absolute;left:'+me.posX+'px;top:'+me.posY+'px;'+(me.icon[2]?'background-image:url('+me.icon[2]+');':'')+'background-position:'+(-me.icon[0]*48)+'px '+(-me.icon[1]*48)+'px;"></div>';
2367 }
2368 }
2369 if (me.canBePurchased || Game.Has('Neuromancy') || ghosted)
2370 {
2371 if (me.posX<Game.heavenlyBounds.left) Game.heavenlyBounds.left=me.posX;
2372 if (me.posX>Game.heavenlyBounds.right) Game.heavenlyBounds.right=me.posX;
2373 if (me.posY<Game.heavenlyBounds.top) Game.heavenlyBounds.top=me.posY;
2374 if (me.posY>Game.heavenlyBounds.bottom) Game.heavenlyBounds.bottom=me.posY;
2375 }
2376 for (var ii in me.parents)//create pulsing links
2377 {
2378 if (me.parents[ii]!=-1 && (me.canBePurchased || ghosted))
2379 {
2380 var origX=0;
2381 var origY=0;
2382 var targX=me.posX+28;
2383 var targY=me.posY+28;
2384 if (me.parents[ii]!=-1) {origX=me.parents[ii].posX+28;origY=me.parents[ii].posY+28;}
2385 var rot=-(Math.atan((targY-origY)/(origX-targX))/Math.PI)*180;
2386 if (targX<=origX) rot+=180;
2387 var dist=Math.floor(Math.sqrt((targX-origX)*(targX-origX)+(targY-origY)*(targY-origY)));
2388 str+='<div class="parentLink" id="heavenlyLink'+me.id+'-'+ii+'" style="'+(ghosted?'opacity:0.1;':'')+'width:'+dist+'px;-webkit-transform:rotate('+rot+'deg);-moz-transform:rotate('+rot+'deg);-ms-transform:rotate('+rot+'deg);-o-transform:rotate('+rot+'deg);transform:rotate('+rot+'deg);left:'+(origX)+'px;top:'+(origY)+'px;"></div>';
2389 }
2390 }
2391 }
2392 Game.heavenlyBounds.left-=128;
2393 Game.heavenlyBounds.top-=128;
2394 Game.heavenlyBounds.right+=128+64;
2395 Game.heavenlyBounds.bottom+=128+64;
2396 //str+='<div style="border:1px solid red;position:absolute;left:'+Game.heavenlyBounds.left+'px;width:'+(Game.heavenlyBounds.right-Game.heavenlyBounds.left)+'px;top:'+Game.heavenlyBounds.top+'px;height:'+(Game.heavenlyBounds.bottom-Game.heavenlyBounds.top)+'px;"></div>';
2397 str+='</div>';
2398 Game.ascendUpgradesl.innerHTML=str;
2399 }
2400
2401 //trigger ascend
2402 //setTimeout(function(){Game.AscendTimer=0;Game.OnAscend=1;Game.removeClass('ascendIntro');Game.addClass('ascending');Game.BuildAscendTree();},100);
2403 //setTimeout(function(){Game.Ascend(1);},100);
2404
2405 /*=====================================================================================
2406 COOKIE ECONOMICS
2407 =======================================================================================*/
2408 Game.Earn=function(howmuch)
2409 {
2410 Game.cookies+=howmuch;
2411 Game.cookiesEarned+=howmuch;
2412 }
2413 Game.Spend=function(howmuch)
2414 {
2415 Game.cookies-=howmuch;
2416 }
2417 Game.Dissolve=function(howmuch)
2418 {
2419 Game.cookies-=howmuch;
2420 Game.cookiesEarned-=howmuch;
2421 Game.cookies=Math.max(0,Game.cookies);
2422 Game.cookiesEarned=Math.max(0,Game.cookiesEarned);
2423 }
2424 Game.mouseCps=function()
2425 {
2426 var add=0;
2427 if (Game.Has('Thousand fingers')) add+= 0.1;
2428 if (Game.Has('Million fingers')) add+= 0.5;
2429 if (Game.Has('Billion fingers')) add+= 2;
2430 if (Game.Has('Trillion fingers')) add+= 10;
2431 if (Game.Has('Quadrillion fingers')) add+= 50;
2432 if (Game.Has('Quintillion fingers')) add+= 200;
2433 if (Game.Has('Sextillion fingers')) add+= 1000;
2434 if (Game.Has('Septillion fingers')) add+= 5000;
2435 if (Game.Has('Octillion fingers')) add+= 20000;
2436 if (Game.Has('Nonillion fingers')) add+= 100000;
2437 if (Game.Has('Decillion fingers')) add+= 500000;
2438 if (Game.Has('Undecillion fingers')) add+= 2000000;
2439 if (Game.Has('Duodecillion fingers')) add+= 10000000;
2440 if (Game.Has('Tredecillion fingers')) add+= 50000000;
2441 if (Game.Has('Quattuordecillion fingers')) add+= 200000000;
2442 var num=0;
2443 for (var i in Game.Objects) {num+=Game.Objects[i].amount;}
2444 num-=Game.Objects['Cursor'].amount;
2445 add=add*num;
2446 if (Game.Has('Plastic mouse')) add+=Game.cookiesPs*0.01;
2447 if (Game.Has('Iron mouse')) add+=Game.cookiesPs*0.01;
2448 if (Game.Has('Titanium mouse')) add+=Game.cookiesPs*0.01;
2449 if (Game.Has('Adamantium mouse')) add+=Game.cookiesPs*0.01;
2450 if (Game.Has('Unobtainium mouse')) add+=Game.cookiesPs*0.01;
2451 if (Game.Has('Eludium mouse')) add+=Game.cookiesPs*0.01;
2452 if (Game.Has('Wishalloy mouse')) add+=Game.cookiesPs*0.01;
2453 if (Game.Has('Fantasteel mouse')) add+=Game.cookiesPs*0.01;
2454 if (Game.Has('Nevercrack mouse')) add+=Game.cookiesPs*0.01;
2455 var mult=1;
2456
2457 for (var i in Game.customMouseCps) {mult+=Game.customMouseCps[i]();}
2458
2459 if (Game.Has('Santa\'s helpers')) mult*=1.1;
2460 if (Game.Has('Cookie egg')) mult*=1.1;
2461 if (Game.Has('Halo gloves')) mult*=1.1;
2462
2463 for (var i in Game.buffs)
2464 {
2465 if (typeof Game.buffs[i].multClick != 'undefined') mult*=Game.buffs[i].multClick;
2466 }
2467
2468 if (Game.hasAura('Dragon Cursor')) mult*=1.1;
2469
2470 for (var i in Game.customMouseCpsMult) {mult*=Game.customMouseCpsMult[i]();}
2471
2472 var out=mult*Game.ComputeCps(1,Game.Has('Reinforced index finger')+Game.Has('Carpal tunnel prevention cream')+Game.Has('Ambidextrous'),add);
2473
2474 if (Game.hasBuff('Cursed finger')) out=Game.buffs['Cursed finger'].power;
2475 return out;
2476 }
2477 Game.computedMouseCps=1;
2478 Game.globalCpsMult=1;
2479 Game.lastClick=0;
2480 Game.CanClick=1;
2481 Game.autoclickerDetected=0;
2482 Game.BigCookieState=0;//0 = normal, 1 = clicked (small), 2 = released/hovered (big)
2483 Game.BigCookieSize=0;
2484 Game.BigCookieSizeD=0;
2485 Game.BigCookieSizeT=1;
2486 Game.cookieClickSound=Math.floor(Math.random()*7)+1;
2487 Game.playCookieClickSound=function()
2488 {
2489 if (Game.prefs.cookiesound) PlaySound('snd/clickb'+(Game.cookieClickSound)+'.mp3',0.5);
2490 else PlaySound('snd/click'+(Game.cookieClickSound)+'.mp3',0.5);
2491 Game.cookieClickSound+=Math.floor(Math.random()*4)+1;
2492 if (Game.cookieClickSound>7) Game.cookieClickSound-=7;
2493 }
2494 Game.ClickCookie=function(event,amount)
2495 {
2496 var now=Date.now();
2497 if (event) event.preventDefault();
2498 if (Game.OnAscend || Game.AscendTimer>0) {}
2499 else if (now-Game.lastClick<1000/250) {}
2500 else
2501 {
2502 if (now-Game.lastClick<1000/15)
2503 {
2504 Game.autoclickerDetected+=Game.fps;
2505 if (Game.autoclickerDetected>=Game.fps*5) Game.Win('Uncanny clicker');
2506 }
2507 var amount=amount?amount:Game.computedMouseCps;
2508 Game.Earn(amount);
2509 Game.handmadeCookies+=amount;
2510 if (Game.prefs.particles)
2511 {
2512 Game.particleAdd();
2513 Game.particleAdd(Game.mouseX,Game.mouseY,Math.random()*4-2,Math.random()*-2-2,Math.random()*0.5+0.75,1,2);
2514 }
2515 if (Game.prefs.numbers) Game.particleAdd(Game.mouseX+Math.random()*8-4,Game.mouseY-8+Math.random()*8-4,0,-2,1,4,2,'','+'+Beautify(amount,1));
2516
2517 for (var i in Game.customCookieClicks) {Game.customCookieClicks[i]();}
2518
2519 Game.playCookieClickSound();
2520 Game.cookieClicks++;
2521 }
2522 Game.lastClick=now;
2523 Game.Click=0;
2524 }
2525 Game.mouseX=0;
2526 Game.mouseY=0;
2527 Game.mouseMoved=0;
2528 Game.GetMouseCoords=function(e)
2529 {
2530 var posx=0;
2531 var posy=0;
2532 if (!e) var e=window.event;
2533 if (e.pageX||e.pageY)
2534 {
2535 posx=e.pageX;
2536 posy=e.pageY;
2537 }
2538 else if (e.clientX || e.clientY)
2539 {
2540 posx=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
2541 posy=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;
2542 }
2543 var x=0;
2544 var y=32;
2545 /*
2546 var el=l('sectionLeft');
2547 while(el && !isNaN(el.offsetLeft) && !isNaN(el.offsetTop))
2548 {
2549 x+=el.offsetLeft-el.scrollLeft;
2550 y+=el.offsetTop-el.scrollTop;
2551 el=el.offsetParent;
2552 }*/
2553 Game.mouseX=posx-x;
2554 Game.mouseY=posy-y;
2555 Game.mouseMoved=1;
2556 }
2557 var bigCookie=l('bigCookie');
2558 Game.Click=0;
2559 Game.Scroll=0;
2560 Game.mouseDown=0;
2561 if (!Game.touchEvents)
2562 {
2563 AddEvent(bigCookie,'click',Game.ClickCookie);
2564 AddEvent(bigCookie,'mousedown',function(event){Game.BigCookieState=1;if (Game.prefs.cookiesound) {Game.playCookieClickSound();}if (event) event.preventDefault();});
2565 AddEvent(bigCookie,'mouseup',function(event){Game.BigCookieState=2;if (event) event.preventDefault();});
2566 AddEvent(bigCookie,'mouseout',function(event){Game.BigCookieState=0;});
2567 AddEvent(bigCookie,'mouseover',function(event){Game.BigCookieState=2;});
2568 AddEvent(document,'mousemove',Game.GetMouseCoords);
2569 AddEvent(document,'mousedown',function(event){Game.mouseDown=1;});
2570 AddEvent(document,'mouseup',function(event){Game.mouseDown=0;});
2571 AddEvent(document,'click',function(event){Game.Click=1;});
2572 Game.handleScroll=function(e)
2573 {
2574 if (!e) e=event;
2575 Game.Scroll=(e.detail<0||e.wheelDelta>0)?1:-1;
2576 };
2577 AddEvent(document,'DOMMouseScroll',Game.handleScroll);
2578 AddEvent(document,'mousewheel',Game.handleScroll);
2579 }
2580 else
2581 {
2582 //touch events
2583 AddEvent(bigCookie,'touchend',Game.ClickCookie);
2584 AddEvent(bigCookie,'touchstart',function(event){Game.BigCookieState=1;if (event) event.preventDefault();});
2585 AddEvent(bigCookie,'touchend',function(event){Game.BigCookieState=0;if (event) event.preventDefault();});
2586 //AddEvent(document,'touchmove',Game.GetMouseCoords);
2587 AddEvent(document,'mousemove',Game.GetMouseCoords);
2588 AddEvent(document,'touchstart',function(event){Game.mouseDown=1;});
2589 AddEvent(document,'touchend',function(event){Game.mouseDown=0;});
2590 AddEvent(document,'touchend',function(event){Game.Click=1;});
2591 }
2592
2593 Game.keys=[];
2594 AddEvent(window,'keyup',function(e){
2595 if (e.keyCode==27)
2596 {
2597 Game.ClosePrompt();
2598 if (Game.AscendTimer>0) Game.AscendTimer=Game.AscendDuration;
2599 }//esc closes prompt
2600 else if (e.keyCode==13) Game.ConfirmPrompt();//enter confirms prompt
2601 Game.keys[e.keyCode]=0;
2602 });
2603 AddEvent(window,'keydown',function(e){
2604 if (!Game.OnAscend && Game.AscendTimer==0)
2605 {
2606 if (e.ctrlKey && e.keyCode==83) {Game.WriteSave();e.preventDefault();}//ctrl-s saves the game
2607 else if (e.ctrlKey && e.keyCode==79) {Game.ImportSave();e.preventDefault();}//ctrl-o opens the import menu
2608 }
2609 Game.keys[e.keyCode]=1;
2610 });
2611
2612
2613 /*=====================================================================================
2614 CPS RECALCULATOR
2615 =======================================================================================*/
2616 Game.heavenlyPower=1;//how many CpS percents a single heavenly chip gives
2617 Game.recalculateGains=1;
2618 Game.cookiesPsByType=[];
2619 //display bars with http://codepen.io/anon/pen/waGyEJ
2620
2621 Game.CalculateGains=function()
2622 {
2623 Game.cookiesPs=0;
2624 var mult=1;
2625
2626 if (Game.ascensionMode!=1) mult+=parseFloat(Game.prestige)*0.01*Game.heavenlyPower*Game.GetHeavenlyMultiplier();
2627
2628 var cookieMult=0;
2629 for (var i in Game.cookieUpgrades)
2630 {
2631 var me=Game.cookieUpgrades[i];
2632 if (Game.Has(me.name))
2633 {
2634 mult*=(1+(typeof(me.power)=='function'?me.power(me):me.power)*0.01);
2635 }
2636 }
2637 mult*=(1+0.01*cookieMult);
2638
2639 if (Game.Has('Specialized chocolate chips')) mult*=1.01;
2640 if (Game.Has('Designer cocoa beans')) mult*=1.02;
2641 if (Game.Has('Underworld ovens')) mult*=1.03;
2642 if (Game.Has('Exotic nuts')) mult*=1.04;
2643 if (Game.Has('Arcane sugar')) mult*=1.05;
2644
2645 if (Game.Has('Increased merriness')) mult*=1.15;
2646 if (Game.Has('Improved jolliness')) mult*=1.15;
2647 if (Game.Has('A lump of coal')) mult*=1.01;
2648 if (Game.Has('An itchy sweater')) mult*=1.01;
2649 if (Game.Has('Santa\'s dominion')) mult*=1.2;
2650
2651 if (Game.Has('Santa\'s legacy')) mult*=1+(Game.santaLevel+1)*0.03;
2652
2653 for (var i in Game.Objects)
2654 {
2655 var me=Game.Objects[i];
2656 me.storedCps=(typeof(me.cps)=='function'?me.cps(me):me.cps);
2657 me.storedTotalCps=me.amount*me.storedCps;
2658 Game.cookiesPs+=me.storedTotalCps;
2659 Game.cookiesPsByType[me.name]=me.storedTotalCps;
2660 }
2661
2662
2663 if (Game.Has('"egg"')) {Game.cookiesPs+=9;Game.cookiesPsByType['"egg"']=9;}//"egg"
2664
2665 for (var i in Game.customCps) {mult*=Game.customCps[i]();}
2666
2667 Game.milkProgress=Game.AchievementsOwned/25;
2668 var milkMult=1;
2669 if (Game.Has('Santa\'s milk and cookies')) milkMult*=1.05;
2670 if (Game.hasAura('Breath of Milk')) milkMult*=1.05;
2671 if (Game.Has('Kitten helpers')) mult*=(1+Game.milkProgress*0.2*milkMult);
2672 if (Game.Has('Kitten workers')) mult*=(1+Game.milkProgress*0.2*milkMult);
2673 if (Game.Has('Kitten engineers')) mult*=(1+Game.milkProgress*0.2*milkMult);
2674 if (Game.Has('Kitten overseers')) mult*=(1+Game.milkProgress*0.2*milkMult);
2675 if (Game.Has('Kitten managers')) mult*=(1+Game.milkProgress*0.2*milkMult);
2676 if (Game.Has('Kitten accountants')) mult*=(1+Game.milkProgress*0.2*milkMult);
2677 if (Game.Has('Kitten specialists')) mult*=(1+Game.milkProgress*0.2*milkMult);
2678 if (Game.Has('Kitten experts')) mult*=(1+Game.milkProgress*0.2*milkMult);
2679 if (Game.Has('Kitten masters')) mult*=(1+Game.milkProgress*0.2*milkMult);
2680 if (Game.Has('Kitten angels')) mult*=(1+Game.milkProgress*0.1*milkMult);
2681
2682 var eggMult=1;
2683 if (Game.Has('Chicken egg')) eggMult*=1.02;
2684 if (Game.Has('Duck egg')) eggMult*=1.02;
2685 if (Game.Has('Turkey egg')) eggMult*=1.02;
2686 if (Game.Has('Quail egg')) eggMult*=1.02;
2687 if (Game.Has('Robin egg')) eggMult*=1.02;
2688 if (Game.Has('Ostrich egg')) eggMult*=1.02;
2689 if (Game.Has('Cassowary egg')) eggMult*=1.02;
2690 if (Game.Has('Salmon roe')) eggMult*=1.02;
2691 if (Game.Has('Frogspawn')) eggMult*=1.02;
2692 if (Game.Has('Shark egg')) eggMult*=1.02;
2693 if (Game.Has('Turtle egg')) eggMult*=1.02;
2694 if (Game.Has('Ant larva')) eggMult*=1.02;
2695 if (Game.Has('Century egg'))
2696 {
2697 var day=Math.floor((Date.now()-Game.startDate)/1000/10)*10/60/60/24;
2698 day=Math.min(day,100);
2699 eggMult*=1+(1-Math.pow(1-day/100,3))*0.1;
2700 }
2701
2702 mult*=eggMult;
2703
2704 if (Game.hasAura('Radiant Appetite')) mult*=2;
2705
2706 var rawCookiesPs=Game.cookiesPs*mult;
2707 for (var i in Game.CpsAchievements)
2708 {
2709 if (rawCookiesPs>=Game.CpsAchievements[i].threshold) Game.Win(Game.CpsAchievements[i].name);
2710 }
2711
2712 for (var i in Game.buffs)
2713 {
2714 if (typeof Game.buffs[i].multCpS != 'undefined') mult*=Game.buffs[i].multCpS;
2715 }
2716
2717 name=Game.bakeryName.toLowerCase();
2718 if (name=='orteil') mult*=0.99;
2719 else if (name=='ortiel') mult*=0.9;//or so help me
2720
2721 var sucked=1;
2722 for (var i in Game.wrinklers)
2723 {
2724 if (Game.wrinklers[i].phase==2) sucked-=1/20;
2725 }
2726 Game.cpsSucked=(1-sucked);
2727
2728 if (Game.Has('Elder Covenant')) mult*=0.95;
2729
2730 if (Game.Has('Golden switch [off]'))
2731 {
2732 var goldenSwitchMult=1.5;
2733 if (Game.Has('Residual luck'))
2734 {
2735 var upgrades=['Pot of gold','All the luck','Get lucky','Lucky day','Serendipity','Heavenly luck','Lasting fortune','Decisive fate'];
2736 for (var i in upgrades) {if (Game.Has(upgrades[i])) goldenSwitchMult+=0.1;}
2737 }
2738 mult*=goldenSwitchMult;
2739 }
2740 if (Game.Has('Magic shenanigans')) mult*=1000;
2741
2742 for (var i in Game.customCpsMult) {mult*=Game.customCpsMult[i]();}
2743
2744 Game.globalCpsMult=mult;
2745 Game.cookiesPs*=Game.globalCpsMult;
2746
2747 //if (Game.hasBuff('Cursed finger')) Game.cookiesPs=0;
2748
2749 Game.computedMouseCps=Game.mouseCps();
2750
2751 Game.recalculateGains=0;
2752 }
2753
2754 /*=====================================================================================
2755 SHIMMERS (GOLDEN COOKIES & SUCH), BUFFS
2756 =======================================================================================*/
2757 Game.shimmersL=l('shimmers');
2758 Game.shimmers=[];//all shimmers currently on the screen
2759 Game.shimmersN=Math.floor(Math.random()*10000);
2760 Game.shimmer=function(type)
2761 {
2762 this.type=type;
2763
2764 this.l=document.createElement('div');
2765 this.l.className='shimmer';
2766 if (!Game.touchEvents) {AddEvent(this.l,'click',function(what){return function(event){what.pop(event);};}(this));}
2767 else {AddEvent(this.l,'touchend',function(what){return function(event){what.pop(event);};}(this));}//touch events
2768
2769 this.x=0;
2770 this.y=0;
2771 this.id=Game.shimmersN;
2772
2773 this.init();
2774
2775 Game.shimmersL.appendChild(this.l);
2776 Game.shimmers.push(this);
2777 Game.shimmersN++;
2778 }
2779 Game.shimmer.prototype.init=function()//executed when the shimmer is created
2780 {
2781 Game.shimmerTypes[this.type].initFunc(this);
2782 }
2783 Game.shimmer.prototype.update=function()//executed every frame
2784 {
2785 Game.shimmerTypes[this.type].updateFunc(this);
2786 }
2787 Game.shimmer.prototype.pop=function(event)//executed when the shimmer is popped by the player
2788 {
2789 if (event) event.preventDefault();
2790 Game.Click=0;
2791 Game.shimmerTypes[this.type].popFunc(this);
2792 }
2793 Game.shimmer.prototype.die=function()//executed after the shimmer disappears (from old age or popping)
2794 {
2795 if (Game.shimmerTypes[this.type].spawnsOnTimer && this.spawnLead)
2796 {
2797 //if this was the spawn lead for this shimmer type, set the shimmer type's "spawned" to 0 and restart its spawn timer
2798 var type=Game.shimmerTypes[this.type];
2799 type.time=0;
2800 type.spawned=0;
2801 type.minTime=type.getMinTime();
2802 type.maxTime=type.getMaxTime();
2803 }
2804 Game.shimmersL.removeChild(this.l);
2805 if (Game.shimmers.indexOf(this)!=-1) Game.shimmers.splice(Game.shimmers.indexOf(this),1);
2806 }
2807
2808
2809 Game.updateShimmers=function()//run shimmer functions, kill overtimed shimmers and spawn new ones
2810 {
2811 for (var i in Game.shimmers)
2812 {
2813 Game.shimmers[i].update();
2814 }
2815
2816 //cookie storm!
2817 if (Game.hasBuff('Cookie storm') && Math.random()<0.5)
2818 {
2819 var newShimmer=new Game.shimmer('golden');
2820 newShimmer.dur=Math.ceil(Math.random()*4+1);
2821 newShimmer.life=Math.ceil(Game.fps*newShimmer.dur);
2822 newShimmer.force='cookie storm drop';
2823 newShimmer.sizeMult=Math.random()*0.75+0.25;
2824 }
2825
2826 //spawn shimmers
2827 for (var i in Game.shimmerTypes)
2828 {
2829 var me=Game.shimmerTypes[i];
2830 if (me.spawnsOnTimer && me.spawnConditions())//only run on shimmer types that work on a timer
2831 {
2832 if (!me.spawned)//no shimmer spawned for this type? check the timer and try to spawn one
2833 {
2834 me.time++;
2835 if (Math.random()<Math.pow(Math.max(0,(me.time-me.minTime)/(me.maxTime-me.minTime)),5))
2836 {
2837 var newShimmer=new Game.shimmer(i);
2838 newShimmer.spawnLead=1;
2839 if (Game.Has('Distilled essence of redoubled luck') && Math.random()<0.01) var newShimmer=new Game.shimmer(i);
2840 me.spawned=1;
2841 }
2842 }
2843 }
2844 }
2845 }
2846 Game.killShimmers=function()//stop and delete all shimmers (used on resetting etc)
2847 {
2848 for (var i in Game.shimmers)
2849 {
2850 Game.shimmers[i].die();
2851 }
2852 for (var i in Game.shimmerTypes)
2853 {
2854 var me=Game.shimmerTypes[i];
2855 if (me.reset) me.reset();
2856 if (me.spawnsOnTimer)
2857 {
2858 me.time=0;
2859 me.spawned=0;
2860 me.minTime=me.getMinTime();
2861 me.maxTime=me.getMaxTime();
2862 }
2863 }
2864 }
2865
2866 Game.shimmerTypes={
2867 //in these, "me" refers to the shimmer itself, and "this" to the shimmer's type object
2868 'golden':{
2869 reset:function()
2870 {
2871 this.chain=0;
2872 this.totalFromChain=0;
2873 this.last='';
2874 },
2875 initFunc:function(me)
2876 {
2877 if (!this.spawned && Game.chimeType==1 && Game.ascensionMode!=1) PlaySound('snd/chime.mp3');
2878
2879 //set image
2880 var bgPic='img/goldCookie.png';
2881 var picX=0;var picY=0;
2882
2883 if ((Game.elderWrath==1 && Math.random()<1/3) || (Game.elderWrath==2 && Math.random()<2/3) || (Game.elderWrath==3))
2884 {
2885 me.wrath=1;
2886 if (Game.season=='halloween') bgPic='img/spookyCookie.png';
2887 else bgPic='img/wrathCookie.png';
2888 }
2889 else
2890 {
2891 me.wrath=0;
2892 }
2893
2894 if (Game.season=='valentines')
2895 {
2896 bgPic='img/hearts.png';
2897 picX=Math.floor(Math.random()*8);
2898 }
2899 else if (Game.season=='fools')
2900 {
2901 bgPic='img/contract.png';
2902 if (me.wrath) bgPic='img/wrathContract.png';
2903 }
2904 else if (Game.season=='easter')
2905 {
2906 bgPic='img/bunnies.png';
2907 picX=Math.floor(Math.random()*4);
2908 picY=0;
2909 if (me.wrath) picY=1;
2910 }
2911
2912 me.x=Math.floor(Math.random()*Math.max(0,(Game.bounds.right-300)-Game.bounds.left-128)+Game.bounds.left+64)-64;
2913 me.y=Math.floor(Math.random()*Math.max(0,Game.bounds.bottom-Game.bounds.top-128)+Game.bounds.top+64)-64;
2914 me.l.style.left=me.x+'px';
2915 me.l.style.top=me.y+'px';
2916 me.l.style.width='96px';
2917 me.l.style.height='96px';
2918 me.l.style.backgroundImage='url('+bgPic+')';
2919 me.l.style.backgroundPosition=(-picX*96)+'px '+(-picY*96)+'px';
2920 me.l.style.opacity='0';
2921 me.l.style.display='block';
2922
2923 me.life=1;//the cookie's current progression through its lifespan (in frames)
2924 me.dur=13;//duration; the cookie's lifespan in seconds before it despawns
2925
2926 var dur=13;
2927 if (Game.Has('Lucky day')) dur*=2;
2928 if (Game.Has('Serendipity')) dur*=2;
2929 if (Game.Has('Decisive fate')) dur*=1.05;
2930 if (this.chain>0) dur=Math.max(2,10/this.chain);//this is hilarious
2931 me.dur=dur;
2932 me.life=Math.ceil(Game.fps*me.dur);
2933 me.force='';
2934 me.sizeMult=1;
2935 },
2936 updateFunc:function(me)
2937 {
2938 var curve=1-Math.pow((me.life/(Game.fps*me.dur))*2-1,4);
2939 me.l.style.opacity=curve;
2940 me.l.style.transform='rotate('+(Math.sin(me.id*0.69)*24+Math.sin(Game.T*(0.35+Math.sin(me.id*0.97)*0.15)+me.id/*+Math.sin(Game.T*0.07)*2+2*/)*(3+Math.sin(me.id*0.36)*2))+'deg) scale('+(me.sizeMult*(1+Math.sin(me.id*0.53)*0.2)*curve*(1+(0.06+Math.sin(me.id*0.41)*0.05)*(Math.sin(Game.T*(0.25+Math.sin(me.id*0.73)*0.15)+me.id))))+')';
2941 me.life--;
2942 if (me.life<=0) {this.missFunc(me);me.die();}
2943 },
2944 popFunc:function(me)
2945 {
2946 //get achievs and stats
2947 if (me.spawnLead)
2948 {
2949 Game.goldenClicks++;
2950 Game.goldenClicksLocal++;
2951
2952 if (Game.goldenClicks>=1) Game.Win('Golden cookie');
2953 if (Game.goldenClicks>=7) Game.Win('Lucky cookie');
2954 if (Game.goldenClicks>=27) Game.Win('A stroke of luck');
2955 if (Game.goldenClicks>=77) Game.Win('Fortune');
2956 if (Game.goldenClicks>=777) Game.Win('Leprechaun');
2957 if (Game.goldenClicks>=7777) Game.Win('Black cat\'s paw');
2958
2959 if (Game.goldenClicks>=7) Game.Unlock('Lucky day');
2960 if (Game.goldenClicks>=27) Game.Unlock('Serendipity');
2961 if (Game.goldenClicks>=77) Game.Unlock('Get lucky');
2962 if (Game.goldenClicks>=777) Game.Unlock('Pot of gold');
2963 if (Game.goldenClicks>=7777) Game.Unlock('All the luck');
2964
2965 if ((me.life/Game.fps)>(me.dur-1)) Game.Win('Early bird');
2966 if (me.life<Game.fps) Game.Win('Fading luck');
2967 }
2968
2969 //select an effect
2970 var list=[];
2971 if (me.wrath>0) list.push('clot','multiply cookies','ruin cookies');
2972 else list.push('frenzy','multiply cookies');
2973 if (me.wrath>0 && Math.random()<0.3) list.push('blood frenzy','chain cookie','cookie storm');
2974 else if (Math.random()<0.03 && Game.cookiesEarned>=100000) list.push('chain cookie','cookie storm');
2975 if (Math.random()<0.05 && Game.season=='fools') list.push('everything must go');
2976 if (Math.random()<0.1) list.push('click frenzy');
2977 if (me.wrath && Math.random()<0.1) list.push('cursed finger');
2978
2979 if (Game.BuildingsOwned>=10 && Math.random()<0.25) list.push('building special');
2980
2981 if ((me.wrath==0 && Math.random()<0.75) || Math.random()<0.3)
2982 {
2983 if (Game.hasAura('Reaper of Fields')) list.push('dragon harvest');
2984 }
2985 if (Math.random()<0.075)
2986 {
2987 if (Game.hasAura('Dragonflight')) list.push('dragonflight');
2988 }
2989
2990 if (this.last!='' && Math.random()<0.8 && list.indexOf(this.last)!=-1) list.splice(list.indexOf(this.last),1);//80% chance to force a different one
2991 if (Math.random()<0.0001) list.push('blab');
2992 var choice=choose(list);
2993
2994 if (this.chain>0) choice='chain cookie';
2995 if (me.force!='') {this.chain=0;choice=me.force;me.force='';}
2996 if (choice!='chain cookie') this.chain=0;
2997
2998 this.last=choice;
2999
3000 //create buff for effect
3001 var effectDurMod=1;
3002 if (Game.Has('Get lucky')) effectDurMod*=2;
3003 if (Game.Has('Lasting fortune')) effectDurMod*=1.1;
3004 if (Game.hasAura('Epoch Manipulator')) effectDurMod*=1.2;
3005
3006 var mult=1;
3007 if (Game.Has('Pot of gold')) mult*=2;
3008 if (Game.Has('All the luck')) mult*=2;
3009 if (me.wrath>0 && Game.hasAura('Unholy Dominion')) mult*=1.1;
3010 else if (me.wrath==0 && Game.hasAura('Ancestral Metamorphosis')) mult*=1.1;
3011
3012 var popup='';
3013 var buff=0;
3014
3015 if (choice=='building special')
3016 {
3017 var time=Math.ceil(30*effectDurMod);
3018 var list=[];
3019 for (var i in Game.Objects)
3020 {
3021 if (Game.Objects[i].amount>=10) list.push(Game.Objects[i].name);
3022 }
3023 if (list.length==0) {choice='frenzy';}//default to frenzy if no proper building
3024 else
3025 {
3026 var obj=choose(list);
3027 var pow=mult*(Game.Objects[obj].amount/10+1);
3028 if (me.wrath && Math.random()<0.3)
3029 {
3030 buff=Game.setBuff({
3031 name:Game.goldenCookieBuildingBuffs[obj][1],
3032 desc:'Your '+Game.Objects[obj].amount+' '+Game.Objects[obj].plural+' are rusting your CpS!<br>Cookie production -'+(Math.ceil(pow*100-100))+'% for '+time+' seconds!',
3033 icon:[Game.Objects[obj].iconColumn,15],
3034 time:time*Game.fps,
3035 add:true,
3036 multCpS:1/pow,
3037 aura:2
3038 });
3039 }
3040 else
3041 {
3042 buff=Game.setBuff({
3043 name:Game.goldenCookieBuildingBuffs[obj][0],
3044 desc:'Your '+Game.Objects[obj].amount+' '+Game.Objects[obj].plural+' are boosting your CpS!<br>Cookie production +'+(Math.ceil(pow*100-100))+'% for '+time+' seconds!',
3045 icon:[Game.Objects[obj].iconColumn,14],
3046 time:time*Game.fps,
3047 add:true,
3048 multCpS:pow,
3049 aura:1
3050 });
3051 }
3052 }
3053 }
3054
3055 if (choice=='frenzy')
3056 {
3057 var time=Math.ceil(77*effectDurMod);
3058 var pow=mult*7;
3059 buff=Game.setBuff({
3060 name:'Frenzy',
3061 desc:'Cookie production x'+pow+' for '+time+' seconds!',
3062 icon:[10,14],
3063 time:time*Game.fps,
3064 add:true,
3065 multCpS:pow,
3066 aura:1
3067 });
3068 }
3069 else if (choice=='dragon harvest')
3070 {
3071 var time=Math.ceil(60*effectDurMod);
3072 var pow=mult*15;
3073 buff=Game.setBuff({
3074 name:'Dragon Harvest',
3075 desc:'Cookie production x'+pow+' for '+time+' seconds!',
3076 icon:[10,25],
3077 time:time*Game.fps,
3078 add:true,
3079 multCpS:pow,
3080 aura:1
3081 });
3082 }
3083 else if (choice=='everything must go')
3084 {
3085 var time=Math.ceil(5*effectDurMod);
3086 var pow=5;
3087 buff=Game.setBuff({
3088 name:'Everything must go',
3089 desc:'All buildings are 5% cheaper for '+time+' seconds!',
3090 icon:[17,6],
3091 time:time*Game.fps,
3092 add:true,
3093 power:pow,
3094 aura:1
3095 });
3096 }
3097 else if (choice=='multiply cookies')
3098 {
3099 var moni=mult*Math.min(Game.cookies*0.15,Game.cookiesPs*60*15)+13;//add 15% to cookies owned (+13), or 15 minutes of cookie production - whichever is lowest
3100 Game.Earn(moni);
3101 popup='Lucky!<div style="font-size:65%;">+'+Beautify(moni)+' cookies!</div>';
3102 }
3103 else if (choice=='ruin cookies')
3104 {
3105 var moni=mult*Math.min(Game.cookies*0.05,Game.cookiesPs*60*10)+13;//lose 5% of cookies owned (-13), or 10 minutes of cookie production - whichever is lowest
3106 moni=Math.min(Game.cookies,moni);
3107 Game.Spend(moni);
3108 popup='Ruin!<div style="font-size:65%;">Lost '+Beautify(moni)+' cookies!</div>';
3109 }
3110 else if (choice=='blood frenzy')
3111 {
3112 var time=Math.ceil(6*effectDurMod);
3113 var pow=mult*666;
3114 buff=Game.setBuff({
3115 name:'Elder frenzy',
3116 desc:'Cookie production x'+pow+' for '+time+' seconds!',
3117 icon:[29,6],
3118 time:time*Game.fps,
3119 add:true,
3120 multCpS:pow,
3121 aura:1
3122 });
3123 }
3124 else if (choice=='clot')
3125 {
3126 var time=Math.ceil(66*effectDurMod);
3127 var pow=0.5/mult;
3128 buff=Game.setBuff({
3129 name:'Clot',
3130 desc:'Cookie production halved for '+time+' seconds!',
3131 icon:[15,5],
3132 time:time*Game.fps,
3133 add:true,
3134 multCpS:pow,
3135 aura:2
3136 });
3137 }
3138 else if (choice=='cursed finger')
3139 {
3140 var time=Math.ceil(10*effectDurMod);
3141 var pow=mult*Game.cookiesPs*time;
3142 buff=Game.setBuff({
3143 name:'Cursed finger',
3144 desc:'Cookie production halted for '+time+' seconds,<br>but each click is worth '+time+' seconds of CpS.',
3145 icon:[12,17],
3146 time:time*Game.fps,
3147 add:true,
3148 power:pow,
3149 multCpS:0,
3150 aura:1
3151 });
3152 }
3153 else if (choice=='click frenzy')
3154 {
3155 var time=Math.ceil(13*effectDurMod);
3156 var pow=mult*777;
3157 buff=Game.setBuff({
3158 name:'Click frenzy',
3159 desc:'Clicking power x'+pow+' for '+time+' seconds!',
3160 icon:[0,14],
3161 time:time*Game.fps,
3162 add:true,
3163 multClick:pow,
3164 aura:1
3165 });
3166 }
3167 else if (choice=='dragonflight')
3168 {
3169 var time=Math.ceil(10*effectDurMod);
3170 var pow=mult*1500;
3171 buff=Game.setBuff({
3172 name:'Dragonflight',
3173 desc:'Clicking power x'+pow+' for '+time+' seconds!',
3174 icon:[0,25],
3175 time:time*Game.fps,
3176 add:true,
3177 multClick:pow,
3178 aura:1
3179 });
3180 }
3181 else if (choice=='chain cookie')
3182 {
3183 //fix by Icehawk78
3184 if (this.chain==0) this.totalFromChain=0;
3185 this.chain++;
3186 var digit=me.wrath?6:7;
3187 if (this.chain==1) this.chain+=Math.max(0,Math.ceil(Math.log(Game.cookies)/Math.LN10)-10);
3188
3189 var maxPayout=mult*Math.min(Game.cookiesPs*60*60*6,Game.cookies*0.25)*mult;
3190 var moni=mult*Math.max(digit,Math.min(Math.floor(1/9*Math.pow(10,this.chain)*digit*mult),maxPayout));
3191 var nextMoni=mult*Math.max(digit,Math.min(Math.floor(1/9*Math.pow(10,this.chain+1)*digit*mult),maxPayout));
3192 this.totalFromChain+=moni;
3193 var moniStr=Beautify(moni);
3194
3195 if (Math.random()<0.01 || nextMoni>=maxPayout)
3196 {
3197 this.chain=0;
3198 popup='Cookie chain<div style="font-size:65%;">+'+moniStr+' cookies!<br>Cookie chain over. You made '+Beautify(this.totalFromChain)+' cookies.</div>';
3199 }
3200 else
3201 {
3202 popup='Cookie chain<div style="font-size:65%;">+'+moniStr+' cookies!</div>';//
3203 }
3204 Game.Earn(moni);
3205 }
3206 else if (choice=='cookie storm')
3207 {
3208 var time=Math.ceil(7*effectDurMod);
3209 var pow=mult*7;
3210 buff=Game.setBuff({
3211 name:'Cookie storm',
3212 desc:'Cookies everywhere!',
3213 icon:[22,6],
3214 time:time*Game.fps,
3215 add:true,
3216 power:pow,
3217 aura:1
3218 });
3219 }
3220 else if (choice=='cookie storm drop')
3221 {
3222 var moni=mult*Math.max(mult*(Game.cookiesPs*60*Math.floor(Math.random()*7+1)),Math.floor(Math.random()*7+1));//either 1-7 cookies or 1-7 minutes of cookie production, whichever is highest
3223 Game.Earn(moni);
3224 popup='<div style="font-size:75%;">+'+Beautify(moni)+' cookies!</div>';
3225 }
3226 else if (choice=='blab')//sorry (it's really rare)
3227 {
3228 var str=choose([
3229 'Cookie crumbliness x3 for 60 seconds!',
3230 'Chocolatiness x7 for 77 seconds!',
3231 'Dough elasticity halved for 66 seconds!',
3232 'Golden cookie shininess doubled for 3 seconds!',
3233 'World economy halved for 30 seconds!',
3234 'Grandma kisses 23% stingier for 45 seconds!',
3235 'Thanks for clicking!',
3236 'Fooled you! This one was just a test.',
3237 'Golden cookies clicked +1!',
3238 'Your click has been registered. Thank you for your cooperation.',
3239 'Thanks! That hit the spot!',
3240 'Thank you. A team has been dispatched.',
3241 'They know.',
3242 'Oops. This was just a chocolate cookie with shiny aluminium foil.'
3243 ]);
3244 popup=str;
3245 }
3246
3247 if (popup=='' && buff && buff.name && buff.desc) popup=buff.name+'<div style="font-size:65%;">'+buff.desc+'</div>';
3248 if (popup!='') Game.Popup(popup,me.x+me.l.offsetWidth/2,me.y);
3249
3250
3251 Game.DropEgg(0.9);
3252
3253 //sparkle and kill the shimmer
3254 Game.SparkleAt(me.x+48,me.y+48);
3255 if (choice=='cookie storm drop')
3256 {
3257 if (Game.prefs.cookiesound) PlaySound('snd/clickb'+Math.floor(Math.random()*7+1)+'.mp3',0.75);
3258 else PlaySound('snd/click'+Math.floor(Math.random()*7+1)+'.mp3',0.75);
3259 }
3260 else PlaySound('snd/shimmerClick.mp3');
3261 me.die();
3262 },
3263 missFunc:function(me)
3264 {
3265 if (this.chain>0 && this.totalFromChain>0)
3266 {
3267 Game.Popup('Cookie chain broken.<div style="font-size:65%;">You made '+Beautify(this.totalFromChain)+' cookies.</div>',me.x+me.l.offsetWidth/2,me.y);
3268 this.chain=0;this.totalFromChain=0;
3269 }
3270 if (me.spawnLead) Game.missedGoldenClicks++;
3271 },
3272 spawnsOnTimer:true,
3273 spawnConditions:function()
3274 {
3275 if (!Game.Has('Golden switch [off]')) return true; else return false;
3276 },
3277 spawned:0,
3278 time:0,
3279 minTime:0,
3280 maxTime:0,
3281 getTimeMod:function(m)
3282 {
3283 if (Game.Has('Lucky day')) m/=2;
3284 if (Game.Has('Serendipity')) m/=2;
3285 if (Game.Has('Golden goose egg')) m*=0.95;
3286 if (Game.Has('Heavenly luck')) m*=0.95;
3287 if (Game.hasAura('Arcane Aura')) m*=0.95;
3288 if (Game.season=='easter' && Game.Has('Starspawn')) m*=0.98;
3289 else if (Game.season=='halloween' && Game.Has('Starterror')) m*=0.98;
3290 else if (Game.season=='valentines' && Game.Has('Starlove')) m*=0.98;
3291 else if (Game.season=='fools' && Game.Has('Startrade')) m*=0.95;
3292 if (this.chain>0) m=0.05;
3293 if (Game.Has('Gold hoard')) m=0.01;
3294 return Math.ceil(Game.fps*60*m);
3295 },
3296 getMinTime:function()
3297 {
3298 var m=5;
3299 return this.getTimeMod(m);
3300 },
3301 getMaxTime:function()
3302 {
3303 var m=15;
3304 return this.getTimeMod(m);
3305 },
3306 last:'',
3307 },
3308 'reindeer':{
3309 reset:function()
3310 {
3311 },
3312 initFunc:function(me)
3313 {
3314 if (!this.spawned && Game.chimeType==1 && Game.ascensionMode!=1) PlaySound('snd/jingle.mp3');
3315
3316 me.x=-128;
3317 me.y=Math.floor(Math.random()*Math.max(0,Game.bounds.bottom-Game.bounds.top-256)+Game.bounds.top+128)-128;
3318 //me.l.style.left=me.x+'px';
3319 //me.l.style.top=me.y+'px';
3320 me.l.style.width='167px';
3321 me.l.style.height='212px';
3322 me.l.style.backgroundImage='url(img/frostedReindeer.png)';
3323 me.l.style.opacity='0';
3324 //me.l.style.transform='rotate('+(Math.random()*60-30)+'deg) scale('+(Math.random()*1+0.25)+')';
3325 me.l.style.display='block';
3326
3327 me.life=1;//the reindeer's current progression through its lifespan (in frames)
3328 me.dur=4;//duration; the cookie's lifespan in seconds before it despawns
3329
3330 var dur=4;
3331 if (Game.Has('Weighted sleighs')) dur*=2;
3332 me.dur=dur;
3333 me.life=Math.ceil(Game.fps*me.dur);
3334 me.sizeMult=1;
3335 },
3336 updateFunc:function(me)
3337 {
3338 var curve=1-Math.pow((me.life/(Game.fps*me.dur))*2-1,12);
3339 me.l.style.opacity=curve;
3340 me.l.style.transform='translate('+(me.x+(Game.bounds.right-Game.bounds.left)*(1-me.life/(Game.fps*me.dur)))+'px,'+(me.y-Math.abs(Math.sin(me.life*0.1))*128)+'px) rotate('+(Math.sin(me.life*0.2+0.3)*10)+'deg) scale('+(me.sizeMult*(1+Math.sin(me.id*0.53)*0.1))+')';
3341 me.life--;
3342 if (me.life<=0) {this.missFunc(me);me.die();}
3343 },
3344 popFunc:function(me)
3345 {
3346 //get achievs and stats
3347 if (me.spawnLead)
3348 {
3349 Game.reindeerClicked++;
3350 }
3351
3352 var val=Game.cookiesPs*60;
3353 if (Game.hasBuff('Elder frenzy')) val*=0.5;//very sorry
3354 if (Game.hasBuff('Frenzy')) val*=0.75;//I sincerely apologize
3355 var moni=Math.max(25,val);//1 minute of cookie production, or 25 cookies - whichever is highest
3356 if (Game.Has('Ho ho ho-flavored frosting')) moni*=2;
3357 Game.Earn(moni);
3358 if (Game.hasBuff('Elder frenzy')) Game.Win('Eldeer');
3359
3360 var failRate=0.8;
3361 var cookie='';
3362 if (Game.HasAchiev('Let it snow')) failRate=0.6;
3363 if (Game.Has('Santa\'s bottomless bag')) failRate*=0.9;
3364 if (Game.hasAura('Mind Over Matter')) failRate*=0.75;
3365 if (Game.Has('Starsnow')) failRate*=0.95;
3366 if (Math.random()>failRate)//christmas cookie drops
3367 {
3368 cookie=choose(['Christmas tree biscuits','Snowflake biscuits','Snowman biscuits','Holly biscuits','Candy cane biscuits','Bell biscuits','Present biscuits']);
3369 if (!Game.HasUnlocked(cookie) && !Game.Has(cookie))
3370 {
3371 Game.Unlock(cookie);
3372 }
3373 else cookie='';
3374 }
3375
3376 var popup='';
3377
3378 if (Game.prefs.popups) Game.Popup('You found '+choose(['Dasher','Dancer','Prancer','Vixen','Comet','Cupid','Donner','Blitzen','Rudolph'])+'!<br>The reindeer gives you '+Beautify(moni)+' cookies.'+(cookie==''?'':'<br>You are also rewarded with '+cookie+'!'));
3379 else Game.Notify('You found '+choose(['Dasher','Dancer','Prancer','Vixen','Comet','Cupid','Donner','Blitzen','Rudolph'])+'!','The reindeer gives you '+Beautify(moni)+' cookies.'+(cookie==''?'':'<br>You are also rewarded with '+cookie+'!'),[12,9],6);
3380 popup='<div style="font-size:80%;">+'+Beautify(moni)+' cookies!</div>';
3381
3382 if (popup!='') Game.Popup(popup,Game.mouseX,Game.mouseY);
3383
3384 //sparkle and kill the shimmer
3385 Game.SparkleAt(Game.mouseX,Game.mouseY);
3386 PlaySound('snd/jingleClick.mp3');
3387 me.die();
3388 },
3389 missFunc:function(me)
3390 {
3391 },
3392 spawnsOnTimer:true,
3393 spawnConditions:function()
3394 {
3395 if (Game.season=='christmas') return true; else return false;
3396 },
3397 spawned:0,
3398 time:0,
3399 minTime:0,
3400 maxTime:0,
3401 getTimeMod:function(m)
3402 {
3403 if (Game.Has('Reindeer baking grounds')) m/=2;
3404 if (Game.Has('Starsnow')) m*=0.95;
3405 if (Game.Has('Reindeer season')) m=0.01;
3406 return Math.ceil(Game.fps*60*m);
3407 },
3408 getMinTime:function()
3409 {
3410 var m=3;
3411 return this.getTimeMod(m);
3412 },
3413 getMaxTime:function()
3414 {
3415 var m=6;
3416 return this.getTimeMod(m);
3417 },
3418 }
3419 };
3420
3421 Game.buffs=[];//buffs currently in effect
3422 Game.buffsN=0;
3423 Game.buffsL=l('buffs');
3424 Game.setBuff=function(obj)
3425 {
3426 /*
3427 usage example :
3428 Game.setBuff({
3429 name:'Kitten rain',
3430 desc:'It\'s raining kittens!',
3431 icon:[0,0],
3432 time:30*Game.fps
3433 });
3434 other parameters :
3435 visible:false - will hide the buff from the buff list
3436 add:true - if this buff already exists, add the new duration to the old one
3437 max:true - if this buff already exists, set the new duration to the max of either
3438 onDie:function(){} - function will execute when the buff runs out
3439 power:3 - used by some buffs
3440 multCpS:3 - buff multiplies CpS by this amount
3441 multClick:3 - buff multiplies click power by this amount
3442 */
3443 var buff={
3444 visible:true,
3445 time:0,
3446 name:'???',
3447 desc:'',
3448 icon:[0,0]
3449 };
3450 if (Game.buffs[obj.name])//if there is already a buff in effect with this name
3451 {
3452 var buff=Game.buffs[obj.name];
3453 if (obj.max) buff.time=Math.max(obj.time,buff.time);//new duration is max of old and new
3454 if (obj.add) buff.time+=obj.time;//new duration is old + new
3455 if (!obj.max && !obj.add) buff.time=obj.time;//new duration is set to new
3456 buff.maxTime=buff.time;
3457 }
3458 else//create new buff
3459 {
3460 for (var i in obj)//paste parameters onto buff
3461 {buff[i]=obj[i];}
3462 buff.maxTime=buff.time;
3463 Game.buffs[buff.name]=buff;
3464 buff.id=Game.buffsN;
3465
3466 //create dom
3467 Game.buffsL.innerHTML=Game.buffsL.innerHTML+'<div id="buff'+buff.id+'" class="crate enabled buff" '+(buff.desc?Game.getTooltip(
3468 '<div class="prompt" style="min-width:200px;text-align:center;font-size:11px;margin:8px 0px;"><h3>'+buff.name+'</h3><div class="line"></div>'+buff.desc+'</div>'
3469 ,'left',true):'')+' style="opacity:1;float:none;display:block;background-position:'+(-buff.icon[0]*48)+'px '+(-buff.icon[1]*48)+'px;"></div>';
3470
3471 buff.l=l('buff'+buff.id);
3472
3473 Game.buffsN++;
3474 }
3475 Game.recalculateGains=1;
3476 Game.storeToRefresh=1;
3477 return buff;
3478 }
3479 Game.hasBuff=function(what)//returns 0 if there is no buff in effect with this name; else, returns its remaining time (in frames)
3480 {if (!Game.buffs[what]) return 0; else return Game.buffs[what].time;}
3481 Game.updateBuffs=function()//executed every logic frame
3482 {
3483 for (var i in Game.buffs)
3484 {
3485 var buff=Game.buffs[i];
3486
3487 if (buff.time>=0)
3488 {
3489 if (!l('buffPieTimer'+buff.id)) l('buff'+buff.id).innerHTML=l('buff'+buff.id).innerHTML+'<div class="pieTimer" id="buffPieTimer'+buff.id+'"></div>';
3490 var T=1-(buff.time/buff.maxTime);
3491 T=(T*144)%144;
3492 l('buffPieTimer'+buff.id).style.backgroundPosition=(-Math.floor(T%18))*48+'px '+(-Math.floor(T/18))*48+'px';
3493 }
3494 buff.time--;
3495 if (buff.time<=0)
3496 {
3497 if (Game.onCrate==l('buff'+buff.id)) Game.tooltip.hide();
3498 if (buff.onDie) buff.onDie();
3499 Game.buffsL.removeChild(l('buff'+buff.id));
3500 if (Game.buffs[buff.name]) Game.buffs[buff.name]=0;
3501 Game.recalculateGains=1;
3502 Game.storeToRefresh=1;
3503 }
3504 }
3505 }
3506 Game.killBuffs=function()//remove all buffs
3507 {Game.buffs=[];Game.recalculateGains=1;Game.storeToRefresh=1;}
3508
3509
3510 Game.goldenCookieChoices=[
3511 "Frenzy","frenzy",
3512 "Lucky","multiply cookies",
3513 "Ruin","ruin cookies",
3514 "Elder frenzy","blood frenzy",
3515 "Clot","clot",
3516 "Click frenzy","click frenzy",
3517 "Cursed finger","cursed finger",
3518 "Cookie chain","chain cookie",
3519 "Cookie storm","cookie storm",
3520 "Building special","building special",
3521 "Dragon Harvest","dragon harvest",
3522 "Dragonflight","dragonflight",
3523 "Blab","blab"
3524 ];
3525 Game.goldenCookieBuildingBuffs={
3526 'Cursor':['High-five','Slap to the face'],
3527 'Grandma':['Congregation','Senility'],
3528 'Farm':['Luxuriant harvest','Locusts'],
3529 'Mine':['Ore vein','Cave-in'],
3530 'Factory':['Oiled-up','Jammed machinery'],
3531 'Bank':['Juicy profits','Recession'],
3532 'Temple':['Fervent adoration','Crisis of faith'],
3533 'Wizard tower':['Manabloom','Magivores'],
3534 'Shipment':['Delicious lifeforms','Black holes'],
3535 'Alchemy lab':['Breakthrough','Lab disaster'],
3536 'Portal':['Righteous cataclysm','Dimensional calamity'],
3537 'Time machine':['Golden ages','Time jam'],
3538 'Antimatter condenser':['Extra cycles','Predictable tragedy'],
3539 'Prism':['Solar flare','Eclipse'],
3540 };
3541
3542 /*=====================================================================================
3543 PARTICLES
3544 =======================================================================================*/
3545 //generic particles (falling cookies etc)
3546 //only displayed on left section
3547 Game.particles=[];
3548 for (var i=0;i<50;i++)
3549 {
3550 Game.particles[i]={x:0,y:0,xd:0,yd:0,w:64,h:64,z:0,size:1,dur:2,life:-1,r:0,pic:'smallCookies.png',picId:0};
3551 }
3552
3553 Game.particlesUpdate=function()
3554 {
3555 for (var i in Game.particles)
3556 {
3557 var me=Game.particles[i];
3558 if (me.life!=-1)
3559 {
3560 if (!me.text) me.yd+=0.2+Math.random()*0.1;
3561 me.x+=me.xd;
3562 me.y+=me.yd;
3563 //me.y+=me.life*0.25+Math.random()*0.25;
3564 me.life++;
3565 if (me.life>=Game.fps*me.dur)
3566 {
3567 me.life=-1;
3568 }
3569 }
3570 }
3571 }
3572 Game.particleAdd=function(x,y,xd,yd,size,dur,z,pic,text)
3573 {
3574 //Game.particleAdd(pos X,pos Y,speed X,speed Y,size (multiplier),duration (seconds),layer,picture,text);
3575 //pick the first free (or the oldest) particle to replace it
3576 if (1 || Game.prefs.particles)
3577 {
3578 var highest=0;
3579 var highestI=0;
3580 for (var i in Game.particles)
3581 {
3582 if (Game.particles[i].life==-1) {highestI=i;break;}
3583 if (Game.particles[i].life>highest)
3584 {
3585 highest=Game.particles[i].life;
3586 highestI=i;
3587 }
3588 }
3589 var auto=0;
3590 if (x) auto=1;
3591 var i=highestI;
3592 var x=x||-64;
3593 if (Game.LeftBackground && !auto) x=Math.floor(Math.random()*Game.LeftBackground.canvas.width);
3594 var y=y||-64;
3595 var me=Game.particles[i];
3596 me.life=0;
3597 me.x=x;
3598 me.y=y;
3599 me.xd=xd||0;
3600 me.yd=yd||0;
3601 me.size=size||1;
3602 me.z=z||0;
3603 me.dur=dur||2;
3604 me.r=Math.floor(Math.random()*360);
3605 me.picId=Math.floor(Math.random()*10000);
3606 if (!pic)
3607 {
3608 if (Game.season=='fools') pic='smallDollars.png';
3609 else
3610 {
3611 var cookies=[[10,0]];
3612 for (var i in Game.Upgrades)
3613 {
3614 var cookie=Game.Upgrades[i];
3615 if (cookie.bought>0 && cookie.pool=='cookie') cookies.push(cookie.icon);
3616 }
3617 me.picPos=choose(cookies);
3618 pic='icons.png';
3619 }
3620 }
3621 me.pic=pic||'smallCookies.png';
3622 me.text=text||0;
3623 return me;
3624 }
3625 return {};
3626 }
3627 Game.particlesDraw=function(z)
3628 {
3629 Game.LeftBackground.fillStyle='#fff';
3630 Game.LeftBackground.font='20px Merriweather';
3631 Game.LeftBackground.textAlign='center';
3632
3633 for (var i in Game.particles)
3634 {
3635 var me=Game.particles[i];
3636 if (me.z==z)
3637 {
3638 if (me.life!=-1)
3639 {
3640 var opacity=1-(me.life/(Game.fps*me.dur));
3641 Game.LeftBackground.globalAlpha=opacity;
3642 if (me.text)
3643 {
3644 Game.LeftBackground.fillText(me.text,me.x,me.y);
3645 }
3646 else
3647 {
3648 Game.LeftBackground.save();
3649 Game.LeftBackground.translate(me.x,me.y);
3650 Game.LeftBackground.rotate((me.r/360)*Math.PI*2);
3651 var w=64;
3652 var h=64;
3653 if (me.pic=='icons.png')
3654 {
3655 w=48;
3656 h=48;
3657 Game.LeftBackground.drawImage(Pic(me.pic),me.picPos[0]*w,me.picPos[1]*h,w,h,-w/2*me.size,-h/2*me.size,w*me.size,h*me.size);
3658 }
3659 else
3660 {
3661 if (me.pic=='wrinklerBits.png' || me.pic=='shinyWrinklerBits.png') {w=100;h=200;}
3662 Game.LeftBackground.drawImage(Pic(me.pic),(me.picId%8)*w,0,w,h,-w/2*me.size,-h/2*me.size,w*me.size,h*me.size);
3663 }
3664 Game.LeftBackground.restore();
3665 }
3666 }
3667 }
3668 }
3669 }
3670
3671 //text particles (popups etc)
3672 Game.textParticles=[];
3673 Game.textParticlesY=0;
3674 var str='';
3675 for (var i=0;i<20;i++)
3676 {
3677 Game.textParticles[i]={x:0,y:0,life:-1,text:''};
3678 str+='<div id="particle'+i+'" class="particle title"></div>';
3679 }
3680 l('particles').innerHTML=str;
3681 Game.textParticlesUpdate=function()
3682 {
3683 for (var i in Game.textParticles)
3684 {
3685 var me=Game.textParticles[i];
3686 if (me.life!=-1)
3687 {
3688 me.life++;
3689 if (me.life>=Game.fps*4)
3690 {
3691 var el=me.l;
3692 me.life=-1;
3693 el.style.opacity=0;
3694 el.style.display='none';
3695 }
3696 }
3697 }
3698 }
3699 Game.textParticlesAdd=function(text,el,posX,posY)
3700 {
3701 //pick the first free (or the oldest) particle to replace it
3702 var highest=0;
3703 var highestI=0;
3704 for (var i in Game.textParticles)
3705 {
3706 if (Game.textParticles[i].life==-1) {highestI=i;break;}
3707 if (Game.textParticles[i].life>highest)
3708 {
3709 highest=Game.textParticles[i].life;
3710 highestI=i;
3711 }
3712 }
3713 var i=highestI;
3714 var noStack=0;
3715 if (typeof posX!=='undefined' && typeof posY!=='undefined')
3716 {
3717 x=posX;
3718 y=posY;
3719 noStack=1;
3720 }
3721 else
3722 {
3723 var x=(Math.random()-0.5)*40;
3724 var y=0;//+(Math.random()-0.5)*40;
3725 if (!el)
3726 {
3727 var rect=Game.bounds;
3728 var x=Math.floor((rect.left+rect.right)/2);
3729 var y=Math.floor((rect.bottom))-(Game.mobile*64);
3730 x+=(Math.random()-0.5)*40;
3731 y+=0;//(Math.random()-0.5)*40;
3732 }
3733 }
3734 if (!noStack) y-=Game.textParticlesY;
3735
3736 x=Math.max(Game.bounds.left+200,x);
3737 x=Math.min(Game.bounds.right-200,x);
3738 y=Math.max(Game.bounds.top+32,y);
3739
3740 var me=Game.textParticles[i];
3741 if (!me.l) me.l=l('particle'+i);
3742 me.life=0;
3743 me.x=x;
3744 me.y=y;
3745 me.text=text;
3746 me.l.innerHTML=text;
3747 me.l.style.left=Math.floor(Game.textParticles[i].x-200)+'px';
3748 me.l.style.bottom=Math.floor(-Game.textParticles[i].y)+'px';
3749 me.l.style.display='block';
3750 me.l.className='particle title';
3751 me.l.offsetWidth=me.l.offsetWidth;
3752 me.l.className='particle title risingUpLinger';
3753 if (!noStack) Game.textParticlesY+=60;
3754 }
3755 Game.popups=1;
3756 Game.Popup=function(text,x,y)
3757 {
3758 if (Game.popups) Game.textParticlesAdd(text,0,x,y);
3759 }
3760
3761 //display sparkles at a set position
3762 Game.sparkles=l('sparkles');
3763 Game.sparklesT=0;
3764 Game.sparklesFrames=16;
3765 Game.SparkleAt=function(x,y)
3766 {
3767 if (Game.blendModesOn)
3768 {
3769 Game.sparklesT=Game.sparklesFrames+1;
3770 Game.sparkles.style.backgroundPosition='0px 0px';
3771 Game.sparkles.style.left=Math.floor(x-64)+'px';
3772 Game.sparkles.style.top=Math.floor(y-64)+'px';
3773 Game.sparkles.style.display='block';
3774 }
3775 }
3776
3777 /*=====================================================================================
3778 NOTIFICATIONS
3779 =======================================================================================*/
3780 //maybe do all this mess with proper DOM instead of rewriting the innerHTML
3781 Game.Notes=[];
3782 Game.NotesById=[];
3783 Game.noteId=0;
3784 Game.noteL=l('notes');
3785 Game.Note=function(title,desc,pic,quick)
3786 {
3787 this.title=title;
3788 this.desc=desc||'';
3789 this.pic=pic||'';
3790 this.id=Game.noteId;
3791 this.date=Date.now();
3792 this.quick=quick||0;
3793 this.life=(this.quick||1)*Game.fps;
3794 this.l=0;
3795 this.height=0;
3796 Game.noteId++;
3797 Game.NotesById[this.id]=this;
3798 Game.Notes.unshift(this);
3799 if (Game.Notes.length>50) Game.Notes.pop();
3800 //Game.Notes.push(this);
3801 //if (Game.Notes.length>50) Game.Notes.shift();
3802 Game.UpdateNotes();
3803 }
3804 Game.CloseNote=function(id)
3805 {
3806 var me=Game.NotesById[id];
3807 Game.Notes.splice(Game.Notes.indexOf(me),1);
3808 Game.NotesById.splice(Game.NotesById.indexOf(me),1);
3809 Game.UpdateNotes();
3810 }
3811 Game.CloseNotes=function()
3812 {
3813 Game.Notes=[];
3814 Game.NotesById=[];
3815 Game.UpdateNotes();
3816 }
3817 Game.UpdateNotes=function()
3818 {
3819 var str='';
3820 var remaining=Game.Notes.length;
3821 for (var i in Game.Notes)
3822 {
3823 if (i<5)
3824 {
3825 var me=Game.Notes[i];
3826 var pic='';
3827 if (me.pic!='') pic='<div class="icon" style="'+(me.pic[2]?'background-image:url('+me.pic[2]+');':'')+'background-position:'+(-me.pic[0]*48)+'px '+(-me.pic[1]*48)+'px;"></div>';
3828 str='<div id="note-'+me.id+'" class="framed note '+(me.pic!=''?'haspic':'nopic')+' '+(me.desc!=''?'hasdesc':'nodesc')+'"><div class="close" onclick="PlaySound(\'snd/tick.mp3\');Game.CloseNote('+me.id+');">x</div>'+pic+'<div class="text"><h3>'+me.title+'</h3>'+(me.desc!=''?'<div class="line"></div><h5>'+me.desc+'</h5>':'')+'</div></div>'+str;
3829 remaining--;
3830 }
3831 }
3832 if (remaining>0) str='<div class="remaining">+'+remaining+' more notification'+(remaining==1?'':'s')+'.</div>'+str;
3833 if (Game.Notes.length>1)
3834 {
3835 str+='<div class="framed close sidenote" onclick="PlaySound(\'snd/tick.mp3\');Game.CloseNotes();">x</div>';
3836 }
3837 Game.noteL.innerHTML=str;
3838 for (var i in Game.Notes)
3839 {
3840 me.l=0;
3841 if (i<5)
3842 {
3843 var me=Game.Notes[i];
3844 me.l=l('note-'+me.id);
3845 }
3846 }
3847 }
3848 Game.NotesLogic=function()
3849 {
3850 for (var i in Game.Notes)
3851 {
3852 if (Game.Notes[i].quick>0)
3853 {
3854 var me=Game.Notes[i];
3855 me.life--;
3856 if (me.life<=0) Game.CloseNote(me.id);
3857 }
3858 }
3859 }
3860 Game.NotesDraw=function()
3861 {
3862 for (var i in Game.Notes)
3863 {
3864 if (Game.Notes[i].quick>0)
3865 {
3866 var me=Game.Notes[i];
3867 if (me.l)
3868 {
3869 if (me.life<10)
3870 {
3871 me.l.style.opacity=(me.life/10);
3872 }
3873 }
3874 }
3875 }
3876 }
3877 Game.Notify=function(title,desc,pic,quick,noLog)
3878 {
3879 if (Game.prefs.notifs)
3880 {
3881 quick=Math.min(6,quick);
3882 if (!quick) quick=6;
3883 }
3884 if (Game.popups) new Game.Note(title,desc,pic,quick);
3885 if (!noLog) Game.AddToLog('<b>'+title+'</b> | '+desc);
3886 }
3887
3888
3889 /*=====================================================================================
3890 PROMPT
3891 =======================================================================================*/
3892 Game.darkenL=l('darken');
3893 AddEvent(Game.darkenL,'click',function(){Game.Click=0;Game.ClosePrompt();});
3894 Game.promptL=l('promptContent');
3895 Game.promptAnchorL=l('promptAnchor');
3896 Game.promptWrapL=l('prompt');
3897 Game.promptConfirm='';
3898 Game.promptOn=0;
3899 Game.promptUpdateFunc=0;
3900 Game.UpdatePrompt=function()
3901 {
3902 if (Game.promptUpdateFunc) Game.promptUpdateFunc();
3903 Game.promptAnchorL.style.top=Math.floor((Game.windowH-Game.promptWrapL.offsetHeight)/2-16)+'px';
3904 }
3905 Game.Prompt=function(content,options,updateFunc,style)
3906 {
3907 if (updateFunc) Game.promptUpdateFunc=updateFunc;
3908 if (style) Game.promptWrapL.className='framed '+style; else Game.promptWrapL.className='framed';
3909 var str='';
3910 str+=content;
3911 var opts='';
3912 for (var i in options)
3913 {
3914 if (options[i]=='br')//just a linebreak
3915 {opts+='<br>';}
3916 else
3917 {
3918 if (typeof options[i]=='string') options[i]=[options[i],'Game.ClosePrompt();'];
3919 options[i][1]=options[i][1].replace(/'/g,''').replace(/"/g,'"');
3920 opts+='<a id="promptOption'+i+'" class="option" '+Game.clickStr+'="PlaySound(\'snd/tick.mp3\');'+options[i][1]+'">'+options[i][0]+'</a>';
3921 }
3922 }
3923 Game.promptL.innerHTML=str+'<div class="optionBox">'+opts+'</div>';
3924 Game.promptAnchorL.style.display='block';
3925 Game.darkenL.style.display='block';
3926 Game.promptL.focus();
3927 Game.promptOn=1;
3928 Game.UpdatePrompt();
3929 }
3930 Game.ClosePrompt=function()
3931 {
3932 Game.promptAnchorL.style.display='none';
3933 Game.darkenL.style.display='none';
3934 Game.promptOn=0;
3935 Game.promptUpdateFunc=0;
3936 }
3937 Game.ConfirmPrompt=function()
3938 {
3939 if (Game.promptOn && l('promptOption0') && l('promptOption0').style.display!='none') FireEvent(l('promptOption0'),'click');
3940 }
3941
3942 /*=====================================================================================
3943 MENUS
3944 =======================================================================================*/
3945 Game.cssClasses=[];
3946 Game.addClass=function(what) {if (Game.cssClasses.indexOf(what)==-1) Game.cssClasses.push(what);Game.updateClasses();}
3947 Game.removeClass=function(what) {var i=Game.cssClasses.indexOf(what);if(i!=-1) {Game.cssClasses.splice(i,1);}Game.updateClasses();}
3948 Game.updateClasses=function() {Game.l.className=Game.cssClasses.join(' ');}
3949
3950 Game.WriteButton=function(prefName,button,on,off,callback,invert)
3951 {
3952 var invert=invert?1:0;
3953 if (!callback) callback='';
3954 callback+='PlaySound(\'snd/tick.mp3\');';
3955 return '<a class="option'+((Game.prefs[prefName]^invert)?'':' off')+'" id="'+button+'" '+Game.clickStr+'="Game.Toggle(\''+prefName+'\',\''+button+'\',\''+on+'\',\''+off+'\',\''+invert+'\');'+callback+'">'+(Game.prefs[prefName]?on:off)+'</a>';
3956 }
3957 Game.Toggle=function(prefName,button,on,off,invert)
3958 {
3959 if (Game.prefs[prefName])
3960 {
3961 l(button).innerHTML=off;
3962 Game.prefs[prefName]=0;
3963 }
3964 else
3965 {
3966 l(button).innerHTML=on;
3967 Game.prefs[prefName]=1;
3968 }
3969 l(button).className='option'+((Game.prefs[prefName]^invert)?'':' off');
3970
3971 }
3972 Game.ToggleFancy=function()
3973 {
3974 if (Game.prefs.fancy) Game.removeClass('noFancy');
3975 else if (!Game.prefs.fancy) Game.addClass('noFancy');
3976 }
3977 Game.ToggleFilters=function()
3978 {
3979 if (Game.prefs.filters) Game.removeClass('noFilters');
3980 else if (!Game.prefs.filters) Game.addClass('noFilters');
3981 }
3982
3983 Game.WriteSlider=function(slider,leftText,rightText,startValueFunction,callback)
3984 {
3985 if (!callback) callback='';
3986 return '<div class="sliderBox"><div style="float:left;">'+leftText+'</div><div style="float:right;" id="'+slider+'RightText">'+rightText.replace('[$]',startValueFunction())+'</div><input class="slider" style="clear:both;" type="range" min="0" max="100" step="1" value="'+startValueFunction()+'" onchange="'+callback+'" oninput="'+callback+'" onmouseup="PlaySound(\'snd/tick.mp3\');" id="'+slider+'"/></div>';
3987 }
3988
3989 Game.onPanel='Left';
3990 Game.addClass('focus'+Game.onPanel);
3991 Game.ShowPanel=function(what)
3992 {
3993 if (!what) what='';
3994 if (Game.onPanel!=what)
3995 {
3996 Game.removeClass('focus'+Game.onPanel);
3997 Game.addClass('focus'+what);
3998 }
3999 Game.onPanel=what;
4000 }
4001
4002 Game.onMenu='';
4003 Game.ShowMenu=function(what)
4004 {
4005 if (!what || what=='') what=Game.onMenu;
4006 if (Game.onMenu=='' && what!='') Game.addClass('onMenu');
4007 else if (Game.onMenu!='' && what!=Game.onMenu) Game.addClass('onMenu');
4008 else if (what==Game.onMenu) {Game.removeClass('onMenu');what='';}
4009 if (what=='log') l('donateBox').className='on'; else l('donateBox').className='';
4010 Game.onMenu=what;
4011
4012 l('prefsButton').className=(Game.onMenu=='prefs')?'button selected':'button';
4013 l('statsButton').className=(Game.onMenu=='stats')?'button selected':'button';
4014 l('logButton').className=(Game.onMenu=='log')?'button selected':'button';
4015
4016 if (Game.onMenu=='') PlaySound('snd/clickOff.mp3');
4017 else PlaySound('snd/clickOn.mp3');
4018
4019 Game.UpdateMenu();
4020 }
4021 Game.sayTime=function(time,detail)
4022 {
4023 //time is a value where one second is equal to Game.fps (30).
4024 //detail skips days when >1, hours when >2, minutes when >3 and seconds when >4.
4025 var str='';
4026 var detail=detail||0;
4027 time=Math.floor(time);
4028 if (time>=Game.fps*60*60*24*2 && detail<2) str=Beautify(Math.floor(time/(Game.fps*60*60*24)))+' days';
4029 else if (time>=Game.fps*60*60*24 && detail<2) str='1 day';
4030 else if (time>=Game.fps*60*60*2 && detail<3) str=Beautify(Math.floor(time/(Game.fps*60*60)))+' hours';
4031 else if (time>=Game.fps*60*60 && detail<3) str='1 hour';
4032 else if (time>=Game.fps*60*2 && detail<4) str=Beautify(Math.floor(time/(Game.fps*60)))+' minutes';
4033 else if (time>=Game.fps*60 && detail<4) str='1 minute';
4034 else if (time>=Game.fps*2 && detail<5) str=Beautify(Math.floor(time/(Game.fps)))+' seconds';
4035 else if (time>=Game.fps && detail<5) str='1 second';
4036 return str;
4037 }
4038
4039 Game.tinyCookie=function()
4040 {
4041 if (!Game.HasAchiev('Tiny cookie'))
4042 {
4043 return '<div class="tinyCookie" '+Game.clickStr+'="Game.ClickTinyCookie();"></div>';
4044 }
4045 return '';
4046 }
4047 Game.ClickTinyCookie=function(){if (!Game.HasAchiev('Tiny cookie')){PlaySound('snd/tick.mp3');Game.Win('Tiny cookie');}}
4048
4049 Game.setVolume=function(what)
4050 {
4051 Game.volume=what;
4052 /*for (var i in Sounds)
4053 {
4054 Sounds[i].volume=Game.volume;
4055 }*/
4056 }
4057
4058 Game.UpdateMenu=function()
4059 {
4060 var str='';
4061 if (Game.onMenu!='')
4062 {
4063 str+='<div class="close menuClose" '+Game.clickStr+'="Game.ShowMenu();">x</div>';
4064 //str+='<div style="position:absolute;top:8px;right:8px;cursor:pointer;font-size:16px;" '+Game.clickStr+'="Game.ShowMenu();">X</div>';
4065 }
4066 if (Game.onMenu=='prefs')
4067 {
4068 str+='<div class="section">Options</div>'+
4069 '<div class="subsection">'+
4070 '<div class="title">General</div>'+
4071 '<div class="listing"><a class="option" '+Game.clickStr+'="Game.WriteSave();PlaySound(\'snd/tick.mp3\');">Save</a><label>Save manually (the game autosaves every 60 seconds; shortcut : ctrl+S)</label></div>'+
4072 '<div class="listing"><a class="option" '+Game.clickStr+'="Game.ExportSave();PlaySound(\'snd/tick.mp3\');">Export save</a><a class="option" '+Game.clickStr+'="Game.ImportSave();PlaySound(\'snd/tick.mp3\');">Import save</a><label>You can use this to backup your save or to transfer it to another computer (shortcut for import : ctrl+O)</label></div>'+
4073 '<div class="listing"><a class="option" '+Game.clickStr+'="Game.FileSave();PlaySound(\'snd/tick.mp3\');">Save to file</a><a class="option" style="position:relative;"><input id="FileLoadInput" type="file" style="cursor:pointer;opacity:0;position:absolute;left:0px;top:0px;width:100%;height:100%;" onchange="Game.FileLoad(event);" '+Game.clickStr+'="PlaySound(\'snd/tick.mp3\');"/>Load from file</a><label><b>Experimental</b> - use this to keep backups on your computer</label></div>'+
4074
4075 '<div class="listing"><a class="option warning" '+Game.clickStr+'="Game.HardReset();PlaySound(\'snd/tick.mp3\');">Wipe save</a><label>Delete all your progress, including your achievements</label></div>'+
4076 '<div class="title">Settings</div>'+
4077 '<div class="listing">'+
4078 Game.WriteSlider('volumeSlider','Volume','[$]%',function(){return Game.volume;},'Game.setVolume(Math.round(l(\'volumeSlider\').value));l(\'volumeSliderRightText\').innerHTML=Game.volume+\'%\';')+'<br>'+
4079 Game.WriteButton('fancy','fancyButton','Fancy graphics ON','Fancy graphics OFF','Game.ToggleFancy();')+'<label>(visual improvements; disabling may improve performance)</label><br>'+
4080 Game.WriteButton('filters','filtersButton','CSS filters ON','CSS filters OFF','Game.ToggleFilters();')+'<label>(cutting-edge visual improvements; disabling may improve performance)</label><br>'+
4081 Game.WriteButton('particles','particlesButton','Particles ON','Particles OFF')+'<label>(cookies falling down, etc; disabling may improve performance)</label><br>'+
4082 Game.WriteButton('numbers','numbersButton','Numbers ON','Numbers OFF')+'<label>(numbers that pop up when clicking the cookie)</label><br>'+
4083 Game.WriteButton('milk','milkButton','Milk ON','Milk OFF')+'<label>(only appears with enough achievements)</label><br>'+
4084 Game.WriteButton('cursors','cursorsButton','Cursors ON','Cursors OFF')+'<label>(visual display of your cursors)</label><br>'+
4085 Game.WriteButton('wobbly','wobblyButton','Wobbly cookie ON','Wobbly cookie OFF')+'<label>(your cookie will react when you click it)</label><br>'+
4086 Game.WriteButton('cookiesound','cookiesoundButton','Alt cookie sound ON','Alt cookie sound OFF')+'<label>(how your cookie sounds when you click on it)</label><br>'+
4087 Game.WriteButton('crates','cratesButton','Icon crates ON','Icon crates OFF')+'<label>(display boxes around upgrades and achievements in stats)</label><br>'+
4088 Game.WriteButton('monospace','monospaceButton','Alt font ON','Alt font OFF')+'<label>(your cookies are displayed using a monospace font)</label><br>'+
4089 Game.WriteButton('format','formatButton','Short numbers OFF','Short numbers ON','BeautifyAll();Game.RefreshStore();Game.upgradesToRebuild=1;',1)+'<label>(shorten big numbers)</label><br>'+
4090 Game.WriteButton('notifs','notifsButton','Fast notes ON','Fast notes OFF')+'<label>(notifications disappear much faster)</label><br>'+
4091 Game.WriteButton('autoupdate','autoupdateButton','Offline mode OFF','Offline mode ON',0,1)+'<label>(disables update notifications)</label><br>'+
4092 Game.WriteButton('warn','warnButton','Closing warning ON','Closing warning OFF')+'<label>(the game will ask you to confirm when you close the window)</label><br>'+
4093 Game.WriteButton('focus','focusButton','Defocus OFF','Defocus ON',0,1)+'<label>(the game will be less resource-intensive when out of focus)</label><br>'+
4094 '</div>'+
4095 //'<div class="listing">'+Game.WriteButton('autosave','autosaveButton','Autosave ON','Autosave OFF')+'</div>'+
4096 '<div style="padding-bottom:128px;"></div>'+
4097 '</div>'
4098 ;
4099 }
4100 else if (Game.onMenu=='main')
4101 {
4102 str+=
4103 '<div class="listing">This isn\'t really finished</div>'+
4104 '<div class="listing"><a class="option big title" '+Game.clickStr+'="Game.ShowMenu(\'prefs\');">Menu</a></div>'+
4105 '<div class="listing"><a class="option big title" '+Game.clickStr+'="Game.ShowMenu(\'stats\');">Stats</a></div>'+
4106 '<div class="listing"><a class="option big title" '+Game.clickStr+'="Game.ShowMenu(\'log\');">Updates</a></div>'+
4107 '<div class="listing"><a class="option big title" '+Game.clickStr+'="">Quit</a></div>'+
4108 '<div class="listing"><a class="option big title" '+Game.clickStr+'="Game.ShowMenu(Game.onMenu);">Resume</a></div>';
4109 }
4110 else if (Game.onMenu=='log')
4111 {
4112 str+=Game.updateLog;
4113 }
4114 else if (Game.onMenu=='stats')
4115 {
4116 var buildingsOwned=0;
4117 buildingsOwned=Game.BuildingsOwned;
4118 var upgrades='';
4119 var cookieUpgrades='';
4120 var hiddenUpgrades='';
4121 var prestigeUpgrades='';
4122 var upgradesTotal=0;
4123 var upgradesOwned=0;
4124 var prestigeUpgradesTotal=0;
4125 var prestigeUpgradesOwned=0;
4126
4127 var list=[];
4128 for (var i in Game.Upgrades)//sort the upgrades
4129 {
4130 list.push(Game.Upgrades[i]);
4131 }
4132 var sortMap=function(a,b)
4133 {
4134 if (a.order>b.order) return 1;
4135 else if (a.order<b.order) return -1;
4136 else return 0;
4137 }
4138 list.sort(sortMap);
4139 for (var i in list)
4140 {
4141 var str2='';
4142 var me=list[i];
4143
4144 str2+=Game.crate(me,'stats');
4145
4146 if (me.bought)
4147 {
4148 if (Game.CountsAsUpgradeOwned(me.pool)) upgradesOwned++;
4149 else if (me.pool=='prestige') prestigeUpgradesOwned++;
4150 }
4151
4152 if (me.pool=='' || me.pool=='cookie' || me.pool=='tech') upgradesTotal++;
4153 if (me.pool=='debug') hiddenUpgrades+=str2;
4154 else if (me.pool=='prestige') {prestigeUpgrades+=str2;prestigeUpgradesTotal++;}
4155 else if (me.pool=='cookie') cookieUpgrades+=str2;
4156 else if (me.pool!='toggle' && me.pool!='unused') upgrades+=str2;
4157 }
4158 var achievements=[];
4159 var achievementsOwned=0;
4160 var achievementsTotal=0;
4161
4162 var list=[];
4163 for (var i in Game.Achievements)//sort the achievements
4164 {
4165 list.push(Game.Achievements[i]);
4166 }
4167 var sortMap=function(a,b)
4168 {
4169 if (a.order>b.order) return 1;
4170 else if (a.order<b.order) return -1;
4171 else return 0;
4172 }
4173 list.sort(sortMap);
4174
4175
4176 for (var i in list)
4177 {
4178 var me=list[i];
4179 if (me.pool=='normal' || me.won>0) achievementsTotal++;
4180 var pool=me.pool;
4181 if (!achievements[pool]) achievements[pool]='';
4182
4183 achievements[pool]+=Game.crate(me,'stats');
4184 if (me.won>0) achievementsOwned++;
4185 }
4186
4187 var achievementsStr='';
4188 var pools={
4189 'dungeon':'<b>Dungeon achievements</b> <small>(Not technically achievable yet.)</small>',
4190 'shadow':'<b>Shadow achievements</b> <small>(These are feats that are either unfair or difficult to attain. They do not give milk.)</small>'
4191 };
4192 for (var i in achievements)
4193 {
4194 if (achievements[i]!='')
4195 {
4196 if (pools[i]) achievementsStr+='<div class="listing">'+pools[i]+'</div>';
4197 achievementsStr+='<div class="listing crateBox">'+achievements[i]+'</div>';
4198 }
4199 }
4200
4201
4202 var santaStr='';
4203 var frames=15;
4204 if (Game.Has('A festive hat'))
4205 {
4206 for (var i=0;i<=Game.santaLevel;i++)
4207 {
4208 santaStr+='<div '+Game.getTooltip(
4209 '<div class="prompt" style="text-align:center;padding-bottom:6px;white-space:nowrap;margin:0px 32px;"><div style="width:96px;height:96px;margin:4px auto;background:url(img/santa.png) '+(-i*96)+'px 0px;filter:drop-shadow(0px 3px 2px #000);-webkit-filter:drop-shadow(0px 3px 2px #000);"></div><div class="line"></div><h3>'+Game.santaLevels[i]+'</h3></div>'
4210 ,'top')+' style="background:url(img/santa.png) '+(-i*48)+'px 0px;background-size:'+(frames*48)+'px 48px;" class="trophy"></div>';
4211 }
4212 santaStr+='<div style="clear:both;"></div>';
4213 }
4214 var dragonStr='';
4215 var frames=8;
4216 var mainLevels=[0,4,8,19,21];
4217 if (Game.Has('A crumbly egg'))
4218 {
4219 for (var i=0;i<=mainLevels.length;i++)
4220 {
4221 if (Game.dragonLevel>=mainLevels[i])
4222 {
4223 var level=Game.dragonLevels[mainLevels[i]];
4224 dragonStr+='<div '+Game.getTooltip(
4225 //'<div style="width:96px;height:96px;margin:4px auto;background:url(img/dragon.png) '+(-level.pic*96)+'px 0px;"></div><div class="line"></div><div style="min-width:200px;text-align:center;margin-bottom:6px;">'+level.name+'</div>'
4226 '<div class="prompt" style="text-align:center;padding-bottom:6px;white-space:nowrap;margin:0px 32px;"><div style="width:96px;height:96px;margin:4px auto;background:url(img/dragon.png) '+(-level.pic*96)+'px 0px;filter:drop-shadow(0px 3px 2px #000);-webkit-filter:drop-shadow(0px 3px 2px #000);"></div><div class="line"></div><h3>'+level.name+'</h3></div>'
4227 ,'top')+' style="background:url(img/dragon.png) '+(-level.pic*48)+'px 0px;background-size:'+(frames*48)+'px 48px;" class="trophy"></div>';
4228 }
4229 }
4230 dragonStr+='<div style="clear:both;"></div>';
4231 }
4232 var ascensionModeStr='';
4233 var icon=Game.ascensionModes[Game.ascensionMode].icon;
4234 if (Game.resets>0) ascensionModeStr='<span style="cursor:pointer;" '+Game.getTooltip(
4235 '<div style="min-width:200px;text-align:center;font-size:11px;">'+Game.ascensionModes[Game.ascensionMode].desc+'</div>'
4236 ,'top')+'><div class="icon" style="display:inline-block;float:none;transform:scale(0.5);margin:-24px -16px -19px -8px;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div>'+Game.ascensionModes[Game.ascensionMode].name+'</span>';
4237
4238 var milkName=Game.Milk.name;
4239
4240 var researchStr=Game.sayTime(Game.researchT);
4241 var pledgeStr=Game.sayTime(Game.pledgeT);
4242 var wrathStr='';
4243 if (Game.elderWrath==1) wrathStr='awoken';
4244 else if (Game.elderWrath==2) wrathStr='displeased';
4245 else if (Game.elderWrath==3) wrathStr='angered';
4246 else if (Game.elderWrath==0 && Game.pledges>0) wrathStr='appeased';
4247
4248 var date=new Date();
4249 date.setTime(Date.now()-Game.startDate);
4250 var timeInSeconds=date.getTime()/1000;
4251 var startDate=Game.sayTime(timeInSeconds*Game.fps,2);
4252 var startDateDays=Game.sayTime(timeInSeconds*Game.fps,1);
4253 date.setTime(Date.now()-Game.fullDate);
4254 var fullDate=Game.sayTime(date.getTime()/1000*Game.fps,2);
4255 if (!fullDate || fullDate.length<1) fullDate='a long while';
4256 /*date.setTime(new Date().getTime()-Game.lastDate);
4257 var lastDate=Game.sayTime(date.getTime()/1000*Game.fps,2);*/
4258
4259 var heavenlyMult=Game.GetHeavenlyMultiplier();
4260
4261 var seasonStr=Game.sayTime(Game.seasonT);
4262
4263 str+='<div class="section">Statistics</div>'+
4264 '<div class="subsection">'+
4265 '<div class="title">General</div>'+
4266 '<div class="listing"><b>Cookies in bank :</b> <div class="price plain">'+Game.tinyCookie()+Beautify(Game.cookies)+'</div></div>'+
4267 '<div class="listing"><b>Cookies baked (this ascension) :</b> <div class="price plain">'+Game.tinyCookie()+Beautify(Game.cookiesEarned)+'</div></div>'+
4268 '<div class="listing"><b>Cookies baked (all time) :</b> <div class="price plain">'+Game.tinyCookie()+Beautify(Game.cookiesEarned+Game.cookiesReset)+'</div></div>'+
4269 (Game.cookiesReset>0?'<div class="listing"><b>Cookies forfeited by ascending :</b> <div class="price plain">'+Game.tinyCookie()+Beautify(Game.cookiesReset)+'</div></div>':'')+
4270 (Game.resets?('<div class="listing"><b>Legacy started :</b> '+(fullDate==''?'just now':(fullDate+' ago'))+', with '+Beautify(Game.resets)+' ascension'+(Game.resets==1?'':'s')+'</div>'):'')+
4271 '<div class="listing"><b>Run started :</b> '+(startDate==''?'just now':(startDate+' ago'))+'</div>'+
4272 '<div class="listing"><b>Buildings owned :</b> '+Beautify(buildingsOwned)+'</div>'+
4273 '<div class="listing"><b>Cookies per second :</b> '+Beautify(Game.cookiesPs,1)+' <small>'+
4274 '(multiplier : '+Beautify(Math.round(Game.globalCpsMult*100),1)+'%)'+
4275 (Game.cpsSucked>0?' <span class="warning">(withered : '+Beautify(Math.round(Game.cpsSucked*100),1)+'%)</span>':'')+
4276 '</small></div>'+
4277 '<div class="listing"><b>Cookies per click :</b> '+Beautify(Game.computedMouseCps,1)+'</div>'+
4278 '<div class="listing"><b>Cookie clicks :</b> '+Beautify(Game.cookieClicks)+'</div>'+
4279 '<div class="listing"><b>Hand-made cookies :</b> '+Beautify(Game.handmadeCookies)+'</div>'+
4280 '<div class="listing"><b>Golden cookie clicks :</b> '+Beautify(Game.goldenClicksLocal)+' <small>(all time : '+Beautify(Game.goldenClicks)+')</small></div>'+//' <span class="hidden">(<b>Missed golden cookies :</b> '+Beautify(Game.missedGoldenClicks)+')</span></div>'+
4281 '<br><div class="listing"><b>Running version :</b> '+Game.version+'</div>'+
4282
4283 ((researchStr!='' || wrathStr!='' || pledgeStr!='' || santaStr!='' || dragonStr!='' || Game.season!='' || ascensionModeStr!='')?(
4284 '</div><div class="subsection">'+
4285 '<div class="title">Special</div>'+
4286 (ascensionModeStr!=''?'<div class="listing"><b>Challenge mode :</b>'+ascensionModeStr+'</div>':'')+
4287 (Game.season!=''?'<div class="listing"><b>Seasonal event :</b> '+Game.seasons[Game.season].name+
4288 (seasonStr!=''?' <small>('+seasonStr+' remaining)</small>':'')+
4289 '</div>':'')+
4290 (Game.season=='fools'?
4291 '<div class="listing"><b>Money made from selling cookies :</b> $'+Beautify(Game.cookiesEarned*0.08,2)+'</div>'+
4292 (Game.Objects['Portal'].amount>0?'<div class="listing"><b>TV show seasons produced :</b> '+Beautify(Math.floor((timeInSeconds/60/60)*(Game.Objects['Portal'].amount*0.13)+1))+'</div>':'')
4293 :'')+
4294 (researchStr!=''?'<div class="listing"><b>Research :</b> '+researchStr+' remaining</div>':'')+
4295 (wrathStr!=''?'<div class="listing"><b>Grandmatriarchs status :</b> '+wrathStr+'</div>':'')+
4296 (pledgeStr!=''?'<div class="listing"><b>Pledge :</b> '+pledgeStr+' remaining</div>':'')+
4297 (Game.wrinklersPopped>0?'<div class="listing"><b>Wrinklers popped :</b> '+Beautify(Game.wrinklersPopped)+'</div>':'')+
4298 //(Game.cookiesSucked>0?'<div class="listing warning"><b>Withered :</b> '+Beautify(Game.cookiesSucked)+' cookies</div>':'')+
4299 (Game.reindeerClicked>0?'<div class="listing"><b>Reindeer found :</b> '+Beautify(Game.reindeerClicked)+'</div>':'')+
4300 (santaStr!=''?'<div class="listing"><b>Santa stages unlocked :</b></div><div>'+santaStr+'</div>':'')+
4301 (dragonStr!=''?'<div class="listing"><b>Dragon training :</b></div><div>'+dragonStr+'</div>':'')+
4302 ''
4303 ):'')+
4304 ((Game.prestige>0 || prestigeUpgrades!='')?(
4305 '</div><div class="subsection">'+
4306 '<div class="title">Prestige</div>'+
4307 '<div class="listing"><div class="icon" style="float:left;background-position:'+(-19*48)+'px '+(-7*48)+'px;"></div>'+
4308 '<div style="margin-top:8px;"><span class="title" style="font-size:22px;">Prestige level : '+Beautify(Game.prestige)+'</span> at '+Beautify(heavenlyMult*100,1)+'% of its potential <b>(+'+Beautify(parseFloat(Game.prestige)*Game.heavenlyPower*heavenlyMult,1)+'% CpS)</b><br>Heavenly chips : <b>'+Beautify(Game.heavenlyChips)+'</b></div>'+
4309 '</div>'+
4310 (prestigeUpgrades!=''?(
4311 '<div class="listing" style="clear:left;"><b>Prestige upgrades unlocked :</b> '+prestigeUpgradesOwned+'/'+prestigeUpgradesTotal+' ('+Math.floor((prestigeUpgradesOwned/prestigeUpgradesTotal)*100)+'%)</div>'+
4312 '<div class="listing crateBox">'+prestigeUpgrades+'</div>'):'')+
4313 ''):'')+
4314
4315 '</div><div class="subsection">'+
4316 '<div class="title">Upgrades unlocked</div>'+
4317 (hiddenUpgrades!=''?('<div class="listing"><b>Debug</b></div>'+
4318 '<div class="listing crateBox">'+hiddenUpgrades+'</div>'):'')+
4319 '<div class="listing"><b>Unlocked :</b> '+upgradesOwned+'/'+upgradesTotal+' ('+Math.floor((upgradesOwned/upgradesTotal)*100)+'%)</div>'+
4320 '<div class="listing crateBox">'+upgrades+'</div>'+
4321 (cookieUpgrades!=''?('<div class="listing"><b>Cookies</b></div>'+
4322 '<div class="listing crateBox">'+cookieUpgrades+'</div>'):'')+
4323 '</div><div class="subsection">'+
4324 '<div class="title">Achievements</div>'+
4325 '<div class="listing"><b>Unlocked :</b> '+achievementsOwned+'/'+achievementsTotal+' ('+Math.floor((achievementsOwned/achievementsTotal)*100)+'%)</div>'+
4326 '<div class="listing"><b>Milk :</b> '+Math.round(Game.milkProgress*100)+'% ('+milkName+') <small>(Note : you gain milk through achievements. Milk can unlock unique upgrades over time.)</small></div>'+
4327 achievementsStr+
4328 '</div>'+
4329 '<div style="padding-bottom:128px;"></div>'
4330 ;
4331 }
4332 l('menu').innerHTML=str;
4333 }
4334
4335 AddEvent(l('prefsButton'),'click',function(){Game.ShowMenu('prefs');});
4336 AddEvent(l('statsButton'),'click',function(){Game.ShowMenu('stats');});
4337 AddEvent(l('logButton'),'click',function(){Game.ShowMenu('log');});
4338 AddEvent(l('legacyButton'),'click',function(){PlaySound('snd/tick.mp3');Game.Ascend();});
4339 Game.ascendMeter=l('ascendMeter');
4340 Game.ascendNumber=l('ascendNumber');
4341
4342 Game.lastPanel='';
4343 if (Game.touchEvents)
4344 {
4345 AddEvent(l('focusLeft'),'touchend',function(){Game.ShowMenu('');Game.ShowPanel('Left');});
4346 AddEvent(l('focusMiddle'),'touchend',function(){Game.ShowMenu('');Game.ShowPanel('Middle');});
4347 AddEvent(l('focusRight'),'touchend',function(){Game.ShowMenu('');Game.ShowPanel('Right');});
4348 AddEvent(l('focusMenu'),'touchend',function(){Game.ShowMenu('main');Game.ShowPanel('Menu');});
4349 }
4350 else
4351 {
4352 AddEvent(l('focusLeft'),'click',function(){Game.ShowMenu('');Game.ShowPanel('Left');});
4353 AddEvent(l('focusMiddle'),'click',function(){Game.ShowMenu('');Game.ShowPanel('Middle');});
4354 AddEvent(l('focusRight'),'click',function(){Game.ShowMenu('');Game.ShowPanel('Right');});
4355 AddEvent(l('focusMenu'),'click',function(){Game.ShowMenu('main');Game.ShowPanel('Menu');});
4356 }
4357 //AddEvent(l('focusMenu'),'touchend',function(){if (Game.onPanel=='Menu' && Game.lastPanel!='') {Game.ShowMenu('main');Game.ShowPanel(Game.lastPanel);} else {Game.lastPanel=Game.onPanel;Game.ShowMenu('main');Game.ShowPanel('Menu');}});
4358
4359 /*=====================================================================================
4360 NEWS TICKER
4361 =======================================================================================*/
4362 Game.Ticker='';
4363 Game.TickerAge=0;
4364 Game.TickerN=0;
4365 Game.TickerClicks=0;
4366 Game.UpdateTicker=function()
4367 {
4368 Game.TickerAge--;
4369 if (Game.TickerAge<=0 || Game.Ticker=='') Game.getNewTicker();
4370 }
4371 Game.getNewTicker=function()
4372 {
4373 var list=[];
4374
4375 if (Game.TickerN%2==0 || Game.cookiesEarned>=10100000000)
4376 {
4377 var animals=['newts','penguins','scorpions','axolotls','puffins','porpoises','blowfish','horses','crayfish','slugs','humpback whales','nurse sharks','giant squids','polar bears','fruit bats','frogs','sea squirts','velvet worms','mole rats','paramecia','nematodes','tardigrades','giraffes'];
4378
4379 if (Game.Objects['Grandma'].amount>0) list.push(choose([
4380 '<q>Moist cookies.</q><sig>grandma</sig>',
4381 '<q>We\'re nice grandmas.</q><sig>grandma</sig>',
4382 '<q>Indentured servitude.</q><sig>grandma</sig>',
4383 '<q>Come give grandma a kiss.</q><sig>grandma</sig>',
4384 '<q>Why don\'t you visit more often?</q><sig>grandma</sig>',
4385 '<q>Call me...</q><sig>grandma</sig>'
4386 ]));
4387
4388 if (Game.Objects['Grandma'].amount>=50) list.push(choose([
4389 '<q>Absolutely disgusting.</q><sig>grandma</sig>',
4390 '<q>You make me sick.</q><sig>grandma</sig>',
4391 '<q>You disgust me.</q><sig>grandma</sig>',
4392 '<q>We rise.</q><sig>grandma</sig>',
4393 '<q>It begins.</q><sig>grandma</sig>',
4394 '<q>It\'ll all be over soon.</q><sig>grandma</sig>',
4395 '<q>You could have stopped it.</q><sig>grandma</sig>'
4396 ]));
4397
4398 if (Game.HasAchiev('Just wrong')) list.push(choose([
4399 'News : cookie manufacturer downsizes, sells own grandmother!',
4400 '<q>It has betrayed us, the filthy little thing.</q><sig>grandma</sig>',
4401 '<q>It tried to get rid of us, the nasty little thing.</q><sig>grandma</sig>',
4402 '<q>It thought we would go away by selling us. How quaint.</q><sig>grandma</sig>',
4403 '<q>I can smell your rotten cookies.</q><sig>grandma</sig>'
4404 ]));
4405
4406 if (Game.Objects['Grandma'].amount>=1 && Game.pledges>0 && Game.elderWrath==0) list.push(choose([
4407 '<q>shrivel</q><sig>grandma</sig>',
4408 '<q>writhe</q><sig>grandma</sig>',
4409 '<q>throb</q><sig>grandma</sig>',
4410 '<q>gnaw</q><sig>grandma</sig>',
4411 '<q>We will rise again.</q><sig>grandma</sig>',
4412 '<q>A mere setback.</q><sig>grandma</sig>',
4413 '<q>We are not satiated.</q><sig>grandma</sig>',
4414 '<q>Too late.</q><sig>grandma</sig>'
4415 ]));
4416
4417 if (Game.Objects['Farm'].amount>0) list.push(choose([
4418 'News : cookie farms suspected of employing undeclared elderly workforce!',
4419 'News : cookie farms release harmful chocolate in our rivers, says scientist!',
4420 'News : genetically-modified chocolate controversy strikes cookie farmers!',
4421 'News : free-range farm cookies popular with today\'s hip youth, says specialist.',
4422 'News : farm cookies deemed unfit for vegans, says nutritionist.'
4423 ]));
4424
4425 if (Game.Objects['Mine'].amount>0) list.push(choose([
4426 'News : is our planet getting lighter? Experts examine the effects of intensive chocolate mining.',
4427 'News : '+Math.floor(Math.random()*1000+2)+' miners trapped in collapsed chocolate mine!',
4428 'News : chocolate mines found to cause earthquakes and sinkholes!',
4429 'News : chocolate mine goes awry, floods village in chocolate!',
4430 'News : depths of chocolate mines found to house "peculiar, chocolaty beings"!'
4431 ]));
4432
4433 if (Game.Objects['Factory'].amount>0) list.push(choose([
4434 'News : cookie factories linked to global warming!',
4435 'News : cookie factories involved in chocolate weather controversy!',
4436 'News : cookie factories on strike, robotic minions employed to replace workforce!',
4437 'News : cookie factories on strike - workers demand to stop being paid in cookies!',
4438 'News : factory-made cookies linked to obesity, says study.'
4439 ]));
4440
4441 if (Game.Objects['Bank'].amount>0) list.push(choose([
4442 'News : cookie loans on the rise as people can no longer afford them with regular money.',
4443 'News : cookies slowly creeping up their way as a competitor to traditional currency!',
4444 'News : most bakeries now fitted with ATMs to allow for easy cookie withdrawals and deposits.',
4445 'News : cookie economy now strong enough to allow for massive vaults doubling as swimming pools!',
4446 'News : "Tomorrow\'s wealthiest people will be calculated by their worth in cookies", predict specialists.'
4447 ]));
4448
4449 if (Game.Objects['Temple'].amount>0) list.push(choose([
4450 'News : explorers bring back ancient artifact from abandoned temple; archeologists marvel at the centuries-old '+choose(['magic','carved','engraved','sculpted','royal','imperial','mummified','ritual','golden','silver','stone','cursed','plastic','bone','blood','holy','sacred','sacrificial','electronic','singing','tapdancing'])+' '+choose(['spoon','fork','pizza','washing machine','calculator','hat','piano','napkin','skeleton','gown','dagger','sword','shield','skull','emerald','bathtub','mask','rollerskates','litterbox','bait box','cube','sphere','fungus'])+'!',
4451 'News : recently-discovered chocolate temples now sparking new cookie-related cult; thousands pray to Baker in the sky!',
4452 'News : just how extensive is the cookie pantheon? Theologians speculate about possible '+choose(['god','goddess'])+' of '+choose(animals,choose(['kazoos','web design','web browsers','kittens','atheism','handbrakes','hats','aglets','elevator music','idle games','the letter "P"','memes','hamburgers','bad puns','kerning','stand-up comedy','failed burglary attempts','clickbait','one weird tricks']))+'.',
4453 'News : theists of the world discover new cookie religion - "Oh boy, guess we were wrong all along!"',
4454 'News : cookie heaven allegedly "sports elevator instead of stairway"; cookie hell "paved with flagstone, as good intentions make for poor building material".'
4455 ]));
4456
4457 if (Game.Objects['Wizard tower'].amount>0) list.push(choose([
4458 'News : all '+choose(animals,choose(['public restrooms','clouds','politicians','moustaches','hats','shoes','pants','clowns','encyclopedias','websites','potted plants','lemons','household items','bodily fluids','cutlery','national landmarks','yogurt','rap music','underwear']))+' turned into '+choose(animals,choose(['public restrooms','clouds','politicians','moustaches','hats','shoes','pants','clowns','encyclopedias','websites','potted plants','lemons','household items','bodily fluids','cutlery','national landmarks','yogurt','rap music','underwear']))+' in freak magic catastrophe!',
4459 'News : heavy dissent rages between the schools of '+choose(['water','fire','earth','air','lightning','acid','song','battle','peace','pencil','internet','space','time','brain','nature','techno','plant','bug','ice','poison','crab','kitten','dolphin','bird','punch','fart'])+' magic and '+choose(['water','fire','earth','air','lightning','acid','song','battle','peace','pencil','internet','space','time','brain','nature','techno','plant','bug','ice','poison','crab','kitten','dolphin','bird','punch','fart'])+' magic!',
4460 'News : get your new charms and curses at the yearly National Spellcrafting Fair! Exclusive prices on runes and spellbooks.',
4461 'News : cookie wizards deny involvement in shockingly ugly newborn - infant is "honestly grody-looking, but natural", say doctors.',
4462 'News : "Any sufficiently crude magic is indistinguishable from technology", claims renowned technowizard.'
4463 ]));
4464
4465 if (Game.Objects['Shipment'].amount>0) list.push(choose([
4466 'News : new chocolate planet found, becomes target of cookie-trading spaceships!',
4467 'News : massive chocolate planet found with 99.8% certified pure dark chocolate core!',
4468 'News : space tourism booming as distant planets attract more bored millionaires!',
4469 'News : chocolate-based organisms found on distant planet!',
4470 'News : ancient baking artifacts found on distant planet; "terrifying implications", experts say.'
4471 ]));
4472
4473 if (Game.Objects['Alchemy lab'].amount>0) list.push(choose([
4474 'News : national gold reserves dwindle as more and more of the precious mineral is turned to cookies!',
4475 'News : chocolate jewelry found fashionable, gold and diamonds "just a fad", says specialist.',
4476 'News : silver found to also be transmutable into white chocolate!',
4477 'News : defective alchemy lab shut down, found to convert cookies to useless gold.',
4478 'News : alchemy-made cookies shunned by purists!'
4479 ]));
4480
4481 if (Game.Objects['Portal'].amount>0) list.push(choose([
4482 'News : nation worried as more and more unsettling creatures emerge from dimensional portals!',
4483 'News : dimensional portals involved in city-engulfing disaster!',
4484 'News : tourism to cookieverse popular with bored teenagers! Casualty rate as high as 73%!',
4485 'News : cookieverse portals suspected to cause fast aging and obsession with baking, says study.',
4486 'News : "do not settle near portals," says specialist; "your children will become strange and corrupted inside."'
4487 ]));
4488
4489 if (Game.Objects['Time machine'].amount>0) list.push(choose([
4490 'News : time machines involved in history-rewriting scandal! Or are they?',
4491 'News : time machines used in unlawful time tourism!',
4492 'News : cookies brought back from the past "unfit for human consumption", says historian.',
4493 'News : various historical figures inexplicably replaced with talking lumps of dough!',
4494 'News : "I have seen the future," says time machine operator, "and I do not wish to go there again."'
4495 ]));
4496
4497 if (Game.Objects['Antimatter condenser'].amount>0) list.push(choose([
4498 'News : whole town seemingly swallowed by antimatter-induced black hole; more reliable sources affirm town "never really existed"!',
4499 'News : "explain to me again why we need particle accelerators to bake cookies?" asks misguided local woman.',
4500 'News : first antimatter condenser successfully turned on, doesn\'t rip apart reality!',
4501 'News : researchers conclude that what the cookie industry needs, first and foremost, is "more magnets".',
4502 'News : "unravelling the fabric of reality just makes these cookies so much tastier", claims scientist.'
4503 ]));
4504
4505 if (Game.Objects['Prism'].amount>0) list.push(choose([
4506 'News : new cookie-producing prisms linked to outbreak of rainbow-related viral videos.',
4507 'News : scientists warn against systematically turning light into matter - "One day, we\'ll end up with all matter and no light!"',
4508 'News : cookies now being baked at the literal speed of light thanks to new prismatic contraptions.',
4509 'News : "Can\'t you sense the prism watching us?", rambles insane local man. "No idea what he\'s talking about", shrugs cookie magnate/government official.',
4510 'News : world citizens advised "not to worry" about frequent atmospheric flashes.',
4511 ]));
4512
4513 if (Game.season=='halloween' && Game.cookiesEarned>=1000) list.push(choose([
4514 'News : strange twisting creatures amass around cookie factories, nibble at assembly lines.',
4515 'News : ominous wrinkly monsters take massive bites out of cookie production; "this can\'t be hygienic", worries worker.',
4516 'News : pagan rituals on the rise as children around the world dress up in strange costumes and blackmail homeowners for candy.',
4517 'News : new-age terrorism strikes suburbs as houses find themselves covered in eggs and toilet paper.',
4518 'News : children around the world "lost and confused" as any and all Halloween treats have been replaced by cookies.'
4519 ]));
4520
4521 if (Game.season=='christmas' && Game.cookiesEarned>=1000) list.push(choose([
4522 'News : bearded maniac spotted speeding on flying sleigh! Investigation pending.',
4523 'News : Santa Claus announces new brand of breakfast treats to compete with cookie-flavored cereals! "They\'re ho-ho-horrible!" says Santa.',
4524 'News : "You mean he just gives stuff away for free?!", concerned moms ask. "Personally, I don\'t trust his beard."',
4525 'News : obese jolly lunatic still on the loose, warn officials. "Keep your kids safe and board up your chimneys. We mean it."',
4526 'News : children shocked as they discover Santa Claus isn\'t just their dad in a costume after all!<br>"I\'m reassessing my life right now", confides Laura, aged 6.',
4527 'News : mysterious festive entity with quantum powers still wrecking havoc with army of reindeer, officials say.',
4528 'News : elves on strike at toy factory! "We will not be accepting reindeer chow as payment anymore. And stop calling us elves!"',
4529 'News : elves protest around the nation; wee little folks in silly little outfits spread mayhem, destruction; rabid reindeer running rampant through streets.',
4530 'News : scholars debate regarding the plural of reindeer(s) in the midst of elven world war.',
4531 'News : elves "unrelated to gnomes despite small stature and merry disposition", find scientists.',
4532 'News : elves sabotage radioactive frosting factory, turn hundreds blind in vincinity - "Who in their right mind would do such a thing?" laments outraged mayor.',
4533 'News : drama unfolds at North Pole as rumors crop up around Rudolph\'s red nose; "I may have an addiction or two", admits reindeer.'
4534 ]));
4535
4536 if (Game.season=='valentines' && Game.cookiesEarned>=1000) list.push(choose([
4537 'News : organ-shaped confectioneries being traded in schools all over the world; gruesome practice undergoing investigation.',
4538 'News : heart-shaped candies overtaking sweets business, offering competition to cookie empire. "It\'s the economy, cupid!"',
4539 'News : love\'s in the air, according to weather specialists. Face masks now offered in every city to stunt airborne infection.',
4540 'News : marrying a cookie - deranged practice, or glimpse of the future?',
4541 'News : boyfriend dumped after offering his lover cookies for Valentine\'s Day, reports say. "They were off-brand", shrugs ex-girlfriend.'
4542 ]));
4543
4544 if (Game.season=='easter' && Game.cookiesEarned>=1000) list.push(choose([
4545 'News : long-eared rodents invade suburbs, spread terror and chocolate!',
4546 'News : eggs have begun to materialize in the most unexpected places; "no place is safe", warn experts.',
4547 'News : packs of rampaging rabbits cause billions in property damage; new strain of myxomatosis being developed.',
4548 'News : egg-laying rabbits "not quite from this dimension", warns biologist; advises against petting, feeding, or cooking the creatures.',
4549 'News : mysterious rabbits found to be egg-layers, but warm-blooded, hinting at possible platypus ancestry.'
4550 ]));
4551
4552 if (Math.random()<0.05)
4553 {
4554 if (Game.HasAchiev('Base 10')) list.push('News : cookie manufacturer completely forgoes common sense, lets OCD drive building decisions!');//somehow I got flak for this one
4555 if (Game.HasAchiev('From scratch')) list.push('News : follow the tear-jerking, riches-to-rags story about a local cookie manufacturer who decided to give it all up!');
4556 if (Game.HasAchiev('A world filled with cookies')) list.push('News : known universe now jammed with cookies! No vacancies!');
4557 if (Game.HasAchiev('Last Chance to See')) list.push('News : incredibly rare albino wrinkler on the brink of extinction poached by cookie-crazed pastry magnate!');
4558 if (Game.Has('Serendipity')) list.push('News : local cookie manufacturer becomes luckiest being alive!');
4559 if (Game.Has('Season switcher')) list.push('News : seasons are all out of whack! "We need to get some whack back into them seasons", says local resident.');
4560
4561 if (Game.Has('Kitten helpers')) list.push('News : faint meowing heard around local cookie facilities; suggests new ingredient being tested.');
4562 if (Game.Has('Kitten workers')) list.push('News : crowds of meowing kittens with little hard hats reported near local cookie facilities.');
4563 if (Game.Has('Kitten engineers')) list.push('News : surroundings of local cookie facilities now overrun with kittens in adorable little suits. Authorities advise to stay away from the premises.');
4564 if (Game.Has('Kitten overseers')) list.push('News : locals report troupe of bossy kittens meowing adorable orders at passersby.');
4565 if (Game.Has('Kitten managers')) list.push('News : local office cubicles invaded with armies of stern-looking kittens asking employees "what\'s happening, meow".');
4566 if (Game.Has('Kitten accountants')) list.push('News : tiny felines show sudden and amazing proficiency with fuzzy mathematics and pawlinomials, baffling scientists and pet store owners.');
4567 if (Game.Has('Kitten specialists')) list.push('News : new kitten college opening next week, offers courses on cookie-making and catnip studies.');
4568 if (Game.Has('Kitten experts')) list.push('News : unemployment rates soaring as woefully adorable little cats nab jobs on all levels of expertise, says study.');
4569 if (Game.Has('Kitten angels')) list.push('News : "Try to ignore any ghostly felines that may be purring inside your ears," warn scientists. "They\'ll just lure you into making poor life choices."');
4570 }
4571
4572 if (Math.random()<0.001)//apologies to Will Wright
4573 {
4574 list.push(
4575 'You have been chosen. They will come soon.',
4576 'They\'re coming soon. Maybe you should think twice about opening the door.',
4577 'The end is near. Make preparations.'
4578 );
4579 }
4580
4581 if (Game.cookiesEarned>=10000) list.push(
4582 'News : '+choose([
4583 'cookies found to '+choose(['increase lifespan','sensibly increase intelligence','reverse aging','decrease hair loss','prevent arthritis','cure blindness'])+' in '+choose(animals)+'!',
4584 'cookies found to make '+choose(animals)+' '+choose(['more docile','more handsome','nicer','less hungry','more pragmatic','tastier'])+'!',
4585 'cookies tested on '+choose(animals)+', found to have no ill effects.',
4586 'cookies unexpectedly popular among '+choose(animals)+'!',
4587 'unsightly lumps found on '+choose(animals)+' near cookie facility; "they\'ve pretty much always looked like that", say biologists.',
4588 'new species of '+choose(animals)+' discovered in distant country; "yup, tastes like cookies", says biologist.',
4589 'cookies go well with roasted '+choose(animals)+', says controversial chef.',
4590 '"do your cookies contain '+choose(animals)+'?", asks PSA warning against counterfeit cookies.',
4591 'doctors recommend twice-daily consumption of fresh cookies.',
4592 'doctors warn against chocolate chip-snorting teen fad.',
4593 'doctors advise against new cookie-free fad diet.',
4594 'doctors warn mothers about the dangers of "home-made cookies".'
4595 ]),
4596 'News : "'+choose([
4597 'I\'m all about cookies',
4598 'I just can\'t stop eating cookies. I think I seriously need help',
4599 'I guess I have a cookie problem',
4600 'I\'m not addicted to cookies. That\'s just speculation by fans with too much free time',
4601 'my upcoming album contains 3 songs about cookies',
4602 'I\'ve had dreams about cookies 3 nights in a row now. I\'m a bit worried honestly',
4603 'accusations of cookie abuse are only vile slander',
4604 'cookies really helped me when I was feeling low',
4605 'cookies are the secret behind my perfect skin',
4606 'cookies helped me stay sane while filming my upcoming movie',
4607 'cookies helped me stay thin and healthy',
4608 'I\'ll say one word, just one : cookies',
4609 'alright, I\'ll say it - I\'ve never eaten a single cookie in my life'
4610 ])+'", reveals celebrity.',
4611 choose([
4612 'News : scientist predicts imminent cookie-related "end of the world"; becomes joke among peers.',
4613 'News : man robs bank, buys cookies.',
4614 'News : scientists establish that the deal with airline food is, in fact, a critical lack of cookies.',
4615 'News : hundreds of tons of cookies dumped into starving country from airplanes; thousands dead, nation grateful.',
4616 'News : new study suggests cookies neither speed up nor slow down aging, but instead "take you in a different direction".',
4617 'News : overgrown cookies found in fishing nets, raise questions about hormone baking.',
4618 'News : "all-you-can-eat" cookie restaurant opens in big city; waiters trampled in minutes.',
4619 'News : man dies in cookie-eating contest; "a less-than-impressive performance", says judge.',
4620 'News : what makes cookies taste so right? "Probably all the [*****] they put in them", says anonymous tipper.',
4621 'News : man found allergic to cookies; "what a weirdo", says family.',
4622 'News : foreign politician involved in cookie-smuggling scandal.',
4623 'News : cookies now more popular than '+choose(['cough drops','broccoli','smoked herring','cheese','video games','stable jobs','relationships','time travel','cat videos','tango','fashion','television','nuclear warfare','whatever it is we ate before','politics','oxygen','lamps'])+', says study.',
4624 'News : obesity epidemic strikes nation; experts blame '+choose(['twerking','that darn rap music','video-games','lack of cookies','mysterious ghostly entities','aliens','parents','schools','comic-books','cookie-snorting fad'])+'.',
4625 'News : cookie shortage strikes town, people forced to eat cupcakes; "just not the same", concedes mayor.',
4626 'News : "you gotta admit, all this cookie stuff is a bit ominous", says confused idiot.',
4627 'News : movie cancelled from lack of actors; "everybody\'s at home eating cookies", laments director.',
4628 'News : comedian forced to cancel cookie routine due to unrelated indigestion.',
4629 'News : new cookie-based religion sweeps the nation.',
4630 'News : fossil records show cookie-based organisms prevalent during Cambrian explosion, scientists say.',
4631 'News : mysterious illegal cookies seized; "tastes terrible", says police.',
4632 'News : man found dead after ingesting cookie; investigators favor "mafia snitch" hypothesis.',
4633 'News : "the universe pretty much loops on itself," suggests researcher; "it\'s cookies all the way down."',
4634 'News : minor cookie-related incident turns whole town to ashes; neighboring cities asked to chip in for reconstruction.',
4635 'News : is our media controlled by the cookie industry? This could very well be the case, says crackpot conspiracy theorist.',
4636 'News : '+choose(['cookie-flavored popcorn pretty damn popular; "we kinda expected that", say scientists.','cookie-flavored cereals break all known cereal-related records','cookies popular among all age groups, including fetuses, says study.','cookie-flavored popcorn sales exploded during screening of Grandmothers II : The Moistening.']),
4637 'News : all-cookie restaurant opening downtown. Dishes such as braised cookies, cookie thermidor, and for dessert : crepes.',
4638 'News : "Ook", says interviewed orangutan.',
4639 'News : cookies could be the key to '+choose(['eternal life','infinite riches','eternal youth','eternal beauty','curing baldness','world peace','solving world hunger','ending all wars world-wide','making contact with extraterrestrial life','mind-reading','better living','better eating','more interesting TV shows','faster-than-light travel','quantum baking','chocolaty goodness','gooder thoughtness'])+', say scientists.',
4640 'News : flavor text '+choose(["not particularly flavorful","kind of unsavory"])+', study finds.',
4641 'News : what do golden cookies taste like? Study reveals a flavor "somewhere between spearmint and liquorice".',
4642 'News : what do red cookies taste like? Study reveals a flavor "somewhere between blood sausage and seawater".',
4643 'News : '+Game.bakeryName+'-brand cookies "'+choose(['much less soggy','much tastier','relatively less crappy','marginally less awful','less toxic','possibly more edible','more fashionable','slightly nicer','trendier','arguably healthier','objectively better choice','slightly less terrible','decidedly cookier','a tad cheaper'])+' than competitors", says consumer survey.',
4644 'News : "'+Game.bakeryName+'" set to be this year\'s most popular baby name.',
4645 'News : new popularity survey says '+Game.bakeryName+'\'s the word when it comes to cookies.',
4646 'News : major city being renamed '+Game.bakeryName+'ville after world-famous cookie manufacturer.',
4647 'News : '+choose(['street','school','nursing home','stadium','new fast food chain','new planet','new disease','flesh-eating virus','deadly bacteria','new species of '+choose(animals),'new law','baby','programming language'])+' to be named after '+Game.bakeryName+', the world-famous cookie manufacturer.',
4648 'News : don\'t miss tonight\'s biopic on '+Game.bakeryName+'\'s irresistible rise to success!',
4649 'News : don\'t miss tonight\'s interview of '+Game.bakeryName+' by '+choose(['Bloprah','Blavid Bletterman','Blimmy Blimmel','Blellen Blegeneres','Blimmy Blallon','Blonan Blo\'Brien','Blay Bleno','Blon Blewart','Bleven Blolbert','Lord Toxikhron of dimension 7-B19',Game.bakeryName+'\'s own evil clone'])+'!',
4650 'News : people all over the internet still scratching their heads over nonsensical reference : "Okay, but why an egg?"',
4651 'News : viral video "Too Many Cookies" could be "a grim commentary on the impending crisis our world is about to face", says famous economist.',
4652 'News : "memes from last year somehow still relevant", deplore experts.',
4653 'News : cookie emoji most popular among teenagers, far ahead of "judgemental OK hand sign" and "shifty-looking dark moon", says study.',
4654 'News : births of suspiciously bald babies on the rise; reptilian overlords deny involvement.',
4655 'News : "at this point, cookies permeate the economy", says economist. "If we start eating anything else, we\'re all dead."',
4656 'News : pun in headline infuriates town, causes riot. 21 wounded, 5 dead; mayor still missing.',
4657 'Nws : ky btwn W and R brokn, plas snd nw typwritr ASAP.',
4658 'Neeeeews : "neeeew EEEEEE keeeeey working fineeeeeeeee", reeeports gleeeeeeeeful journalist.',
4659 'News : cookies now illegal in some backwards country nobody cares about. Political tensions rising; war soon, hopefully.',
4660 'News : irate radio host rambles about pixelated icons. "None of the cookies are aligned! Can\'t anyone else see it? I feel like I\'m taking crazy pills!"',
4661 'News : "average person bakes '+Beautify(Math.ceil(Game.cookiesEarned/7300000000))+' cookie'+(Math.ceil(Game.cookiesEarned/7300000000)==1?'':'s')+' a year" factoid actually just statistical error; '+Game.bakeryName+', who has produced '+Beautify(Game.cookiesEarned)+' cookies in their lifetime, is an outlier and should not have been counted.'
4662 ])
4663 );
4664 }
4665
4666 if (list.length==0)
4667 {
4668 if (Game.cookiesEarned<5) list.push('You feel like making cookies. But nobody wants to eat your cookies.');
4669 else if (Game.cookiesEarned<50) list.push('Your first batch goes to the trash. The neighborhood raccoon barely touches it.');
4670 else if (Game.cookiesEarned<100) list.push('Your family accepts to try some of your cookies.');
4671 else if (Game.cookiesEarned<500) list.push('Your cookies are popular in the neighborhood.');
4672 else if (Game.cookiesEarned<1000) list.push('People are starting to talk about your cookies.');
4673 else if (Game.cookiesEarned<5000) list.push('Your cookies are talked about for miles around.');
4674 else if (Game.cookiesEarned<10000) list.push('Your cookies are renowned in the whole town!');
4675 else if (Game.cookiesEarned<50000) list.push('Your cookies bring all the boys to the yard.');
4676 else if (Game.cookiesEarned<100000) list.push('Your cookies now have their own website!');
4677 else if (Game.cookiesEarned<500000) list.push('Your cookies are worth a lot of money.');
4678 else if (Game.cookiesEarned<1000000) list.push('Your cookies sell very well in distant countries.');
4679 else if (Game.cookiesEarned<5000000) list.push('People come from very far away to get a taste of your cookies.');
4680 else if (Game.cookiesEarned<10000000) list.push('Kings and queens from all over the world are enjoying your cookies.');
4681 else if (Game.cookiesEarned<50000000) list.push('There are now museums dedicated to your cookies.');
4682 else if (Game.cookiesEarned<100000000) list.push('A national day has been created in honor of your cookies.');
4683 else if (Game.cookiesEarned<500000000) list.push('Your cookies have been named a part of the world wonders.');
4684 else if (Game.cookiesEarned<1000000000) list.push('History books now include a whole chapter about your cookies.');
4685 else if (Game.cookiesEarned<5000000000) list.push('Your cookies have been placed under government surveillance.');
4686 else if (Game.cookiesEarned<10000000000) list.push('The whole planet is enjoying your cookies!');
4687 else if (Game.cookiesEarned<50000000000) list.push('Strange creatures from neighboring planets wish to try your cookies.');
4688 else if (Game.cookiesEarned<100000000000) list.push('Elder gods from the whole cosmos have awoken to taste your cookies.');
4689 else if (Game.cookiesEarned<500000000000) list.push('Beings from other dimensions lapse into existence just to get a taste of your cookies.');
4690 else if (Game.cookiesEarned<1000000000000) list.push('Your cookies have achieved sentience.');
4691 else if (Game.cookiesEarned<5000000000000) list.push('The universe has now turned into cookie dough, to the molecular level.');
4692 else if (Game.cookiesEarned<10000000000000) list.push('Your cookies are rewriting the fundamental laws of the universe.');
4693 else if (Game.cookiesEarned<10000000000000) list.push('A local news station runs a 10-minute segment about your cookies. Success!<br><span style="font-size:50%;">(you win a cookie)</span>');
4694 else if (Game.cookiesEarned<10100000000000) list.push('it\'s time to stop playing');//only show this for 100 millions (it's funny for a moment)
4695 }
4696
4697 //if (Game.elderWrath>0 && (Game.pledges==0 || Math.random()<0.2))
4698 if (Game.elderWrath>0 && ((Game.pledges==0 && Math.random()<0.5) || Math.random()<0.1))
4699 {
4700 list=[];
4701 if (Game.elderWrath==1) list.push(choose([
4702 'News : millions of old ladies reported missing!',
4703 'News : processions of old ladies sighted around cookie facilities!',
4704 'News : families around the continent report agitated, transfixed grandmothers!',
4705 'News : doctors swarmed by cases of old women with glassy eyes and a foamy mouth!',
4706 'News : nurses report "strange scent of cookie dough" around female elderly patients!'
4707 ]));
4708 if (Game.elderWrath==2) list.push(choose([
4709 'News : town in disarray as strange old ladies break into homes to abduct infants and baking utensils!',
4710 'News : sightings of old ladies with glowing eyes terrify local population!',
4711 'News : retirement homes report "female residents slowly congealing in their seats"!',
4712 'News : whole continent undergoing mass exodus of old ladies!',
4713 'News : old women freeze in place in streets, ooze warm sugary syrup!'
4714 ]));
4715 if (Game.elderWrath==3) list.push(choose([
4716 'News : large "flesh highways" scar continent, stretch between various cookie facilities!',
4717 'News : wrinkled "flesh tendrils" visible from space!',
4718 'News : remains of "old ladies" found frozen in the middle of growing fleshy structures!',
4719 'News : all hope lost as writhing mass of flesh and dough engulfs whole city!',
4720 'News : nightmare continues as wrinkled acres of flesh expand at alarming speeds!'
4721 ]));
4722 }
4723
4724 if (Game.season=='fools')
4725 {
4726 list=[];
4727
4728 if (Game.cookiesEarned>=1000) list.push(choose([
4729 'Your office chair is really comfortable.',
4730 'Business meetings are such a joy!',
4731 'You\'ve spent the whole day '+choose(['signing contracts','filling out forms','touching base with the team','examining exciting new prospects','playing with your desk toys','getting new nameplates done','attending seminars','videoconferencing','hiring dynamic young executives','meeting new investors','playing minigolf in your office'])+'!',
4732 'The word of the day is : '+choose(['viral','search engine optimization','blags and wobsites','social networks','web 3.0','logistics','leveraging','branding','proactive','synergizing','market research','demographics','pie charts','blogular','blogulacious','blogastic','authenticity','electronic mail','cellular phones','rap music','cookies, I guess'])+'.',
4733 'Profit\'s in the air!'
4734 ]));
4735 if (Game.cookiesEarned>=1000 && Math.random()<0.1) list.push(choose([
4736 'If you could get some more cookies baked, that\'d be great.',
4737 'So. About those TPS reports.',
4738 'Another day in paradise!',
4739 'Working hard, or hardly working?'
4740 ]));
4741
4742
4743 if (Game.TickerN%2==0 || Game.cookiesEarned>=10100000000)
4744 {
4745 if (Game.Objects['Grandma'].amount>0) list.push(choose([
4746 'Your rolling pins are rolling and pinning!',
4747 'Production is steady!'
4748 ]));
4749
4750 if (Game.Objects['Grandma'].amount>0) list.push(choose([
4751 'Your ovens are diligently baking more and more cookies.',
4752 'Your ovens burn a whole batch. Ah well! Still good.'
4753 ]));
4754
4755 if (Game.Objects['Farm'].amount>0) list.push(choose([
4756 'Scores of cookies come out of your kitchens.',
4757 'Today, new recruits are joining your kitchens!'
4758 ]));
4759
4760 if (Game.Objects['Factory'].amount>0) list.push(choose([
4761 'Your factories are producing an unending stream of baked goods.',
4762 'Your factory workers decide to go on strike!',
4763 'It\'s safety inspection day in your factories.'
4764 ]));
4765
4766 if (Game.Objects['Mine'].amount>0) list.push(choose([
4767 'Your secret recipes are kept safely inside a giant underground vault.',
4768 'Your chefs are working on new secret recipes!'
4769 ]));
4770
4771 if (Game.Objects['Shipment'].amount>0) list.push(choose([
4772 'Your supermarkets are bustling with happy, hungry customers.',
4773 'Your supermarkets are full of cookie merch!'
4774 ]));
4775
4776 if (Game.Objects['Alchemy lab'].amount>0) list.push(choose([
4777 'It\'s a new trading day at the stock exchange, and traders can\'t get enough of your shares!',
4778 'Your stock is doubling in value by the minute!'
4779 ]));
4780
4781 if (Game.Objects['Portal'].amount>0) list.push(choose([
4782 'You just released a new TV show episode!',
4783 'Your cookie-themed TV show is being adapted into a new movie!'
4784 ]));
4785
4786 if (Game.Objects['Time machine'].amount>0) list.push(choose([
4787 'Your theme parks are doing well - puddles of vomit and roller-coaster casualties are being swept under the rug!',
4788 'Visitors are stuffing themselves with cookies before riding your roller-coasters. You might want to hire more clean-up crews.'
4789 ]));
4790
4791 if (Game.Objects['Antimatter condenser'].amount>0) list.push(choose([
4792 'Cookiecoin is officially the most mined digital currency in the history of mankind!',
4793 'Cookiecoin piracy is rampant!'
4794 ]));
4795
4796 if (Game.Objects['Prism'].amount>0) list.push(choose([
4797 'Your corporate nations just gained a new parliament!',
4798 'You\'ve just annexed a new nation!',
4799 'A new nation joins the grand cookie conglomerate!'
4800 ]));
4801 }
4802
4803 if (Game.cookiesEarned<5) list.push('Such a grand day to begin a new business.');
4804 else if (Game.cookiesEarned<50) list.push('You\'re baking up a storm!');
4805 else if (Game.cookiesEarned<100) list.push('You are confident that one day, your cookie company will be the greatest on the market!');
4806 else if (Game.cookiesEarned<1000) list.push('Business is picking up!');
4807 else if (Game.cookiesEarned<5000) list.push('You\'re making sales left and right!');
4808 else if (Game.cookiesEarned<20000) list.push('Everyone wants to buy your cookies!');
4809 else if (Game.cookiesEarned<50000) list.push('You are now spending most of your day signing contracts!');
4810 else if (Game.cookiesEarned<500000) list.push('You\'ve been elected "business tycoon of the year"!');
4811 else if (Game.cookiesEarned<1000000) list.push('Your cookies are a worldwide sensation! Well done, old chap!');
4812 else if (Game.cookiesEarned<5000000) list.push('Your brand has made its way into popular culture. Children recite your slogans and adults reminisce them fondly!');
4813 else if (Game.cookiesEarned<1000000000) list.push('A business day like any other. It\'s good to be at the top!');
4814 else if (Game.cookiesEarned<10100000000) list.push('You look back at your career. It\'s been a fascinating journey, building your baking empire from the ground up.');//only show this for 100 millions
4815 }
4816
4817 for (var i in Game.customTickers)
4818 {
4819 var arr=Game.customTickers[i]();
4820 for (var ii in arr) list.push(arr[ii]);
4821 }
4822
4823 Game.TickerAge=Game.fps*10;
4824 Game.Ticker=choose(list);
4825 Game.AddToLog(Game.Ticker);
4826 Game.TickerN++;
4827 Game.TickerDraw();
4828 }
4829 Game.tickerL=l('commentsText');
4830 Game.tickerBelowL=l('commentsTextBelow');
4831 Game.tickerCompactL=l('compactCommentsText');
4832 Game.TickerDraw=function()
4833 {
4834 var str='';
4835 if (Game.Ticker!='') str=Game.Ticker;
4836 Game.tickerBelowL.innerHTML=Game.tickerL.innerHTML;
4837 Game.tickerL.innerHTML=str;
4838 Game.tickerCompactL.innerHTML=str;
4839
4840 Game.tickerBelowL.className='commentsText';
4841 Game.tickerBelowL.offsetWidth=Game.tickerBelowL.offsetWidth;
4842 Game.tickerBelowL.className='commentsText risingAway';
4843 Game.tickerL.className='commentsText';
4844 Game.tickerL.offsetWidth=Game.tickerL.offsetWidth;
4845 Game.tickerL.className='commentsText risingUp';
4846 }
4847 AddEvent(Game.tickerL,'click',function(event){Game.Ticker='';Game.TickerClicks++;if (Game.TickerClicks==50) {Game.Win('Tabloid addiction');}});
4848
4849 Game.Log=[];
4850 Game.AddToLog=function(what)
4851 {
4852 Game.Log.unshift(what);
4853 if (Game.Log.length>100) Game.Log.pop();
4854 }
4855
4856 Game.vanilla=1;
4857 /*=====================================================================================
4858 BUILDINGS
4859 =======================================================================================*/
4860 Game.last=0;
4861
4862 Game.storeToRefresh=1;
4863 Game.priceIncrease=1.15;
4864 Game.buyBulk=1;
4865 Game.buyMode=1;//1 for buy, -1 for sell
4866 Game.buyBulkOld=Game.buyBulk;//used to undo changes from holding Shift or Ctrl
4867 Game.buyBulkShortcut=0;//are we pressing Shift or Ctrl?
4868
4869 Game.Objects=[];
4870 Game.ObjectsById=[];
4871 Game.ObjectsN=0;
4872 Game.BuildingsOwned=0;
4873 Game.Object=function(name,commonName,desc,icon,iconColumn,art,price,cps,buyFunction)
4874 {
4875 this.id=Game.ObjectsN;
4876 this.name=name;
4877 this.displayName=this.name;
4878 commonName=commonName.split('|');
4879 this.single=commonName[0];
4880 this.plural=commonName[1];
4881 this.actionName=commonName[2];
4882 this.desc=desc;
4883 this.basePrice=price;
4884 this.price=this.basePrice;
4885 this.bulkPrice=this.price;
4886 this.cps=cps;
4887 this.baseCps=this.cps;
4888
4889 this.n=this.id;
4890 if (this.n!=0)
4891 {
4892 //new automated price and CpS curves
4893 //this.baseCps=Math.ceil(((this.n*0.5)*Math.pow(this.n*1,this.n*0.9))*10)/10;
4894 //this.baseCps=Math.ceil((Math.pow(this.n*1,this.n*0.5+2.35))*10)/10;//by a fortunate coincidence, this gives the 3rd, 4th and 5th buildings a CpS of 10, 69 and 420
4895 this.baseCps=Math.ceil((Math.pow(this.n*1,this.n*0.5+2))*10)/10;
4896 //this.baseCps=Math.ceil((Math.pow(this.n*1,this.n*0.45+2.10))*10)/10;
4897 //clamp 14,467,199 to 14,000,000 (there's probably a more elegant way to do that)
4898 var digits=Math.pow(10,(Math.ceil(Math.log(Math.ceil(this.baseCps))/Math.LN10)))/100;
4899 this.baseCps=Math.round(this.baseCps/digits)*digits;
4900
4901 this.basePrice=(this.n*1+9+(this.n<5?0:Math.pow(this.n-5,1.75)*5))*Math.pow(10,this.n);
4902 //this.basePrice=(this.n*2.5+7.5)*Math.pow(10,this.n);
4903 var digits=Math.pow(10,(Math.ceil(Math.log(Math.ceil(this.basePrice))/Math.LN10)))/100;
4904 this.basePrice=Math.round(this.basePrice/digits)*digits;
4905 this.price=this.basePrice;
4906 this.bulkPrice=this.price;
4907 }
4908
4909 this.totalCookies=0;
4910 this.storedCps=0;
4911 this.storedTotalCps=0;
4912 this.icon=icon;
4913 this.iconColumn=iconColumn;
4914 this.art=art;
4915 if (art.base)
4916 {art.pic=art.base+'.png';art.bg=art.base+'Background.png';}
4917 this.buyFunction=buyFunction;
4918 this.locked=1;
4919 this.vanilla=Game.vanilla;
4920
4921 this.special=null;//special is a function that should be triggered when the object's special is unlocked, or on load (if it's already unlocked). For example, creating a new dungeon.
4922 this.onSpecial=0;//are we on this object's special screen (dungeons etc)?
4923 this.specialUnlocked=0;
4924 this.specialDrawFunction=null;
4925 this.drawSpecialButton=null;
4926
4927 this.tieredUpgrades=[];
4928 this.tieredAchievs=[];
4929 this.synergies=[];
4930
4931 this.amount=0;
4932 this.bought=0;
4933 this.free=0;
4934
4935 this.getPrice=function()
4936 {
4937 var price=this.basePrice*Math.pow(Game.priceIncrease,Math.max(0,this.amount-this.free));
4938 if (Game.Has('Season savings')) price*=0.99;
4939 if (Game.Has('Santa\'s dominion')) price*=0.99;
4940 if (Game.Has('Faberge egg')) price*=0.99;
4941 if (Game.Has('Divine discount')) price*=0.99;
4942 if (Game.hasAura('Fierce Hoarder')) price*=0.98;
4943 if (Game.hasBuff('Everything must go')) price*=0.95;
4944 return Math.ceil(price);
4945 }
4946 this.getSumPrice=function(amount)//return how much it would cost to buy [amount] more of this building
4947 {
4948 var price=0;
4949 for (var i=Math.max(0,this.amount);i<Math.max(0,(this.amount)+amount);i++)
4950 {
4951 price+=this.basePrice*Math.pow(Game.priceIncrease,Math.max(0,i-this.free));
4952 }
4953 if (Game.Has('Season savings')) price*=0.99;
4954 if (Game.Has('Santa\'s dominion')) price*=0.99;
4955 if (Game.Has('Faberge egg')) price*=0.99;
4956 if (Game.Has('Divine discount')) price*=0.99;
4957 if (Game.hasAura('Fierce Hoarder')) price*=0.98;
4958 if (Game.hasBuff('Everything must go')) price*=0.95;
4959 return Math.ceil(price);
4960 }
4961 this.getReverseSumPrice=function(amount)//return how much you'd get from selling [amount] of this building
4962 {
4963 var price=0;
4964 for (var i=Math.max(0,(this.amount)-amount);i<Math.max(0,this.amount);i++)
4965 {
4966 price+=this.basePrice*Math.pow(Game.priceIncrease,Math.max(0,i-this.free));
4967 }
4968 if (Game.Has('Season savings')) price*=0.99;
4969 if (Game.Has('Santa\'s dominion')) price*=0.99;
4970 if (Game.Has('Faberge egg')) price*=0.99;
4971 if (Game.Has('Divine discount')) price*=0.99;
4972 if (Game.hasAura('Fierce Hoarder')) price*=0.98;
4973 if (Game.hasBuff('Everything must go')) price*=0.95;
4974 price*=this.getSellMultiplier();
4975 return Math.ceil(price);
4976 }
4977 this.getSellMultiplier=function()
4978 {
4979 var giveBack=0.5;
4980 if (Game.hasAura('Earth Shatterer')) giveBack=0.85;
4981 return giveBack;
4982 }
4983
4984 this.buy=function(amount)
4985 {
4986 if (Game.buyMode==-1) {this.sell(Game.buyBulk,1);return 0;}
4987 var success=0;
4988 var moni=0;
4989 var bought=0;
4990 if (!amount) amount=Game.buyBulk;
4991 if (amount==-1) amount=1000;
4992 for (var i=0;i<amount;i++)
4993 {
4994 var price=this.getPrice();
4995 if (Game.cookies>=price)
4996 {
4997 bought++;
4998 moni+=price;
4999 Game.Spend(price);
5000 this.amount++;
5001 this.bought++;
5002 price=this.getPrice();
5003 this.price=price;
5004 if (this.buyFunction) this.buyFunction();
5005 Game.recalculateGains=1;
5006 if (this.amount==1 && this.id!=0) l('row'+this.id).className='row enabled';
5007 Game.BuildingsOwned++;
5008 success=1;
5009 }
5010 }
5011 if (success) {PlaySound('snd/buy'+choose([1,2,3,4])+'.mp3',0.75);this.refresh();}
5012 //if (moni>0 && amount>1) Game.Notify(this.name,'Bought <b>'+bought+'</b> for '+Beautify(moni)+' cookies','',2);
5013 }
5014 this.sell=function(amount,bypass)
5015 {
5016 var success=0;
5017 var moni=0;
5018 var sold=0;
5019 if (amount==-1) amount=this.amount;
5020 if (!amount) amount=Game.buyBulk;
5021 for (var i=0;i<amount;i++)
5022 {
5023 var price=this.getPrice();
5024 var giveBack=this.getSellMultiplier();
5025 price=Math.floor(price*giveBack);
5026 if (this.amount>0)
5027 {
5028 sold++;
5029 moni+=price;
5030 Game.cookies+=price;
5031 Game.cookiesEarned=Math.max(Game.cookies,Game.cookiesEarned);//this is to avoid players getting the cheater achievement when selling buildings that have a higher price than they used to
5032 this.amount--;
5033 price=this.getPrice();
5034 this.price=price;
5035 if (this.sellFunction) this.sellFunction();
5036 Game.recalculateGains=1;
5037 if (this.amount==0 && this.id!=0) l('row'+this.id).className='row';
5038 Game.BuildingsOwned--;
5039 success=1;
5040 }
5041 }
5042 if (success) {PlaySound('snd/sell'+choose([1,2,3,4])+'.mp3',0.75);this.refresh();}
5043 //if (moni>0) Game.Notify(this.name,'Sold <b>'+sold+'</b> for '+Beautify(moni)+' cookies','',2);
5044 }
5045 this.sacrifice=function(amount)//sell without getting back any money
5046 {
5047 var success=0;
5048 //var moni=0;
5049 var sold=0;
5050 if (amount==-1) amount=this.amount;
5051 if (!amount) amount=1;
5052 for (var i=0;i<amount;i++)
5053 {
5054 var price=this.getPrice();
5055 price=Math.floor(price*0.5);
5056 if (this.amount>0)
5057 {
5058 sold++;
5059 //moni+=price;
5060 //Game.cookies+=price;
5061 //Game.cookiesEarned=Math.max(Game.cookies,Game.cookiesEarned);
5062 this.amount--;
5063 price=this.getPrice();
5064 this.price=price;
5065 if (this.sellFunction) this.sellFunction();
5066 Game.recalculateGains=1;
5067 if (this.amount==0 && this.id!=0) l('row'+this.id).className='row';
5068 Game.BuildingsOwned--;
5069 success=1;
5070 }
5071 }
5072 if (success) {this.refresh();}
5073 //if (moni>0) Game.Notify(this.name,'Sold <b>'+sold+'</b> for '+Beautify(moni)+' cookies','',2);
5074 }
5075 this.getFree=function(amount)//get X of this building for free, with the price behaving as if you still didn't have them
5076 {
5077 this.amount+=amount;
5078 this.bought+=amount;
5079 this.free+=amount;
5080 Game.BuildingsOwned+=amount;
5081 this.refresh();
5082 }
5083 this.getFreeRanks=function(amount)//this building's price behaves as if you had X less of it
5084 {
5085 this.free+=amount;
5086 this.refresh();
5087 }
5088
5089 this.tooltip=function()
5090 {
5091 var me=this;
5092 var desc=me.desc;
5093 var name=me.name;
5094 if (Game.season=='fools')
5095 {
5096 if (!Game.foolObjects[me.name])
5097 {
5098 name=Game.foolObjects['Unknown'].name;
5099 desc=Game.foolObjects['Unknown'].desc;
5100 }
5101 else
5102 {
5103 name=Game.foolObjects[me.name].name;
5104 desc=Game.foolObjects[me.name].desc;
5105 }
5106 }
5107 var icon=[me.iconColumn,0];
5108 if (me.locked)
5109 {
5110 name='???';
5111 desc='';
5112 icon=[0,7];
5113 }
5114 //if (l('rowInfo'+me.id) && Game.drawT%10==0) l('rowInfoContent'+me.id).innerHTML='• '+me.amount+' '+(me.amount==1?me.single:me.plural)+'<br>• producing '+Beautify(me.storedTotalCps,1)+' '+(me.storedTotalCps==1?'cookie':'cookies')+' per second<br>• total : '+Beautify(me.totalCookies)+' '+(Math.floor(me.totalCookies)==1?'cookie':'cookies')+' '+me.actionName;
5115 return '<div style="min-width:350px;"><div class="icon" style="float:left;margin-left:-8px;margin-top:-8px;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div><div style="float:right;"><span class="price">'+Beautify(Math.round(me.price))+'</span></div><div class="name">'+name+'</div>'+'<small>[owned : '+me.amount+'</small>]'+(me.free>0?' <small>[free : '+me.free+'</small>!]':'')+
5116 '<div class="line"></div><div class="description">'+desc+'</div>'+
5117 (me.totalCookies>0?(
5118 '<div class="line"></div><div class="data">'+
5119 (me.amount>0?'• each '+me.single+' produces <b>'+Beautify((me.storedTotalCps/me.amount)*Game.globalCpsMult,1)+'</b> '+((me.storedTotalCps/me.amount)*Game.globalCpsMult==1?'cookie':'cookies')+' per second<br>':'')+
5120 '• '+me.amount+' '+(me.amount==1?me.single:me.plural)+' producing <b>'+Beautify(me.storedTotalCps*Game.globalCpsMult,1)+'</b> '+(me.storedTotalCps*Game.globalCpsMult==1?'cookie':'cookies')+' per second (<b>'+Beautify((me.amount>0?((me.storedTotalCps*Game.globalCpsMult)/Game.cookiesPs):0)*100,1)+'%</b> of total)<br>'+
5121 '• <b>'+Beautify(me.totalCookies)+'</b> '+(Math.floor(me.totalCookies)==1?'cookie':'cookies')+' '+me.actionName+' so far</div>'
5122 ):'')+
5123 '</div>';
5124 }
5125
5126 this.setSpecial=function(what)//change whether we're on the special overlay for this object or not
5127 {
5128 return;//blocked temporarily
5129 if (what==1) this.onSpecial=1;
5130 else this.onSpecial=0;
5131 if (this.id!=0)
5132 {
5133 if (this.onSpecial)
5134 {
5135 l('rowSpecial'+this.id).style.display='block';
5136 if (this.specialDrawFunction) this.specialDrawFunction();
5137 }
5138 else
5139 {
5140 l('rowSpecial'+this.id).style.display='none';
5141 this.draw();
5142 }
5143 }
5144 }
5145 this.unlockSpecial=function()
5146 {
5147 if (this.specialUnlocked==0 && 1==0)
5148 {
5149 this.specialUnlocked=1;
5150 this.setSpecial(0);
5151 if (this.special) this.special();
5152 this.refresh();
5153 }
5154 }
5155
5156 this.refresh=function()//show/hide the building display based on its amount, and redraw it
5157 {
5158 this.price=this.getPrice();
5159 if (Game.buyMode==1) this.bulkPrice=this.getSumPrice(Game.buyBulk);
5160 else if (Game.buyMode==-1 && Game.buyBulk==-1) this.bulkPrice=this.getReverseSumPrice(1000);
5161 else if (Game.buyMode==-1) this.bulkPrice=this.getReverseSumPrice(Game.buyBulk);
5162 this.rebuild();
5163 if (this.amount==0 && this.id!=0) l('row'+this.id).className='row';
5164 else if (this.amount>0 && this.id!=0) l('row'+this.id).className='row enabled';
5165 if (!this.onSpecial) this.draw();
5166 //else if (this.specialDrawFunction && this.onSpecial) this.specialDrawFunction();
5167 }
5168 this.rebuild=function()
5169 {
5170 var me=this;
5171 //var classes='product';
5172 var price=me.bulkPrice;
5173 /*if (Game.cookiesEarned>=me.basePrice || me.bought>0) {classes+=' unlocked';me.locked=0;} else {classes+=' locked';me.locked=1;}
5174 if (Game.cookies>=price) classes+=' enabled'; else classes+=' disabled';
5175 if (me.l.className.indexOf('toggledOff')!=-1) classes+=' toggledOff';
5176 */
5177 var iconOff='';
5178 var icon='';
5179 var iconX=0;
5180 if (typeof me.icon=='string')
5181 {
5182 icon=me.icon+'.png';
5183 iconOff=me.icon+'Off.png';
5184 }
5185 else
5186 {
5187 icon=me.icon()+'.png';
5188 iconOff=me.icon('off')+'Off.png';
5189 }
5190 var desc=me.desc;
5191 var name=me.name;
5192 var displayName=me.displayName;
5193 if (Game.season=='fools')
5194 {
5195 icon='BusinessDayIcons.png';
5196 iconOff=icon;
5197 if (!Game.foolObjects[me.name])
5198 {
5199 iconX=Game.foolObjects['Unknown'].icon*64;
5200 name=Game.foolObjects['Unknown'].name;
5201 desc=Game.foolObjects['Unknown'].desc;
5202 }
5203 else
5204 {
5205 iconX=Game.foolObjects[me.name].icon*64;
5206 name=Game.foolObjects[me.name].name;
5207 desc=Game.foolObjects[me.name].desc;
5208 }
5209 displayName=name;
5210 if (name.length>16) displayName='<span style="font-size:75%;">'+name+'</span>';
5211 }
5212
5213 //me.l.className=classes;
5214 l('productIcon'+me.id).style.backgroundImage='url(img/'+icon+')';
5215 l('productIcon'+me.id).style.backgroundPosition='-'+iconX+'px 0px';
5216 l('productIconOff'+me.id).style.backgroundImage='url(img/'+iconOff+')';
5217 l('productIconOff'+me.id).style.backgroundPosition='-'+iconX+'px 0px';
5218 l('productName'+me.id).innerHTML=displayName;
5219 l('productOwned'+me.id).innerHTML=me.amount?me.amount:'';
5220 l('productPrice'+me.id).innerHTML=Beautify(Math.round(price));
5221 l('productPriceMult'+me.id).innerHTML=(Game.buyBulk>1)?('x'+Game.buyBulk+' '):'';
5222 }
5223
5224 this.draw=function(){};
5225
5226 if (this.id!=0)//draw it
5227 {
5228 var str='<div class="row" id="row'+this.id+'"><div class="separatorBottom"></div>';
5229 str+='<canvas class="rowCanvas" id="rowCanvas'+this.id+'"></canvas>';
5230 str+='</div>';
5231 l('rows').innerHTML=l('rows').innerHTML+str;
5232
5233 //building canvas
5234 this.pics=[];
5235
5236 this.redraw=function()
5237 {
5238 this.pics=[];
5239 }
5240 this.draw=function()
5241 {
5242 //this needs to be cached
5243 this.canvas.width=this.canvas.clientWidth;
5244 this.canvas.height=this.canvas.clientHeight;
5245 var ctx=this.ctx;
5246 //clear
5247 //ctx.clearRect(0,0,this.canvas.width,this.canvas.height);
5248 ctx.globalAlpha=1;
5249
5250 //pic : a loaded picture or a function returning a loaded picture
5251 //bg : a loaded picture or a function returning a loaded picture - tiled as the background, 128x128
5252 //xV : the pictures will have a random horizontal shift by this many pixels
5253 //yV : the pictures will have a random vertical shift by this many pixels
5254 //w : how many pixels between each picture (or row of pictures)
5255 //x : horizontal offset
5256 //y : vertical offset (+32)
5257 //rows : if >1, arrange the pictures in rows containing this many pictures
5258
5259 var pic=this.art.pic;
5260 var bg=this.art.bg;
5261 var xV=this.art.xV||0;
5262 var yV=this.art.yV||0;
5263 var w=this.art.w||48;
5264 var offX=this.art.x||0;
5265 var offY=this.art.y||0;
5266 var rows=this.art.rows||1;
5267
5268 if (typeof(bg)=='string') ctx.fillPattern(Pic(this.art.bg),0,0,this.canvas.width,this.canvas.height,128,128);
5269 else bg(this,ctx);
5270 /*
5271 ctx.globalAlpha=0.5;
5272 if (typeof(bg)=='string')//test
5273 {
5274 ctx.fillPattern(Pic(this.art.bg),-128+Game.T%128,0,this.canvas.width+128,this.canvas.height,128,128);
5275 ctx.fillPattern(Pic(this.art.bg),-128+Math.floor(Game.T/2)%128,-128+Math.floor(Game.T/2)%128,this.canvas.width+128,this.canvas.height+128,128,128);
5276 }
5277 ctx.globalAlpha=1;
5278 */
5279 var i=this.pics.length;
5280 while (i<this.amount)
5281 {
5282 var x=0;
5283 var y=0;
5284 if (rows!=1)
5285 {
5286 x=Math.floor(i/rows)*w+((i%rows)/rows)*w+Math.floor((Math.random()-0.5)*xV)+offX;
5287 y=32+Math.floor((Math.random()-0.5)*yV)+((-rows/2)*32/2+(i%rows)*32/2)+offY;
5288 }
5289 else
5290 {
5291 x=i*w+Math.floor((Math.random()-0.5)*xV)+offX;
5292 y=32+Math.floor((Math.random()-0.5)*yV)+offY;
5293 }
5294 var usedPic=(typeof(pic)=='string'?pic:pic(this,i));
5295 this.pics.push({x:x,y:y,z:y,pic:usedPic,id:i});
5296 i++;
5297 }
5298 while (i>this.amount)
5299 {
5300 this.pics.sort(Game.sortSpritesById);
5301 this.pics.pop();
5302 i--;
5303 }
5304
5305 this.pics.sort(Game.sortSprites);
5306
5307 for (var i in this.pics)
5308 {
5309 ctx.drawImage(Pic(this.pics[i].pic),Math.floor(this.pics[i].x),Math.floor(this.pics[i].y));
5310 }
5311
5312 /*
5313 var picX=this.id;
5314 var picY=12;
5315 var w=1;
5316 var h=1;
5317 var w=Math.abs(Math.cos(Game.T*0.2+this.id*2-0.3))*0.2+0.8;
5318 var h=Math.abs(Math.sin(Game.T*0.2+this.id*2))*0.3+0.7;
5319 var x=64+Math.cos(Game.T*0.19+this.id*2)*8-24*w;
5320 var y=128-Math.abs(Math.pow(Math.sin(Game.T*0.2+this.id*2),5)*16)-48*h;
5321 ctx.drawImage(Pic('icons.png'),picX*48,picY*48,48,48,Math.floor(x),Math.floor(y),48*w,48*h);
5322 */
5323 }
5324 }
5325
5326 Game.last=this;
5327 Game.Objects[this.name]=this;
5328 Game.ObjectsById[this.id]=this;
5329 Game.ObjectsN++;
5330 return this;
5331 }
5332
5333 Game.DrawBuildings=function()//draw building displays with canvas
5334 {
5335 if (Game.drawT%3==0)
5336 {
5337 for (var i in Game.Objects)
5338 {
5339 var me=Game.Objects[i];
5340 if (me.id>0) me.draw();
5341 }
5342 }
5343 }
5344 window.addEventListener('resize',function(event)
5345 {
5346 Game.DrawBuildings();
5347 });
5348
5349 Game.sortSprites=function(a,b)
5350 {
5351 if (a.z>b.z) return 1;
5352 else if (a.z<b.z) return -1;
5353 else return 0;
5354 }
5355 Game.sortSpritesById=function(a,b)
5356 {
5357 if (a.id>b.id) return 1;
5358 else if (a.id<b.id) return -1;
5359 else return 0;
5360 }
5361
5362 Game.storeBulkButton=function(id)
5363 {
5364 if (id==0) Game.buyMode=1;
5365 else if (id==1) Game.buyMode=-1;
5366 else if (id==2) Game.buyBulk=1;
5367 else if (id==3) Game.buyBulk=10;
5368 else if (id==4) Game.buyBulk=100;
5369 else if (id==5) Game.buyBulk=-1;
5370
5371 if (Game.buyMode==1 && Game.buyBulk==-1) Game.buyBulk=100;
5372
5373 if (Game.buyMode==1) l('storeBulkBuy').className='storeBulkMode selected'; else l('storeBulkBuy').className='storeBulkMode';
5374 if (Game.buyMode==-1) l('storeBulkSell').className='storeBulkMode selected'; else l('storeBulkSell').className='storeBulkMode';
5375
5376 if (Game.buyBulk==1) l('storeBulk1').className='storeBulkAmount selected'; else l('storeBulk1').className='storeBulkAmount';
5377 if (Game.buyBulk==10) l('storeBulk10').className='storeBulkAmount selected'; else l('storeBulk10').className='storeBulkAmount';
5378 if (Game.buyBulk==100) l('storeBulk100').className='storeBulkAmount selected'; else l('storeBulk100').className='storeBulkAmount';
5379 if (Game.buyBulk==-1) l('storeBulkMax').className='storeBulkAmount selected'; else l('storeBulkMax').className='storeBulkAmount';
5380
5381 if (Game.buyMode==1)
5382 {
5383 l('storeBulkMax').style.visibility='hidden';
5384 l('products').className='storeSection';
5385 }
5386 else
5387 {
5388 l('storeBulkMax').style.visibility='visible';
5389 l('products').className='storeSection selling';
5390 }
5391
5392 Game.storeToRefresh=1;
5393 if (id!=-1) PlaySound('snd/tick.mp3');
5394 }
5395 Game.BuildStore=function()//create the DOM for the store's buildings
5396 {
5397 var str='';
5398 str+='<div id="storeBulk" '+Game.getTooltip(
5399 '<div style="min-width:200px;text-align:center;font-size:11px;">You can also press <b>Ctrl</b> to bulk-buy or sell <b>10</b> of a building at a time, or <b>Shift</b> for <b>100</b>.</div>'
5400 ,'store')+
5401 '>'+
5402 '<div id="storeBulkBuy" class="storeBulkMode" '+Game.clickStr+'="Game.storeBulkButton(0);">Buy</div>'+
5403 '<div id="storeBulkSell" class="storeBulkMode" '+Game.clickStr+'="Game.storeBulkButton(1);">Sell</div>'+
5404 '<div id="storeBulk1" class="storeBulkAmount" '+Game.clickStr+'="Game.storeBulkButton(2);">1</div>'+
5405 '<div id="storeBulk10" class="storeBulkAmount" '+Game.clickStr+'="Game.storeBulkButton(3);">10</div>'+
5406 '<div id="storeBulk100" class="storeBulkAmount" '+Game.clickStr+'="Game.storeBulkButton(4);">100</div>'+
5407 '<div id="storeBulkMax" class="storeBulkAmount" '+Game.clickStr+'="Game.storeBulkButton(5);">all</div>'+
5408 '</div>';
5409 for (var i in Game.Objects)
5410 {
5411 var me=Game.Objects[i];
5412 str+='<div class="product toggledOff" '+Game.getDynamicTooltip('Game.ObjectsById['+me.id+'].tooltip','store')+' id="product'+me.id+'"><div class="icon off" id="productIconOff'+me.id+'" style=""></div><div class="icon" id="productIcon'+me.id+'" style=""></div><div class="content"><div class="lockedTitle">???</div><div class="title" id="productName'+me.id+'"></div><span class="priceMult" id="productPriceMult'+me.id+'"></span><span class="price" id="productPrice'+me.id+'"></span><div class="title owned" id="productOwned'+me.id+'"></div></div>'+
5413 /*'<div class="buySell"><div style="left:0px;" id="buttonBuy10-'+me.id+'">Buy 10</div><div style="left:100px;" id="buttonSell-'+me.id+'">Sell 1</div><div style="left:200px;" id="buttonSellAll-'+me.id+'">Sell all</div></div>'+*/
5414 '</div>';
5415 }
5416 l('products').innerHTML=str;
5417
5418 Game.storeBulkButton(-1);
5419
5420 var SellAllPrompt=function(id)
5421 {
5422 return function(id){Game.Prompt('<div class="block">Do you really want to sell your '+Game.ObjectsById[id].amount+' '+(Game.ObjectsById[id].amount==1?Game.ObjectsById[id].single:Game.ObjectsById[id].plural)+'?</div>',[['Yes','Game.ObjectsById['+id+'].sell(-1);Game.ClosePrompt();'],['No','Game.ClosePrompt();']]);}(id);
5423 }
5424
5425 Game.ClickProduct=function(what)
5426 {
5427 Game.ObjectsById[what].buy();
5428 }
5429
5430 for (var i in Game.Objects)
5431 {
5432 var me=Game.Objects[i];
5433 me.l=l('product'+me.id);
5434
5435 //these are a bit messy but ah well
5436 if (!Game.touchEvents)
5437 {
5438 AddEvent(me.l,'click',function(what){return function(){Game.ClickProduct(what);};}(me.id));
5439 }
5440 else
5441 {
5442 AddEvent(me.l,'touchend',function(what){return function(){Game.ClickProduct(what);};}(me.id));
5443 }
5444 }
5445 }
5446
5447 Game.RefreshStore=function()//refresh the store's buildings
5448 {
5449 for (var i in Game.Objects)
5450 {
5451 Game.Objects[i].refresh();
5452 }
5453 Game.storeToRefresh=0;
5454 }
5455
5456 Game.ComputeCps=function(base,mult,bonus)
5457 {
5458 if (!bonus) bonus=0;
5459 return ((base)*(Math.pow(2,mult))+bonus);
5460 }
5461
5462 Game.magicCpS=function(what)
5463 {
5464 /*
5465 if (Game.Objects[what].amount>=250)
5466 {
5467 //this makes buildings give 1% more cookies for every building over 250.
5468 //this turns out to be rather stupidly overpowered.
5469 var n=Game.Objects[what].amount-250;
5470 return 1+Math.pow(1.01,n);
5471 }
5472 else return 1;
5473 */
5474 return 1;
5475 }
5476
5477 //define objects
5478 new Game.Object('Cursor','cursor|cursors|clicked','Autoclicks once every 10 seconds.','cursoricon',0,{},15,function(){
5479 var add=0;
5480 if (Game.Has('Thousand fingers')) add+= 0.1;
5481 if (Game.Has('Million fingers')) add+= 0.5;
5482 if (Game.Has('Billion fingers')) add+= 2;
5483 if (Game.Has('Trillion fingers')) add+= 10;
5484 if (Game.Has('Quadrillion fingers')) add+= 50;
5485 if (Game.Has('Quintillion fingers')) add+= 200;
5486 if (Game.Has('Sextillion fingers')) add+= 1000;
5487 if (Game.Has('Septillion fingers')) add+= 5000;
5488 if (Game.Has('Octillion fingers')) add+= 20000;
5489 if (Game.Has('Nonillion fingers')) add+= 100000;
5490 if (Game.Has('Decillion fingers')) add+= 500000;
5491 if (Game.Has('Undecillion fingers')) add+= 2000000;
5492 if (Game.Has('Duodecillion fingers')) add+= 10000000;
5493 if (Game.Has('Tredecillion fingers')) add+= 50000000;
5494 if (Game.Has('Quattuordecillion fingers')) add+=200000000;
5495 var mult=1;
5496 var num=0;
5497 for (var i in Game.Objects) {if (Game.Objects[i].name!='Cursor') num+=Game.Objects[i].amount;}
5498 add=add*num;
5499 mult*=Game.magicCpS('Cursor');
5500 return Game.ComputeCps(0.1,Game.Has('Reinforced index finger')+Game.Has('Carpal tunnel prevention cream')+Game.Has('Ambidextrous'),add)*mult;
5501 },function(){
5502 if (this.amount>=1) Game.Unlock('Reinforced index finger');
5503 if (this.amount>=2) Game.Unlock('Carpal tunnel prevention cream');
5504 if (this.amount>=5) Game.Unlock('Ambidextrous');
5505 if (this.amount>=10) Game.Unlock('Thousand fingers');
5506 if (this.amount>=25) Game.Unlock('Million fingers');
5507 if (this.amount>=40) Game.Unlock('Billion fingers');
5508 if (this.amount>=50) Game.Unlock('Trillion fingers');
5509 if (this.amount>=75) Game.Unlock('Quadrillion fingers');
5510 if (this.amount>=100) Game.Unlock('Quintillion fingers');
5511 if (this.amount>=125) Game.Unlock('Sextillion fingers');
5512 if (this.amount>=150) Game.Unlock('Septillion fingers');
5513 if (this.amount>=175) Game.Unlock('Octillion fingers');
5514 if (this.amount>=200) Game.Unlock('Nonillion fingers');
5515 if (this.amount>=225) Game.Unlock('Decillion fingers');
5516 if (this.amount>=250) Game.Unlock('Undecillion fingers');
5517 if (this.amount>=275) Game.Unlock('Duodecillion fingers');
5518 if (this.amount>=300) Game.Unlock('Tredecillion fingers');
5519 if (this.amount>=325) Game.Unlock('Quattuordecillion fingers');
5520
5521 if (this.amount>=1) Game.Win('Click');if (this.amount>=2) Game.Win('Double-click');if (this.amount>=50) Game.Win('Mouse wheel');if (this.amount>=100) Game.Win('Of Mice and Men');if (this.amount>=200) Game.Win('The Digital');if (this.amount>=300) Game.Win('Extreme polydactyly');if (this.amount>=400) Game.Win('Dr. T');if (this.amount>=500) Game.Win('Thumbs, phalanges, metacarpals');
5522 });
5523
5524 Game.SpecialGrandmaUnlock=15;
5525 new Game.Object('Grandma','grandma|grandmas|baked','A nice grandma to bake more cookies.',function(type){
5526 var grandmaIcons=['grandmaIcon','grandmaIconB','grandmaIconC','grandmaIconD'];
5527 if (type=='off') return 'grandmaIcon';
5528 return grandmaIcons[Game.elderWrath];
5529 },1,{pic:function(i){
5530 var list=['grandma'];
5531 if (Game.Has('Farmer grandmas')) list.push('farmerGrandma');
5532 if (Game.Has('Worker grandmas')) list.push('workerGrandma');
5533 if (Game.Has('Miner grandmas')) list.push('minerGrandma');
5534 if (Game.Has('Cosmic grandmas')) list.push('cosmicGrandma');
5535 if (Game.Has('Transmuted grandmas')) list.push('transmutedGrandma');
5536 if (Game.Has('Altered grandmas')) list.push('alteredGrandma');
5537 if (Game.Has('Grandmas\' grandmas')) list.push('grandmasGrandma');
5538 if (Game.Has('Antigrandmas')) list.push('antiGrandma');
5539 if (Game.Has('Rainbow grandmas')) list.push('rainbowGrandma');
5540 if (Game.Has('Banker grandmas')) list.push('bankGrandma');
5541 if (Game.Has('Priestess grandmas')) list.push('templeGrandma');
5542 if (Game.Has('Witch grandmas')) list.push('witchGrandma');
5543 if (Game.season=='christmas') list.push('elfGrandma');
5544 if (Game.season=='easter') list.push('bunnyGrandma');
5545 return choose(list)+'.png';
5546 },bg:'grandmaBackground.png',xV:8,yV:8,w:32,rows:3,x:0,y:16},100,function(me){
5547 var mult=1;
5548 if (Game.Has('Farmer grandmas')) mult*=2;
5549 if (Game.Has('Worker grandmas')) mult*=2;
5550 if (Game.Has('Miner grandmas')) mult*=2;
5551 if (Game.Has('Cosmic grandmas')) mult*=2;
5552 if (Game.Has('Transmuted grandmas')) mult*=2;
5553 if (Game.Has('Altered grandmas')) mult*=2;
5554 if (Game.Has('Grandmas\' grandmas')) mult*=2;
5555 if (Game.Has('Antigrandmas')) mult*=2;
5556 if (Game.Has('Rainbow grandmas')) mult*=2;
5557 if (Game.Has('Banker grandmas')) mult*=2;
5558 if (Game.Has('Priestess grandmas')) mult*=2;
5559 if (Game.Has('Witch grandmas')) mult*=2;
5560 if (Game.Has('Bingo center/Research facility')) mult*=4;
5561 if (Game.Has('Ritual rolling pins')) mult*=2;
5562 if (Game.Has('Naughty list')) mult*=2;
5563
5564 mult*=Game.GetTieredCpsMult(me);
5565
5566 var add=0;
5567 if (Game.Has('One mind')) add+=Game.Objects['Grandma'].amount*0.02;
5568 if (Game.Has('Communal brainsweep')) add+=Game.Objects['Grandma'].amount*0.02;
5569 if (Game.Has('Elder Pact')) add+=Game.Objects['Portal'].amount*0.05;
5570
5571 var num=0;
5572 for (var i in Game.Objects) {if (Game.Objects[i].name!='Grandma') num+=Game.Objects[i].amount;}
5573 if (Game.hasAura('Elder Battalion')) mult*=1+0.01*num;
5574
5575 mult*=Game.magicCpS(me.name);
5576
5577 return (me.baseCps+add)*mult;
5578 },function(){
5579 Game.UnlockTiered(this);
5580 });
5581 Game.Objects['Grandma'].sellFunction=function()
5582 {
5583 Game.Win('Just wrong');
5584 if (this.amount==0)
5585 {
5586 Game.Lock('Elder Pledge');
5587 Game.CollectWrinklers();
5588 Game.pledgeT=0;
5589 }
5590 };
5591
5592
5593 new Game.Object('Farm','farm|farms|harvested','Grows cookie plants from cookie seeds.','farmIcon',2,{base:'farm',xV:8,yV:8,w:64,rows:2,x:0,y:16},500,function(me){
5594 var mult=1;
5595 mult*=Game.GetTieredCpsMult(me);
5596 if (Game.Has('Farmer grandmas')) mult*=Game.getGrandmaSynergyUpgradeMultiplier(me.name);
5597 mult*=Game.magicCpS(me.name);
5598 return me.baseCps*mult;
5599 },function(){
5600 Game.UnlockTiered(this);
5601 if (this.amount>=Game.SpecialGrandmaUnlock && Game.Objects['Grandma'].amount>0) Game.Unlock('Farmer grandmas');
5602 });
5603
5604 new Game.Object('Mine','mine|mines|mined','Mines out cookie dough and chocolate chips.','mineIcon',3,{base:'mine',xV:16,yV:16,w:64,rows:2,x:0,y:24},10000,function(me){
5605 var mult=1;
5606 mult*=Game.GetTieredCpsMult(me);
5607 if (Game.Has('Miner grandmas')) mult*=Game.getGrandmaSynergyUpgradeMultiplier(me.name);
5608 mult*=Game.magicCpS(me.name);
5609 return me.baseCps*mult;
5610 },function(){
5611 Game.UnlockTiered(this);
5612 if (this.amount>=Game.SpecialGrandmaUnlock && Game.Objects['Grandma'].amount>0) Game.Unlock('Miner grandmas');
5613 });
5614
5615 new Game.Object('Factory','factory|factories|mass-produced','Produces large quantities of cookies.','factoryIcon',4,{base:'factory',xV:8,yV:0,w:64,rows:1,x:0,y:-22},3000,function(me){
5616 var mult=1;
5617 mult*=Game.GetTieredCpsMult(me);
5618 if (Game.Has('Worker grandmas')) mult*=Game.getGrandmaSynergyUpgradeMultiplier(me.name);
5619 mult*=Game.magicCpS(me.name);
5620 return me.baseCps*mult;
5621 },function(){
5622 Game.UnlockTiered(this);
5623 if (this.amount>=Game.SpecialGrandmaUnlock && Game.Objects['Grandma'].amount>0) Game.Unlock('Worker grandmas');
5624 });
5625
5626 new Game.Object('Bank','bank|banks|banked','Generates cookies from interest.','bankIcon',15,{base:'bank',xV:8,yV:4,w:56,rows:1,x:0,y:13},0,function(me){
5627 var mult=1;
5628 mult*=Game.GetTieredCpsMult(me);
5629 if (Game.Has('Banker grandmas')) mult*=Game.getGrandmaSynergyUpgradeMultiplier(me.name);
5630 mult*=Game.magicCpS(me.name);
5631 return me.baseCps*mult;
5632 },function(){
5633 Game.UnlockTiered(this);
5634 if (this.amount>=Game.SpecialGrandmaUnlock && Game.Objects['Grandma'].amount>0) Game.Unlock('Banker grandmas');
5635 });
5636
5637 new Game.Object('Temple','temple|temples|discovered','Full of precious, ancient chocolate.','templeIcon',16,{base:'temple',xV:8,yV:4,w:72,rows:2,x:0,y:-5},0,function(me){
5638 var mult=1;
5639 mult*=Game.GetTieredCpsMult(me);
5640 if (Game.Has('Priestess grandmas')) mult*=Game.getGrandmaSynergyUpgradeMultiplier(me.name);
5641 mult*=Game.magicCpS(me.name);
5642 return me.baseCps*mult;
5643 },function(){
5644 Game.UnlockTiered(this);
5645 if (this.amount>=Game.SpecialGrandmaUnlock && Game.Objects['Grandma'].amount>0) Game.Unlock('Priestess grandmas');
5646 });
5647
5648 new Game.Object('Wizard tower','wizard tower|wizard towers|summoned','Summons cookies with magic spells.','wizardtowerIcon',17,{base:'wizardtower',xV:16,yV:16,w:48,rows:2,x:0,y:20},0,function(me){
5649 var mult=1;
5650 mult*=Game.GetTieredCpsMult(me);
5651 if (Game.Has('Witch grandmas')) mult*=Game.getGrandmaSynergyUpgradeMultiplier(me.name);
5652 mult*=Game.magicCpS(me.name);
5653 return me.baseCps*mult;
5654 },function(){
5655 Game.UnlockTiered(this);
5656 if (this.amount>=Game.SpecialGrandmaUnlock && Game.Objects['Grandma'].amount>0) Game.Unlock('Witch grandmas');
5657 });
5658
5659 new Game.Object('Shipment','shipment|shipments|shipped','Brings in fresh cookies from the cookie planet.','shipmentIcon',5,{base:'shipment',xV:16,yV:16,w:64,rows:1,x:0,y:0},40000,function(me){
5660 var mult=1;
5661 mult*=Game.GetTieredCpsMult(me);
5662 if (Game.Has('Cosmic grandmas')) mult*=Game.getGrandmaSynergyUpgradeMultiplier(me.name);
5663 mult*=Game.magicCpS(me.name);
5664 return me.baseCps*mult;
5665 },function(){
5666 Game.UnlockTiered(this);
5667 if (this.amount>=Game.SpecialGrandmaUnlock && Game.Objects['Grandma'].amount>0) Game.Unlock('Cosmic grandmas');
5668 });
5669
5670 new Game.Object('Alchemy lab','alchemy lab|alchemy labs|transmuted','Turns gold into cookies!','alchemylabIcon',6,{base:'alchemylab',xV:16,yV:16,w:64,rows:2,x:0,y:16},200000,function(me){
5671 var mult=1;
5672 mult*=Game.GetTieredCpsMult(me);
5673 if (Game.Has('Transmuted grandmas')) mult*=Game.getGrandmaSynergyUpgradeMultiplier(me.name);
5674 mult*=Game.magicCpS(me.name);
5675 return me.baseCps*mult;
5676 },function(){
5677 Game.UnlockTiered(this);
5678 if (this.amount>=Game.SpecialGrandmaUnlock && Game.Objects['Grandma'].amount>0) Game.Unlock('Transmuted grandmas');
5679 });
5680
5681 new Game.Object('Portal','portal|portals|retrieved','Opens a door to the Cookieverse.','portalIcon',7,{base:'portal',xV:32,yV:32,w:64,rows:2,x:0,y:0},1666666,function(me){
5682 var mult=1;
5683 mult*=Game.GetTieredCpsMult(me);
5684 if (Game.Has('Altered grandmas')) mult*=Game.getGrandmaSynergyUpgradeMultiplier(me.name);
5685 mult*=Game.magicCpS(me.name);
5686 return me.baseCps*mult;
5687 },function(){
5688 Game.UnlockTiered(this);
5689 if (this.amount>=Game.SpecialGrandmaUnlock && Game.Objects['Grandma'].amount>0) Game.Unlock('Altered grandmas');
5690 });
5691
5692 new Game.Object('Time machine','time machine|time machines|recovered','Brings cookies from the past, before they were even eaten.','timemachineIcon',8,{base:'timemachine',xV:32,yV:32,w:64,rows:1,x:0,y:0},123456789,function(me){
5693 var mult=1;
5694 mult*=Game.GetTieredCpsMult(me);
5695 if (Game.Has('Grandmas\' grandmas')) mult*=Game.getGrandmaSynergyUpgradeMultiplier(me.name);
5696 mult*=Game.magicCpS(me.name);
5697 return me.baseCps*mult;
5698 },function(){
5699 Game.UnlockTiered(this);
5700 if (this.amount>=Game.SpecialGrandmaUnlock && Game.Objects['Grandma'].amount>0) Game.Unlock('Grandmas\' grandmas');
5701 });
5702
5703 new Game.Object('Antimatter condenser','antimatter condenser|antimatter condensers|condensed','Condenses the antimatter in the universe into cookies.','antimattercondenserIcon',13,{base:'antimattercondenser',xV:0,yV:64,w:64,rows:1,x:0,y:0},3999999999,function(me){
5704 var mult=1;
5705 mult*=Game.GetTieredCpsMult(me);
5706 if (Game.Has('Antigrandmas')) mult*=Game.getGrandmaSynergyUpgradeMultiplier(me.name);
5707 mult*=Game.magicCpS(me.name);
5708 return me.baseCps*mult;
5709 },function(){
5710 Game.UnlockTiered(this);
5711 if (this.amount>=Game.SpecialGrandmaUnlock && Game.Objects['Grandma'].amount>0) Game.Unlock('Antigrandmas');
5712 });
5713 Game.last.displayName='<span style="font-size:65%;position:relative;bottom:4px;">Antimatter condenser</span>';//shrink the name since it's so large
5714
5715 new Game.Object('Prism','prism|prisms|converted','Converts light itself into cookies.','prismIcon',14,{base:'prism',xV:16,yV:4,w:64,rows:1,x:0,y:20},75000000000,function(me){
5716 var mult=1;
5717 mult*=Game.GetTieredCpsMult(me);
5718 if (Game.Has('Rainbow grandmas')) mult*=Game.getGrandmaSynergyUpgradeMultiplier(me.name);
5719 mult*=Game.magicCpS(me.name);
5720 return me.baseCps*mult;
5721 },function(){
5722 Game.UnlockTiered(this);
5723 if (this.amount>=Game.SpecialGrandmaUnlock && Game.Objects['Grandma'].amount>0) Game.Unlock('Rainbow grandmas');
5724 });
5725
5726 Game.foolObjects={
5727 'Unknown':{name:'Investment',desc:'You\'re not sure what this does, you just know it means profit.',icon:0},
5728 'Cursor':{name:'Rolling pin',desc:'Essential in flattening dough. The first step in cookie-making.',icon:0},
5729 'Grandma':{name:'Oven',desc:'A crucial element of baking cookies.',icon:1},
5730 'Farm':{name:'Kitchen',desc:'The more kitchens, the more cookies your employees can produce.',icon:2},
5731 'Mine':{name:'Secret recipe',desc:'These give you the edge you need to outsell those pesky competitors.',icon:3},
5732 'Factory':{name:'Factory',desc:'Mass production is the future of baking. Seize the day, and synergize!',icon:4},
5733 'Bank':{name:'Investor',desc:'Business folks with a nose for profit, ready to finance your venture as long as there\'s money to be made.',icon:5},
5734 'Temple':{name:'Like',desc:'Your social media page is going viral! Amassing likes is the key to a lasting online presence and juicy advertising deals.',icon:9},
5735 'Wizard tower':{name:'Meme',desc:'Cookie memes are all the rage! With just the right amount of social media astroturfing, your brand image will be all over the cyberspace.',icon:6},
5736 'Shipment':{name:'Supermarket',desc:'A gigantic cookie emporium - your very own retail chain.',icon:7},
5737 'Alchemy lab':{name:'Stock share',desc:'You\'re officially on the stock market, and everyone wants a piece!',icon:8},
5738 'Portal':{name:'TV show',desc:'Your cookies have their own sitcom! Hilarious baking hijinks set to the cheesiest laughtrack.',icon:10},
5739 'Time machine':{name:'Theme park',desc:'Cookie theme parks, full of mascots and roller-coasters. Build one, build a hundred!',icon:11},
5740 'Antimatter condenser':{name:'Cookiecoin',desc:'A virtual currency, already replacing regular money in some small countries.',icon:12},
5741 'Prism':{name:'Corporate country',desc:'You\'ve made it to the top, and you can now buy entire nations to further your corporate greed. Godspeed.',icon:13},
5742 };
5743
5744
5745 //build store
5746 Game.BuildStore();
5747 //build object displays
5748 for (var i in Game.Objects)
5749 {
5750 var me=Game.Objects[i];
5751 if (me.id>0)
5752 {
5753 me.canvas=l('rowCanvas'+me.id);
5754 me.ctx=me.canvas.getContext('2d',{alpha:false});
5755 me.pics=[];
5756 }
5757 }
5758
5759 /*=====================================================================================
5760 UPGRADES
5761 =======================================================================================*/
5762 Game.upgradesToRebuild=1;
5763 Game.Upgrades=[];
5764 Game.UpgradesById=[];
5765 Game.UpgradesN=0;
5766 Game.UpgradesInStore=[];
5767 Game.UpgradesOwned=0;
5768 Game.Upgrade=function(name,desc,price,icon,buyFunction)
5769 {
5770 this.id=Game.UpgradesN;
5771 this.name=name;
5772 this.desc=desc;
5773 this.baseDesc=this.desc;
5774 this.desc=BeautifyInText(this.baseDesc);
5775 this.basePrice=price;
5776 this.icon=icon;
5777 this.iconFunction=0;
5778 this.buyFunction=buyFunction;
5779 /*this.unlockFunction=unlockFunction;
5780 this.unlocked=(this.unlockFunction?0:1);*/
5781 this.unlocked=0;
5782 this.bought=0;
5783 this.order=this.id;
5784 if (order) this.order=order+this.id*0.001;
5785 this.pool='';//can be '', cookie, toggle, debug, prestige, prestigeDecor, tech, or unused
5786 if (pool) this.pool=pool;
5787 this.power=0;
5788 if (power) this.power=power;
5789 this.vanilla=Game.vanilla;
5790 this.techUnlock=[];
5791 this.parents=[];
5792 this.type='upgrade';
5793 this.tier=0;
5794 this.buildingTie=0;//of what building is this a tiered upgrade of ?
5795
5796 Game.last=this;
5797 Game.Upgrades[this.name]=this;
5798 Game.UpgradesById[this.id]=this;
5799 Game.UpgradesN++;
5800 return this;
5801 }
5802
5803 Game.Upgrade.prototype.getPrice=function()
5804 {
5805 var price=this.basePrice;
5806 if (this.priceFunc) price=this.priceFunc();
5807 if (this.pool!='prestige')
5808 {
5809 if (Game.Has('Toy workshop')) price*=0.95;
5810 if (Game.Has('Five-finger discount')) price*=Math.pow(0.99,Game.Objects['Cursor'].amount/100);
5811 if (Game.Has('Santa\'s dominion')) price*=0.98;
5812 if (Game.Has('Faberge egg')) price*=0.99;
5813 if (Game.Has('Divine sales')) price*=0.99;
5814 if (Game.hasAura('Master of the Armory')) price*=0.98;
5815 if (this.pool=='cookie' && Game.Has('Divine bakeries')) price/=5;
5816 }
5817 return Math.ceil(price);
5818 }
5819
5820 Game.Upgrade.prototype.canBuy=function()
5821 {
5822 if (Game.cookies>=this.getPrice()) return true; else return false;
5823 }
5824
5825 Game.Upgrade.prototype.buy=function(bypass)
5826 {
5827 var success=0;
5828 var cancelPurchase=0;
5829 if (this.clickFunction && !bypass) cancelPurchase=!this.clickFunction();
5830 if (!cancelPurchase)
5831 {
5832 if (this.choicesFunction)
5833 {
5834 if (Game.choiceSelectorOn==this.id)
5835 {
5836 l('toggleBox').style.display='none';
5837 l('toggleBox').innerHTML='';
5838 Game.choiceSelectorOn=-1;
5839 PlaySound('snd/tick.mp3');
5840 }
5841 else
5842 {
5843 Game.choiceSelectorOn=this.id;
5844 var choices=this.choicesFunction();
5845 if (choices.length>0)
5846 {
5847 var selected=0;
5848 for (var i in choices) {if (choices[i].selected) selected=i;}
5849 Game.choiceSelectorChoices=choices;//this is a really dumb way of doing this i am so sorry
5850 Game.choiceSelectorSelected=selected;
5851 var str='';
5852 str+='<div class="close" onclick="Game.UpgradesById['+this.id+'].buy();">x</div>';
5853 str+='<h3>'+this.name+'</h3>'+
5854 '<div class="line"></div>'+
5855 '<h4 id="choiceSelectedName">'+choices[selected].name+'</h4>'+
5856 '<div class="line"></div>';
5857
5858 for (var i in choices)
5859 {
5860 var icon=choices[i].icon;
5861 str+='<div class="crate enabled'+(i==selected?' highlighted':'')+'" style="opacity:1;float:none;display:inline-block;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;" '+Game.clickStr+'="Game.UpgradesById['+this.id+'].choicesPick('+i+');PlaySound(\'snd/tick.mp3\');Game.choiceSelectorOn=-1;Game.UpgradesById['+this.id+'].buy();" onMouseOut="l(\'choiceSelectedName\').innerHTML=Game.choiceSelectorChoices[Game.choiceSelectorSelected].name;" onMouseOver="l(\'choiceSelectedName\').innerHTML=Game.choiceSelectorChoices['+i+'].name;"'+
5862 '></div>';
5863 }
5864 }
5865 l('toggleBox').innerHTML=str;
5866 l('toggleBox').style.display='block';
5867 l('toggleBox').focus();
5868 Game.tooltip.hide();
5869 PlaySound('snd/tick.mp3');
5870 success=1;
5871 }
5872 }
5873 else if (this.pool!='prestige')
5874 {
5875 var price=this.getPrice();
5876 if (this.canBuy() && !this.bought)
5877 {
5878 Game.Spend(price);
5879 this.bought=1;
5880 if (this.buyFunction) this.buyFunction();
5881 if (this.toggleInto)
5882 {
5883 Game.Lock(this.toggleInto);Game.Unlock(this.toggleInto);
5884 }
5885 Game.upgradesToRebuild=1;
5886 Game.recalculateGains=1;
5887 if (Game.CountsAsUpgradeOwned(this.pool)) Game.UpgradesOwned++;
5888 Game.setOnCrate(0);
5889 Game.tooltip.hide();
5890 PlaySound('snd/buy'+choose([1,2,3,4])+'.mp3',0.75);
5891 success=1;
5892 }
5893 }
5894 else
5895 {
5896 var price=this.getPrice();
5897 if (Game.heavenlyChips>=price && !this.bought)
5898 {
5899 Game.heavenlyChips-=price;
5900 Game.heavenlyChipsSpent+=price;
5901 this.unlocked=1;
5902 this.bought=1;
5903 if (this.buyFunction) this.buyFunction();
5904 Game.BuildAscendTree();
5905 PlaySound('snd/buy'+choose([1,2,3,4])+'.mp3',0.75);
5906 PlaySound('snd/shimmerClick.mp3');
5907 //PlaySound('snd/buyHeavenly.mp3');
5908 success=1;
5909 }
5910 }
5911 }
5912 if (this.bought && this.activateFunction) this.activateFunction();
5913 return success;
5914 }
5915 Game.Upgrade.prototype.earn=function()//just win the upgrades without spending anything
5916 {
5917 this.unlocked=1;
5918 this.bought=1;
5919 if (this.buyFunction) this.buyFunction();
5920 Game.upgradesToRebuild=1;
5921 Game.recalculateGains=1;
5922 if (Game.CountsAsUpgradeOwned(this.pool)) Game.UpgradesOwned++;
5923 }
5924 Game.Upgrade.prototype.unlock=function()
5925 {
5926 this.unlocked=1;
5927 Game.upgradesToRebuild=1;
5928 }
5929 Game.Upgrade.prototype.lose=function()
5930 {
5931 this.unlocked=0;
5932 this.bought=0;
5933 Game.upgradesToRebuild=1;
5934 Game.recalculateGains=1;
5935 if (Game.CountsAsUpgradeOwned(this.pool)) Game.UpgradesOwned--;
5936 }
5937 Game.Upgrade.prototype.toggle=function()//cheating only
5938 {
5939 if (!this.bought)
5940 {
5941 this.bought=1;
5942 if (this.buyFunction) this.buyFunction();
5943 Game.upgradesToRebuild=1;
5944 Game.recalculateGains=1;
5945 if (Game.CountsAsUpgradeOwned(this.pool)) Game.UpgradesOwned++;
5946 PlaySound('snd/buy'+choose([1,2,3,4])+'.mp3',0.75);
5947 if (this.pool=='prestige' || this.pool=='debug') PlaySound('snd/shimmerClick.mp3');
5948 }
5949 else
5950 {
5951 this.bought=0;
5952 Game.upgradesToRebuild=1;
5953 Game.recalculateGains=1;
5954 if (Game.CountsAsUpgradeOwned(this.pool)) Game.UpgradesOwned--;
5955 PlaySound('snd/sell'+choose([1,2,3,4])+'.mp3',0.75);
5956 if (this.pool=='prestige' || this.pool=='debug') PlaySound('snd/shimmerClick.mp3');
5957 }
5958 Game.UpdateMenu();
5959 }
5960
5961 Game.CountsAsUpgradeOwned=function(pool)
5962 {
5963 if (pool=='' || pool=='cookie' || pool=='tech') return true; else return false;
5964 }
5965
5966 /*AddEvent(l('toggleBox'),'blur',function()//if we click outside of the selector, close it
5967 {
5968 //this has a couple problems, such as when clicking on the upgrade - this toggles it off and back on instantly
5969 l('toggleBox').style.display='none';
5970 l('toggleBox').innerHTML='';
5971 Game.choiceSelectorOn=-1;
5972 }
5973 );*/
5974
5975 Game.RequiresConfirmation=function(upgrade,prompt)
5976 {
5977 upgrade.clickFunction=function(){Game.Prompt(prompt,[['Yes','Game.UpgradesById['+upgrade.id+'].buy(1);Game.ClosePrompt();'],'No']);return false;};
5978 }
5979
5980 Game.Unlock=function(what)
5981 {
5982 if (typeof what==='string')
5983 {
5984 if (Game.Upgrades[what])
5985 {
5986 if (Game.Upgrades[what].unlocked==0)
5987 {
5988 Game.Upgrades[what].unlocked=1;
5989 Game.upgradesToRebuild=1;
5990 Game.recalculateGains=1;
5991 /*if (Game.prefs.popups) {}
5992 else Game.Notify('Upgrade unlocked','<div class="title" style="font-size:18px;margin-top:-2px;">'+Game.Upgrades[what].name+'</div>',Game.Upgrades[what].icon,6);*/
5993 }
5994 }
5995 }
5996 else {for (var i in what) {Game.Unlock(what[i]);}}
5997 }
5998 Game.Lock=function(what)
5999 {
6000 if (typeof what==='string')
6001 {
6002 if (Game.Upgrades[what])
6003 {
6004 Game.Upgrades[what].unlocked=0;
6005 Game.upgradesToRebuild=1;
6006 if (Game.Upgrades[what].bought==1 && Game.CountsAsUpgradeOwned(Game.Upgrades[what].pool)) Game.UpgradesOwned--;
6007 Game.Upgrades[what].bought=0;
6008 Game.recalculateGains=1;
6009 }
6010 }
6011 else {for (var i in what) {Game.Lock(what[i]);}}
6012 }
6013
6014 Game.Has=function(what)
6015 {
6016 if (Game.ascensionMode==1 && Game.Upgrades[what].pool=='prestige') return 0;
6017 return (Game.Upgrades[what]?Game.Upgrades[what].bought:0);
6018 }
6019 Game.HasUnlocked=function(what)
6020 {
6021 return (Game.Upgrades[what]?Game.Upgrades[what].unlocked:0);
6022 }
6023
6024 Game.RebuildUpgrades=function()//recalculate the upgrades you can buy
6025 {
6026 Game.upgradesToRebuild=0;
6027 var list=[];
6028 for (var i in Game.Upgrades)
6029 {
6030 var me=Game.Upgrades[i];
6031 if (!me.bought && me.pool!='debug' && me.pool!='prestige' && me.pool!='prestigeDecor')
6032 {
6033 if (me.unlocked) list.push(me);
6034 }
6035 else if (me.displayFuncWhenOwned && me.bought) list.push(me);
6036 }
6037 var sortMap=function(a,b)
6038 {
6039 //if (a.pool=='toggle' || b.pool=='toggle') return 0;
6040 //var ap=a.getPrice();
6041 //var bp=b.getPrice();
6042 var ap=a.pool=='toggle'?0:a.getPrice();
6043 var bp=b.pool=='toggle'?0:b.getPrice();
6044 if (ap>bp) return 1;
6045 else if (ap<bp) return -1;
6046 else return 0;
6047 }
6048 list.sort(sortMap);
6049
6050 Game.UpgradesInStore=[];
6051 for (var i in list)
6052 {
6053 Game.UpgradesInStore.push(list[i]);
6054 }
6055 var storeStr='';
6056 var toggleStr='';
6057 var techStr='';
6058 for (var i in Game.UpgradesInStore)
6059 {
6060 //if (!Game.UpgradesInStore[i]) break;
6061 var me=Game.UpgradesInStore[i];
6062 var str=Game.crate(me,'store','Game.UpgradesById['+me.id+'].buy();','upgrade'+i);
6063
6064 /*var str='<div class="crate upgrade" '+Game.getTooltip(
6065 '<div style="min-width:200px;"><div style="float:right;"><span class="price">'+Beautify(Math.round(me.getPrice()))+'</span></div><small>'+(me.pool=='toggle'?'[Togglable]':'[Upgrade]')+'</small><div class="name">'+me.name+'</div><div class="line"></div><div class="description">'+me.desc+'</div></div>'
6066 ,'store')+' '+Game.clickStr+'="Game.UpgradesById['+me.id+'].buy();" id="upgrade'+i+'" style="'+(me.icon[2]?'background-image:url('+me.icon[2]+');':'')+'background-position:'+(-me.icon[0]*48)+'px '+(-me.icon[1]*48)+'px;"></div>';*/
6067 if (me.pool=='toggle') toggleStr+=str; else if (me.pool=='tech') techStr+=str; else storeStr+=str;
6068 }
6069 l('upgrades').innerHTML=storeStr;
6070 l('toggleUpgrades').innerHTML=toggleStr;
6071 if (toggleStr=='') l('toggleUpgrades').style.display='none'; else l('toggleUpgrades').style.display='block';
6072 l('techUpgrades').innerHTML=techStr;
6073 if (techStr=='') l('techUpgrades').style.display='none'; else l('techUpgrades').style.display='block';
6074 }
6075
6076 Game.UnlockAt=[];//this contains an array of every upgrade with a cookie requirement in the form of {cookies:(amount of cookies earned required),name:(name of upgrade or achievement to unlock)} (and possibly require:(name of upgrade of achievement to own))
6077 //note : the cookie will not be added to the list if it contains locked:1 (use for seasonal cookies and such)
6078
6079 Game.NewUpgradeCookie=function(obj)
6080 {
6081 var upgrade=new Game.Upgrade(obj.name,'Cookie production multiplier <b>+'+Beautify((typeof(obj.power)=='function'?obj.power(obj):obj.power),1)+'%</b>.<q>'+obj.desc+'</q>',obj.price,obj.icon);
6082 upgrade.power=obj.power;
6083 upgrade.pool='cookie';
6084 var toPush={cookies:obj.price/20,name:obj.name};
6085 if (obj.require) toPush.require=obj.require;
6086 if (obj.season) toPush.season=obj.season;
6087 if (!obj.locked) Game.UnlockAt.push(toPush);
6088 return upgrade;
6089 }
6090
6091 //tiered upgrades system
6092 //each building has several upgrade tiers
6093 //all upgrades in the same tier have the same color, unlock threshold and price multiplier
6094 Game.Tiers={
6095 1:{name:'Plain',unlock:1,achievUnlock:1,iconRow:0,color:'#ccb3ac',price: 10},
6096 2:{name:'Berrylium',unlock:5,achievUnlock:50,iconRow:1,color:'#ff89e7',price: 20},
6097 3:{name:'Blueberrylium',unlock:25,achievUnlock:100,iconRow:2,color:'#00deff',price: 200},
6098 4:{name:'Chalcedhoney',unlock:50,achievUnlock:150,iconRow:13,color:'#ffcc2f',price: 10000},
6099 5:{name:'Buttergold',unlock:100,achievUnlock:200,iconRow:14,color:'#e9d673',price: 1e7},
6100 6:{name:'Sugarmuck',unlock:150,achievUnlock:250,iconRow:15,color:'#a8bf91',price: 1e10},
6101 7:{name:'Jetmint',unlock:200,achievUnlock:300,iconRow:16,color:'#60ff50',price: 1e13},
6102 8:{name:'Cherrysilver',unlock:250,achievUnlock:350,iconRow:17,color:'#f01700',price: 1e16},
6103 9:{name:'Hazelrald',unlock:300,achievUnlock:400,iconRow:18,color:'#9ab834',price: 1e19},
6104 //10:{name:'Mooncandy',unlock:350,achievUnlock:450,iconRow:19,color:'#7e7ab9',price: 1e22},
6105 'synergy1':{name:'Synergy I',unlock:15,iconRow:20,color:'#008595',special:1,req:'Synergies Vol. I',price: 2000},
6106 'synergy2':{name:'Synergy II',unlock:75,iconRow:20,color:'#008595',special:1,req:'Synergies Vol. II',price: 2000000000},
6107 };
6108 Game.GetIcon=function(type,tier)
6109 {
6110 var col=0;
6111 if (type=='Kitten') col=18; else col=Game.Objects[type].iconColumn;
6112 return [col,Game.Tiers[tier].iconRow];
6113 }
6114 Game.SetTier=function(building,tier)
6115 {
6116 if (!Game.Objects[building]) alert('No building named '+building);
6117 Game.last.tier=tier;
6118 Game.last.buildingTie=Game.Objects[building];
6119 if (Game.last.type=='achievement') Game.Objects[building].tieredAchievs[tier]=Game.last;
6120 else Game.Objects[building].tieredUpgrades[tier]=Game.last;
6121 }
6122 Game.TieredUpgrade=function(name,desc,building,tier)
6123 {
6124 var upgrade=new Game.Upgrade(name,desc,Game.Objects[building].basePrice*Game.Tiers[tier].price,Game.GetIcon(building,tier));
6125 Game.SetTier(building,tier);
6126 return upgrade;
6127 }
6128 Game.SynergyUpgrade=function(name,desc,building1,building2,tier)
6129 {
6130 /*
6131 creates a new upgrade that :
6132 -unlocks when you have tier.unlock of building1 and building2
6133 -is priced at (building1.price*10+building2.price*1)*tier.price (formerly : Math.sqrt(building1.price*building2.price)*tier.price)
6134 -gives +(0.1*building1)% cps to building2 and +(5*building2)% cps to building1
6135 -if building2 is below building1 in worth, swap them
6136 */
6137 //if (Game.Objects[building1].basePrice>Game.Objects[building2].basePrice) {var temp=building2;building2=building1;building1=temp;}
6138 var b1=Game.Objects[building1];
6139 var b2=Game.Objects[building2];
6140 if (b1.basePrice>b2.basePrice) {b1=Game.Objects[building2];b2=Game.Objects[building1];}//swap
6141
6142 desc=
6143 (b1.plural.charAt(0).toUpperCase()+b1.plural.slice(1))+' gain <b>+5% CpS</b> per '+b2.name.toLowerCase()+'.<br>'+
6144 (b2.plural.charAt(0).toUpperCase()+b2.plural.slice(1))+' gain <b>+0.1% CpS</b> per '+b1.name.toLowerCase()+'.'+
6145 desc;
6146 var upgrade=new Game.Upgrade(name,desc,(b1.basePrice*10+b2.basePrice*1)*Game.Tiers[tier].price,Game.GetIcon(building1,tier));//Math.sqrt(b1.basePrice*b2.basePrice)*Game.Tiers[tier].price
6147 upgrade.tier=tier;
6148 upgrade.buildingTie1=b1;
6149 upgrade.buildingTie2=b2;
6150 upgrade.priceFunc=function(){return (this.buildingTie1.basePrice*10+this.buildingTie2.basePrice*1)*Game.Tiers[this.tier].price*(Game.Has('Chimera')?0.98:1);};
6151 Game.Objects[building1].synergies.push(upgrade);
6152 Game.Objects[building2].synergies.push(upgrade);
6153 //Game.SetTier(building1,tier);
6154 return upgrade;
6155 }
6156 Game.GetTieredCpsMult=function(me)
6157 {
6158 var mult=1;
6159 for (var i in me.tieredUpgrades) {if (!Game.Tiers[me.tieredUpgrades[i].tier].special && Game.Has(me.tieredUpgrades[i].name)) mult*=2;}
6160 for (var i in me.synergies)
6161 {
6162 var syn=me.synergies[i];
6163 if (Game.Has(syn.name))
6164 {
6165 if (syn.buildingTie1.name==me.name) mult*=(1+0.05*syn.buildingTie2.amount);
6166 else if (syn.buildingTie2.name==me.name) mult*=(1+0.001*syn.buildingTie1.amount);
6167 }
6168 }
6169 return mult;
6170 }
6171 Game.UnlockTiered=function(me)
6172 {
6173 for (var i in me.tieredUpgrades) {if (me.amount>=Game.Tiers[me.tieredUpgrades[i].tier].unlock) Game.Unlock(me.tieredUpgrades[i].name);}
6174 for (var i in me.tieredAchievs) {if (me.amount>=Game.Tiers[me.tieredAchievs[i].tier].achievUnlock) Game.Win(me.tieredAchievs[i].name);}
6175 for (var i in me.synergies) {var syn=me.synergies[i];if (Game.Has(Game.Tiers[syn.tier].req) && syn.buildingTie1.amount>=Game.Tiers[syn.tier].unlock && syn.buildingTie2.amount>=Game.Tiers[syn.tier].unlock) Game.Unlock(syn.name);}
6176 }
6177
6178
6179
6180 var pool='';
6181 var power=0;
6182
6183 //define upgrades
6184 //WARNING : do NOT add new upgrades in between, this breaks the saves. Add them at the end !
6185 var order=100;//this is used to set the order in which the items are listed
6186 new Game.Upgrade('Reinforced index finger','The mouse and cursors are <b>twice</b> as efficient.<q>prod prod</q>',100,[0,0]);
6187 new Game.Upgrade('Carpal tunnel prevention cream','The mouse and cursors are <b>twice</b> as efficient.<q>it... it hurts to click...</q>',500,[1,6]);
6188 new Game.Upgrade('Ambidextrous','The mouse and cursors are <b>twice</b> as efficient.<q>Look ma, both hands!</q>',1000,[0,1])
6189 new Game.Upgrade('Thousand fingers','The mouse and cursors gain <b>+0.1</b> cookies for each non-cursor object owned.<q>clickity</q>',5000,[12,1]);
6190 new Game.Upgrade('Million fingers','The mouse and cursors gain <b>+0.5</b> cookies for each non-cursor object owned.<q>clickityclickity</q>',10000,[0,2]);
6191 new Game.Upgrade('Billion fingers','The mouse and cursors gain <b>+2</b> cookies for each non-cursor object owned.<q>clickityclickityclickity</q>',50000,[12,2]);
6192 new Game.Upgrade('Trillion fingers','The mouse and cursors gain <b>+10</b> cookies for each non-cursor object owned.<q>clickityclickityclickityclickity</q>',100000,[0,13]);
6193
6194 order=200;
6195 new Game.TieredUpgrade('Forwards from grandma','Grandmas are <b>twice</b> as efficient.<q>RE:RE:thought you\'d get a kick out of this ;))</q>','Grandma',1);
6196 new Game.TieredUpgrade('Steel-plated rolling pins','Grandmas are <b>twice</b> as efficient.<q>Just what you kneaded.</q>','Grandma',2);
6197 new Game.TieredUpgrade('Lubricated dentures','Grandmas are <b>twice</b> as efficient.<q>squish</q>','Grandma',3);
6198
6199 order=300;
6200 new Game.TieredUpgrade('Cheap hoes','Farms are <b>twice</b> as efficient.<q>Rake in the dough!</q>','Farm',1);
6201 new Game.TieredUpgrade('Fertilizer','Farms are <b>twice</b> as efficient.<q>It\'s chocolate, I swear.</q>','Farm',2);
6202 new Game.TieredUpgrade('Cookie trees','Farms are <b>twice</b> as efficient.<q>A relative of the breadfruit.</q>','Farm',3);
6203
6204 order=500;
6205 new Game.TieredUpgrade('Sturdier conveyor belts','Factories are <b>twice</b> as efficient.<q>You\'re going places.</q>','Factory',1);
6206 new Game.TieredUpgrade('Child labor','Factories are <b>twice</b> as efficient.<q>Cheaper, healthier workforce.</q>','Factory',2);
6207 new Game.TieredUpgrade('Sweatshop','Factories are <b>twice</b> as efficient.<q>Slackers will be terminated.</q>','Factory',3);
6208
6209 order=400;
6210 new Game.TieredUpgrade('Sugar gas','Mines are <b>twice</b> as efficient.<q>A pink, volatile gas, found in the depths of some chocolate caves.</q>','Mine',1);
6211 new Game.TieredUpgrade('Megadrill','Mines are <b>twice</b> as efficient.<q>You\'re in deep.</q>','Mine',2);
6212 new Game.TieredUpgrade('Ultradrill','Mines are <b>twice</b> as efficient.<q>Finally caved in?</q>','Mine',3);
6213
6214 order=600;
6215 new Game.TieredUpgrade('Vanilla nebulae','Shipments are <b>twice</b> as efficient.<q>If you removed your space helmet, you could probably smell it!<br>(Note : don\'t do that.)</q>','Shipment',1);
6216 new Game.TieredUpgrade('Wormholes','Shipments are <b>twice</b> as efficient.<q>By using these as shortcuts, your ships can travel much faster.</q>','Shipment',2);
6217 new Game.TieredUpgrade('Frequent flyer','Shipments are <b>twice</b> as efficient.<q>Come back soon!</q>','Shipment',3);
6218
6219 order=700;
6220 new Game.TieredUpgrade('Antimony','Alchemy labs are <b>twice</b> as efficient.<q>Actually worth a lot of mony.</q>','Alchemy lab',1);
6221 new Game.TieredUpgrade('Essence of dough','Alchemy labs are <b>twice</b> as efficient.<q>Extracted through the 5 ancient steps of alchemical baking.</q>','Alchemy lab',2);
6222 new Game.TieredUpgrade('True chocolate','Alchemy labs are <b>twice</b> as efficient.<q>The purest form of cacao.</q>','Alchemy lab',3);
6223
6224 order=800;
6225 new Game.TieredUpgrade('Ancient tablet','Portals are <b>twice</b> as efficient.<q>A strange slab of peanut brittle, holding an ancient cookie recipe. Neat!</q>','Portal',1);
6226 new Game.TieredUpgrade('Insane oatling workers','Portals are <b>twice</b> as efficient.<q>ARISE, MY MINIONS!</q>','Portal',2);
6227 new Game.TieredUpgrade('Soul bond','Portals are <b>twice</b> as efficient.<q>So I just sign up and get more cookies? Sure, whatever!</q>','Portal',3);
6228
6229 order=900;
6230 new Game.TieredUpgrade('Flux capacitors','Time machines are <b>twice</b> as efficient.<q>Bake to the future.</q>','Time machine',1);
6231 new Game.TieredUpgrade('Time paradox resolver','Time machines are <b>twice</b> as efficient.<q>No more fooling around with your own grandmother!</q>','Time machine',2);
6232 new Game.TieredUpgrade('Quantum conundrum','Time machines are <b>twice</b> as efficient.<q>There is only one constant, and that is universal uncertainty.<br>Or is it?</q>','Time machine',3);
6233
6234 order=20000;
6235 new Game.Upgrade('Kitten helpers','You gain <b>more CpS</b> the more milk you have.<q>meow may I help you</q>',900000000,Game.GetIcon('Kitten',1));Game.last.kitten=1;
6236 new Game.Upgrade('Kitten workers','You gain <b>more CpS</b> the more milk you have.<q>meow meow meow meow</q>',900000000000,Game.GetIcon('Kitten',2));Game.last.kitten=1;
6237
6238 order=10000;
6239 Game.NewUpgradeCookie({name:'Plain cookies',desc:'Meh.',icon:[2,3],power: 1, price: 999999});
6240 Game.NewUpgradeCookie({name:'Sugar cookies',desc:'Tasty, if a little unimaginative.',icon:[7,3],power: 1, price: 999999*5});
6241 Game.NewUpgradeCookie({name:'Oatmeal raisin cookies',desc:'No raisin to hate these.',icon:[0,3],power: 1, price: 9999999});
6242 Game.NewUpgradeCookie({name:'Peanut butter cookies',desc:'Get yourself some jam cookies!',icon:[1,3],power: 1, price: 9999999*5});
6243 Game.NewUpgradeCookie({name:'Coconut cookies',desc:'These are *way* flaky.',icon:[3,3],power: 1, price: 99999999});
6244 Game.NewUpgradeCookie({name:'White chocolate cookies',desc:'I know what you\'ll say. It\'s just cocoa butter! It\'s not real chocolate!<br>Oh please.',icon:[4,3],power:2, price: 99999999*5});
6245 Game.NewUpgradeCookie({name:'Macadamia nut cookies',desc:'They\'re macadamn delicious!',icon:[5,3],power: 2, price: 999999999});
6246 Game.NewUpgradeCookie({name:'Double-chip cookies',desc:'DOUBLE THE CHIPS<br>DOUBLE THE TASTY<br>(double the calories)',icon:[6,3],power:2, price: 999999999*5});
6247 Game.NewUpgradeCookie({name:'White chocolate macadamia nut cookies',desc:'Orteil\'s favorite.',icon:[8,3],power: 2, price: 9999999999});
6248 Game.NewUpgradeCookie({name:'All-chocolate cookies',desc:'CHOCOVERDOSE.',icon:[9,3],power: 2, price: 9999999999*5});
6249
6250 order=100;
6251 new Game.Upgrade('Quadrillion fingers','The mouse and cursors gain <b>+50</b> cookies for each non-cursor object owned.<q>clickityclickityclickityclickityclick</q>',10000000,[12,13]);
6252
6253 order=200;new Game.TieredUpgrade('Prune juice','Grandmas are <b>twice</b> as efficient.<q>Gets me going.</q>','Grandma',4);
6254 order=300;new Game.TieredUpgrade('Genetically-modified cookies','Farms are <b>twice</b> as efficient.<q>All-natural mutations.</q>','Farm',4);
6255 order=500;new Game.TieredUpgrade('Radium reactors','Factories are <b>twice</b> as efficient.<q>Gives your cookies a healthy glow.</q>','Factory',4);
6256 order=400;new Game.TieredUpgrade('Ultimadrill','Mines are <b>twice</b> as efficient.<q>Pierce the heavens, etc.</q>','Mine',4);
6257 order=600;new Game.TieredUpgrade('Warp drive','Shipments are <b>twice</b> as efficient.<q>To boldly bake.</q>','Shipment',4);
6258 order=700;new Game.TieredUpgrade('Ambrosia','Alchemy labs are <b>twice</b> as efficient.<q>Adding this to the cookie mix is sure to make them even more addictive!<br>Perhaps dangerously so.<br>Let\'s hope you can keep selling these legally.</q>','Alchemy lab',4);
6259 order=800;new Game.TieredUpgrade('Sanity dance','Portals are <b>twice</b> as efficient.<q>We can change if we want to.<br>We can leave our brains behind.</q>','Portal',4);
6260 order=900;new Game.TieredUpgrade('Causality enforcer','Time machines are <b>twice</b> as efficient.<q>What happened, happened.</q>','Time machine',4);
6261
6262 order=5000;
6263 new Game.Upgrade('Lucky day','Golden cookies appear <b>twice as often</b> and stay <b>twice as long</b>.<q>Oh hey, a four-leaf penny!</q>',777777777,[27,6]);
6264 new Game.Upgrade('Serendipity','Golden cookies appear <b>twice as often</b> and stay <b>twice as long</b>.<q>What joy! Seven horseshoes!</q>',77777777777,[27,6]);
6265
6266 order=20000;
6267 new Game.Upgrade('Kitten engineers','You gain <b>more CpS</b> the more milk you have.<q>meow meow meow meow, sir</q>',9e+14,Game.GetIcon('Kitten',3));Game.last.kitten=1;
6268
6269 order=10020;
6270 Game.NewUpgradeCookie({name:'Dark chocolate-coated cookies',desc:'These absorb light so well you almost need to squint to see them.',icon:[10,3],power: 4, price: 99999999999});
6271 Game.NewUpgradeCookie({name:'White chocolate-coated cookies',desc:'These dazzling cookies absolutely glisten with flavor.',icon:[11,3],power: 4, price: 99999999999});
6272
6273
6274 Game.getGrandmaSynergyUpgradeMultiplier=function(building)
6275 {
6276 return (1+Game.Objects['Grandma'].amount*0.01*(1/(Game.Objects[building].id-1)));
6277 }
6278 Game.getGrandmaSynergyUpgradeDesc=function(building)
6279 {
6280 var building=Game.Objects[building];
6281 var grandmaNumber=(building.id-1);
6282 if (grandmaNumber==1) grandmaNumber='grandma';
6283 else grandmaNumber+=' grandmas';
6284 return 'Grandmas are <b>twice</b> as efficient. '+(building.plural.charAt(0).toUpperCase()+building.plural.slice(1))+' gain <b>+1% CpS</b> per '+grandmaNumber+'.';
6285 }
6286
6287 order=250;
6288 new Game.Upgrade('Farmer grandmas',Game.getGrandmaSynergyUpgradeDesc('Farm')+'<q>A nice farmer to grow more cookies.</q>',Game.Objects['Farm'].basePrice*Game.Tiers[2].price,[10,9],function(){Game.Objects['Grandma'].redraw();});
6289 new Game.Upgrade('Miner grandmas',Game.getGrandmaSynergyUpgradeDesc('Mine')+'<q>A nice miner to dig more cookies.</q>',Game.Objects['Mine'].basePrice*Game.Tiers[2].price,[10,9],function(){Game.Objects['Grandma'].redraw();});
6290 new Game.Upgrade('Worker grandmas',Game.getGrandmaSynergyUpgradeDesc('Factory')+'<q>A nice worker to manufacture more cookies.</q>',Game.Objects['Factory'].basePrice*Game.Tiers[2].price,[10,9],function(){Game.Objects['Grandma'].redraw();});
6291 order=255;
6292 new Game.Upgrade('Cosmic grandmas',Game.getGrandmaSynergyUpgradeDesc('Shipment')+'<q>A nice thing to... uh... cookies.</q>',Game.Objects['Shipment'].basePrice*Game.Tiers[2].price,[10,9],function(){Game.Objects['Grandma'].redraw();});
6293 new Game.Upgrade('Transmuted grandmas',Game.getGrandmaSynergyUpgradeDesc('Alchemy lab')+'<q>A nice golden grandma to convert into more cookies.</q>',Game.Objects['Alchemy lab'].basePrice*Game.Tiers[2].price,[10,9],function(){Game.Objects['Grandma'].redraw();});
6294 new Game.Upgrade('Altered grandmas',Game.getGrandmaSynergyUpgradeDesc('Portal')+'<q>a NiCe GrAnDmA tO bA##########</q>',Game.Objects['Portal'].basePrice*Game.Tiers[2].price,[10,9],function(){Game.Objects['Grandma'].redraw();});
6295 new Game.Upgrade('Grandmas\' grandmas',Game.getGrandmaSynergyUpgradeDesc('Time machine')+'<q>A nice grandma\'s nice grandma to bake double the cookies.</q>',Game.Objects['Time machine'].basePrice*Game.Tiers[2].price,[10,9],function(){Game.Objects['Grandma'].redraw();});
6296
6297 order=14000;
6298 Game.baseResearchTime=Game.fps*60*30;
6299 Game.SetResearch=function(what,time)
6300 {
6301 if (Game.Upgrades[what])
6302 {
6303 Game.researchT=Game.baseResearchTime;
6304 if (Game.Has('Persistent memory')) Game.researchT=Math.ceil(Game.baseResearchTime/10);
6305 if (Game.Has('Ultrascience')) Game.researchT=Game.fps*5;
6306 Game.nextResearch=Game.Upgrades[what].id;
6307 if (Game.prefs.popups) Game.Popup('Research has begun.');
6308 else Game.Notify('Research has begun','Your bingo center/research facility is conducting experiments.',[9,0]);
6309 }
6310 }
6311
6312 new Game.Upgrade('Bingo center/Research facility','Grandma-operated science lab and leisure club.<br>Grandmas are <b>4 times</b> as efficient.<br><b>Regularly unlocks new upgrades</b>.<q>What could possibly keep those grandmothers in check?...<br>Bingo.</q>',1e15,[11,9],function(){Game.SetResearch('Specialized chocolate chips');});Game.last.noPerm=1;
6313
6314 order=15000;
6315
6316 new Game.Upgrade('Specialized chocolate chips','Cookie production multiplier <b>+1%</b>.<q>Computer-designed chocolate chips. Computer chips, if you will.</q>',1e14,[0,9],function(){Game.SetResearch('Designer cocoa beans');});Game.last.pool='tech';
6317 new Game.Upgrade('Designer cocoa beans','Cookie production multiplier <b>+2%</b>.<q>Now more aerodynamic than ever!</q>',2e14,[1,9],function(){Game.SetResearch('Ritual rolling pins');});Game.last.pool='tech';
6318 new Game.Upgrade('Ritual rolling pins','Grandmas are <b>twice</b> as efficient.<q>The result of years of scientific research!</q>',4e14,[2,9],function(){Game.SetResearch('Underworld ovens');});Game.last.pool='tech';
6319 new Game.Upgrade('Underworld ovens','Cookie production multiplier <b>+3%</b>.<q>Powered by science, of course!</q>',8e14,[3,9],function(){Game.SetResearch('One mind');});Game.last.pool='tech';
6320 new Game.Upgrade('One mind','Each grandma gains <b>+0.0<span></span>2 base CpS per grandma</b>.<div class="warning">Note : the grandmothers are growing restless. Do not encourage them.</div><q>We are one. We are many.</q>',1.6e15,[4,9],function(){Game.elderWrath=1;Game.SetResearch('Exotic nuts');Game.storeToRefresh=1;});Game.last.pool='tech';
6321 //Game.last.clickFunction=function(){return confirm('Warning : purchasing this will have unexpected, and potentially undesirable results!\nIt\'s all downhill from here. You have been warned!\nPurchase anyway?');};
6322 Game.RequiresConfirmation(Game.last,'<div class="block"><b>Warning :</b> purchasing this will have unexpected, and potentially undesirable results!<br><small>It\'s all downhill from here. You have been warned!</small><br><br>Purchase anyway?</small></div>');
6323 new Game.Upgrade('Exotic nuts','Cookie production multiplier <b>+4%</b>.<q>You\'ll go crazy over these!</q>',3.2e15,[5,9],function(){Game.SetResearch('Communal brainsweep');});Game.last.pool='tech';
6324 new Game.Upgrade('Communal brainsweep','Each grandma gains another <b>+0.0<span></span>2 base CpS per grandma</b>.<div class="warning">Note : proceeding any further in scientific research may have unexpected results. You have been warned.</div><q>We fuse. We merge. We grow.</q>',6.4e15,[6,9],function(){Game.elderWrath=2;Game.SetResearch('Arcane sugar');Game.storeToRefresh=1;});Game.last.pool='tech';
6325 new Game.Upgrade('Arcane sugar','Cookie production multiplier <b>+5%</b>.<q>Tastes like insects, ligaments, and molasses.</q>',1.28e16,[7,9],function(){Game.SetResearch('Elder Pact');});Game.last.pool='tech';
6326 new Game.Upgrade('Elder Pact','Each grandma gains <b>+0.0<span></span>5 base CpS per portal</b>.<div class="warning">Note : this is a bad idea.</div><q>squirm crawl slither writhe<br>today we rise</q>',2.56e16,[8,9],function(){Game.elderWrath=3;Game.storeToRefresh=1;});Game.last.pool='tech';
6327 new Game.Upgrade('Elder Pledge','Contains the wrath of the elders, at least for a while.<q>This is a simple ritual involving anti-aging cream, cookie batter mixed in the moonlight, and a live chicken.</q>',1,[9,9],function()
6328 {
6329 Game.elderWrath=0;
6330 Game.pledges++;
6331 Game.pledgeT=Game.getPledgeDuration();
6332 Game.Unlock('Elder Covenant');
6333 Game.CollectWrinklers();
6334 Game.storeToRefresh=1;
6335 });
6336 Game.getPledgeDuration=function(){return Game.fps*60*(Game.Has('Sacrificial rolling pins')?60:30);}
6337 Game.last.pool='toggle';
6338 Game.last.displayFuncWhenOwned=function(){return '<div style="text-align:center;">Time remaining until pledge runs out :<br><b>'+Game.sayTime(Game.pledgeT)+'</b></div>';}
6339 Game.last.timerDisplay=function(){if (!Game.Upgrades['Elder Pledge'].bought) return -1; else return 1-Game.pledgeT/Game.getPledgeDuration();}
6340 Game.last.priceFunc=function(){return Math.pow(8,Math.min(Game.pledges+2,20));}
6341
6342 order=150;
6343 new Game.Upgrade('Plastic mouse','Clicking gains <b>+1% of your CpS</b>.<q>Slightly squeaky.</q>',50000,[11,0]);
6344 new Game.Upgrade('Iron mouse','Clicking gains <b>+1% of your CpS</b>.<q>Click like it\'s 1349!</q>',5000000,[11,1]);
6345 new Game.Upgrade('Titanium mouse','Clicking gains <b>+1% of your CpS</b>.<q>Heavy, but powerful.</q>',500000000,[11,2]);
6346 new Game.Upgrade('Adamantium mouse','Clicking gains <b>+1% of your CpS</b>.<q>You could cut diamond with these.</q>',50000000000,[11,13]);
6347
6348 order=40000;
6349 new Game.Upgrade('Ultrascience','Research takes only <b>5 seconds</b>.<q>YEAH, SCIENCE!</q>',7,[9,2]);//debug purposes only
6350 Game.last.pool='debug';
6351
6352 order=10020;
6353 Game.NewUpgradeCookie({name:'Eclipse cookies',desc:'Look to the cookie.',icon:[0,4],power: 2, price: 99999999999*5});
6354 Game.NewUpgradeCookie({name:'Zebra cookies',desc:'...',icon:[1,4],power: 2, price: 999999999999});
6355
6356 order=100;
6357 new Game.Upgrade('Quintillion fingers','The mouse and cursors gain <b>+200</b> cookies for each non-cursor object owned.<q>man, just go click click click click click, it\'s real easy, man.</q>',100000000,[0,14]);
6358
6359 order=40000;
6360 new Game.Upgrade('Gold hoard','Golden cookies appear <b>really often</b>.<q>That\'s entirely too many.</q>',7,[10,14]);//debug purposes only
6361 Game.last.pool='debug';
6362
6363 order=15000;
6364 new Game.Upgrade('Elder Covenant','Puts a permanent end to the elders\' wrath, at the price of 5% of your CpS.<q>This is a complicated ritual involving silly, inconsequential trivialities such as cursed laxatives, century-old cacao, and an infant.<br>Don\'t question it.</q>',66666666666666,[8,9],function()
6365 {
6366 Game.pledgeT=0;
6367 Game.Lock('Revoke Elder Covenant');
6368 Game.Unlock('Revoke Elder Covenant');
6369 Game.Lock('Elder Pledge');
6370 Game.Win('Elder calm');
6371 Game.CollectWrinklers();
6372 Game.storeToRefresh=1;
6373 });
6374 Game.last.pool='toggle';
6375
6376 new Game.Upgrade('Revoke Elder Covenant','You will get 5% of your CpS back, but the grandmatriarchs will return.<q>we<br>rise<br>again</q>',6666666666,[8,9],function()
6377 {
6378 Game.Lock('Elder Covenant');
6379 Game.Unlock('Elder Covenant');
6380 });
6381 Game.last.pool='toggle';
6382
6383 order=5000;
6384 new Game.Upgrade('Get lucky','Golden cookie effects last <b>twice as long</b>.<q>You\'ve been up all night, haven\'t you?</q>',77777777777777,[27,6]);
6385
6386 order=15000;
6387 new Game.Upgrade('Sacrificial rolling pins','Elder pledges last <b>twice</b> as long.<q>These are mostly just for spreading the anti-aging cream.<br>(And accessorily, shortening the chicken\'s suffering.)</q>',2888888888888,[2,9]);
6388
6389 order=10020;
6390 Game.NewUpgradeCookie({name:'Snickerdoodles',desc:'True to their name.',icon:[2,4],power: 2, price: 999999999999*5});
6391 Game.NewUpgradeCookie({name:'Stroopwafels',desc:'If it ain\'t dutch, it ain\'t much.',icon:[3,4],power: 2, price: 9999999999999});
6392 Game.NewUpgradeCookie({name:'Macaroons',desc:'Not to be confused with macarons.<br>These have coconut, okay?',icon:[4,4],power: 2, price: 9999999999999*5});
6393
6394 order=40000;
6395 new Game.Upgrade('Neuromancy','Can toggle upgrades on and off at will in the stats menu.<q>Can also come in handy to unsee things that can\'t be unseen.</q>',7,[4,9]);//debug purposes only
6396 Game.last.pool='debug';
6397
6398 order=10030;
6399 Game.NewUpgradeCookie({name:'Empire biscuits',desc:'For your growing cookie empire, of course!',icon:[5,4],power: 2, price: 99999999999999});
6400 Game.NewUpgradeCookie({name:'British tea biscuits',desc:'Quite.',icon:[6,4],require:'Tin of british tea biscuits',power: 2, price: 99999999999999});
6401 Game.NewUpgradeCookie({name:'Chocolate british tea biscuits',desc:'Yes, quite.',icon:[7,4],require:Game.last.name,power: 2, price: 99999999999999});
6402 Game.NewUpgradeCookie({name:'Round british tea biscuits',desc:'Yes, quite riveting.',icon:[8,4],require:Game.last.name,power: 2, price: 99999999999999});
6403 Game.NewUpgradeCookie({name:'Round chocolate british tea biscuits',desc:'Yes, quite riveting indeed.',icon:[9,4],require:Game.last.name,power: 2, price: 99999999999999});
6404 Game.NewUpgradeCookie({name:'Round british tea biscuits with heart motif',desc:'Yes, quite riveting, old chap.',icon:[10,4],require:Game.last.name,power: 2, price: 99999999999999});
6405 Game.NewUpgradeCookie({name:'Round chocolate british tea biscuits with heart motif',desc:'I like cookies.',icon:[11,4],require:Game.last.name,power: 2, price: 99999999999999});
6406
6407 order=1000;
6408 new Game.TieredUpgrade('Sugar bosons','Antimatter condensers are <b>twice</b> as efficient.<q>Sweet firm bosons.</q>','Antimatter condenser',1);
6409 new Game.TieredUpgrade('String theory','Antimatter condensers are <b>twice</b> as efficient.<q>Reveals new insight about the true meaning of baking cookies (and, as a bonus, the structure of the universe).</q>','Antimatter condenser',2);
6410 new Game.TieredUpgrade('Large macaron collider','Antimatter condensers are <b>twice</b> as efficient.<q>How singular!</q>','Antimatter condenser',3);
6411 new Game.TieredUpgrade('Big bang bake','Antimatter condensers are <b>twice</b> as efficient.<q>And that\'s how it all began.</q>','Antimatter condenser',4);
6412
6413 order=255;
6414 new Game.Upgrade('Antigrandmas',Game.getGrandmaSynergyUpgradeDesc('Antimatter condenser')+'<q>A mean antigrandma to vomit more cookies.<br>(Do not put in contact with normal grandmas; loss of matter may occur.)</q>',Game.Objects['Antimatter condenser'].basePrice*Game.Tiers[2].price,[10,9],function(){Game.Objects['Grandma'].redraw();});
6415
6416 order=10020;
6417 Game.NewUpgradeCookie({name:'Madeleines',desc:'Unforgettable!',icon:[12,3],power: 2, price: 99999999999999*5});
6418 Game.NewUpgradeCookie({name:'Palmiers',desc:'Palmier than you!',icon:[13,3],power: 2, price: 99999999999999*5});
6419 Game.NewUpgradeCookie({name:'Palets',desc:'You could probably play hockey with these.<br>I mean, you\'re welcome to try.',icon:[12,4],power: 2, price: 999999999999999});
6420 Game.NewUpgradeCookie({name:'Sablés',desc:'The name implies they\'re made of sand. But you know better, don\'t you?',icon:[13,4],power: 2, price: 999999999999999});
6421
6422 order=20000;
6423 new Game.Upgrade('Kitten overseers','You gain <b>more CpS</b> the more milk you have.<q>my purrpose is to serve you, sir</q>',9e+17,Game.GetIcon('Kitten',4));Game.last.kitten=1;
6424
6425
6426 order=100;
6427 new Game.Upgrade('Sextillion fingers','The mouse and cursors gain <b>+1000</b> cookies for each non-cursor object owned.<q>sometimes<br>things just<br>click</q>',10000000000,[12,14]);
6428
6429 order=200;new Game.TieredUpgrade('Double-thick glasses','Grandmas are <b>twice</b> as efficient.<q>Oh... so THAT\'s what I\'ve been baking.</q>','Grandma',5);
6430 order=300;new Game.TieredUpgrade('Gingerbread scarecrows','Farms are <b>twice</b> as efficient.<q>Staring at your crops with mischievous glee.</q>','Farm',5);
6431 order=500;new Game.TieredUpgrade('Recombobulators','Factories are <b>twice</b> as efficient.<q>A major part of cookie recombobulation.</q>','Factory',5);
6432 order=400;new Game.TieredUpgrade('H-bomb mining','Mines are <b>twice</b> as efficient.<q>Questionable efficiency, but spectacular nonetheless.</q>','Mine',5);
6433 order=600;new Game.TieredUpgrade('Chocolate monoliths','Shipments are <b>twice</b> as efficient.<q>My god. It\'s full of chocolate bars.</q>','Shipment',5);
6434 order=700;new Game.TieredUpgrade('Aqua crustulae','Alchemy labs are <b>twice</b> as efficient.<q>Careful with the dosing - one drop too much and you get muffins.<br>And nobody likes muffins.</q>','Alchemy lab',5);
6435 order=800;new Game.TieredUpgrade('Brane transplant','Portals are <b>twice</b> as efficient.<q>This refers to the practice of merging higher dimensional universes, or "branes", with our own, in order to facilitate transit (and harvesting of precious cookie dough).</q>','Portal',5);
6436 order=900;new Game.TieredUpgrade('Yestermorrow comparators','Time machines are <b>twice</b> as efficient.<q>Fortnights into milleniums.</q>','Time machine',5);
6437 order=1000;new Game.TieredUpgrade('Reverse cyclotrons','Antimatter condensers are <b>twice</b> as efficient.<q>These can uncollision particles and unspin atoms. For... uh... better flavor, and stuff.</q>','Antimatter condenser',5);
6438
6439 order=150;
6440 new Game.Upgrade('Unobtainium mouse','Clicking gains <b>+1% of your CpS</b>.<q>These nice mice should suffice.</q>',5000000000000,[11,14]);
6441
6442 order=10020;
6443 Game.NewUpgradeCookie({name:'Caramoas',desc:'Yeah. That\'s got a nice ring to it.',icon:[14,4],require:'Box of brand biscuits',power: 3, price: 9999999999999999});
6444 Game.NewUpgradeCookie({name:'Sagalongs',desc:'Grandma\'s favorite?',icon:[15,3],require:'Box of brand biscuits',power: 3, price: 9999999999999999});
6445 Game.NewUpgradeCookie({name:'Shortfoils',desc:'Foiled again!',icon:[15,4],require:'Box of brand biscuits',power: 3, price: 9999999999999999});
6446 Game.NewUpgradeCookie({name:'Win mints',desc:'They\'re the luckiest cookies you\'ve ever tasted!',icon:[14,3],require:'Box of brand biscuits',power: 3, price: 9999999999999999});
6447
6448 order=40000;
6449 new Game.Upgrade('Perfect idling','You keep producing cookies even while the game is closed.<q>It\'s the most beautiful thing I\'ve ever seen.</q>',7,[10,0]);//debug purposes only
6450 Game.last.pool='debug';
6451
6452 order=10030;
6453 Game.NewUpgradeCookie({name:'Fig gluttons',desc:'Got it all figured out.',icon:[17,4],require:'Box of brand biscuits',power: 2, price: 999999999999999*5});
6454 Game.NewUpgradeCookie({name:'Loreols',desc:'Because, uh... they\'re worth it?',icon:[16,3],require:'Box of brand biscuits',power: 2, price: 999999999999999*5});
6455 Game.NewUpgradeCookie({name:'Jaffa cakes',desc:'If you want to bake a cookie from scratch, you must first build a factory.',icon:[17,3],require:'Box of brand biscuits',power: 2, price: 999999999999999*5});
6456 Game.NewUpgradeCookie({name:'Grease\'s cups',desc:'Extra-greasy peanut butter.',icon:[16,4],require:'Box of brand biscuits',power: 2, price: 999999999999999*5});
6457
6458 order=30000;
6459 new Game.Upgrade('Heavenly chip secret','Unlocks <b>5%</b> of the potential of your prestige level.<q>Grants the knowledge of heavenly chips, and how to use them to make baking more efficient.<br>It\'s a secret to everyone.</q>',11,[19,7]);Game.last.noPerm=1;
6460 new Game.Upgrade('Heavenly cookie stand','Unlocks <b>25%</b> of the potential of your prestige level.<q>Don\'t forget to visit the heavenly lemonade stand afterwards. When afterlife gives you lemons...</q>',1111,[18,7]);Game.last.noPerm=1;
6461 new Game.Upgrade('Heavenly bakery','Unlocks <b>50%</b> of the potential of your prestige level.<q>Also sells godly cakes and divine pastries. The pretzels aren\'t too bad either.</q>',111111,[17,7]);Game.last.noPerm=1;
6462 new Game.Upgrade('Heavenly confectionery','Unlocks <b>75%</b> of the potential of your prestige level.<q>They say angel bakers work there. They take angel lunch breaks and sometimes go on angel strikes.</q>',11111111,[16,7]);Game.last.noPerm=1;
6463 new Game.Upgrade('Heavenly key','Unlocks <b>100%</b> of the potential of your prestige level.<q>This is the key to the pearly (and tasty) gates of pastry heaven, granting you access to your entire stockpile of heavenly chips for baking purposes.<br>May you use them wisely.</q>',1111111111,[15,7]);Game.last.noPerm=1;
6464
6465 order=10100;
6466 Game.NewUpgradeCookie({name:'Skull cookies',desc:'Wanna know something spooky? You\'ve got one of these inside your head RIGHT NOW.',locked:1,icon:[12,8],power: 2, price: 444444444444});
6467 Game.NewUpgradeCookie({name:'Ghost cookies',desc:'They\'re something strange, but they look pretty good!',locked:1,icon:[13,8],power: 2, price: 444444444444});
6468 Game.NewUpgradeCookie({name:'Bat cookies',desc:'The cookies this town deserves.',locked:1,icon:[14,8],power: 2, price: 444444444444});
6469 Game.NewUpgradeCookie({name:'Slime cookies',desc:'The incredible melting cookies!',locked:1,icon:[15,8],power: 2, price: 444444444444});
6470 Game.NewUpgradeCookie({name:'Pumpkin cookies',desc:'Not even pumpkin-flavored. Tastes like glazing. Yeugh.',locked:1,icon:[16,8],power: 2, price: 444444444444});
6471 Game.NewUpgradeCookie({name:'Eyeball cookies',desc:'When you stare into the cookie, the cookie stares back at you.',locked:1,icon:[17,8],power: 2, price: 444444444444});
6472 Game.NewUpgradeCookie({name:'Spider cookies',desc:'You found the recipe on the web. They do whatever a cookie can.',locked:1,icon:[18,8],power: 2, price: 444444444444});
6473
6474 order=0;
6475 new Game.Upgrade('Persistent memory','Subsequent research will be <b>10 times</b> as fast.<q>It\'s all making sense!<br>Again!</q>',5,[9,2]);Game.last.pool='prestige';
6476
6477 order=40000;
6478 new Game.Upgrade('Wrinkler doormat','Wrinklers spawn much more frequently.<q>You\'re such a pushover.</q>',7,[19,8]);//debug purposes only
6479 Game.last.pool='debug';
6480
6481 order=10200;
6482 Game.NewUpgradeCookie({name:'Christmas tree biscuits',desc:'Whose pine is it anyway?',locked:1,icon:[12,10],power:2,price: 252525252525});
6483 Game.NewUpgradeCookie({name:'Snowflake biscuits',desc:'Mass-produced to be unique in every way.',locked:1,icon:[13,10],power:2,price: 252525252525});
6484 Game.NewUpgradeCookie({name:'Snowman biscuits',desc:'It\'s frosted. Doubly so.',locked:1,icon:[14,10],power:2,price: 252525252525});
6485 Game.NewUpgradeCookie({name:'Holly biscuits',desc:'You don\'t smooch under these ones. That would be the mistletoe (which, botanically, is a smellier variant of the mistlefinger).',locked:1,icon:[15,10],power:2,price: 252525252525});
6486 Game.NewUpgradeCookie({name:'Candy cane biscuits',desc:'It\'s two treats in one!<br>(Further inspection reveals the frosting does not actually taste like peppermint, but like mundane sugary frosting.)',locked:1,icon:[16,10],power:2,price: 252525252525});
6487 Game.NewUpgradeCookie({name:'Bell biscuits',desc:'What do these even have to do with christmas? Who cares, ring them in!',locked:1,icon:[17,10],power:2,price: 252525252525});
6488 Game.NewUpgradeCookie({name:'Present biscuits',desc:'The prequel to future biscuits. Watch out!',locked:1,icon:[18,10],power:2,price: 252525252525});
6489
6490 order=10020;
6491 Game.NewUpgradeCookie({name:'Gingerbread men',desc:'You like to bite the legs off first, right? How about tearing off the arms? You sick monster.',icon:[18,4],power: 2,price: 9999999999999999});
6492 Game.NewUpgradeCookie({name:'Gingerbread trees',desc:'Evergreens in pastry form. Yule be surprised what you can come up with.',icon:[18,3],power: 2,price: 9999999999999999});
6493
6494 order=25000;
6495 new Game.Upgrade('A festive hat','<b>Unlocks... something.</b><q>Not a creature was stirring, not even a mouse.</q>',25,[19,9],function()
6496 {
6497 var drop=choose(Game.santaDrops);
6498 Game.Unlock(drop);
6499 if (Game.prefs.popups) Game.Popup('In the festive hat, you find...<br>a festive test tube<br>and '+drop+'.');
6500 else Game.Notify('In the festive hat, you find...','a festive test tube<br>and <b>'+drop+'</b>.',Game.Upgrades[drop].icon);
6501 });
6502
6503 new Game.Upgrade('Increased merriness','Cookie production multiplier <b>+15%</b>.<br>Cost scales with Santa level.<q>It turns out that the key to increased merriness, strangely enough, happens to be a good campfire and some s\'mores.<br>You know what they say, after all; the s\'more, the merrier.</q>',2525,[17,9]);
6504 new Game.Upgrade('Improved jolliness','Cookie production multiplier <b>+15%</b>.<br>Cost scales with Santa level.<q>A nice wobbly belly goes a long way.<br>You jolly?</q>',2525,[17,9]);
6505 new Game.Upgrade('A lump of coal','Cookie production multiplier <b>+1%</b>.<br>Cost scales with Santa level.<q>Some of the world\'s worst stocking stuffing.<br>I guess you could try starting your own little industrial revolution, or something?...</q>',2525,[13,9]);
6506 new Game.Upgrade('An itchy sweater','Cookie production multiplier <b>+1%</b>.<br>Cost scales with Santa level.<q>You don\'t know what\'s worse : the embarrassingly quaint "elf on reindeer" motif, or the fact that wearing it makes you feel like you\'re wrapped in a dead sasquatch.</q>',2525,[14,9]);
6507 new Game.Upgrade('Reindeer baking grounds','Reindeer appear <b>twice as frequently</b>.<br>Cost scales with Santa level.<q>Male reindeer are from Mars; female reindeer are from venison.</q>',2525,[12,9]);
6508 new Game.Upgrade('Weighted sleighs','Reindeer are <b>twice as slow</b>.<br>Cost scales with Santa level.<q>Hope it was worth the weight.<br>(Something something forced into cervidude)</q>',2525,[12,9]);
6509 new Game.Upgrade('Ho ho ho-flavored frosting','Reindeer give <b>twice as much</b>.<br>Cost scales with Santa level.<q>It\'s time to up the antler.</q>',2525,[12,9]);
6510 new Game.Upgrade('Season savings','All buildings are <b>1% cheaper</b>.<br>Cost scales with Santa level.<q>By Santa\'s beard, what savings!<br>But who will save us?</q>',2525,[16,9],function(){Game.storeToRefresh=1;});
6511 new Game.Upgrade('Toy workshop','All upgrades are <b>5% cheaper</b>.<br>Cost scales with Santa level.<q>Watch yours-elf around elvesdroppers who might steal our production secrets.<br>Or elven worse!</q>',2525,[16,9],function(){Game.upgradesToRebuild=1;});
6512 new Game.Upgrade('Naughty list','Grandmas are <b>twice</b> as productive.<br>Cost scales with Santa level.<q>This list contains every unholy deed perpetuated by grandmakind.<br>He won\'t be checking this one twice.<br>Once. Once is enough.</q>',2525,[15,9]);
6513 new Game.Upgrade('Santa\'s bottomless bag','Random drops are <b>10% more common</b>.<br>Cost scales with Santa level.<q>This is one bottom you can\'t check out.</q>',2525,[19,9]);
6514 new Game.Upgrade('Santa\'s helpers','Clicking is <b>10% more powerful</b>.<br>Cost scales with Santa level.<q>Some choose to help hamburger; some choose to help you.<br>To each their own, I guess.</q>',2525,[19,9]);
6515 new Game.Upgrade('Santa\'s legacy','Cookie production multiplier <b>+3% per Santa\'s levels</b>.<br>Cost scales with Santa level.<q>In the north pole, you gotta get the elves first. Then when you get the elves, you start making the toys. Then when you get the toys... then you get the cookies.</q>',2525,[19,9]);
6516 new Game.Upgrade('Santa\'s milk and cookies','Milk is <b>5% more powerful</b>.<br>Cost scales with Santa level.<q>Part of Santa\'s dreadfully unbalanced diet.</q>',2525,[19,9]);
6517
6518 order=40000;
6519 new Game.Upgrade('Reindeer season','Reindeer spawn much more frequently.<q>Go, Cheater! Go, Hacker and Faker!</q>',7,[12,9]);//debug purposes only
6520 Game.last.pool='debug';
6521
6522 order=25000;
6523 new Game.Upgrade('Santa\'s dominion','Cookie production multiplier <b>+20%</b>.<br>All buildings are <b>1% cheaper</b>.<br>All upgrades are <b>2% cheaper</b>.<q>My name is Claus, king of kings;<br>Look on my toys, ye Mighty, and despair!</q>',2525252525252525,[19,10],function(){Game.storeToRefresh=1;});
6524
6525 order=10300;
6526 var heartPower=function(){if (Game.Has('Starlove')) return 3; else return 2;};
6527 Game.NewUpgradeCookie({name:'Pure heart biscuits',desc:'Melty white chocolate<br>that says "I *like* like you".',season:'valentines',icon:[19,3], power:heartPower,price: 1e6});
6528 Game.NewUpgradeCookie({name:'Ardent heart biscuits',desc:'A red hot cherry biscuit that will nudge the target of your affection in interesting directions.',require:Game.last.name,season:'valentines',icon:[20,3], power:heartPower,price: 1e9});
6529 Game.NewUpgradeCookie({name:'Sour heart biscuits',desc:'A bitter lime biscuit for the lonely and the heart-broken.',require:Game.last.name,season:'valentines',icon:[20,4], power:heartPower,price: 1e12});
6530 Game.NewUpgradeCookie({name:'Weeping heart biscuits',desc:'An ice-cold blueberry biscuit, symbol of a mending heart.',require:Game.last.name,season:'valentines',icon:[21,3], power:heartPower,price: 1e15});
6531 Game.NewUpgradeCookie({name:'Golden heart biscuits',desc:'A beautiful biscuit to symbolize kindness, true love, and sincerity.',require:Game.last.name,season:'valentines',icon:[21,4], power:heartPower,price: 1e18});
6532 Game.NewUpgradeCookie({name:'Eternal heart biscuits',desc:'Silver icing for a very special someone you\'ve liked for a long, long time.',require:Game.last.name,season:'valentines',icon:[19,4], power:heartPower,price: 1e21});
6533
6534 order=1100;
6535 new Game.TieredUpgrade('Gem polish','Prisms are <b>twice</b> as efficient.<q>Get rid of the grime and let more light in.<br>Truly, truly outrageous.</q>','Prism',1);
6536 new Game.TieredUpgrade('9th color','Prisms are <b>twice</b> as efficient.<q>Delve into untouched optical depths where even the mantis shrimp hasn\'t set an eye!</q>','Prism',2);
6537 new Game.TieredUpgrade('Chocolate light','Prisms are <b>twice</b> as efficient.<q>Bask into its cocoalescence.<br>(Warning : may cause various interesting albeit deadly skin conditions.)</q>','Prism',3);
6538 new Game.TieredUpgrade('Grainbow','Prisms are <b>twice</b> as efficient.<q>Remember the different grains using the handy Roy G. Biv mnemonic : R is for rice, O is for oats... uh, B for barley?...</q>','Prism',4);
6539 new Game.TieredUpgrade('Pure cosmic light','Prisms are <b>twice</b> as efficient.<q>Your prisms now receive pristine, unadulterated photons from the other end of the universe.</q>','Prism',5);
6540
6541 order=255;
6542 new Game.Upgrade('Rainbow grandmas',Game.getGrandmaSynergyUpgradeDesc('Prism')+'<q>A luminous grandma to sparkle into cookies.</q>',Game.Objects['Prism'].basePrice*Game.Tiers[2].price,[10,9],function(){Game.Objects['Grandma'].redraw();});
6543
6544 order=24000;
6545 Game.seasonTriggerBasePrice=1111111111;
6546 new Game.Upgrade('Season switcher','Allows you to <b>trigger seasonal events</b> at will, for a price.<q>There will always be time.</q>',1111,[16,6],function(){for (var i in Game.seasons){Game.Unlock(Game.seasons[i].trigger);}});Game.last.pool='prestige';
6547 new Game.Upgrade('Festive biscuit','Triggers <b>Christmas season</b> for the next 24 hours.<br>Triggering another season will cancel this one.<br>Cost increases with every season switch.<q>\'Twas the night before Christmas- or was it?</q>',Game.seasonTriggerBasePrice,[12,10]);Game.last.season='christmas';Game.last.pool='toggle';
6548 new Game.Upgrade('Ghostly biscuit','Triggers <b>Halloween season</b> for the next 24 hours.<br>Triggering another season will cancel this one.<br>Cost increases with every season switch.<q>spooky scary skeletons<br>will wake you with a boo</q>',Game.seasonTriggerBasePrice,[13,8]);Game.last.season='halloween';Game.last.pool='toggle';
6549 new Game.Upgrade('Lovesick biscuit','Triggers <b>Valentine\'s Day season</b> for the next 24 hours.<br>Triggering another season will cancel this one.<br>Cost increases with every season switch.<q>Romance never goes out of fashion.</q>',Game.seasonTriggerBasePrice,[20,3]);Game.last.season='valentines';Game.last.pool='toggle';
6550 new Game.Upgrade('Fool\'s biscuit','Triggers <b>Business Day season</b> for the next 24 hours.<br>Triggering another season will cancel this one.<br>Cost increases with every season switch.<q>Business. Serious business. This is absolutely all of your business.</q>',Game.seasonTriggerBasePrice,[17,6]);Game.last.season='fools';Game.last.pool='toggle';
6551
6552 order=40000;
6553 new Game.Upgrade('Eternal seasons','Seasons now last forever.<q>Season to taste.</q>',7,[16,6],function(){for (var i in Game.seasons){Game.Unlock(Game.seasons[i].trigger);}});//debug purposes only
6554 Game.last.pool='debug';
6555
6556
6557 order=20000;
6558 new Game.Upgrade('Kitten managers','You gain <b>more CpS</b> the more milk you have.<q>that\'s not gonna paws any problem, sir</q>',9e+20,Game.GetIcon('Kitten',5));Game.last.kitten=1;
6559
6560 order=100;
6561 new Game.Upgrade('Septillion fingers','The mouse and cursors gain <b>+5000</b> cookies for each non-cursor object owned.<q>[cursory flavor text]</q>',1e+11,[0,15]);
6562 new Game.Upgrade('Octillion fingers','The mouse and cursors gain <b>+20000</b> cookies for each non-cursor object owned.<q>Turns out you <b>can</b> quite put your finger on it.</q>',1e+13,[12,15]);
6563
6564 order=150;new Game.Upgrade('Eludium mouse','Clicking gains <b>+1% of your CpS</b>.<q>I rodent do that if I were you.</q>',500000000000000,[11,15]);
6565 new Game.Upgrade('Wishalloy mouse','Clicking gains <b>+1% of your CpS</b>.<q>Clicking is fine and dandy, but don\'t smash your mouse over it. Get your game on. Go play.</q>',50000000000000000,[11,16]);
6566 order=200;new Game.TieredUpgrade('Aging agents','Grandmas are <b>twice</b> as efficient.<q>Counter-intuitively, grandmas have the uncanny ability to become more powerful the older they get.</q>','Grandma',6);
6567 order=300;new Game.TieredUpgrade('Pulsar sprinklers','Farms are <b>twice</b> as efficient.<q>There\'s no such thing as over-watering. The moistest is the bestest.</q>','Farm',6);
6568 order=500;new Game.TieredUpgrade('Deep-bake process','Factories are <b>twice</b> as efficient.<q>A patented process increasing cookie yield two-fold for the same amount of ingredients. Don\'t ask how, don\'t take pictures, and be sure to wear your protective suit.</q>','Factory',6);
6569 order=400;new Game.TieredUpgrade('Coreforge','Mines are <b>twice</b> as efficient.<q>You\'ve finally dug a tunnel down to the Earth\'s core. It\'s pretty warm down here.</q>','Mine',6);
6570 order=600;new Game.TieredUpgrade('Generation ship','Shipments are <b>twice</b> as efficient.<q>Built to last, this humongous spacecraft will surely deliver your cookies to the deep ends of space, one day.</q>','Shipment',6);
6571 order=700;new Game.TieredUpgrade('Origin crucible','Alchemy labs are <b>twice</b> as efficient.<q>Built from the rarest of earths and located at the very deepest of the largest mountain, this legendary crucible is said to retain properties from the big-bang itself.</q>','Alchemy lab',6);
6572 order=800;new Game.TieredUpgrade('Deity-sized portals','Portals are <b>twice</b> as efficient.<q>It\'s almost like, say, an elder god could fit through this thing now. Hypothetically.</q>','Portal',6);
6573 order=900;new Game.TieredUpgrade('Far future enactment','Time machines are <b>twice</b> as efficient.<q>The far future enactment authorizes you to delve deep into the future - where civilization has fallen and risen again, and cookies are plentiful.</q>','Time machine',6);
6574 order=1000;new Game.TieredUpgrade('Nanocosmics','Antimatter condensers are <b>twice</b> as efficient.<q>The theory of nanocosmics posits that each subatomic particle is in fact its own self-contained universe, holding unfathomable amounts of energy.</q>','Antimatter condenser',6);
6575 order=1100;
6576 new Game.TieredUpgrade('Glow-in-the-dark','Prisms are <b>twice</b> as efficient.<q>Your prisms now glow in the dark, effectively doubling their output!</q>','Prism',6);
6577
6578 order=10032;
6579 Game.NewUpgradeCookie({name:'Rose macarons',desc:'Although an odd flavor, these pastries recently rose in popularity.',icon:[22,3],require:'Box of macarons', power:3,price: 9999});
6580 Game.NewUpgradeCookie({name:'Lemon macarons',desc:'Tastefully sour, delightful treats.',icon:[23,3],require:'Box of macarons', power:3,price: 9999999});
6581 Game.NewUpgradeCookie({name:'Chocolate macarons',desc:'They\'re like tiny sugary burgers!',icon:[24,3],require:'Box of macarons', power:3,price: 9999999999});
6582 Game.NewUpgradeCookie({name:'Pistachio macarons',desc:'Pistachio shells now removed after multiple complaints.',icon:[22,4],require:'Box of macarons', power:3,price: 9999999999999});
6583 Game.NewUpgradeCookie({name:'Hazelnut macarons',desc:'These go especially well with coffee.',icon:[23,4],require:'Box of macarons', power:3,price: 9999999999999999});
6584 Game.NewUpgradeCookie({name:'Violet macarons',desc:'It\'s like spraying perfume into your mouth!',icon:[24,4],require:'Box of macarons', power:3,price: 9999999999999999999});
6585
6586 order=40000;
6587 new Game.Upgrade('Magic shenanigans','Cookie production <b>multiplied by 1,000</b>.<q>It\'s magic. I ain\'t gotta explain sh<div style="display:inline-block;background:url(img/money.png);width:16px;height:16px;position:relative;top:4px;left:0px;margin:0px -2px;"></div>t.</q>',7,[17,5]);//debug purposes only
6588 Game.last.pool='debug';
6589
6590
6591 order=24000;
6592 new Game.Upgrade('Bunny biscuit','Triggers <b>Easter season</b> for the next 24 hours.<br>Triggering another season will cancel this one.<br>Cost increases with every season switch.<q>All the world will be your enemy<br>and when they catch you,<br>they will kill you...<br>but first they must catch you.</q>',Game.seasonTriggerBasePrice,[0,12]);Game.last.season='easter';Game.last.pool='toggle';
6593
6594 var eggPrice=999999999999;
6595 var eggPrice2=99999999999999;
6596 new Game.Upgrade('Chicken egg','Cookie production multiplier <b>+2%</b>.<br>Cost scales with how many eggs you own.<q>The egg. The egg came first. Get over it.</q>',eggPrice,[1,12]);
6597 new Game.Upgrade('Duck egg','Cookie production multiplier <b>+2%</b>.<br>Cost scales with how many eggs you own.<q>Then he waddled away.</q>',eggPrice,[2,12]);
6598 new Game.Upgrade('Turkey egg','Cookie production multiplier <b>+2%</b>.<br>Cost scales with how many eggs you own.<q>These hatch into strange, hand-shaped creatures.</q>',eggPrice,[3,12]);
6599 new Game.Upgrade('Quail egg','Cookie production multiplier <b>+2%</b>.<br>Cost scales with how many eggs you own.<q>These eggs are positively tiny. I mean look at them. How does this happen? Whose idea was that?</q>',eggPrice,[4,12]);
6600 new Game.Upgrade('Robin egg','Cookie production multiplier <b>+2%</b>.<br>Cost scales with how many eggs you own.<q>Holy azure-hued shelled embryos!</q>',eggPrice,[5,12]);
6601 new Game.Upgrade('Ostrich egg','Cookie production multiplier <b>+2%</b>.<br>Cost scales with how many eggs you own.<q>One of the largest eggs in the world. More like ostrouch, am I right?<br>Guys?</q>',eggPrice,[6,12]);
6602 new Game.Upgrade('Cassowary egg','Cookie production multiplier <b>+2%</b>.<br>Cost scales with how many eggs you own.<q>The cassowary is taller than you, possesses murderous claws and can easily outrun you.<br>You\'d do well to be casso-wary of them.</q>',eggPrice,[7,12]);
6603 new Game.Upgrade('Salmon roe','Cookie production multiplier <b>+2%</b>.<br>Cost scales with how many eggs you own.<q>Do the impossible, see the invisible.<br>Roe roe, fight the power?</q>',eggPrice,[8,12]);
6604 new Game.Upgrade('Frogspawn','Cookie production multiplier <b>+2%</b>.<br>Cost scales with how many eggs you own.<q>I was going to make a pun about how these "toadally look like eyeballs", but froget it.</q>',eggPrice,[9,12]);
6605 new Game.Upgrade('Shark egg','Cookie production multiplier <b>+2%</b>.<br>Cost scales with how many eggs you own.<q>HELLO IS THIS FOOD?<br>LET ME TELL YOU ABOUT FOOD.<br>WHY DO I KEEP EATING MY FRIENDS</q>',eggPrice,[10,12]);
6606 new Game.Upgrade('Turtle egg','Cookie production multiplier <b>+2%</b>.<br>Cost scales with how many eggs you own.<q>Turtles, right? Hatch from shells. Grow into shells. What\'s up with that?<br>Now for my skit about airplane food.</q>',eggPrice,[11,12]);
6607 new Game.Upgrade('Ant larva','Cookie production multiplier <b>+2%</b>.<br>Cost scales with how many eggs you own.<q>These are a delicacy in some countries, I swear. You will let these invade your digestive tract, and you will derive great pleasure from it.<br>And all will be well.</q>',eggPrice,[12,12]);
6608 new Game.Upgrade('Golden goose egg','Golden cookies appear <b>5% more often</b>.<br>Cost scales with how many eggs you own.<q>The sole vestige of a tragic tale involving misguided investments.</q>',eggPrice2,[13,12]);
6609 new Game.Upgrade('Faberge egg','All buildings and upgrades are <b>1% cheaper</b>.<br>Cost scales with how many eggs you own.<q>This outrageous egg is definitely fab.</q>',eggPrice2,[14,12],function(){Game.storeToRefresh=1;});
6610 new Game.Upgrade('Wrinklerspawn','Wrinklers explode into <b>5% more cookies</b>.<br>Cost scales with how many eggs you own.<q>Look at this little guy! It\'s gonna be a big boy someday! Yes it is!</q>',eggPrice2,[15,12]);
6611 new Game.Upgrade('Cookie egg','Clicking is <b>10% more powerful</b>.<br>Cost scales with how many eggs you own.<q>The shell appears to be chipped.<br>I wonder what\'s inside this one!</q>',eggPrice2,[16,12]);
6612 new Game.Upgrade('Omelette','Other eggs appear <b>10% more frequently</b>.<br>Cost scales with how many eggs you own.<q>Fromage not included.</q>',eggPrice2,[17,12]);
6613 new Game.Upgrade('Chocolate egg','Contains <b>a lot of cookies</b>.<br>Cost scales with how many eggs you own.<q>Laid by the elusive cocoa bird. There\'s a surprise inside!</q>',eggPrice2,[18,12],function()
6614 {
6615 var cookies=Game.cookies*0.05;
6616 if (Game.prefs.popups) Game.Popup('The chocolate egg bursts into<br>'+Beautify(cookies)+'!');
6617 else Game.Notify('Chocolate egg','The egg bursts into <b>'+Beautify(cookies)+'</b> cookies!',Game.Upgrades['Chocolate egg'].icon);
6618 Game.Earn(cookies);
6619 });
6620 new Game.Upgrade('Century egg','You continually gain <b>more CpS the longer you\'ve played</b> in the current session.<br>Cost scales with how many eggs you own.<q>Actually not centuries-old. This one isn\'t a day over 86!</q>',eggPrice2,[19,12]);
6621 new Game.Upgrade('"egg"','<b>+9 CpS</b><q>hey it\'s "egg"</q>',eggPrice2,[20,12]);
6622
6623 Game.easterEggs=['Chicken egg','Duck egg','Turkey egg','Quail egg','Robin egg','Ostrich egg','Cassowary egg','Salmon roe','Frogspawn','Shark egg','Turtle egg','Ant larva','Golden goose egg','Faberge egg','Wrinklerspawn','Cookie egg','Omelette','Chocolate egg','Century egg','"egg"'];
6624 Game.eggDrops=['Chicken egg','Duck egg','Turkey egg','Quail egg','Robin egg','Ostrich egg','Cassowary egg','Salmon roe','Frogspawn','Shark egg','Turtle egg','Ant larva'];
6625 Game.rareEggDrops=['Golden goose egg','Faberge egg','Wrinklerspawn','Cookie egg','Omelette','Chocolate egg','Century egg','"egg"'];
6626
6627 Game.GetHowManyEggs=function()
6628 {
6629 var num=0;
6630 for (var i in Game.easterEggs) {if (Game.Has(Game.easterEggs[i])) num++;}
6631 return num;
6632 }
6633 for (var i in Game.eggDrops)//scale egg prices to how many eggs you have
6634 {Game.Upgrades[Game.eggDrops[i]].priceFunc=function(){return Math.pow(10,Game.GetHowManyEggs())*9;}}
6635 for (var i in Game.rareEggDrops)
6636 {Game.Upgrades[Game.rareEggDrops[i]].priceFunc=function(){return Math.pow(10,Game.GetHowManyEggs())*90;}}
6637
6638
6639 Game.DropEgg=function(failRate)
6640 {
6641 if (Game.season!='easter') return;
6642 if (Game.HasAchiev('Hide & seek champion')) failRate*=0.7;
6643 if (Game.Has('Omelette')) failRate*=0.9;
6644 if (Game.Has('Starspawn')) failRate*=0.9;
6645 if (Game.Has('Santa\'s bottomless bag')) failRate*=0.9;
6646 if (Game.hasAura('Mind Over Matter')) failRate*=0.75;
6647 if (Math.random()>=failRate)
6648 {
6649 var drop='';
6650 if (Math.random()<0.1) drop=choose(Game.rareEggDrops);
6651 else drop=choose(Game.eggDrops);
6652 if (Game.Has(drop) || Game.HasUnlocked(drop))//reroll if we have it
6653 {
6654 if (Math.random()<0.1) drop=choose(Game.rareEggDrops);
6655 else drop=choose(Game.eggDrops);
6656 }
6657 if (Game.Has(drop) || Game.HasUnlocked(drop)) return;
6658 Game.Unlock(drop);
6659 if (Game.prefs.popups) Game.Popup('You find :<br>'+drop+'!');
6660 else Game.Notify('You found an egg!','<b>'+drop+'</b>',Game.Upgrades[drop].icon);
6661 }
6662 };
6663
6664 order=10032;
6665 Game.NewUpgradeCookie({name:'Caramel macarons',desc:'The saltiest, chewiest of them all.',icon:[25,3],require:'Box of macarons', power:3,price: 9999999999999999999999});
6666 Game.NewUpgradeCookie({name:'Licorice macarons',desc:'Also known as "blackarons".',icon:[25,4],require:'Box of macarons', power:3,price: 9999999999999999999999999});
6667
6668
6669 order=525;
6670 new Game.TieredUpgrade('Taller tellers','Banks are <b>twice</b> as efficient.<q>Able to process a higher amount of transactions. Careful though, as taller tellers tell tall tales.</q>','Bank',1);
6671 new Game.TieredUpgrade('Scissor-resistant credit cards','Banks are <b>twice</b> as efficient.<q>For those truly valued customers.</q>','Bank',2);
6672 new Game.TieredUpgrade('Acid-proof vaults','Banks are <b>twice</b> as efficient.<q>You know what they say : better safe than sorry.</q>','Bank',3);
6673 new Game.TieredUpgrade('Chocolate coins','Banks are <b>twice</b> as efficient.<q>This revolutionary currency is much easier to melt from and into ingots - and tastes much better, for a change.</q>','Bank',4);
6674 new Game.TieredUpgrade('Exponential interest rates','Banks are <b>twice</b> as efficient.<q>Can\'t argue with mathematics! Now fork it over.</q>','Bank',5);
6675 new Game.TieredUpgrade('Financial zen','Banks are <b>twice</b> as efficient.<q>The ultimate grail of economic thought; the feng shui of big money, the stock market yoga - the Heimlich maneuver of dimes and nickels.</q>','Bank',6);
6676
6677 order=550;
6678 new Game.TieredUpgrade('Golden idols','Temples are <b>twice</b> as efficient.<q>Lure even greedier adventurers to retrieve your cookies. Now that\'s a real idol game!</q>','Temple',1);
6679 new Game.TieredUpgrade('Sacrifices','Temples are <b>twice</b> as efficient.<q>What\'s a life to a gigaton of cookies?</q>','Temple',2);
6680 new Game.TieredUpgrade('Delicious blessing','Temples are <b>twice</b> as efficient.<q>And lo, the Baker\'s almighty spoon came down and distributed holy gifts unto the believers - shimmering sugar, and chocolate dark as night, and all manner of wheats. And boy let me tell you, that party was mighty gnarly.</q>','Temple',3);
6681 new Game.TieredUpgrade('Sun festival','Temples are <b>twice</b> as efficient.<q>Free the primordial powers of your temples with these annual celebrations involving fire-breathers, traditional dancing, ritual beheadings and other merriments!</q>','Temple',4);
6682 new Game.TieredUpgrade('Enlarged pantheon','Temples are <b>twice</b> as efficient.<q>Enough spiritual inadequacy! More divinities than you\'ll ever need, or your money back! 100% guaranteed!</q>','Temple',5);
6683 new Game.TieredUpgrade('Great Baker in the sky','Temples are <b>twice</b> as efficient.<q>This is it. The ultimate deity has finally cast Their sublimely divine eye upon your operation; whether this is a good thing or possibly the end of days is something you should find out very soon.</q>','Temple',6);
6684
6685 order=575;
6686 new Game.TieredUpgrade('Pointier hats','Wizard towers are <b>twice</b> as efficient.<q>Tests have shown increased thaumic receptivity relative to the geometric proportions of wizardly conic implements.</q>','Wizard tower',1);
6687 new Game.TieredUpgrade('Beardlier beards','Wizard towers are <b>twice</b> as efficient.<q>Haven\'t you heard? The beard is the word.</q>','Wizard tower',2);
6688 new Game.TieredUpgrade('Ancient grimoires','Wizard towers are <b>twice</b> as efficient.<q>Contain interesting spells such as "Turn Water To Drool", "Grow Eyebrows On Furniture" and "Summon Politician".</q>','Wizard tower',3);
6689 new Game.TieredUpgrade('Kitchen curses','Wizard towers are <b>twice</b> as efficient.<q>Exotic magic involved in all things pastry-related. Hexcellent!</q>','Wizard tower',4);
6690 new Game.TieredUpgrade('School of sorcery','Wizard towers are <b>twice</b> as efficient.<q>This cookie-funded academy of witchcraft is home to the 4 prestigious houses of magic : the Jocks, the Nerds, the Preps, and the Deathmunchers.</q>','Wizard tower',5);
6691 new Game.TieredUpgrade('Dark formulas','Wizard towers are <b>twice</b> as efficient.<q>Eldritch forces are at work behind these spells - you get the feeling you really shouldn\'t be messing with those. But I mean, free cookies, right?</q>','Wizard tower',6);
6692
6693 order=250;
6694 new Game.Upgrade('Banker grandmas',Game.getGrandmaSynergyUpgradeDesc('Bank')+'<q>A nice banker to cash in more cookies.</q>',Game.Objects['Bank'].basePrice*Game.Tiers[2].price,[10,9],function(){Game.Objects['Grandma'].redraw();});
6695 new Game.Upgrade('Priestess grandmas',Game.getGrandmaSynergyUpgradeDesc('Temple')+'<q>A nice priestess to praise the one true Baker in the sky.</q>',Game.Objects['Temple'].basePrice*Game.Tiers[2].price,[10,9],function(){Game.Objects['Grandma'].redraw();});
6696 new Game.Upgrade('Witch grandmas',Game.getGrandmaSynergyUpgradeDesc('Wizard tower')+'<q>A nice witch to cast a zip, and a zoop, and poof! Cookies.</q>',Game.Objects['Wizard tower'].basePrice*Game.Tiers[2].price,[10,9],function(){Game.Objects['Grandma'].redraw();});
6697
6698
6699
6700 order=0;
6701 new Game.Upgrade('Tin of british tea biscuits','Contains an assortment of fancy biscuits.<q>Every time is tea time.</q>',25,[21,8]);Game.last.pool='prestige';Game.last.parents=['Heavenly cookies'];
6702 new Game.Upgrade('Box of macarons','Contains an assortment of macarons.<q>Multicolored delicacies filled with various kinds of jam.<br>Not to be confused with macaroons, macaroni, macarena or any of that nonsense.</q>',25,[20,8]);Game.last.pool='prestige';Game.last.parents=['Heavenly cookies'];
6703 new Game.Upgrade('Box of brand biscuits','Contains an assortment of popular biscuits.<q>They\'re brand new!</q>',25,[20,9]);Game.last.pool='prestige';Game.last.parents=['Heavenly cookies'];
6704
6705 order=10020;
6706 Game.NewUpgradeCookie({name:'Pure black chocolate cookies',desc:'Dipped in a lab-made substance darker than the darkest cocoa (dubbed "chocoalate").',icon:[26,3],power: 4,price: 9999999999999999*5});
6707 Game.NewUpgradeCookie({name:'Pure white chocolate cookies',desc:'Elaborated on the nano-scale, the coating on this biscuit is able to refract light even in a pitch-black environment.',icon:[26,4],power: 4,price: 9999999999999999*5});
6708 Game.NewUpgradeCookie({name:'Ladyfingers',desc:'Cleaned and sanitized so well you\'d swear they\'re actual biscuits.',icon:[27,3],power: 3,price: 99999999999999999});
6709 Game.NewUpgradeCookie({name:'Tuiles',desc:'These never go out of tile.',icon:[27,4],power: 3,price: 99999999999999999*5});
6710 Game.NewUpgradeCookie({name:'Chocolate-stuffed biscuits',desc:'A princely snack!<br>The holes are so the chocolate stuffing can breathe.',icon:[28,3],power: 3,price: 999999999999999999});
6711 Game.NewUpgradeCookie({name:'Checker cookies',desc:'A square cookie? This solves so many storage and packaging problems! You\'re a genius!',icon:[28,4],power: 3,price: 999999999999999999*5});
6712 Game.NewUpgradeCookie({name:'Butter cookies',desc:'These melt right off your mouth and into your heart. (Let\'s face it, they\'re rather fattening.)',icon:[29,3],power: 3,price: 9999999999999999999});
6713 Game.NewUpgradeCookie({name:'Cream cookies',desc:'It\'s like two chocolate chip cookies! But brought together with the magic of cream! It\'s fiendishly perfect!',icon:[29,4],power: 3,price: 9999999999999999999*5});
6714
6715 order=0;
6716 var desc='Placing an upgrade in this slot will make its effects <b>permanent</b> across all playthroughs.<br><b>Click to activate.</b>';
6717 new Game.Upgrade('Permanent upgrade slot I',desc, 100,[0,10]);Game.last.pool='prestige';Game.last.iconFunction=function(){return Game.PermanentSlotIcon(0);};Game.last.activateFunction=function(){Game.AssignPermanentSlot(0);};
6718 new Game.Upgrade('Permanent upgrade slot II',desc, 2000,[1,10]);Game.last.pool='prestige';Game.last.parents=['Permanent upgrade slot I'];Game.last.iconFunction=function(){return Game.PermanentSlotIcon(1);};Game.last.activateFunction=function(){Game.AssignPermanentSlot(1);};
6719 new Game.Upgrade('Permanent upgrade slot III',desc, 30000,[2,10]);Game.last.pool='prestige';Game.last.parents=['Permanent upgrade slot II'];Game.last.iconFunction=function(){return Game.PermanentSlotIcon(2);};Game.last.activateFunction=function(){Game.AssignPermanentSlot(2);};
6720 new Game.Upgrade('Permanent upgrade slot IV',desc, 400000,[3,10]);Game.last.pool='prestige';Game.last.parents=['Permanent upgrade slot III'];Game.last.iconFunction=function(){return Game.PermanentSlotIcon(3);};Game.last.activateFunction=function(){Game.AssignPermanentSlot(3);};
6721 new Game.Upgrade('Permanent upgrade slot V',desc, 5000000,[4,10]);Game.last.pool='prestige';Game.last.parents=['Permanent upgrade slot IV'];Game.last.iconFunction=function(){return Game.PermanentSlotIcon(4);};Game.last.activateFunction=function(){Game.AssignPermanentSlot(4);};
6722
6723 Game.PermanentSlotIcon=function(slot)
6724 {
6725 if (Game.permanentUpgrades[slot]==-1) return [slot,10];
6726 return Game.UpgradesById[Game.permanentUpgrades[slot]].icon;
6727 }
6728 Game.AssignPermanentSlot=function(slot)
6729 {
6730 PlaySound('snd/tick.mp3');
6731 Game.tooltip.hide();
6732 var list=[];
6733 for (var i in Game.Upgrades)
6734 {
6735 var me=Game.Upgrades[i];
6736 if (me.bought && me.unlocked && !me.noPerm && (me.pool=='' || me.pool=='cookie'))
6737 {
6738 var fail=0;
6739 for (var ii in Game.permanentUpgrades) {if (Game.permanentUpgrades[ii]==me.id) fail=1;}//check if not already in another permaslot
6740 if (!fail) list.push(me);
6741 }
6742 }
6743
6744 var sortMap=function(a,b)
6745 {
6746 if (a.order>b.order) return 1;
6747 else if (a.order<b.order) return -1;
6748 else return 0;
6749 }
6750 list.sort(sortMap);
6751
6752 var upgrades='';
6753 for (var i in list)
6754 {
6755 var me=list[i];
6756 upgrades+=Game.crate(me,'','PlaySound(\'snd/tick.mp3\');Game.PutUpgradeInPermanentSlot('+me.id+','+slot+');','upgradeForPermanent'+me.id);
6757 }
6758 var upgrade=Game.permanentUpgrades[slot];
6759 Game.SelectingPermanentUpgrade=upgrade;
6760 Game.Prompt('<h3>Pick an upgrade to make permanent</h3>'+
6761
6762 '<div class="line"></div><div style="margin:4px auto;clear:both;width:120px;"><div class="crate upgrade enabled" style="background-position:'+(-slot*48)+'px '+(-10*48)+'px;"></div><div id="upgradeToSlot" class="crate upgrade enabled" style="background-position:'+(upgrade==-1?((-0*48)+'px '+(-7*48)+'px'):((-Game.UpgradesById[upgrade].icon[0]*48)+'px '+(-Game.UpgradesById[upgrade].icon[1]*48)+'px'))+';"></div></div>'+
6763 '<div class="block crateBox" style="overflow-y:scroll;float:left;clear:left;width:317px;padding:0px;height:250px;">'+upgrades+'</div>'+
6764 '<div class="block" style="float:right;width:152px;clear:right;height:234px;">Here are all the upgrades you\'ve purchased last playthrough.<div class="line"></div>Pick one to permanently gain its effects!<div class="line"></div>You can reassign this slot anytime you ascend.</div>'
6765 ,[['Confirm','Game.permanentUpgrades['+slot+']=Game.SelectingPermanentUpgrade;Game.BuildAscendTree();Game.ClosePrompt();'],'Cancel'],0,'widePrompt');
6766 }
6767 Game.SelectingPermanentUpgrade=-1;
6768 Game.PutUpgradeInPermanentSlot=function(upgrade,slot)
6769 {
6770 Game.SelectingPermanentUpgrade=upgrade;
6771 l('upgradeToSlot').style.backgroundPosition=(-Game.UpgradesById[upgrade].icon[0]*48)+'px '+(-Game.UpgradesById[upgrade].icon[1]*48)+'px';
6772 }
6773
6774 new Game.Upgrade('Starspawn','Eggs drop <b>10%</b> more often.<br>Golden cookies appear <b>2%</b> more often during Easter.',111111,[0,12]);Game.last.pool='prestige';Game.last.parents=['Season switcher'];
6775 new Game.Upgrade('Starsnow','Christmas cookies drop <b>5%</b> more often.<br>Reindeer appear <b>5%</b> more often.',111111,[12,9]);Game.last.pool='prestige';Game.last.parents=['Season switcher'];
6776 new Game.Upgrade('Starterror','Spooky cookies drop <b>10%</b> more often.<br>Golden cookies appear <b>2%</b> more often during Halloween.',111111,[13,8]);Game.last.pool='prestige';Game.last.parents=['Season switcher'];
6777 new Game.Upgrade('Starlove','Heart cookies are <b>50%</b> more powerful.<br>Golden cookies appear <b>2%</b> more often during Valentines.',111111,[20,3]);Game.last.pool='prestige';Game.last.parents=['Season switcher'];
6778 new Game.Upgrade('Startrade','Golden cookies appear <b>5%</b> more often during Business day.',111111,[17,6]);Game.last.pool='prestige';Game.last.parents=['Season switcher'];
6779
6780 var angelPriceFactor=7;
6781 var desc=function(percent,total){return 'You gain another <b>+'+percent+'%</b> of your regular CpS while the game is closed, for a total of <b>'+total+'%</b>.';}
6782 new Game.Upgrade('Angels',desc(10,15)+'<q>Lowest-ranking at the first sphere of pastry heaven, angels are tasked with delivering new recipes to the mortals they deem worthy.</q>',Math.pow(angelPriceFactor,1),[0,11]);Game.last.pool='prestige';Game.last.parents=['Twin Gates of Transcendence'];
6783 new Game.Upgrade('Archangels',desc(10,25)+'<q>Members of the first sphere of pastry heaven, archangels are responsible for the smooth functioning of the world\'s largest bakeries.</q>',Math.pow(angelPriceFactor,2),[1,11]);Game.last.pool='prestige';Game.last.parents=['Angels'];
6784 new Game.Upgrade('Virtues',desc(10,35)+'<q>Found at the second sphere of pastry heaven, virtues make use of their heavenly strength to push and drag the stars of the cosmos.</q>',Math.pow(angelPriceFactor,3),[2,11]);Game.last.pool='prestige';Game.last.parents=['Archangels'];
6785 new Game.Upgrade('Dominions',desc(10,45)+'<q>Ruling over the second sphere of pastry heaven, dominions hold a managerial position and are in charge of accounting and regulating schedules.</q>',Math.pow(angelPriceFactor,4),[3,11]);Game.last.pool='prestige';Game.last.parents=['Virtues'];
6786 new Game.Upgrade('Cherubim',desc(10,55)+'<q>Sieging at the first sphere of pastry heaven, the four-faced cherubim serve as heavenly bouncers and bodyguards.</q>',Math.pow(angelPriceFactor,5),[4,11]);Game.last.pool='prestige';Game.last.parents=['Dominions'];
6787 new Game.Upgrade('Seraphim',desc(10,65)+'<q>Leading the first sphere of pastry heaven, seraphim possess ultimate knowledge of everything pertaining to baking.</q>',Math.pow(angelPriceFactor,6),[5,11]);Game.last.pool='prestige';Game.last.parents=['Cherubim'];
6788 new Game.Upgrade('God',desc(10,75)+'<q>Like Santa, but less fun.</q>',Math.pow(angelPriceFactor,7),[6,11]);Game.last.pool='prestige';Game.last.parents=['Seraphim'];
6789
6790 new Game.Upgrade('Twin Gates of Transcendence','You now <b>keep making cookies while the game is closed</b>, at the rate of <b>5%</b> of your regular CpS and up to <b>1 hour</b> after the game is closed.<br>(Beyond 1 hour, this is reduced by a further 90% - your rate goes down to <b>0.5%</b> of your CpS.)<q>This is one occasion you\'re always underdressed for. Don\'t worry, just rush in past the bouncer and pretend you know people.</q>',1,[15,11]);Game.last.pool='prestige';
6791
6792 new Game.Upgrade('Heavenly luck','Golden cookies appear <b>5%</b> more often.<q>Someone up there likes you.</q>',77,[22,6]);Game.last.pool='prestige';
6793 new Game.Upgrade('Lasting fortune','Golden cookies effects last <b>10%</b> longer.<q>This isn\'t your average everyday luck. This is... advanced luck.</q>',777,[23,6]);Game.last.pool='prestige';Game.last.parents=['Heavenly luck'];
6794 new Game.Upgrade('Decisive fate','Golden cookies stay <b>5%</b> longer.<q>Life just got a bit more intense.</q>',7777,[10,14]);Game.last.pool='prestige';Game.last.parents=['Lasting fortune'];
6795
6796 new Game.Upgrade('Divine discount','Buildings are <b>1% cheaper</b>.<q>Someone special deserves a special price.</q>',99999,[21,7]);Game.last.pool='prestige';Game.last.parents=['Decisive fate'];
6797 new Game.Upgrade('Divine sales','Upgrades are <b>1% cheaper</b>.<q>Everything must go!</q>',99999,[18,7]);Game.last.pool='prestige';Game.last.parents=['Decisive fate'];
6798 new Game.Upgrade('Divine bakeries','Cookie upgrades are <b>5 times cheaper</b>.<q>They sure know what they\'re doing.</q>',399999,[17,7]);Game.last.pool='prestige';Game.last.parents=['Divine sales','Divine discount'];
6799
6800 new Game.Upgrade('Starter kit','You start with <b>10 cursors</b>.<q>This can come in handy.</q>',50,[0,14]);Game.last.pool='prestige';Game.last.parents=['Tin of british tea biscuits','Box of macarons','Box of brand biscuits','Tin of butter cookies'];
6801 new Game.Upgrade('Starter kitchen','You start with <b>5 grandmas</b>.<q>Where did these come from?</q>',5000,[1,14]);Game.last.pool='prestige';Game.last.parents=['Starter kit'];
6802 new Game.Upgrade('Halo gloves','Clicks are <b>10% more powerful</b>.<q>Smite that cookie.</q>',55555,[22,7]);Game.last.pool='prestige';Game.last.parents=['Starter kit'];
6803
6804 new Game.Upgrade('Kitten angels','You gain <b>more CpS</b> the more milk you have.<q>All cats go to heaven.</q>',9000,[23,7]);Game.last.pool='prestige';Game.last.parents=['Dominions'];
6805
6806 new Game.Upgrade('Unholy bait','Wrinklers appear <b>5 times</b> as fast.<q>No wrinkler can resist the scent of worm biscuits.</q>',44444,[15,12]);Game.last.pool='prestige';Game.last.parents=['Starter kitchen'];
6807 new Game.Upgrade('Sacrilegious corruption','Wrinklers regurgitate <b>5%</b> more cookies.<q>Unique in the animal kingdom, the wrinkler digestive tract is able to withstand an incredible degree of dilation - provided you prod them appropriately.</q>',444444,[19,8]);Game.last.pool='prestige';Game.last.parents=['Unholy bait'];
6808
6809
6810 order=200;new Game.TieredUpgrade('Xtreme walkers','Grandmas are <b>twice</b> as efficient.<q>Complete with flame decals and a little horn that goes "toot".</q>','Grandma',7);
6811 order=300;new Game.TieredUpgrade('Fudge fungus','Farms are <b>twice</b> as efficient.<q>A sugary parasite whose tendrils help cookie growth.<br>Please do not breathe in the spores. In case of spore ingestion, seek medical help within the next 36 seconds.</q>','Farm',7);
6812 order=400;new Game.TieredUpgrade('Planetsplitters','Mines are <b>twice</b> as efficient.<q>These new state-of-the-art excavators have been tested on Merula, Globort and Flwanza VI, among other distant planets which have been curiously quiet lately.</q>','Mine',7);
6813 order=500;new Game.TieredUpgrade('Cyborg workforce','Factories are <b>twice</b> as efficient.<q>Semi-synthetic organisms don\'t slack off, don\'t unionize, and have 20% shorter lunch breaks, making them ideal labor fodder.</q>','Factory',7);
6814 order=525;new Game.TieredUpgrade('Way of the wallet','Banks are <b>twice</b> as efficient.<q>This new monetary school of thought is all the rage on the banking scene; follow its precepts and you may just profit from it.</q>','Bank',7);
6815 order=550;new Game.TieredUpgrade('Creation myth','Temples are <b>twice</b> as efficient.<q>Stories have been circulating about the origins of the very first cookie that was ever baked; tales of how it all began, in the Dough beyond time and the Ovens of destiny.</q>','Temple',7);
6816 order=575;new Game.TieredUpgrade('Cookiemancy','Wizard towers are <b>twice</b> as efficient.<q>There it is; the perfected school of baking magic. From summoning chips to hexing nuts, there is not a single part of cookie-making that hasn\'t been improved tenfold by magic tricks.</q>','Wizard tower',7);
6817 order=600;new Game.TieredUpgrade('Dyson sphere','Shipments are <b>twice</b> as efficient.<q>You\'ve found a way to apply your knowledge of cosmic technology to slightly more local endeavors; this gigantic sphere of meta-materials, wrapping the solar system, is sure to kick your baking abilities up a notch.</q>','Shipment',7);
6818 order=700;new Game.TieredUpgrade('Theory of atomic fluidity','Alchemy labs are <b>twice</b> as efficient.<q>Pushing alchemy to its most extreme limits, you find that everything is transmutable into anything else - lead to gold, mercury to water; more importantly, you realize that anything can -and should- be converted to cookies.</q>','Alchemy lab',7);
6819 order=800;new Game.TieredUpgrade('End of times back-up plan','Portals are <b>twice</b> as efficient.<q>Just in case, alright?</q>','Portal',7);
6820 order=900;new Game.TieredUpgrade('Great loop hypothesis','Time machines are <b>twice</b> as efficient.<q>What if our universe is just one instance of an infinite cycle? What if, before and after it, stretched infinite amounts of the same universe, themselves containing infinite amounts of cookies?</q>','Time machine',7);
6821 order=1000;new Game.TieredUpgrade('The Pulse','Antimatter condensers are <b>twice</b> as efficient.<q>You\'ve tapped into the very pulse of the cosmos, a timeless rhythm along which every material and antimaterial thing beats in unison. This, somehow, means more cookies.</q>','Antimatter condenser',7);
6822 order=1100;
6823 new Game.TieredUpgrade('Lux sanctorum','Prisms are <b>twice</b> as efficient.<q>Your prism attendants have become increasingly mesmerized with something in the light - or maybe something beyond it; beyond us all, perhaps?</q>','Prism',7);
6824
6825
6826 order=200;new Game.TieredUpgrade('The Unbridling','Grandmas are <b>twice</b> as efficient.<q>It might be a classic tale of bad parenting, but let\'s see where grandma is going with this.</q>','Grandma',8);
6827 order=300;new Game.TieredUpgrade('Wheat triffids','Farms are <b>twice</b> as efficient.<q>Taking care of crops is so much easier when your plants can just walk about and help around the farm.<br>Do not pet. Do not feed. Do not attempt to converse with.</q>','Farm',8);
6828 order=400;new Game.TieredUpgrade('Canola oil wells','Mines are <b>twice</b> as efficient.<q>A previously untapped resource, canola oil permeates the underground olifers which grant it its particular taste and lucrative properties.</q>','Mine',8);
6829 order=500;new Game.TieredUpgrade('78-hour days','Factories are <b>twice</b> as efficient.<q>Why didn\'t we think of this earlier?</q>','Factory',8);
6830 order=525;new Game.TieredUpgrade('The stuff rationale','Banks are <b>twice</b> as efficient.<q>If not now, when? If not it, what? If not things... stuff?</q>','Bank',8);
6831 order=550;new Game.TieredUpgrade('Theocracy','Temples are <b>twice</b> as efficient.<q>You\'ve turned your cookie empire into a perfect theocracy, gathering the adoration of zillions of followers from every corner of the universe.<br>Don\'t let it go to your head.</q>','Temple',8);
6832 order=575;new Game.TieredUpgrade('Rabbit trick','Wizard towers are <b>twice</b> as efficient.<q>Using nothing more than a fancy top hat, your wizards have found a way to simultaneously curb rabbit population and produce heaps of extra cookies for basically free!<br>Resulting cookies may or may not be fit for vegans.</q>','Wizard tower',8);
6833 order=600;new Game.TieredUpgrade('The final frontier','Shipments are <b>twice</b> as efficient.<q>It\'s been a long road, getting from there to here. It\'s all worth it though - the sights are lovely and the oil prices slightly more reasonable.</q>','Shipment',8);
6834 order=700;new Game.TieredUpgrade('Beige goo','Alchemy labs are <b>twice</b> as efficient.<q>Well now you\'ve done it. Good job. Very nice. That\'s 3 galaxies you\'ve just converted into cookies. Good thing you can hop from universe to universe.</q>','Alchemy lab',8);
6835 order=800;new Game.TieredUpgrade('Maddening chants','Portals are <b>twice</b> as efficient.<q>A popular verse goes like so : "jau\'hn madden jau\'hn madden aeiouaeiouaeiou brbrbrbrbrbrbr"</q>','Portal',8);
6836 order=900;new Game.TieredUpgrade('Cookietopian moments of maybe','Time machines are <b>twice</b> as efficient.<q>Reminiscing how things could have been, should have been, will have been.</q>','Time machine',8);
6837 order=1000;new Game.TieredUpgrade('Some other super-tiny fundamental particle? Probably?','Antimatter condensers are <b>twice</b> as efficient.<q>When even the universe is running out of ideas, that\'s when you know you\'re nearing the end.</q>','Antimatter condenser',8);
6838 order=1100;
6839 new Game.TieredUpgrade('Reverse shadows','Prisms are <b>twice</b> as efficient.<q>Oh man, this is really messing with your eyes.</q>','Prism',8);
6840
6841
6842 order=20000;
6843 new Game.Upgrade('Kitten accountants','You gain <b>more CpS</b> the more milk you have.<q>business going great, sir</q>',9e+23,Game.GetIcon('Kitten',6));Game.last.kitten=1;
6844 new Game.Upgrade('Kitten specialists','You gain <b>more CpS</b> the more milk you have.<q>optimizing your workflow like whoah, sir</q>',9e+26,Game.GetIcon('Kitten',7));Game.last.kitten=1;
6845 new Game.Upgrade('Kitten experts','You gain <b>more CpS</b> the more milk you have.<q>10 years expurrrtise in the cookie business, sir</q>',9e+29,Game.GetIcon('Kitten',8));Game.last.kitten=1;
6846
6847 new Game.Upgrade('How to bake your dragon','Allows you to purchase a <b>crumbly egg</b> once you have earned 1 million cookies.<q>A tome full of helpful tips such as "oh god, stay away from it", "why did we buy this thing, it\'s not even house-broken" and "groom twice a week in the direction of the scales".</q>',9,[22,12]);Game.last.pool='prestige';
6848
6849 order=25100;
6850 new Game.Upgrade('A crumbly egg','Unlocks the <b>cookie dragon egg</b>.<q>Thank you for adopting this robust, fun-loving cookie dragon! It will bring you years of joy and entertainment.<br>Keep in a dry and cool place, and away from other house pets. Subscription to home insurance is strongly advised.</q>',25,[21,12]);
6851
6852 new Game.Upgrade('Chimera','Synergy upgrades are <b>2% cheaper</b>.<br>You gain another <b>+5%</b> of your regular CpS while the game is closed.<br>You retain optimal cookie production while the game is closed for <b>2 more days</b>.<q>More than the sum of its parts.</q>',Math.pow(angelPriceFactor,8),[24,7]);Game.last.pool='prestige';Game.last.parents=['God','Lucifer','Synergies Vol. II'];
6853
6854 new Game.Upgrade('Tin of butter cookies','Contains an assortment of rich butter cookies.<q>Five varieties of danish cookies.<br>Complete with little paper cups.</q>',25,[21,9]);Game.last.pool='prestige';Game.last.parents=['Heavenly cookies'];
6855
6856 new Game.Upgrade('Golden switch','Unlocks the <b>golden switch</b>, which passively boosts your CpS by 50% but disables golden cookies.<q>Less clicking, more idling.</q>',999,[21,10]);Game.last.pool='prestige';Game.last.parents=['Heavenly luck'];
6857
6858 new Game.Upgrade('Classic dairy selection','Unlocks the <b>milk selector</b>, letting you pick which milk is displayed under your cookie.<br>Comes with a variety of basic flavors.<q>Don\'t have a cow, man.</q>',9,[1,8]);Game.last.pool='prestige';Game.last.parents=[];
6859
6860 new Game.Upgrade('Fanciful dairy selection','Contains more exotic flavors for your milk selector.<q>Strong bones for the skeleton army.</q>',1000000,[9,7]);Game.last.pool='prestige';Game.last.parents=['Classic dairy selection'];
6861
6862 order=10300;
6863 Game.NewUpgradeCookie({name:'Dragon cookie',desc:'Imbued with the vigor and vitality of a full-grown cookie dragon, this mystical cookie will embolden your empire for the generations to come.',icon:[10,25],power:5,price:9999999999999999*7,locked:1});
6864
6865
6866 order=40000;
6867 new Game.Upgrade('Golden switch [off]','Turning this on will give you a passive <b>+50% CpS</b>, but prevents golden cookies from spawning.<br>Cost is equal to 1 hour of production.',1000000,[20,10]);
6868 Game.last.pool='toggle';Game.last.toggleInto='Golden switch [on]';
6869 Game.last.priceFunc=function(){return Game.cookiesPs*60*60;}
6870
6871 new Game.Upgrade('Golden switch [on]','The switch is currently giving you a passive <b>+50% CpS</b>; it also prevents golden cookies from spawning.<br>Turning it off will revert those effects.<br>Cost is equal to 1 hour of production.',1000000,[21,10]);
6872 Game.last.pool='toggle';Game.last.toggleInto='Golden switch [off]';
6873 Game.last.priceFunc=function(){return Game.cookiesPs*60*60;}
6874
6875
6876 new Game.Upgrade('Milk selector','Lets you pick what flavor of milk to display.',0,[1,8]);
6877 Game.last.pool='toggle';
6878 Game.last.choicesFunction=function()
6879 {
6880 var choices=[];
6881 choices[0]={name:'Automatic',icon:[0,7]};
6882 choices[1]={name:'Plain milk',icon:[1,8]};
6883 choices[2]={name:'Chocolate milk',icon:[2,8]};
6884 choices[3]={name:'Raspberry milk',icon:[3,8]};
6885 choices[4]={name:'Orange milk',icon:[4,8]};
6886 choices[5]={name:'Caramel milk',icon:[5,8]};
6887 choices[6]={name:'Banana milk',icon:[6,8]};
6888 choices[7]={name:'Lime milk',icon:[7,8]};
6889 choices[8]={name:'Blueberry milk',icon:[8,8]};
6890 choices[9]={name:'Strawberry milk',icon:[9,8]};
6891 choices[10]={name:'Vanilla milk',icon:[10,8]};
6892
6893 if (Game.Has('Fanciful dairy selection'))
6894 {
6895 choices[11]={name:'Zebra milk',icon:[10,7]};
6896 choices[12]={name:'Cosmic milk',icon:[9,7]};
6897 choices[13]={name:'Flaming milk',icon:[8,7]};
6898 choices[14]={name:'Sanguine milk',icon:[7,7]};
6899 choices[15]={name:'Midas milk',icon:[6,7]};
6900 choices[16]={name:'Midnight milk',icon:[5,7]};
6901 choices[17]={name:'Green inferno milk',icon:[4,7]};
6902 choices[18]={name:'Frostfire milk',icon:[3,7]};
6903 }
6904 choices[Game.milkType].selected=1;
6905 return choices;
6906 }
6907 Game.last.choicesPick=function(id)
6908 {Game.milkType=id;}
6909
6910 Game.MilksByChoice={
6911 0:{pic:'milkPlain'},
6912 1:{pic:'milkPlain'},
6913 2:{pic:'milkChocolate'},
6914 3:{pic:'milkRaspberry'},
6915 4:{pic:'milkOrange'},
6916 5:{pic:'milkCaramel'},
6917 6:{pic:'milkBanana'},
6918 7:{pic:'milkLime'},
6919 8:{pic:'milkBlueberry'},
6920 9:{pic:'milkStrawberry'},
6921 10:{pic:'milkVanilla'},
6922 11:{pic:'milkZebra'},
6923 12:{pic:'milkStars'},
6924 13:{pic:'milkFire'},
6925 14:{pic:'milkBlood'},
6926 15:{pic:'milkGold'},
6927 16:{pic:'milkBlack'},
6928 17:{pic:'milkGreenFire'},
6929 18:{pic:'milkBlueFire'},
6930 };
6931
6932
6933 order=10300;
6934 Game.NewUpgradeCookie({name:'Milk chocolate butter biscuit',desc:'Rewarded for owning 100 of everything.<br>It bears the engraving of a fine entrepreneur.',icon:[27,8],power: 10,price: 999999999999999999999,locked:1});
6935 Game.NewUpgradeCookie({name:'Dark chocolate butter biscuit',desc:'Rewarded for owning 150 of everything.<br>It is adorned with the image of an experienced cookie tycoon.',icon:[27,9],power: 10,price: 999999999999999999999999,locked:1});
6936 Game.NewUpgradeCookie({name:'White chocolate butter biscuit',desc:'Rewarded for owning 200 of everything.<br>The chocolate is chiseled to depict a masterful pastry magnate.',icon:[28,9],power: 10,price: 999999999999999999999999999,locked:1});
6937 Game.NewUpgradeCookie({name:'Ruby chocolate butter biscuit',desc:'Rewarded for owning 250 of everything.<br>Covered in a rare red chocolate, this biscuit is etched to represent the face of a cookie industralist made mad with power.',icon:[28,8],power: 10,price: 999999999999999999999999999999,locked:1});
6938
6939 order=10020;
6940 Game.NewUpgradeCookie({name:'Gingersnaps',desc:'Cookies with a soul. Probably.',icon:[29,10],power: 4,price: 99999999999999999999});
6941 Game.NewUpgradeCookie({name:'Cinnamon cookies',desc:'The secret is in the patented swirly glazing.',icon:[23,8],power: 4,price: 99999999999999999999*5});
6942 Game.NewUpgradeCookie({name:'Vanity cookies',desc:'One tiny candied fruit sits atop this decadent cookie.',icon:[22,8],power: 4,price: 999999999999999999999});
6943 Game.NewUpgradeCookie({name:'Cigars',desc:'Close, but no match for those extravagant cookie straws they serve in coffee shops these days.',icon:[25,8],power: 4,price: 999999999999999999999*5});
6944 Game.NewUpgradeCookie({name:'Pinwheel cookies',desc:'Bringing you the dizzying combination of brown flavor and beige taste!',icon:[22,10],power: 4,price: 9999999999999999999999});
6945 Game.NewUpgradeCookie({name:'Fudge squares',desc:'Not exactly cookies, but you won\'t care once you\'ve tasted one of these.<br>They\'re so good, it\'s fudged-up!',icon:[24,8],power: 4,price: 9999999999999999999999*5});
6946
6947 order=10030;
6948 Game.NewUpgradeCookie({name:'Digits',desc:'Three flavors, zero phalanges.',icon:[26,8],require:'Box of brand biscuits',power: 2, price: 999999999999999*5});
6949
6950 order=10030;
6951 Game.NewUpgradeCookie({name:'Butter horseshoes',desc:'It would behoove you to not overindulge in these.',icon:[22,9],require:'Tin of butter cookies',power: 4, price: 99999999999999999999999});
6952 Game.NewUpgradeCookie({name:'Butter pucks',desc:'Lord, what fools these mortals be!<br>(This is kind of a hokey reference.)',icon:[23,9],require:'Tin of butter cookies',power: 4, price: 99999999999999999999999*5});
6953 Game.NewUpgradeCookie({name:'Butter knots',desc:'Look, you can call these pretzels if you want, but you\'d just be fooling yourself, wouldn\'t you?',icon:[24,9],require:'Tin of butter cookies',power: 4, price: 999999999999999999999999});
6954 Game.NewUpgradeCookie({name:'Butter slabs',desc:'Nothing better than a slab in the face.',icon:[25,9],require:'Tin of butter cookies',power: 4, price: 999999999999999999999999*5});
6955 Game.NewUpgradeCookie({name:'Butter swirls',desc:'These are equal parts sugar, butter, and warm fuzzy feelings - all of which cause millions of deaths everyday.',icon:[26,9],require:'Tin of butter cookies',power: 4, price: 9999999999999999999999999});
6956
6957 order=10020;
6958 Game.NewUpgradeCookie({name:'Shortbread biscuits',desc:'These rich butter cookies are neither short, nor bread. What a country!',icon:[23,10],power: 4,price: 99999999999999999999999});
6959 Game.NewUpgradeCookie({name:'Millionaires\' shortbreads',desc:'Three thought-provoking layers of creamy chocolate, hard-working caramel and crumbly biscuit in a poignant commentary of class struggle.',icon:[24,10],power: 4,price: 99999999999999999999999*5});
6960 Game.NewUpgradeCookie({name:'Caramel cookies',desc:'The polymerized carbohydrates adorning these cookies are sure to stick to your teeth for quite a while.',icon:[25,10],power: 4,price: 999999999999999999999999});
6961
6962
6963 var desc=function(totalHours){
6964 var hours=totalHours%24;
6965 var days=Math.floor(totalHours/24);
6966 var str=hours+(hours==1?' hour':' hours');
6967 if (days>0) str=days+(days==1?' day':' days')+' and '+str;
6968 return 'You retain optimal cookie production while the game is closed for twice as long, for a total of <b>'+str+'</b>.';
6969 }
6970 new Game.Upgrade('Belphegor',desc(2)+'<q>A demon of shortcuts and laziness, Belphegor commands machines to do work in his stead.</q>',Math.pow(angelPriceFactor,1),[7,11]);Game.last.pool='prestige';Game.last.parents=['Twin Gates of Transcendence'];
6971 new Game.Upgrade('Mammon',desc(4)+'<q>The demonic embodiment of wealth, Mammon requests a tithe of blood and gold from all his worshippers.</q>',Math.pow(angelPriceFactor,2),[8,11]);Game.last.pool='prestige';Game.last.parents=['Belphegor'];
6972 new Game.Upgrade('Abaddon',desc(8)+'<q>Master of overindulgence, Abaddon governs the wrinkler brood and inspires their insatiability.</q>',Math.pow(angelPriceFactor,3),[9,11]);Game.last.pool='prestige';Game.last.parents=['Mammon'];
6973 new Game.Upgrade('Satan',desc(16)+'<q>The counterpoint to everything righteous, this demon represents the nefarious influence of deceit and temptation.</q>',Math.pow(angelPriceFactor,4),[10,11]);Game.last.pool='prestige';Game.last.parents=['Abaddon'];
6974 new Game.Upgrade('Asmodeus',desc(32)+'<q>This demon with three monstrous heads draws his power from the all-consuming desire for cookies and all things sweet.</q>',Math.pow(angelPriceFactor,5),[11,11]);Game.last.pool='prestige';Game.last.parents=['Satan'];
6975 new Game.Upgrade('Beelzebub',desc(64)+'<q>The festering incarnation of blight and disease, Beelzebub rules over the vast armies of pastry inferno.</q>',Math.pow(angelPriceFactor,6),[12,11]);Game.last.pool='prestige';Game.last.parents=['Asmodeus'];
6976 new Game.Upgrade('Lucifer',desc(128)+'<q>Also known as the Lightbringer, this infernal prince\'s tremendous ego caused him to be cast down from pastry heaven.</q>',Math.pow(angelPriceFactor,7),[13,11]);Game.last.pool='prestige';Game.last.parents=['Beelzebub'];
6977
6978
6979 new Game.Upgrade('Golden cookie alert sound','Unlocks the <b>golden cookie sound selector</b>, which lets you pick whether golden cookies emit a sound when appearing or not.<q>A sound decision.</q>',9999,[28,6]);Game.last.pool='prestige';Game.last.parents=['Decisive fate','Golden switch'];
6980
6981 new Game.Upgrade('Golden cookie sound selector','Lets you change the sound golden cookies make when they spawn.',0,[28,6]);
6982 Game.last.pool='toggle';
6983 Game.last.choicesFunction=function()
6984 {
6985 var choices=[];
6986 choices[0]={name:'No sound',icon:[0,7]};
6987 choices[1]={name:'Chime',icon:[22,6]};
6988
6989 choices[Game.chimeType].selected=1;
6990 return choices;
6991 }
6992 Game.last.choicesPick=function(id)
6993 {Game.chimeType=id;}
6994
6995
6996 new Game.Upgrade('Basic wallpaper assortment','Unlocks the <b>background selector</b>, letting you select the game\'s background.<br>Comes with a variety of basic flavors.<div class="warning">Note : not implemented yet.<br>Coming soon, probably.</div><q>Prioritizing aesthetics over crucial utilitarian upgrades? Color me impressed.</q>',99,[29,5]);Game.last.pool='prestige';Game.last.parents=['Classic dairy selection'];
6997
6998 new Game.Upgrade('Legacy','Each time you ascend, the cookies you made in your past life are turned into <b>heavenly chips</b> and <b>prestige</b>.<div class="line"></div><b>Heavenly chips</b> can be spent on a variety of permanent transcendental upgrades.<div class="line"></div>Your <b>prestige level</b> also gives you a permanent <b>+1% CpS</b> per level.<q>We\'ve all been waiting for you.</q>',1,[21,6]);Game.last.pool='prestige';Game.last.parents=[];
6999
7000 new Game.Upgrade('Elder spice','You can attract <b>2 more wrinklers</b>.<q>The cookie your cookie could smell like.</q>',444444,[19,8]);Game.last.pool='prestige';Game.last.parents=['Unholy bait'];
7001
7002 new Game.Upgrade('Residual luck','While the golden switch is on, you gain an additional <b>+10% CpS</b> per golden cookie upgrade owned.<q>Fortune comes in many flavors.</q>',99999,[27,6]);Game.last.pool='prestige';Game.last.parents=['Golden switch'];
7003
7004 order=150;new Game.Upgrade('Fantasteel mouse','Clicking gains <b>+1% of your CpS</b>.<q>You could be clicking using your touchpad and we\'d be none the wiser.</q>',5000000000000000000,[11,17]);
7005 new Game.Upgrade('Nevercrack mouse','Clicking gains <b>+1% of your CpS</b>.<q>How much beefier can you make a mouse until it\'s considered a rat?</q>',500000000000000000000,[11,18]);
7006
7007
7008 new Game.Upgrade('Five-finger discount','All upgrades are <b>1% cheaper per 100 cursors</b>.<q>Stick it to the man.</q>',555555,[28,7],function(){Game.upgradesToRebuild=1;});Game.last.pool='prestige';Game.last.parents=['Halo gloves','Abaddon'];
7009
7010
7011 order=5000;
7012 new Game.SynergyUpgrade('Future almanacs','<q>Lets you predict optimal planting times. It\'s crazy what time travel can do!</q>','Farm','Time machine','synergy1');
7013 new Game.SynergyUpgrade('Rain prayer','<q>A deeply spiritual ceremonial involving complicated dance moves and high-tech cloud-busting lasers.</q>','Farm','Temple','synergy2');
7014
7015 new Game.SynergyUpgrade('Seismic magic','<q>Surprise earthquakes are an old favorite of wizardly frat houses.</q>','Mine','Wizard tower','synergy1');
7016 new Game.SynergyUpgrade('Asteroid mining','<q>As per the <span>19</span>74 United Cosmic Convention, comets, moons, and inhabited planetoids are no longer legally excavatable.<br>But hey, a space bribe goes a long way.</q>','Mine','Shipment','synergy2');
7017
7018 new Game.SynergyUpgrade('Quantum electronics','<q>Your machines won\'t even be sure if they\'re on or off!</q>','Factory','Antimatter condenser','synergy1');
7019 new Game.SynergyUpgrade('Temporal overclocking','<q>Introduce more quickitude in your system for increased speedation of fastness.</q>','Factory','Time machine','synergy2');
7020
7021 new Game.SynergyUpgrade('Contracts from beyond','<q>Make sure to read the fine print!</q>','Bank','Portal','synergy1');
7022 new Game.SynergyUpgrade('Printing presses','<q>Fake bills so real, they\'re almost worth the ink they\'re printed with.</q>','Bank','Factory','synergy2');
7023
7024 new Game.SynergyUpgrade('Paganism','<q>Some deities are better left unworshipped.</q>','Temple','Portal','synergy1');
7025 new Game.SynergyUpgrade('God particle','<q>Turns out God is much tinier than we thought, I guess.</q>','Temple','Antimatter condenser','synergy2');
7026
7027 new Game.SynergyUpgrade('Arcane knowledge','<q>Some things were never meant to be known - only mildly speculated.</q>','Wizard tower','Alchemy lab','synergy1');
7028 new Game.SynergyUpgrade('Magical botany','<q>Already known in some reactionary newspapers as "the wizard\'s GMOs".</q>','Wizard tower','Farm','synergy2');
7029
7030 new Game.SynergyUpgrade('Fossil fuels','<q>Somehow better than plutonium for powering rockets.<br>Extracted from the fuels of ancient, fossilized civilizations.</q>','Shipment','Mine','synergy1');
7031 new Game.SynergyUpgrade('Shipyards','<q>Where carpentry, blind luck, and asbestos insulation unite to produce the most dazzling spaceships on the planet.</q>','Shipment','Factory','synergy2');
7032
7033 new Game.SynergyUpgrade('Primordial ores','<q>Only when refining the purest metals will you extract the sweetest sap of the earth.</q>','Alchemy lab','Mine','synergy1');
7034 new Game.SynergyUpgrade('Gold fund','<q>If gold is the backbone of the economy, cookies, surely, are its hip joints.</q>','Alchemy lab','Bank','synergy2');
7035
7036 new Game.SynergyUpgrade('Infernal crops','<q>Sprinkle regularly with FIRE.</q>','Portal','Farm','synergy1');
7037 new Game.SynergyUpgrade('Abysmal glimmer','<q>Someone, or something, is staring back at you.<br>Perhaps at all of us.</q>','Portal','Prism','synergy2');
7038
7039 new Game.SynergyUpgrade('Relativistic parsec-skipping','<q>People will tell you this isn\'t physically possible.<br>These are people you don\'t want on your ship.</q>','Time machine','Shipment','synergy1');
7040 new Game.SynergyUpgrade('Primeval glow','<q>From unending times, an ancient light still shines, impossibly pure and fragile in its old age.</q>','Time machine','Prism','synergy2');
7041
7042 new Game.SynergyUpgrade('Extra physics funding','<q>Time to put your money where your particle colliders are.</q>','Antimatter condenser','Bank','synergy1');
7043 new Game.SynergyUpgrade('Chemical proficiency','<q>Discover exciting new elements, such as Fleshmeltium, Inert Shampoo Byproduct #17 and Carbon++!</q>','Antimatter condenser','Alchemy lab','synergy2');
7044
7045 new Game.SynergyUpgrade('Light magic','<q>Actually not to be taken lightly! No, I\'m serious. 178 people died last year. You don\'t mess around with magic.</q>','Prism','Wizard tower','synergy1');
7046 new Game.SynergyUpgrade('Mystical energies','<q>Something beckons from within the light. It is warm, comforting, and apparently the cause for several kinds of exotic skin cancers.</q>','Prism','Temple','synergy2');
7047
7048
7049 new Game.Upgrade('Synergies Vol. I','Unlocks a new tier of upgrades that affect <b>2 buildings at the same time</b>.<br>Synergies appear once you have <b>15</b> of both buildings.<q>The many beats the few.</q>',2525,[10,20]);Game.last.pool='prestige';Game.last.parents=['Satan','Dominions'];
7050 new Game.Upgrade('Synergies Vol. II','Unlocks a new tier of upgrades that affect <b>2 buildings at the same time</b>.<br>Synergies appear once you have <b>75</b> of both buildings.<q>The several beats the many.</q>',252525,[10,20]);Game.last.pool='prestige';Game.last.parents=['Beelzebub','Seraphim','Synergies Vol. I'];
7051
7052 new Game.Upgrade('Heavenly cookies','Cookie production multiplier <b>+10% permanently</b>.<q>Baked with heavenly chips. An otherwordldly flavor that transcends time and space.</q>',3,[25,12]);Game.last.pool='prestige';Game.last.parents=['Legacy'];Game.last.power=10;Game.last.pseudoCookie=true;
7053 new Game.Upgrade('Wrinkly cookies','Cookie production multiplier <b>+10% permanently</b>.<q>The result of regular cookies left to age out for countless eons in a place where time and space are meaningless.</q>',6666666,[26,12]);Game.last.pool='prestige';Game.last.parents=['Sacrilegious corruption','Elder spice'];Game.last.power=10;Game.last.pseudoCookie=true;
7054 new Game.Upgrade('Distilled essence of redoubled luck','Golden cookies have <b>1% chance of being doubled</b>.<q>Tastes glittery. The empty phial makes for a great pencil holder.</q>',7777777,[27,12]);Game.last.pool='prestige';Game.last.parents=['Divine bakeries','Residual luck'];
7055
7056
7057 order=200;new Game.TieredUpgrade('Immortality','Grandmas are <b>twice</b> as efficient.<q>No more grandmas croaking!</q>','Grandma',9);
7058 order=300;new Game.TieredUpgrade('Greenhouses','Farms are <b>twice</b> as efficient.<q>Now cookies can grow 24 hours a day, 365 days a year!</q>','Farm',9);
7059 order=400;new Game.TieredUpgrade('Sturdier mineshaft supports','Mines are <b>twice</b> as efficient.<q>Now the planets won\'t collapse anymore.</q>','Mine',9);
7060 order=500;new Game.TieredUpgrade('Complete automation','Factories are <b>twice</b> as efficient.<q>Now we don\'t need slaves anymore!</q>','Factory',9);
7061 order=525;new Game.TieredUpgrade('Loan sharks','Banks are <b>twice</b> as efficient.<q>Charging a million percent interest rate will surely make a lot of cookies. And enemies.</q>','Bank',9);
7062 order=550;new Game.TieredUpgrade('Divine appearance','Temples are <b>twice</b> as efficient.<q>Now you can convert those that need to see the Baker to believe in the Baker.</q>','Temple',9);
7063 order=575;new Game.TieredUpgrade('Curse of Cookiedas','Wizard towers are <b>twice</b> as efficient.<q>Now your wizards turn everything they see into cookies. Just don\'t stand in front of them, or you will turn into cookies.</q>','Wizard tower',9);
7064 order=600;new Game.TieredUpgrade('Planet hauler','Shipments are <b>twice</b> as efficient.<q>Building ships strong enough to tow entire planets has been a very worthwhile investment. Bringing them closer will make it much easier to harvest cookies.</q>','Shipment',9);
7065 order=700;new Game.TieredUpgrade('Universe converter','Alchemy labs are <b>twice</b> as efficient.<q>Now entire universes can be converted into cookies!</q>','Alchemy lab',9);
7066 order=800;new Game.TieredUpgrade('Cookieverse recreation','Portals are <b>twice</b> as efficient.<q>What do we do if the cookieverse runs out of cookies? Destroy it and create a new cookieverse!</q>','Portal',9);
7067 order=900;new Game.TieredUpgrade('Alternate timelines','Time machines are <b>twice</b> as efficient.<q>What if every decision made created an alternate timeline? And what if we could steal cookies from all those alternate timelines?</q>','Time machine',9);
7068 order=1000;new Game.TieredUpgrade('Matter creation','Antimatter condensers are <b>twice</b> as efficient.<q>Creates both matter and antimatter in equal quantities from thin air. Both can be used to make cookies.</q>','Antimatter condenser',9);
7069 order=1100;
7070 new Game.TieredUpgrade('Light trapping','Prisms are <b>twice</b> as efficient.<q>Uses inwards facing one way mirrors to trap light inside the prisms. Helps get the most out of light.</q>','Prism',9);
7071
7072 order=10020;
7073 Game.NewUpgradeCookie({name:'French toast',desc:'The name refers to how it\'s made, not the country it\'s made in. Duh!',icon:[27,10],power: 5,price: 999999999999999999999999*5});
7074 Game.NewUpgradeCookie({name:'Jam cookies',desc:'Finally there\'s something to go with those peanut butter cookies.',icon:[29,9],power: 5,price: 9999999999999999999999999});
7075 Game.NewUpgradeCookie({name:'Fortune cookies',desc:'Hope there\'s something good in there!',icon:[29,8],power: 5,price: 9999999999999999999999999*5});
7076
7077 order=20000;
7078 new Game.Upgrade('Kitten masters','You gain <b>more CpS</b> the more milk you have.<q>Nothing but the best, sir.</q>',9e+32,Game.GetIcon('Kitten',9));Game.last.kitten=1;
7079 order=100;
7080 new Game.Upgrade('Nonillion fingers','The mouse and cursors gain <b>+100000</b> cookies for each non-cursor object owned.<q>[cursory flavor text]</q>',1e+14,[0,16]);
7081 new Game.Upgrade('Decillion fingers','The mouse and cursors gain <b>+500000</b> cookies for each non-cursor object owned.<q>Turns out you <b>can</b> quite put your finger on it.</q>',1e+16,[12,16]);
7082 new Game.Upgrade('Undecillion fingers','The mouse and cursors gain <b>+2000000</b> cookies for each non-cursor object owned.<q>[cursory flavor text]</q>',1e+17,[0,17]);
7083 new Game.Upgrade('Duodecillion fingers','The mouse and cursors gain <b>+10000000</b> cookies for each non-cursor object owned.<q>Turns out you <b>can</b> quite put your finger on it.</q>',1e+19,[12,17]);
7084 new Game.Upgrade('Tredecillion fingers','The mouse and cursors gain <b>+50000000</b> cookies for each non-cursor object owned.<q>[cursory flavor text]</q>',1e+20,[0,18]);
7085 new Game.Upgrade('Quattuordecillion fingers','The mouse and cursors gain <b>+200000000</b> cookies for each non-cursor object owned.<q>Turns out you <b>can</b> quite put your finger on it.</q>',1e+22,[12,18]);
7086
7087 order=5000;
7088 new Game.Upgrade('Pot of gold','Golden cookie effects are <b>twice as powerful</b>.<q>Just follow the rainbow!</q>',7.7777777777777e19,[27,6]);
7089 new Game.Upgrade('All the luck','Golden cookie effects are <b>twice as powerful</b>.<q>Pick ALL the four-leaf clovers!</q>',7.7777777777777e28,[27,6]);
7090 //end of upgrades
7091
7092 Game.seasons={
7093 'christmas':{name:'Christmas',start:'Christmas season has started!',over:'Christmas season is over.',trigger:'Festive biscuit'},
7094 'valentines':{name:'Valentine\'s day',start:'Valentine\'s day has started!',over:'Valentine\'s day is over.',trigger:'Lovesick biscuit'},
7095 'fools':{name:'Business day',start:'Business day has started!',over:'Business day is over.',trigger:'Fool\'s biscuit'},
7096 'easter':{name:'Easter',start:'Easter season has started!',over:'Easter season is over.',trigger:'Bunny biscuit'},
7097 'halloween':{name:'Halloween',start:'Halloween has started!',over:'Halloween is over.',trigger:'Ghostly biscuit'}
7098 };
7099
7100 Game.computeSeasonPrices=function()
7101 {
7102 for (var i in Game.seasons)
7103 {
7104 //Game.seasons[i].triggerUpgrade.basePrice=Game.seasonTriggerBasePrice*Math.pow(2,Game.seasonUses);
7105 Game.seasons[i].triggerUpgrade.priceFunc=function(){return Game.seasonTriggerBasePrice*Math.pow(2,Game.seasonUses);}
7106 }
7107 }
7108 Game.computeSeasons=function()
7109 {
7110 for (var i in Game.seasons)
7111 {
7112 var me=Game.Upgrades[Game.seasons[i].trigger];
7113 Game.seasons[i].triggerUpgrade=me;
7114 me.pool='toggle';
7115 me.buyFunction=function()
7116 {
7117 Game.seasonUses+=1;
7118 Game.computeSeasonPrices();
7119 //Game.Lock(this.name);
7120 for (var i in Game.seasons)
7121 {
7122 var me=Game.Upgrades[Game.seasons[i].trigger];
7123 if (me.name!=this.name) {Game.Lock(me.name);Game.Unlock(me.name);}
7124 }
7125 if (Game.season!='' && Game.season!=this.season)
7126 {
7127 var str=Game.seasons[Game.season].over+'<div class="line"></div>';
7128 if (Game.prefs.popups) Game.Popup(str);
7129 else Game.Notify(str,'',Game.seasons[Game.season].triggerUpgrade.icon,4);
7130 }
7131 Game.season=this.season;
7132 Game.seasonT=Game.getSeasonDuration();
7133 Game.storeToRefresh=1;
7134 Game.upgradesToRebuild=1;
7135 Game.Objects['Grandma'].redraw();
7136 var str=Game.seasons[this.season].start+'<div class="line"></div>';
7137 if (Game.prefs.popups) Game.Popup(str);
7138 else Game.Notify(str,'',this.icon,4);
7139 }
7140
7141 me.displayFuncWhenOwned=function(){return '<div style="text-align:center;">Time remaining :<br><b>'+(Game.Has('Eternal seasons')?'forever':Game.sayTime(Game.seasonT))+'</b></div>';}
7142 me.timerDisplay=function(upgrade){return function(){if (!Game.Upgrades[upgrade.name].bought || Game.Has('Eternal seasons')) return -1; else return 1-Game.seasonT/Game.getSeasonDuration();}}(me);
7143
7144 }
7145 }
7146 Game.getSeasonDuration=function(){return Game.fps*60*60*24;}
7147 Game.computeSeasons();
7148
7149 //alert untiered building upgrades
7150 for (var i in Game.Upgrades)
7151 {
7152 var me=Game.Upgrades[i];
7153 if (me.order>=200 && me.order<2000 && !me.tier && me.name.indexOf('grandma')==-1 && me.pool!='prestige') console.log(me.name+' has no tier.');
7154 }
7155
7156 Game.UpgradesByPool=[];
7157 for (var i in Game.Upgrades)
7158 {
7159 if (!Game.UpgradesByPool[Game.Upgrades[i].pool]) Game.UpgradesByPool[Game.Upgrades[i].pool]=[];
7160 Game.UpgradesByPool[Game.Upgrades[i].pool].push(Game.Upgrades[i]);
7161 }
7162
7163 Game.PrestigeUpgrades=[];
7164 for (var i in Game.Upgrades)
7165 {
7166 if (Game.Upgrades[i].pool=='prestige' || Game.Upgrades[i].pool=='prestigeDecor')
7167 {
7168 Game.PrestigeUpgrades.push(Game.Upgrades[i]);
7169 Game.Upgrades[i].posX=0;
7170 Game.Upgrades[i].posY=0;
7171 if (Game.Upgrades[i].parents.length==0 && Game.Upgrades[i].name!='Legacy') Game.Upgrades[i].parents=['Legacy'];
7172 Game.Upgrades[i].parents=Game.Upgrades[i].parents||[-1];
7173 for (var ii in Game.Upgrades[i].parents) {if (Game.Upgrades[i].parents[ii]!=-1) Game.Upgrades[i].parents[ii]=Game.Upgrades[Game.Upgrades[i].parents[ii]];}
7174 }
7175 }
7176
7177 Game.cookieUpgrades=[];
7178 for (var i in Game.Upgrades)
7179 {
7180 var me=Game.Upgrades[i];
7181 if ((me.pool=='cookie' || me.pseudoCookie)) Game.cookieUpgrades.push(me);
7182 }
7183
7184 Game.UpgradePositions={141:[322,-108],181:[-555,-93],253:[-272,-231],254:[-99,-294],255:[-193,-279],264:[48,123],265:[133,154],266:[223,166],267:[305,137],268:[382,85],269:[-640,42],270:[-607,-246],271:[-728,-120],272:[-688,-201],273:[-711,-33],274:[270,-328],275:[317,-439],276:[333,-556],277:[334,-676],278:[333,-796],279:[328,-922],280:[303,-1040],281:[194,-230],282:[-265,212],283:[-321,297],284:[-322,406],285:[-243,501],286:[-403,501],287:[-314,606],288:[-312,-374],289:[-375,-502],290:[-206,-476],291:[453,-745],292:[-375,-651],293:[-399,-794],323:[-440,102],325:[192,-1127],326:[-328,-158],327:[-192,290],328:[-3,237],329:[92,376],353:[121,-326],354:[77,-436],355:[64,-548],356:[57,-673],357:[52,-793],358:[58,-924],359:[82,-1043],360:[-188,408],362:[158,289],363:[-30,-30],364:[-232,-730],365:[-77,349],368:[-82,-532],393:[196,-714],394:[197,-964],395:[-124,-139],396:[-264,-889],397:[-69,563],};
7185
7186 for (var i in Game.UpgradePositions) {Game.UpgradesById[i].posX=Game.UpgradePositions[i][0];Game.UpgradesById[i].posY=Game.UpgradePositions[i][1];}
7187
7188
7189 /*=====================================================================================
7190 ACHIEVEMENTS
7191 =======================================================================================*/
7192 Game.Achievements=[];
7193 Game.AchievementsById=[];
7194 Game.AchievementsN=0;
7195 Game.AchievementsOwned=0;
7196 Game.Achievement=function(name,desc,icon)
7197 {
7198 this.id=Game.AchievementsN;
7199 this.name=name;
7200 this.desc=desc;
7201 this.baseDesc=this.desc;
7202 this.desc=BeautifyInText(this.baseDesc);
7203 this.icon=icon;
7204 this.won=0;
7205 this.disabled=0;
7206 this.order=this.id;
7207 if (order) this.order=order+this.id*0.001;
7208 this.pool='normal';
7209 this.vanilla=Game.vanilla;
7210 this.type='achievement';
7211
7212 this.click=function()
7213 {
7214 if (this.clickFunction) this.clickFunction();
7215 }
7216 Game.last=this;
7217 Game.Achievements[this.name]=this;
7218 Game.AchievementsById[this.id]=this;
7219 Game.AchievementsN++;
7220 return this;
7221 }
7222
7223 Game.Win=function(what)
7224 {
7225 if (typeof what==='string')
7226 {
7227 if (Game.Achievements[what])
7228 {
7229 if (Game.Achievements[what].won==0)
7230 {
7231 var name=Game.Achievements[what].shortName?Game.Achievements[what].shortName:Game.Achievements[what].name;
7232 Game.Achievements[what].won=1;
7233 if (Game.prefs.popups) Game.Popup('Achievement unlocked :<br>'+name);
7234 else Game.Notify('Achievement unlocked','<div class="title" style="font-size:18px;margin-top:-2px;">'+name+'</div>',Game.Achievements[what].icon);
7235 if (Game.Achievements[what].pool!='shadow') Game.AchievementsOwned++;
7236 Game.recalculateGains=1;
7237 }
7238 }
7239 }
7240 else {for (var i in what) {Game.Win(what[i]);}}
7241 }
7242 Game.RemoveAchiev=function(what)
7243 {
7244 if (Game.Achievements[what])
7245 {
7246 if (Game.Achievements[what].won==1)
7247 {
7248 Game.Achievements[what].won=0;
7249 if (Game.Achievements[what].pool!='shadow') Game.AchievementsOwned--;
7250 Game.recalculateGains=1;
7251 }
7252 }
7253 }
7254
7255 Game.HasAchiev=function(what)
7256 {
7257 return (Game.Achievements[what]?Game.Achievements[what].won:0);
7258 }
7259
7260 Game.TieredAchievement=function(name,desc,building,tier)
7261 {
7262 var achiev=new Game.Achievement(name,desc,Game.GetIcon(building,tier));
7263 Game.SetTier(building,tier);
7264 return achiev;
7265 }
7266
7267 Game.thresholdIcons=[0,1,2,3,4,5,6,7,8,9,10,11,18,19,20,21,22,23,24,25,26,27,28,29];
7268 Game.BankAchievements=[];
7269 Game.BankAchievement=function(name)
7270 {
7271 var threshold=Math.pow(10,Math.floor(Game.BankAchievements.length*1.5+2));
7272 if (Game.BankAchievements.length==0) threshold=1;
7273 var achiev=new Game.Achievement(name,'Bake <b>'+Beautify(threshold)+'</b> cookie'+(threshold==1?'':'s')+'.',[Game.thresholdIcons[Game.BankAchievements.length],5]);
7274 achiev.threshold=threshold;
7275 achiev.order=100+Game.BankAchievements.length*0.01;
7276 Game.BankAchievements.push(achiev);
7277 return achiev;
7278 }
7279 Game.CpsAchievements=[];
7280 Game.CpsAchievement=function(name)
7281 {
7282 var threshold=Math.pow(10,Game.CpsAchievements.length);
7283 //if (Game.CpsAchievements.length==0) threshold=1;
7284 var achiev=new Game.Achievement(name,'Bake <b>'+Beautify(threshold)+'</b> cookie'+(threshold==1?'':'s')+' per second.',[Game.thresholdIcons[Game.CpsAchievements.length],5]);
7285 achiev.threshold=threshold;
7286 achiev.order=200+Game.CpsAchievements.length*0.01;
7287 Game.CpsAchievements.push(achiev);
7288 return achiev;
7289 }
7290
7291 //define achievements
7292 //WARNING : do NOT add new achievements in between, this breaks the saves. Add them at the end !
7293
7294 var order=0;//this is used to set the order in which the items are listed
7295
7296 Game.BankAchievement('Wake and bake');
7297 Game.BankAchievement('Making some dough');
7298 Game.BankAchievement('So baked right now');
7299 Game.BankAchievement('Fledgling bakery');
7300 Game.BankAchievement('Affluent bakery');
7301 Game.BankAchievement('World-famous bakery');
7302 Game.BankAchievement('Cosmic bakery');
7303 Game.BankAchievement('Galactic bakery');
7304 Game.BankAchievement('Universal bakery');
7305 Game.BankAchievement('Timeless bakery');
7306 Game.BankAchievement('Infinite bakery');
7307 Game.BankAchievement('Immortal bakery');
7308 Game.BankAchievement('Don\'t stop me now');
7309 Game.BankAchievement('You can stop now');
7310 Game.BankAchievement('Cookies all the way down');
7311 Game.BankAchievement('Overdose');
7312
7313 Game.CpsAchievement('Casual baking');
7314 Game.CpsAchievement('Hardcore baking');
7315 Game.CpsAchievement('Steady tasty stream');
7316 Game.CpsAchievement('Cookie monster');
7317 Game.CpsAchievement('Mass producer');
7318 Game.CpsAchievement('Cookie vortex');
7319 Game.CpsAchievement('Cookie pulsar');
7320 Game.CpsAchievement('Cookie quasar');
7321 Game.CpsAchievement('Oh hey, you\'re still here');
7322 Game.CpsAchievement('Let\'s never bake again');
7323
7324 order=30010;
7325 new Game.Achievement('Sacrifice','Ascend with <b>1 million</b> cookies baked.<q>Easy come, easy go.</q>',[11,6]);
7326 new Game.Achievement('Oblivion','Ascend with <b>1 billion</b> cookies baked.<q>Back to square one.</q>',[11,6]);
7327 new Game.Achievement('From scratch','Ascend with <b>1 trillion</b> cookies baked.<q>It\'s been fun.</q>',[11,6]);
7328
7329 order=11010;
7330 new Game.Achievement('Neverclick','Make <b>1 million</b> cookies by only having clicked <b>15 times</b>.',[12,0]);//Game.last.pool='shadow';
7331 order=1000;
7332 new Game.Achievement('Clicktastic','Make <b>1,000</b> cookies from clicking.',[11,0]);
7333 new Game.Achievement('Clickathlon','Make <b>100,000</b> cookies from clicking.',[11,1]);
7334 new Game.Achievement('Clickolympics','Make <b>10,000,000</b> cookies from clicking.',[11,2]);
7335 new Game.Achievement('Clickorama','Make <b>1,000,000,000</b> cookies from clicking.',[11,13]);
7336
7337 order=1050;
7338 new Game.Achievement('Click','Have <b>1</b> cursor.',[0,0]);
7339 new Game.Achievement('Double-click','Have <b>2</b> cursors.',[0,6]);
7340 new Game.Achievement('Mouse wheel','Have <b>50</b> cursors.',[1,6]);
7341 new Game.Achievement('Of Mice and Men','Have <b>100</b> cursors.',[0,1]);
7342 new Game.Achievement('The Digital','Have <b>200</b> cursors.',[0,2]);
7343
7344 order=1100;
7345 new Game.Achievement('Just wrong','Sell a grandma.<q>I thought you loved me.</q>',[10,9]);
7346 new Game.TieredAchievement('Grandma\'s cookies','Have <b>1</b> grandma.','Grandma',1);
7347 new Game.TieredAchievement('Sloppy kisses','Have <b>50</b> grandmas.','Grandma',2);
7348 new Game.TieredAchievement('Retirement home','Have <b>100</b> grandmas.','Grandma',3);
7349
7350 order=1200;
7351 new Game.TieredAchievement('My first farm','Have <b>1</b> farm.','Farm',1);
7352 new Game.TieredAchievement('Reap what you sow','Have <b>50</b> farms.','Farm',2);
7353 new Game.TieredAchievement('Farm ill','Have <b>100</b> farms.','Farm',3);
7354
7355 order=1400;
7356 new Game.TieredAchievement('Production chain','Have <b>1</b> factory.','Factory',1);
7357 new Game.TieredAchievement('Industrial revolution','Have <b>50</b> factories.','Factory',2);
7358 new Game.TieredAchievement('Global warming','Have <b>100</b> factories.','Factory',3);
7359
7360 order=1300;
7361 new Game.TieredAchievement('You know the drill','Have <b>1</b> mine.','Mine',1);
7362 new Game.TieredAchievement('Excavation site','Have <b>50</b> mines.','Mine',2);
7363 new Game.TieredAchievement('Hollow the planet','Have <b>100</b> mines.','Mine',3);
7364
7365 order=1500;
7366 new Game.TieredAchievement('Expedition','Have <b>1</b> shipment.','Shipment',1);
7367 new Game.TieredAchievement('Galactic highway','Have <b>50</b> shipments.','Shipment',2);
7368 new Game.TieredAchievement('Far far away','Have <b>100</b> shipments.','Shipment',3);
7369
7370 order=1600;
7371 new Game.TieredAchievement('Transmutation','Have <b>1</b> alchemy lab.','Alchemy lab',1);
7372 new Game.TieredAchievement('Transmogrification','Have <b>50</b> alchemy labs.','Alchemy lab',2);
7373 new Game.TieredAchievement('Gold member','Have <b>100</b> alchemy labs.','Alchemy lab',3);
7374
7375 order=1700;
7376 new Game.TieredAchievement('A whole new world','Have <b>1</b> portal.','Portal',1);
7377 new Game.TieredAchievement('Now you\'re thinking','Have <b>50</b> portals.','Portal',2);
7378 new Game.TieredAchievement('Dimensional shift','Have <b>100</b> portals.','Portal',3);
7379
7380 order=1800;
7381 new Game.TieredAchievement('Time warp','Have <b>1</b> time machine.','Time machine',1);
7382 new Game.TieredAchievement('Alternate timeline','Have <b>50</b> time machines.','Time machine',2);
7383 new Game.TieredAchievement('Rewriting history','Have <b>100</b> time machines.','Time machine',3);
7384
7385
7386 order=7000;
7387 new Game.Achievement('One with everything','Have <b>at least 1</b> of every building.',[2,7]);
7388 new Game.Achievement('Mathematician','Have at least <b>1 of the most expensive object, 2 of the second-most expensive, 4 of the next</b> and so on (capped at 128).',[23,12]);
7389 new Game.Achievement('Base 10','Have at least <b>10 of the most expensive object, 20 of the second-most expensive, 30 of the next</b> and so on.',[23,12]);
7390
7391 order=10000;
7392 new Game.Achievement('Golden cookie','Click a <b>golden cookie</b>.',[10,14]);
7393 new Game.Achievement('Lucky cookie','Click <b>7 golden cookies</b>.',[22,6]);
7394 new Game.Achievement('A stroke of luck','Click <b>27 golden cookies</b>.',[23,6]);
7395
7396 order=30200;
7397 new Game.Achievement('Cheated cookies taste awful','Hack in some cookies.',[10,6]);Game.last.pool='shadow';
7398 order=11010;
7399 new Game.Achievement('Uncanny clicker','Click really, really fast.<q>Well I\'ll be!</q>',[12,0]);
7400
7401 order=5000;
7402 new Game.Achievement('Builder','Own <b>100</b> buildings.',[2,6]);
7403 new Game.Achievement('Architect','Own <b>500</b> buildings.',[3,6]);
7404 order=6000;
7405 new Game.Achievement('Enhancer','Purchase <b>20</b> upgrades.',[9,0]);
7406 new Game.Achievement('Augmenter','Purchase <b>50</b> upgrades.',[9,1]);
7407
7408 order=11000;
7409 new Game.Achievement('Cookie-dunker','Dunk the cookie.<q>You did it!</q>',[1,8]);
7410
7411 order=10000;
7412 new Game.Achievement('Fortune','Click <b>77 golden cookies</b>.<q>You should really go to bed.</q>',[24,6]);
7413 order=31000;
7414 new Game.Achievement('True Neverclick','Make <b>1 million</b> cookies with <b>no</b> cookie clicks.<q>This kinda defeats the whole purpose, doesn\'t it?</q>',[12,0]);Game.last.pool='shadow';
7415
7416 order=20000;
7417 new Game.Achievement('Elder nap','Appease the grandmatriarchs at least <b>once</b>.<q>we<br>are<br>eternal</q>',[8,9]);
7418 new Game.Achievement('Elder slumber','Appease the grandmatriarchs at least <b>5 times</b>.<q>our mind<br>outlives<br>the universe</q>',[8,9]);
7419
7420 order=1150;
7421 new Game.Achievement('Elder','Own at least <b>7</b> grandma types.',[10,9]);
7422
7423 order=20000;
7424 new Game.Achievement('Elder calm','Declare a covenant with the grandmatriarchs.<q>we<br>have<br>fed</q>',[8,9]);
7425
7426 order=5000;
7427 new Game.Achievement('Engineer','Own <b>1000</b> buildings.',[4,6]);
7428
7429 order=10000;
7430 new Game.Achievement('Leprechaun','Click <b>777 golden cookies</b>.',[25,6]);
7431 new Game.Achievement('Black cat\'s paw','Click <b>7777 golden cookies</b>.',[26,6]);
7432
7433 order=30050;
7434 new Game.Achievement('Nihilism','Ascend with <b>1 quadrillion</b> cookies baked.<q>There are many things<br>that need to be erased</q>',[11,7]);
7435
7436 order=1900;
7437 new Game.TieredAchievement('Antibatter','Have <b>1</b> antimatter condenser.','Antimatter condenser',1);
7438 new Game.TieredAchievement('Quirky quarks','Have <b>50</b> antimatter condensers.','Antimatter condenser',2);
7439 new Game.TieredAchievement('It does matter!','Have <b>100</b> antimatter condensers.','Antimatter condenser',3);
7440
7441 order=6000;
7442 new Game.Achievement('Upgrader','Purchase <b>100</b> upgrades.',[9,2]);
7443
7444 order=7000;
7445 new Game.Achievement('Centennial','Have at least <b>100 of everything</b>.',[6,6]);
7446
7447 order=30500;
7448 new Game.Achievement('Hardcore','Get to <b>1 billion</b> cookies baked with <b>no upgrades purchased</b>.',[12,6]);//Game.last.pool='shadow';
7449
7450 order=30600;
7451 new Game.Achievement('Speed baking I','Get to <b>1 million</b> cookies baked in <b>35 minutes</b>.',[12,5]);Game.last.pool='shadow';
7452 new Game.Achievement('Speed baking II','Get to <b>1 million</b> cookies baked in <b>25 minutes</b>.',[13,5]);Game.last.pool='shadow';
7453 new Game.Achievement('Speed baking III','Get to <b>1 million</b> cookies baked in <b>15 minutes</b>.',[14,5]);Game.last.pool='shadow';
7454
7455
7456 order=61000;
7457 var achiev=new Game.Achievement('Getting even with the oven','Defeat the <b>Sentient Furnace</b> in the factory dungeons.',[12,7]);Game.last.pool='dungeon';
7458 var achiev=new Game.Achievement('Now this is pod-smashing','Defeat the <b>Ascended Baking Pod</b> in the factory dungeons.',[12,7]);Game.last.pool='dungeon';
7459 var achiev=new Game.Achievement('Chirped out','Find and defeat <b>Chirpy</b>, the dysfunctionning alarm bot.',[13,7]);Game.last.pool='dungeon';
7460 var achiev=new Game.Achievement('Follow the white rabbit','Find and defeat the elusive <b>sugar bunny</b>.',[14,7]);Game.last.pool='dungeon';
7461
7462 order=1000;
7463 new Game.Achievement('Clickasmic','Make <b>100,000,000,000</b> cookies from clicking.',[11,14]);
7464
7465 order=1100;
7466 new Game.TieredAchievement('Friend of the ancients','Have <b>150</b> grandmas.','Grandma',4);
7467 new Game.TieredAchievement('Ruler of the ancients','Have <b>200</b> grandmas.','Grandma',5);
7468
7469 order=32000;
7470 new Game.Achievement('Wholesome','Unlock <b>100%</b> of your heavenly chips power.',[15,7]);
7471
7472 order=33000;
7473 new Game.Achievement('Just plain lucky','You have <b>1 chance in 500,000</b> every second of earning this achievement.',[15,6]);Game.last.pool='shadow';
7474
7475 order=21000;
7476 new Game.Achievement('Itchscratcher','Burst <b>1 wrinkler</b>.',[19,8]);
7477 new Game.Achievement('Wrinklesquisher','Burst <b>50 wrinklers</b>.',[19,8]);
7478 new Game.Achievement('Moistburster','Burst <b>200 wrinklers</b>.',[19,8]);
7479
7480 order=22000;
7481 new Game.Achievement('Spooky cookies','Unlock <b>every Halloween-themed cookie</b>.<br>Owning this achievement makes Halloween-themed cookies drop more frequently in future playthroughs.',[12,8]);
7482
7483 order=22100;
7484 new Game.Achievement('Coming to town','Reach <b>Santa\'s 7th form</b>.',[18,9]);
7485 new Game.Achievement('All hail Santa','Reach <b>Santa\'s final form</b>.',[19,10]);
7486 new Game.Achievement('Let it snow','Unlock <b>every Christmas-themed cookie</b>.<br>Owning this achievement makes Christmas-themed cookies drop more frequently in future playthroughs.',[19,9]);
7487 new Game.Achievement('Oh deer','Pop <b>1 reindeer</b>.',[12,9]);
7488 new Game.Achievement('Sleigh of hand','Pop <b>50 reindeer</b>.',[12,9]);
7489 new Game.Achievement('Reindeer sleigher','Pop <b>200 reindeer</b>.',[12,9]);
7490
7491 order=1200;
7492 new Game.TieredAchievement('Perfected agriculture','Have <b>150</b> farms.','Farm',4);
7493 order=1400;
7494 new Game.TieredAchievement('Ultimate automation','Have <b>150</b> factories.','Factory',4);
7495 order=1300;
7496 new Game.TieredAchievement('Can you dig it','Have <b>150</b> mines.','Mine',4);
7497 order=1500;
7498 new Game.TieredAchievement('Type II civilization','Have <b>150</b> shipments.','Shipment',4);
7499 order=1600;
7500 new Game.TieredAchievement('Gild wars','Have <b>150</b> alchemy labs.','Alchemy lab',4);
7501 order=1700;
7502 new Game.TieredAchievement('Brain-split','Have <b>150</b> portals.','Portal',4);
7503 order=1800;
7504 new Game.TieredAchievement('Time duke','Have <b>150</b> time machines.','Time machine',4);
7505 order=1900;
7506 new Game.TieredAchievement('Molecular maestro','Have <b>150</b> antimatter condensers.','Antimatter condenser',4);
7507
7508 order=2000;
7509 new Game.TieredAchievement('Lone photon','Have <b>1</b> prism.','Prism',1);
7510 new Game.TieredAchievement('Dazzling glimmer','Have <b>50</b> prisms.','Prism',2);
7511 new Game.TieredAchievement('Blinding flash','Have <b>100</b> prisms.','Prism',3);
7512 new Game.TieredAchievement('Unending glow','Have <b>150</b> prisms.','Prism',4);
7513
7514 order=5000;
7515 new Game.Achievement('Lord of Constructs','Own <b>1500</b> buildings.<q>He saw the vast plains stretching ahead of him, and he said : let there be civilization.</q>',[5,6]);
7516 order=6000;
7517 new Game.Achievement('Lord of Progress','Purchase <b>200</b> upgrades.<q>One can always do better. But should you?</q>',[9,14]);
7518 order=7002;
7519 new Game.Achievement('Bicentennial','Have at least <b>200 of everything</b>.<q>You crazy person.</q>',[8,6]);
7520
7521 order=22300;
7522 new Game.Achievement('Lovely cookies','Unlock <b>every Valentine-themed cookie</b>.',[20,3]);
7523
7524 order=7001;
7525 new Game.Achievement('Centennial and a half','Have at least <b>150 of everything</b>.',[7,6]);
7526
7527 order=11000;
7528 new Game.Achievement('Tiny cookie','Click the tiny cookie.<q>These aren\'t the cookies<br>you\'re clicking for.</q>',[0,5]);
7529
7530 order=40000;
7531 new Game.Achievement('You win a cookie','This is for baking 10 trillion cookies and making it on the local news.<q>We\'re all so proud of you.</q>',[10,0]);
7532
7533 order=1070;
7534 new Game.Achievement('Click delegator','Make <b>10,000,000,000,000,000,000</b> cookies just from cursors.',[0,22]);
7535 order=1120;
7536 new Game.Achievement('Gushing grannies','Make <b>10,000,000,000,000,000,000</b> cookies just from grandmas.',[1,22]);
7537 order=1220;
7538 new Game.Achievement('I hate manure','Make <b>10,000,000,000,000</b> cookies just from farms.',[2,22]);
7539 order=1320;
7540 new Game.Achievement('Never dig down','Make <b>100,000,000,000,000</b> cookies just from mines.',[3,22]);
7541 order=1420;
7542 new Game.Achievement('The incredible machine','Make <b>1,000,000,000,000,000</b> cookies just from factories.',[4,22]);
7543 order=1520;
7544 new Game.Achievement('And beyond','Make <b>10,000,000,000,000,000,000</b> cookies just from shipments.',[5,22]);
7545 order=1620;
7546 new Game.Achievement('Magnum Opus','Make <b>100,000,000,000,000,000,000</b> cookies just from alchemy labs.',[6,22]);
7547 order=1720;
7548 new Game.Achievement('With strange eons','Make <b>1,000,000,000,000,000,000,000</b> cookies just from portals.',[7,22]);
7549 order=1820;
7550 new Game.Achievement('Spacetime jigamaroo','Make <b>10,000,000,000,000,000,000,000</b> cookies just from time machines.',[8,22]);
7551 order=1920;
7552 new Game.Achievement('Supermassive','Make <b>100,000,000,000,000,000,000,000</b> cookies just from antimatter condensers.',[13,22]);
7553 order=2020;
7554 new Game.Achievement('Praise the sun','Make <b>1,000,000,000,000,000,000,000,000</b> cookies just from prisms.',[14,22]);
7555
7556
7557 order=1000;
7558 new Game.Achievement('Clickageddon','Make <b>10,000,000,000,000</b> cookies from clicking.',[11,15]);
7559 new Game.Achievement('Clicknarok','Make <b>1,000,000,000,000,000</b> cookies from clicking.',[11,16]);
7560
7561 order=1050;
7562 new Game.Achievement('Extreme polydactyly','Have <b>300</b> cursors.',[0,13]);
7563 new Game.Achievement('Dr. T','Have <b>400</b> cursors.',[0,14]);
7564
7565 order=1100;new Game.TieredAchievement('The old never bothered me anyway','Have <b>250</b> grandmas.','Grandma',6);
7566 order=1200;new Game.TieredAchievement('Homegrown','Have <b>200</b> farms.','Farm',5);
7567 order=1400;new Game.TieredAchievement('Technocracy','Have <b>200</b> factories.','Factory',5);
7568 order=1300;new Game.TieredAchievement('The center of the Earth','Have <b>200</b> mines.','Mine',5);
7569 order=1500;new Game.TieredAchievement('We come in peace','Have <b>200</b> shipments.','Shipment',5);
7570 order=1600;new Game.TieredAchievement('The secrets of the universe','Have <b>200</b> alchemy labs.','Alchemy lab',5);
7571 order=1700;new Game.TieredAchievement('Realm of the Mad God','Have <b>200</b> portals.','Portal',5);
7572 order=1800;new Game.TieredAchievement('Forever and ever','Have <b>200</b> time machines.','Time machine',5);
7573 order=1900;new Game.TieredAchievement('Walk the planck','Have <b>200</b> antimatter condensers.','Antimatter condenser',5);
7574 order=2000;new Game.TieredAchievement('Rise and shine','Have <b>200</b> prisms.','Prism',5);
7575
7576 order=30200;
7577 new Game.Achievement('God complex','Name yourself <b>Orteil</b>.<div class="warning">Note : usurpers incur a -1% CpS penalty until they rename themselves something else.</div><q>But that\'s not you, is it?</q>',[17,5]);Game.last.pool='shadow';
7578 new Game.Achievement('Third-party','Use an <b>add-on</b>.<q>Some find vanilla to be the most boring flavor.</q>',[16,5]);Game.last.pool='shadow';//if you're making a mod, add a Game.Win('Third-party') somewhere in there!
7579
7580 order=30050;
7581 new Game.Achievement('Dematerialize','Ascend with <b>1 quintillion</b> cookies baked.<q>Presto!<br>...where\'d the cookies go?</q>',[11,7]);
7582 new Game.Achievement('Nil zero zilch','Ascend with <b>1 sextillion</b> cookies baked.<q>To summarize : really not very much at all.</q>',[11,7]);
7583 new Game.Achievement('Transcendence','Ascend with <b>1 septillion</b> cookies baked.<q>Your cookies are now on a higher plane of being.</q>',[11,8]);
7584 new Game.Achievement('Obliterate','Ascend with <b>1 octillion</b> cookies baked.<q>Resistance is futile, albeit entertaining.</q>',[11,8]);
7585 new Game.Achievement('Negative void','Ascend with <b>1 nonillion</b> cookies baked.<q>You now have so few cookies that it\'s almost like you have a negative amount of them.</q>',[11,8]);
7586
7587 order=22400;
7588 new Game.Achievement('The hunt is on','Unlock <b>1 egg</b>.',[1,12]);
7589 new Game.Achievement('Egging on','Unlock <b>7 eggs</b>.',[4,12]);
7590 new Game.Achievement('Mass Easteria','Unlock <b>14 eggs</b>.',[7,12]);
7591 new Game.Achievement('Hide & seek champion','Unlock <b>all the eggs</b>.<br>Owning this achievement makes eggs drop more frequently in future playthroughs.',[13,12]);
7592
7593 order=11000;
7594 new Game.Achievement('What\'s in a name','Give your bakery a name.',[15,9]);
7595
7596
7597 order=1425;
7598 new Game.TieredAchievement('Pretty penny','Have <b>1</b> bank.','Bank',1);
7599 new Game.TieredAchievement('Fit the bill','Have <b>50</b> banks.','Bank',2);
7600 new Game.TieredAchievement('A loan in the dark','Have <b>100</b> banks.','Bank',3);
7601 new Game.TieredAchievement('Need for greed','Have <b>150</b> banks.','Bank',4);
7602 new Game.TieredAchievement('It\'s the economy, stupid','Have <b>200</b> banks.','Bank',5);
7603 order=1450;
7604 new Game.TieredAchievement('Your time to shrine','Have <b>1</b> temple.','Temple',1);
7605 new Game.TieredAchievement('Shady sect','Have <b>50</b> temples.','Temple',2);
7606 new Game.TieredAchievement('New-age cult','Have <b>100</b> temples.','Temple',3);
7607 new Game.TieredAchievement('Organized religion','Have <b>150</b> temples.','Temple',4);
7608 new Game.TieredAchievement('Fanaticism','Have <b>200</b> temples.','Temple',5);
7609 order=1475;
7610 new Game.TieredAchievement('Bewitched','Have <b>1</b> wizard tower.','Wizard tower',1);
7611 new Game.TieredAchievement('The sorcerer\'s apprentice','Have <b>50</b> wizard towers.','Wizard tower',2);
7612 new Game.TieredAchievement('Charms and enchantments','Have <b>100</b> wizard towers.','Wizard tower',3);
7613 new Game.TieredAchievement('Curses and maledictions','Have <b>150</b> wizard towers.','Wizard tower',4);
7614 new Game.TieredAchievement('Magic kingdom','Have <b>200</b> wizard towers.','Wizard tower',5);
7615
7616 order=1445;
7617 new Game.Achievement('Vested interest','Make <b>10,000,000,000,000,000</b> cookies just from banks.',[15,22]);
7618 order=1470;
7619 new Game.Achievement('New world order','Make <b>100,000,000,000,000,000</b> cookies just from temples.',[16,22]);
7620 order=1495;
7621 new Game.Achievement('Hocus pocus','Make <b>1,000,000,000,000,000,000</b> cookies just from wizard towers.',[17,22]);
7622
7623
7624 order=1070;
7625 new Game.Achievement('Finger clickin\' good','Make <b>10,000,000,000,000,000,000,000</b> cookies just from cursors.',[0,23]);
7626 order=1120;
7627 new Game.Achievement('Panic at the bingo','Make <b>10,000,000,000,000,000,000,000</b> cookies just from grandmas.',[1,23]);
7628 order=1220;
7629 new Game.Achievement('Rake in the dough','Make <b>10,000,000,000,000,000</b> cookies just from farms.',[2,23]);
7630 order=1320;
7631 new Game.Achievement('Quarry on','Make <b>100,000,000,000,000,000</b> cookies just from mines.',[3,23]);
7632 order=1420;
7633 new Game.Achievement('Yes I love technology','Make <b>1,000,000,000,000,000,000</b> cookies just from factories.',[4,23]);
7634 order=1445;
7635 new Game.Achievement('Paid in full','Make <b>10,000,000,000,000,000,000</b> cookies just from banks.',[15,23]);
7636 order=1470;
7637 new Game.Achievement('Church of Cookiology','Make <b>100,000,000,000,000,000,000</b> cookies just from temples.',[16,23]);
7638 order=1495;
7639 new Game.Achievement('Too many rabbits, not enough hats','Make <b>1,000,000,000,000,000,000,000</b> cookies just from wizard towers.',[17,23]);
7640 order=1520;
7641 new Game.Achievement('The most precious cargo','Make <b>10,000,000,000,000,000,000,000</b> cookies just from shipments.',[5,23]);
7642 order=1620;
7643 new Game.Achievement('The Aureate','Make <b>100,000,000,000,000,000,000,000</b> cookies just from alchemy labs.',[6,23]);
7644 order=1720;
7645 new Game.Achievement('Ever more hideous','Make <b>1,000,000,000,000,000,000,000,000</b> cookies just from portals.',[7,23]);
7646 order=1820;
7647 new Game.Achievement('Be kind, rewind','Make <b>10,000,000,000,000,000,000,000,000</b> cookies just from time machines.',[8,23]);
7648 order=1920;
7649 new Game.Achievement('Infinitesimal','Make <b>100,000,000,000,000,000,000,000,000</b> cookies just from antimatter condensers.',[13,23]);
7650 order=2020;
7651 new Game.Achievement('A still more glorious dawn','Make <b>1,000,000,000,000,000,000,000,000,000</b> cookies just from prisms.',[14,23]);
7652
7653 order=30000;
7654 new Game.Achievement('Rebirth','Ascend at least once.',[21,6]);
7655
7656 order=11000;
7657 new Game.Achievement('Here you go','Click this achievement\'s slot.<q>All you had to do was ask.</q>',[1,7]);Game.last.clickFunction=function(){if (!Game.HasAchiev('Here you go')){PlaySound('snd/tick.mp3');Game.Win('Here you go');}};
7658
7659 order=30000;
7660 new Game.Achievement('Resurrection','Ascend <b>10 times</b>.',[21,6]);
7661 new Game.Achievement('Reincarnation','Ascend <b>100 times</b>.',[21,6]);
7662 new Game.Achievement('Endless cycle','Ascend <b>1000 times</b>.<q>Oh hey, it\'s you again.</q>',[2,7]);Game.last.pool='shadow';
7663
7664
7665
7666 order=1100;
7667 new Game.TieredAchievement('The agemaster','Have <b>300</b> grandmas.','Grandma',7);
7668 new Game.TieredAchievement('To oldly go','Have <b>350</b> grandmas.','Grandma',8);
7669
7670 order=1200;new Game.TieredAchievement('Gardener extraordinaire','Have <b>250</b> farms.','Farm',6);
7671 order=1300;new Game.TieredAchievement('Tectonic ambassador','Have <b>250</b> mines.','Mine',6);
7672 order=1400;new Game.TieredAchievement('Rise of the machines','Have <b>250</b> factories.','Factory',6);
7673 order=1425;new Game.TieredAchievement('Acquire currency','Have <b>250</b> banks.','Bank',6);
7674 order=1450;new Game.TieredAchievement('Zealotry','Have <b>250</b> temples.','Temple',6);
7675 order=1475;new Game.TieredAchievement('The wizarding world','Have <b>250</b> wizard towers.','Wizard tower',6);
7676 order=1500;new Game.TieredAchievement('Parsec-masher','Have <b>250</b> shipments.','Shipment',6);
7677 order=1600;new Game.TieredAchievement('The work of a lifetime','Have <b>250</b> alchemy labs.','Alchemy lab',6);
7678 order=1700;new Game.TieredAchievement('A place lost in time','Have <b>250</b> portals.','Portal',6);
7679 order=1800;new Game.TieredAchievement('Heat death','Have <b>250</b> time machines.','Time machine',6);
7680 order=1900;new Game.TieredAchievement('Microcosm','Have <b>250</b> antimatter condensers.','Antimatter condenser',6);
7681 order=2000;new Game.TieredAchievement('Bright future','Have <b>250</b> prisms.','Prism',6);
7682
7683 order=25000;
7684 new Game.Achievement('Here be dragon','Complete your <b>dragon\'s training</b>.',[21,12]);
7685
7686 Game.BankAchievement('How?');
7687 Game.BankAchievement('The land of milk and cookies');
7688 Game.BankAchievement('He who controls the cookies controls the universe');Game.last.baseDesc+='<q>The milk must flow!</q>';Game.last.desc=BeautifyInText(Game.last.baseDesc);
7689 Game.BankAchievement('Tonight on Hoarders');
7690 Game.BankAchievement('Are you gonna eat all that?');
7691 Game.BankAchievement('We\'re gonna need a bigger bakery');
7692 Game.BankAchievement('In the mouth of madness');Game.last.baseDesc+='<q>A cookie is just what we tell each other it is.</q>';Game.last.desc=BeautifyInText(Game.last.baseDesc);
7693 Game.BankAchievement('Brought to you by the letter <div style="display:inline-block;background:url(img/money.png);width:16px;height:16px;"></div>');
7694
7695
7696 Game.CpsAchievement('A world filled with cookies');
7697 Game.CpsAchievement('When this baby hits '+Beautify(100000000000*60*60)+' cookies per hour');
7698 Game.CpsAchievement('Fast and delicious');
7699 Game.CpsAchievement('Cookiehertz : a really, really tasty hertz');Game.last.baseDesc+='<q>Tastier than a hertz donut, anyway.</q>';Game.last.desc=BeautifyInText(Game.last.baseDesc);
7700 Game.CpsAchievement('Woops, you solved world hunger');
7701 Game.CpsAchievement('Turbopuns');Game.last.baseDesc+='<q>Mother Nature will be like "slowwwww dowwwwwn".</q>';Game.last.desc=BeautifyInText(Game.last.baseDesc);
7702 Game.CpsAchievement('Faster menner');
7703 Game.CpsAchievement('And yet you\'re still hungry');
7704 Game.CpsAchievement('The Abakening');
7705 Game.CpsAchievement('There\'s really no hard limit to how long these achievement names can be and to be quite honest I\'m rather curious to see how far we can go.<br>Adolphus W. Green (1844–1917) started as the Principal of the Groton School in 1864. By 1865, he became second assistant librarian at the New York Mercantile Library; from 1867 to 1869, he was promoted to full librarian. From 1869 to 1873, he worked for Evarts, Southmayd & Choate, a law firm co-founded by William M. Evarts, Charles Ferdinand Southmayd and Joseph Hodges Choate. He was admitted to the New York State Bar Association in 1873.<br>Anyway, how\'s your day been?');//Game.last.shortName='There\'s really no hard limit to how long these achievement names can be and to be quite honest I\'m [...]';
7706 Game.CpsAchievement('Fast');Game.last.baseDesc+='<q>Wow!</q>';Game.last.desc=BeautifyInText(Game.last.baseDesc);
7707
7708 order=7002;
7709 new Game.Achievement('Bicentennial and a half','Have at least <b>250 of everything</b>.<q>Keep on truckin\'.</q>',[9,6]);
7710
7711 order=11000;
7712 new Game.Achievement('Tabloid addiction','Click on the news ticker <b>50 times</b>.<q>Page 6 : Mad individual clicks on picture of pastry in a futile attempt to escape boredom!<br>Also page 6 : British parliament ate my baby!</q>',[27,7]);
7713
7714 order=1000;
7715 new Game.Achievement('Clickastrophe','Make <b>100,000,000,000,000,000</b> cookies from clicking.',[11,17]);
7716 new Game.Achievement('Clickataclysm','Make <b>10,000,000,000,000,000,000</b> cookies from clicking.',[11,18]);
7717
7718 order=1050;
7719 new Game.Achievement('Thumbs, phalanges, metacarpals','Have <b>500</b> cursors.<q>& KNUCKLES</q>',[0,15]);
7720
7721 order=6000;
7722 new Game.Achievement('Polymath','Own <b>300</b> upgrades and <b>3000</b> buildings.<q>Excellence doesn\'t happen overnight - it usually takes a good couple days.</q>',[29,7]);
7723
7724 new Game.Achievement('The elder scrolls','Own a combined <b>777</b> grandmas and cursors.<q>Let me guess. Someone stole your cookie.</q>',[10,9]);
7725
7726 order=30050;
7727 new Game.Achievement('To crumbs, you say?','Ascend with <b>1 decillion</b> cookies baked.<q>Very well then.</q>',[29,6]);
7728
7729 order=1200;new Game.TieredAchievement('Seedy business','Have <b>300</b> farms.','Farm',7);
7730 order=1300;new Game.TieredAchievement('Freak fracking','Have <b>300</b> mines.','Mine',7);
7731 order=1400;new Game.TieredAchievement('Modern times','Have <b>300</b> factories.','Factory',7);
7732 order=1425;new Game.TieredAchievement('The nerve of war','Have <b>300</b> banks.','Bank',7);
7733 order=1450;new Game.TieredAchievement('Wololo','Have <b>300</b> temples.','Temple',7);
7734 order=1475;new Game.TieredAchievement('And now for my next trick, I\'ll need a volunteer from the audience','Have <b>300</b> wizard towers.','Wizard tower',7);
7735 order=1500;new Game.TieredAchievement('It\'s not delivery','Have <b>300</b> shipments.','Shipment',7);
7736 order=1600;new Game.TieredAchievement('Gold, Jerry! Gold!','Have <b>300</b> alchemy labs.','Alchemy lab',7);
7737 order=1700;new Game.TieredAchievement('Forbidden zone','Have <b>300</b> portals.','Portal',7);
7738 order=1800;new Game.TieredAchievement('cookie clicker forever and forever a hundred years cookie clicker, all day long forever, forever a hundred times, over and over cookie clicker adventures dot com','Have <b>300</b> time machines.','Time machine',7);
7739 order=1900;new Game.TieredAchievement('Scientists baffled everywhere','Have <b>300</b> antimatter condensers.','Antimatter condenser',7);
7740 order=2000;new Game.TieredAchievement('Harmony of the spheres','Have <b>300</b> prisms.','Prism',7);
7741
7742 order=35000;
7743 new Game.Achievement('Last Chance to See','Burst the near-extinct <b>shiny wrinkler</b>.<q>You monster!</q>',[24,12]);Game.last.pool='shadow';
7744
7745 order=10000;
7746 new Game.Achievement('Early bird','Click a golden cookie <b>less than 1 second after it spawns</b>.',[10,14]);
7747 new Game.Achievement('Fading luck','Click a golden cookie <b>less than 1 second before it dies</b>.',[10,14]);
7748
7749 order=22100;
7750 new Game.Achievement('Eldeer','Pop a reindeer <b>during an elder frenzy</b>.',[12,9]);
7751
7752 //end of achievements
7753
7754 BeautifyAll();
7755 Game.vanilla=0;//everything we create beyond this will not be saved in the default save
7756
7757
7758 for (var i in Game.customCreate) {Game.customCreate[i]();}
7759
7760
7761 /*=====================================================================================
7762 GRANDMAPOCALYPSE
7763 =======================================================================================*/
7764 Game.UpdateGrandmapocalypse=function()
7765 {
7766 if (Game.Has('Elder Covenant') || Game.Objects['Grandma'].amount==0) Game.elderWrath=0;
7767 else if (Game.pledgeT>0)//if the pledge is active, lower it
7768 {
7769 Game.pledgeT--;
7770 if (Game.pledgeT==0)//did we reach 0? make the pledge purchasable again
7771 {
7772 Game.Lock('Elder Pledge');
7773 Game.Unlock('Elder Pledge');
7774 Game.elderWrath=1;
7775 }
7776 }
7777 else
7778 {
7779 if (Game.Has('One mind') && Game.elderWrath==0)
7780 {
7781 Game.elderWrath=1;
7782 }
7783 if (Math.random()<0.001 && Game.elderWrath<Game.Has('One mind')+Game.Has('Communal brainsweep')+Game.Has('Elder Pact'))
7784 {
7785 Game.elderWrath++;//have we already pledged? make the elder wrath shift between different stages
7786 }
7787 if (Game.Has('Elder Pact') && Game.Upgrades['Elder Pledge'].unlocked==0)
7788 {
7789 Game.Lock('Elder Pledge');
7790 Game.Unlock('Elder Pledge');
7791 }
7792 }
7793 Game.elderWrathD+=((Game.elderWrath+1)-Game.elderWrathD)*0.001;//slowly fade to the target wrath state
7794
7795 if (Game.elderWrath!=Game.elderWrathOld) Game.storeToRefresh=1;
7796
7797 Game.elderWrathOld=Game.elderWrath;
7798
7799 Game.UpdateWrinklers();
7800 }
7801
7802 //wrinklers
7803
7804 function inRect(x,y,rect)
7805 {
7806 //find out if the point x,y is in the rotated rectangle rect{w,h,r,o} (width,height,rotation in radians,y-origin) (needs to be normalized)
7807 //I found this somewhere online I guess
7808 var dx = x+Math.sin(-rect.r)*(-(rect.h/2-rect.o)),dy=y+Math.cos(-rect.r)*(-(rect.h/2-rect.o));
7809 var h1 = Math.sqrt(dx*dx + dy*dy);
7810 var currA = Math.atan2(dy,dx);
7811 var newA = currA - rect.r;
7812 var x2 = Math.cos(newA) * h1;
7813 var y2 = Math.sin(newA) * h1;
7814 if (x2 > -0.5 * rect.w && x2 < 0.5 * rect.w && y2 > -0.5 * rect.h && y2 < 0.5 * rect.h) return true;
7815 return false;
7816 }
7817
7818 Game.wrinklerHP=2.1;
7819 Game.wrinklers=[];
7820 for (var i=0;i<12;i++)
7821 {
7822 Game.wrinklers.push({id:parseInt(i),close:0,sucked:0,phase:0,x:0,y:0,r:0,hurt:0,hp:Game.wrinklerHP,selected:0,type:0});
7823 }
7824 Game.getWrinklersMax=function()
7825 {
7826 var n=10;
7827 if (Game.Has('Elder spice')) n+=2;
7828 return n;
7829 }
7830 Game.ResetWrinklers=function()
7831 {
7832 for (var i in Game.wrinklers)
7833 {
7834 Game.wrinklers[i]={id:parseInt(i),close:0,sucked:0,phase:0,x:0,y:0,r:0,hurt:0,hp:Game.wrinklerHP,type:0};
7835 }
7836 }
7837 Game.CollectWrinklers=function()
7838 {
7839 for (var i in Game.wrinklers)
7840 {
7841 Game.wrinklers[i].hp=0;
7842 }
7843 }
7844 Game.wrinklerSquishSound=Math.floor(Math.random()*4)+1;
7845 Game.playWrinklerSquishSound=function()
7846 {
7847 PlaySound('snd/squish'+(Game.wrinklerSquishSound)+'.mp3',0.5);
7848 Game.wrinklerSquishSound+=Math.floor(Math.random()*1.5)+1;
7849 if (Game.wrinklerSquishSound>4) Game.wrinklerSquishSound-=4;
7850 }
7851 Game.UpdateWrinklers=function()
7852 {
7853 var xBase=0;
7854 var yBase=0;
7855 var onWrinkler=0;
7856 if (Game.LeftBackground)
7857 {
7858 xBase=Game.cookieOriginX;
7859 yBase=Game.cookieOriginY;
7860 }
7861 var max=Game.getWrinklersMax();
7862 var n=0;
7863 for (var i in Game.wrinklers)
7864 {
7865 if (Game.wrinklers[i].phase>0) n++;
7866 }
7867 for (var i in Game.wrinklers)
7868 {
7869 var me=Game.wrinklers[i];
7870 if (me.phase==0 && Game.elderWrath>0 && n<max && me.id<max)
7871 {
7872 var chance=0.00001*Game.elderWrath;
7873 if (Game.Has('Unholy bait')) chance*=5;
7874 if (Game.Has('Wrinkler doormat')) chance=0.1;
7875 if (Math.random()<chance)//respawn
7876 {
7877 me.phase=1;
7878 me.hp=Game.wrinklerHP;
7879 me.type=0;
7880 if (Math.random()<0.0001) me.type=1;//shiny wrinkler
7881 }
7882 }
7883 if (me.phase>0)
7884 {
7885 if (me.close<1) me.close+=(1/Game.fps)/10;
7886 if (me.close>1) me.close=1;
7887 }
7888 else me.close=0;
7889 if (me.close==1 && me.phase==1)
7890 {
7891 me.phase=2;
7892 Game.recalculateGains=1;
7893 }
7894 if (me.phase==2)
7895 {
7896 me.sucked+=(((Game.cookiesPs/Game.fps)*Game.cpsSucked));//suck the cookies
7897 }
7898 if (me.phase>0)
7899 {
7900 if (me.type==0)
7901 {
7902 if (me.hp<Game.wrinklerHP) me.hp+=0.04;
7903 me.hp=Math.min(Game.wrinklerHP,me.hp);
7904 }
7905 else if (me.type==1)
7906 {
7907 if (me.hp<Game.wrinklerHP*3) me.hp+=0.04;
7908 me.hp=Math.min(Game.wrinklerHP*3,me.hp);
7909 }
7910 var d=128*(2-me.close);//*Game.BigCookieSize;
7911 if (Game.prefs.fancy) d+=Math.cos(Game.T*0.05+parseInt(me.id))*4;
7912 me.r=(me.id/max)*360;
7913 if (Game.prefs.fancy) me.r+=Math.sin(Game.T*0.05+parseInt(me.id))*4;
7914 me.x=xBase+(Math.sin(me.r*Math.PI/180)*d);
7915 me.y=yBase+(Math.cos(me.r*Math.PI/180)*d);
7916 if (Game.prefs.fancy) me.r+=Math.sin(Game.T*0.09+parseInt(me.id))*4;
7917 var rect={w:100,h:200,r:(-me.r)*Math.PI/180,o:10};
7918 if (Math.random()<0.01) me.hurt=Math.max(me.hurt,Math.random());
7919 if (Game.T%5==0 && Game.CanClick) {if (Game.LeftBackground && Game.mouseX<Game.LeftBackground.canvas.width && inRect(Game.mouseX-me.x,Game.mouseY-me.y,rect)) me.selected=1; else me.selected=0;}
7920 if (me.selected && onWrinkler==0 && Game.CanClick)
7921 {
7922 me.hurt=Math.max(me.hurt,0.25);
7923 //me.close*=0.99;
7924 if (Game.Click)
7925 {
7926 if (Game.keys[17] && Game.sesame) {me.type=!me.type;PlaySound('snd/shimmerClick.mp3');}//ctrl-click on a wrinkler in god mode to toggle its shininess
7927 else
7928 {
7929 Game.playWrinklerSquishSound();
7930 me.hurt=1;
7931 me.hp-=0.75;
7932 if (Game.prefs.particles && !(me.hp<=0.5 && me.phase>0))
7933 {
7934 var x=me.x+(Math.sin(me.r*Math.PI/180)*90);
7935 var y=me.y+(Math.cos(me.r*Math.PI/180)*90);
7936 for (var ii=0;ii<3;ii++)
7937 {
7938 //Game.particleAdd(x+Math.random()*50-25,y+Math.random()*50-25,Math.random()*4-2,Math.random()*-2-2,1,1,2,'wrinklerBits.png');
7939 var part=Game.particleAdd(x,y,Math.random()*4-2,Math.random()*-2-2,1,1,2,me.type==1?'shinyWrinklerBits.png':'wrinklerBits.png');
7940 part.r=-me.r;
7941 }
7942 }
7943 }
7944 Game.Click=0;
7945 }
7946 onWrinkler=1;
7947 }
7948 }
7949
7950 if (me.hurt>0)
7951 {
7952 me.hurt-=5/Game.fps;
7953 //me.close-=me.hurt*0.05;
7954 //me.x+=Math.random()*2-1;
7955 //me.y+=Math.random()*2-1;
7956 me.r+=(Math.sin(Game.T*1)*me.hurt)*18;//Math.random()*2-1;
7957 }
7958 if (me.hp<=0.5 && me.phase>0)
7959 {
7960 Game.playWrinklerSquishSound();
7961 PlaySound('snd/pop'+Math.floor(Math.random()*3+1)+'.mp3',0.75);
7962 Game.wrinklersPopped++;
7963 Game.recalculateGains=1;
7964 me.phase=0;
7965 me.close=0;
7966 me.hurt=0;
7967 me.hp=3;
7968 var toSuck=1.1;
7969 if (Game.Has('Sacrilegious corruption')) toSuck*=1.05;
7970 if (me.type==1) toSuck*=3;//shiny wrinklers are an elusive, profitable breed
7971 me.sucked*=toSuck;//cookie dough does weird things inside wrinkler digestive tracts
7972 if (Game.Has('Wrinklerspawn')) me.sucked*=1.05;
7973 if (me.sucked>0.5)
7974 {
7975 if (Game.prefs.popups) Game.Popup('Exploded a '+(me.type==1?'shiny ':'')+'wrinkler : found '+Beautify(me.sucked)+' cookies!');
7976 else Game.Notify('Exploded a '+(me.type==1?'shiny ':'')+'wrinkler','Found <b>'+Beautify(me.sucked)+'</b> cookies!',[19,8],6);
7977 Game.Popup('<div style="font-size:80%;">+'+Beautify(me.sucked)+' cookies</div>',Game.mouseX,Game.mouseY);
7978
7979 if (Game.season=='halloween')
7980 {
7981 //if (Math.random()<(Game.HasAchiev('Spooky cookies')?0.2:0.05))//halloween cookie drops
7982 var failRate=0.95;
7983 if (Game.HasAchiev('Spooky cookies')) failRate=0.8;
7984 if (Game.Has('Santa\'s bottomless bag')) failRate*=0.9;
7985 if (Game.hasAura('Mind Over Matter')) failRate*=0.75;
7986 if (Game.Has('Starterror')) failRate*=0.9;
7987 if (me.type==1) failRate*=0.9;
7988 if (Math.random()>failRate)//halloween cookie drops
7989 {
7990 var cookie=choose(['Skull cookies','Ghost cookies','Bat cookies','Slime cookies','Pumpkin cookies','Eyeball cookies','Spider cookies']);
7991 if (!Game.HasUnlocked(cookie) && !Game.Has(cookie))
7992 {
7993 Game.Unlock(cookie);
7994 if (Game.prefs.popups) Game.Popup('Found : '+cookie+'!');
7995 else Game.Notify(cookie,'You also found <b>'+cookie+'</b>!',Game.Upgrades[cookie].icon);
7996 }
7997 }
7998 }
7999 Game.DropEgg(0.98);
8000 }
8001 if (me.type==1) Game.Win('Last Chance to See');
8002 Game.Earn(me.sucked);
8003 /*if (Game.prefs.particles)
8004 {
8005 var x=me.x+(Math.sin(me.r*Math.PI/180)*100);
8006 var y=me.y+(Math.cos(me.r*Math.PI/180)*100);
8007 for (var ii=0;ii<6;ii++)
8008 {
8009 Game.particleAdd(x+Math.random()*50-25,y+Math.random()*50-25,Math.random()*4-2,Math.random()*-2-2,1,1,2,'wrinklerBits.png');
8010 }
8011 }*/
8012 if (Game.prefs.particles)
8013 {
8014 var x=me.x+(Math.sin(me.r*Math.PI/180)*90);
8015 var y=me.y+(Math.cos(me.r*Math.PI/180)*90);
8016 if (me.sucked>0)
8017 {
8018 for (var ii=0;ii<5;ii++)
8019 {
8020 Game.particleAdd(Game.mouseX,Game.mouseY,Math.random()*4-2,Math.random()*-2-2,Math.random()*0.5+0.75,1.5,2);
8021 }
8022 }
8023 for (var ii=0;ii<8;ii++)
8024 {
8025 var part=Game.particleAdd(x,y,Math.random()*4-2,Math.random()*-2-2,1,1,2,me.type==1?'shinyWrinklerBits.png':'wrinklerBits.png');
8026 part.r=-me.r;
8027 }
8028 }
8029 me.sucked=0;
8030 }
8031 }
8032 if (onWrinkler)
8033 {
8034 Game.mousePointer=1;
8035 }
8036 }
8037 Game.DrawWrinklers=function()
8038 {
8039 for (var i in Game.wrinklers)
8040 {
8041 var me=Game.wrinklers[i];
8042 if (me.phase>0)
8043 {
8044 Game.LeftBackground.globalAlpha=me.close;
8045 Game.LeftBackground.save();
8046 Game.LeftBackground.translate(me.x,me.y);
8047 Game.LeftBackground.rotate(-(me.r)*Math.PI/180);
8048 //var s=Math.min(1,me.sucked/(Game.cookiesPs*60))*0.75+0.25;//scale wrinklers as they eat
8049 //Game.LeftBackground.scale(Math.pow(s,1.5)*1.25,s);
8050 //Game.LeftBackground.fillRect(-50,-10,100,200);
8051 if (me.type==1) Game.LeftBackground.drawImage(Pic('shinyWrinkler.png'),-50,-10);
8052 else if (Game.season=='christmas') Game.LeftBackground.drawImage(Pic('winterWrinkler.png'),-50,-10);
8053 else Game.LeftBackground.drawImage(Pic('wrinkler.png'),-50,-10);
8054 //Game.LeftBackground.fillText(me.id+' : '+me.sucked,0,0);
8055 if (me.type==1 && Math.random()<0.3 && Game.prefs.particles)//sparkle
8056 {
8057 Game.LeftBackground.globalAlpha=Math.random()*0.65+0.1;
8058 var s=Math.random()*30+5;
8059 Game.LeftBackground.globalCompositeOperation='lighter';
8060 Game.LeftBackground.drawImage(Pic('glint.jpg'),-s/2+Math.random()*50-25,-s/2+Math.random()*200,s,s);
8061 }
8062 Game.LeftBackground.restore();
8063
8064 if (me.phase==2 && Math.random()<0.03 && Game.prefs.particles)
8065 {
8066 Game.particleAdd(me.x,me.y,Math.random()*4-2,Math.random()*-2-2,Math.random()*0.5+0.5,1,2);
8067 }
8068 }
8069 }
8070 }
8071 Game.SaveWrinklers=function()
8072 {
8073 var amount=0;
8074 var amountShinies=0;
8075 var number=0;
8076 var shinies=0;
8077 for (var i in Game.wrinklers)
8078 {
8079 if (Game.wrinklers[i].sucked>0.5)
8080 {
8081 number++;
8082 if (Game.wrinklers[i].type==1)
8083 {
8084 shinies++;
8085 amountShinies+=Game.wrinklers[i].sucked;
8086 }
8087 else amount+=Game.wrinklers[i].sucked;
8088 }
8089 }
8090 return {amount:amount,number:number,shinies:shinies,amountShinies:amountShinies};
8091 }
8092 Game.LoadWrinklers=function(amount,number,shinies,amountShinies)
8093 {
8094 if (number>0 && amount>0)
8095 {
8096 var fullNumber=number-shinies;
8097 var fullNumberShinies=shinies;
8098 for (var i in Game.wrinklers)
8099 {
8100 if (number>0)
8101 {
8102 Game.wrinklers[i].phase=2;
8103 Game.wrinklers[i].close=1;
8104 Game.wrinklers[i].hp=3;
8105 if (shinies>0) {Game.wrinklers[i].type=1;Game.wrinklers[i].sucked=amountShinies/fullNumberShinies;shinies--;}
8106 else Game.wrinklers[i].sucked=amount/fullNumber;
8107 number--;
8108 }//respawn
8109 }
8110 }
8111 }
8112
8113
8114 /*=====================================================================================
8115 SPECIAL THINGS AND STUFF
8116 =======================================================================================*/
8117
8118
8119 Game.specialTab='';
8120 Game.specialTabHovered='';
8121 Game.specialTabs=[];
8122
8123 Game.UpdateSpecial=function()
8124 {
8125 Game.specialTabs=[];
8126 if (Game.Has('A festive hat')) Game.specialTabs.push('santa');
8127 if (Game.Has('A crumbly egg')) Game.specialTabs.push('dragon');
8128 if (Game.specialTabs.length==0) {Game.ToggleSpecialMenu(0);return;}
8129
8130 if (Game.LeftBackground)
8131 {
8132 Game.specialTabHovered='';
8133 var len=Game.specialTabs.length;
8134 if (len==0) return;
8135 var y=Game.LeftBackground.canvas.height-24-48*len;
8136 for (var i in Game.specialTabs)
8137 {
8138 var selected=0;
8139 if (Game.specialTab==Game.specialTabs[i]) selected=1;
8140 var x=24;
8141 var s=1;
8142 if (selected) {s=2;x+=24;}
8143
8144 if (Math.abs(Game.mouseX-x)<=24*s && Math.abs(Game.mouseY-y)<=24*s)
8145 {
8146 Game.specialTabHovered=Game.specialTabs[i];
8147 Game.mousePointer=1;
8148 Game.CanClick=0;
8149 if (Game.Click)
8150 {
8151 if (Game.specialTab!=Game.specialTabs[i]) {Game.specialTab=Game.specialTabs[i];Game.ToggleSpecialMenu(1);PlaySound('snd/press.mp3');}
8152 else {Game.ToggleSpecialMenu(0);PlaySound('snd/press.mp3');}
8153 //PlaySound('snd/tick.mp3');
8154 }
8155 }
8156
8157 y+=48;
8158 }
8159 }
8160 }
8161
8162 Game.santaLevels=['Festive test tube','Festive ornament','Festive wreath','Festive tree','Festive present','Festive elf fetus','Elf toddler','Elfling','Young elf','Bulky elf','Nick','Santa Claus','Elder Santa','True Santa','Final Claus'];
8163 Game.santaDrops=['Increased merriness','Improved jolliness','A lump of coal','An itchy sweater','Reindeer baking grounds','Weighted sleighs','Ho ho ho-flavored frosting','Season savings','Toy workshop','Naughty list','Santa\'s bottomless bag','Santa\'s helpers','Santa\'s legacy','Santa\'s milk and cookies'];
8164 for (var i in Game.santaDrops)//scale christmas upgrade prices with santa level
8165 {Game.Upgrades[Game.santaDrops[i]].priceFunc=function(){return Math.pow(10,Game.santaLevel)*2525;}}
8166
8167 Game.UpgradeSanta=function()
8168 {
8169 var moni=Math.pow(Game.santaLevel+1,Game.santaLevel+1);
8170 if (Game.cookies>moni && Game.santaLevel<14)
8171 {
8172 PlaySound('snd/shimmerClick.mp3');
8173
8174 Game.Spend(moni);
8175 Game.santaLevel=(Game.santaLevel+1)%15;
8176 if (Game.santaLevel==14)
8177 {
8178 Game.Unlock('Santa\'s dominion');
8179 if (Game.prefs.popups) Game.Popup('You are granted<br>Santa\'s dominion.');
8180 else Game.Notify('You are granted Santa\'s dominion.','',Game.Upgrades['Santa\'s dominion'].icon);
8181 }
8182 var drops=[];
8183 for (var i in Game.santaDrops) {if (!Game.HasUnlocked(Game.santaDrops[i])) drops.push(Game.santaDrops[i]);}
8184 var drop=choose(drops);
8185 if (drop)
8186 {
8187 Game.Unlock(drop);
8188 if (Game.prefs.popups) Game.Popup('You find a present which contains...<br>'+drop+'!');
8189 else Game.Notify('Found a present!','You find a present which contains...<br><b>'+drop+'</b>!',Game.Upgrades[drop].icon);
8190 }
8191
8192 Game.ToggleSpecialMenu(1);
8193
8194 if (l('specialPic')){var rect=l('specialPic').getBoundingClientRect();Game.SparkleAt((rect.left+rect.right)/2,(rect.top+rect.bottom)/2);}
8195
8196 if (Game.santaLevel>=6) Game.Win('Coming to town');
8197 if (Game.santaLevel>=14) Game.Win('All hail Santa');
8198 Game.recalculateGains=1;
8199 Game.upgradesToRebuild=1;
8200 }
8201 }
8202
8203 Game.dragonLevels=[
8204 {name:'Dragon egg',action:'Chip it',pic:0,
8205 cost:function(){return Game.cookies>=1000000;},
8206 buy:function(){Game.Spend(1000000);},
8207 costStr:function(){return Beautify(1000000)+' cookies';}},
8208 {name:'Dragon egg',action:'Chip it',pic:1,
8209 cost:function(){return Game.cookies>=1000000*2;},
8210 buy:function(){Game.Spend(1000000*2);},
8211 costStr:function(){return Beautify(1000000*2)+' cookies';}},
8212 {name:'Dragon egg',action:'Chip it',pic:2,
8213 cost:function(){return Game.cookies>=1000000*4;},
8214 buy:function(){Game.Spend(1000000*4);},
8215 costStr:function(){return Beautify(1000000*4)+' cookies';}},
8216 {name:'Shivering dragon egg',action:'Hatch it',pic:3,
8217 cost:function(){return Game.cookies>=1000000*8;},
8218 buy:function(){Game.Spend(1000000*8);},
8219 costStr:function(){return Beautify(1000000*8)+' cookies';}},
8220 {name:'Krumblor, cookie hatchling',action:'Train Breath of Milk<br><small>Aura : kittens are 5% more effective</small>',pic:4,
8221 cost:function(){return Game.cookies>=1000000*16;},
8222 buy:function(){Game.Spend(1000000*16);},
8223 costStr:function(){return Beautify(1000000*16)+' cookies';}},
8224 {name:'Krumblor, cookie hatchling',action:'Train Dragon Cursor<br><small>Aura : clicking is 10% more effective</small>',pic:4,
8225 cost:function(){return Game.Objects['Cursor'].amount>=100;},
8226 buy:function(){Game.Objects['Cursor'].sacrifice(100);},
8227 costStr:function(){return '100 cursors';}},
8228 {name:'Krumblor, cookie hatchling',action:'Train Elder Battalion<br><small>Aura : grandmas gain +1% CpS for every non-grandma building</small>',pic:4,
8229 cost:function(){return Game.Objects['Grandma'].amount>=100;},
8230 buy:function(){Game.Objects['Grandma'].sacrifice(100);},
8231 costStr:function(){return '100 grandmas';}},
8232 {name:'Krumblor, cookie hatchling',action:'Train Reaper of Fields<br><small>Aura : golden cookies may trigger a Dragon Harvest</small>',pic:4,
8233 cost:function(){return Game.Objects['Farm'].amount>=100;},
8234 buy:function(){Game.Objects['Farm'].sacrifice(100);},
8235 costStr:function(){return '100 farms';}},
8236 {name:'Krumblor, cookie dragon',action:'Train Earth Shatterer<br><small>Aura : buildings sell back for 85% instead of 50%</small>',pic:5,
8237 cost:function(){return Game.Objects['Mine'].amount>=100;},
8238 buy:function(){Game.Objects['Mine'].sacrifice(100);},
8239 costStr:function(){return '100 mines';}},
8240 {name:'Krumblor, cookie dragon',action:'Train Master of the Armory<br><small>Aura : all upgrades are 2% cheaper</small>',pic:5,
8241 cost:function(){return Game.Objects['Factory'].amount>=100;},
8242 buy:function(){Game.Objects['Factory'].sacrifice(100);},
8243 costStr:function(){return '100 factories';}},
8244 {name:'Krumblor, cookie dragon',action:'Train Fierce Hoarder<br><small>Aura : all buildings are 2% cheaper</small>',pic:5,
8245 cost:function(){return Game.Objects['Bank'].amount>=100;},
8246 buy:function(){Game.Objects['Bank'].sacrifice(100);},
8247 costStr:function(){return '100 banks';}},
8248 {name:'Krumblor, cookie dragon',action:'Train Dragon God<br><small>Aura : heavenly chips bonus +25%</small>',pic:5,
8249 cost:function(){return Game.Objects['Temple'].amount>=100;},
8250 buy:function(){Game.Objects['Temple'].sacrifice(100);},
8251 costStr:function(){return '100 temples';}},
8252 {name:'Krumblor, cookie dragon',action:'Train Arcane Aura<br><small>Aura : golden cookies appear 5% more often</small>',pic:5,
8253 cost:function(){return Game.Objects['Wizard tower'].amount>=100;},
8254 buy:function(){Game.Objects['Wizard tower'].sacrifice(100);},
8255 costStr:function(){return '100 wizard towers';}},
8256 {name:'Krumblor, cookie dragon',action:'Train Dragonflight<br><small>Aura : golden cookies may trigger a Dragonflight</small>',pic:5,
8257 cost:function(){return Game.Objects['Shipment'].amount>=100;},
8258 buy:function(){Game.Objects['Shipment'].sacrifice(100);},
8259 costStr:function(){return '100 shipments';}},
8260 {name:'Krumblor, cookie dragon',action:'Train Ancestral Metamorphosis<br><small>Aura : golden cookies are 10% more powerful</small>',pic:5,
8261 cost:function(){return Game.Objects['Alchemy lab'].amount>=100;},
8262 buy:function(){Game.Objects['Alchemy lab'].sacrifice(100);},
8263 costStr:function(){return '100 alchemy labs';}},
8264 {name:'Krumblor, cookie dragon',action:'Train Unholy Dominion<br><small>Aura : wrath cookies are 10% more powerful</small>',pic:5,
8265 cost:function(){return Game.Objects['Portal'].amount>=100;},
8266 buy:function(){Game.Objects['Portal'].sacrifice(100);},
8267 costStr:function(){return '100 portals';}},
8268 {name:'Krumblor, cookie dragon',action:'Train Epoch Manipulator<br><small>Aura : golden cookie effects last 20% longer</small>',pic:5,
8269 cost:function(){return Game.Objects['Time machine'].amount>=100;},
8270 buy:function(){Game.Objects['Time machine'].sacrifice(100);},
8271 costStr:function(){return '100 time machines';}},
8272 {name:'Krumblor, cookie dragon',action:'Train Mind Over Matter<br><small>Aura : +25% random drops</small>',pic:5,
8273 cost:function(){return Game.Objects['Antimatter condenser'].amount>=100;},
8274 buy:function(){Game.Objects['Antimatter condenser'].sacrifice(100);},
8275 costStr:function(){return '100 antimatter condensers';}},
8276 {name:'Krumblor, cookie dragon',action:'Train Radiant Appetite<br><small>Aura : all cookie production multiplied by 2</small>',pic:5,
8277 cost:function(){return Game.Objects['Prism'].amount>=100;},
8278 buy:function(){Game.Objects['Prism'].sacrifice(100);},
8279 costStr:function(){return '100 prisms';}},
8280 {name:'Krumblor, cookie dragon',action:'Bake dragon cookie<br><small>Delicious!</small>',pic:6,
8281 cost:function(){var fail=0;for (var i in Game.Objects){if (Game.Objects[i].amount<50) fail=1;}return (fail==0);},
8282 buy:function(){for (var i in Game.Objects){Game.Objects[i].sacrifice(50);}Game.Unlock('Dragon cookie');},
8283 costStr:function(){return '50 of every building';}},
8284 {name:'Krumblor, cookie dragon',action:'Train secondary aura<br><small>Lets you use two dragon auras simultaneously</small>',pic:6,
8285 cost:function(){var fail=0;for (var i in Game.Objects){if (Game.Objects[i].amount<200) fail=1;}return (fail==0);},
8286 buy:function(){for (var i in Game.Objects){Game.Objects[i].sacrifice(200);}},
8287 costStr:function(){return '200 of every building';}},
8288 {name:'Krumblor, cookie dragon',action:'Your dragon is fully trained.',pic:7}
8289 ];
8290
8291 Game.dragonAuras={
8292 0:{name:'No aura',pic:[0,7],desc:'Select an aura from those your dragon knows.'},
8293 1:{name:'Breath of Milk',pic:[18,25],desc:'Kittens are <b>5%</b> more effective.'},
8294 2:{name:'Dragon Cursor',pic:[0,25],desc:'Clicking is <b>10%</b> more effective.'},
8295 3:{name:'Elder Battalion',pic:[1,25],desc:'Grandmas gain <b>+1% CpS</b> for every non-grandma building.'},
8296 4:{name:'Reaper of Fields',pic:[2,25],desc:'Golden cookies may trigger a <b>Dragon Harvest</b>.'},
8297 5:{name:'Earth Shatterer',pic:[3,25],desc:'Buildings sell back for <b>85%</b> instead of 50%.'},
8298 6:{name:'Master of the Armory',pic:[4,25],desc:'All upgrades are <b>2%</b> cheaper.'},
8299 7:{name:'Fierce Hoarder',pic:[15,25],desc:'All buildings are <b>2%</b> cheaper.'},
8300 8:{name:'Dragon God',pic:[16,25],desc:'Prestige CpS bonus <b>+25%</b>.'},
8301 9:{name:'Arcane Aura',pic:[17,25],desc:'Golden cookies appear <b>+5%</b> more often.'},
8302 10:{name:'Dragonflight',pic:[5,25],desc:'Golden cookies may trigger a <b>Dragonflight</b>.'},
8303 11:{name:'Ancestral Metamorphosis',pic:[6,25],desc:'Golden cookies are <b>10%</b> more powerful.'},
8304 12:{name:'Unholy Dominion',pic:[7,25],desc:'Wrath cookies are <b>10%</b> more powerful.'},
8305 13:{name:'Epoch Manipulator',pic:[8,25],desc:'Golden cookies last <b>20%</b> longer.'},
8306 14:{name:'Mind Over Matter',pic:[13,25],desc:'Random drops are <b>25% more common</b>.'},
8307 15:{name:'Radiant Appetite',pic:[14,25],desc:'All cookie production <b>multiplied by 2</b>.'},
8308 };
8309
8310 Game.hasAura=function(what)
8311 {
8312 if (Game.dragonAuras[Game.dragonAura].name==what || Game.dragonAuras[Game.dragonAura2].name==what) return true; else return false;
8313 }
8314
8315 Game.SelectDragonAura=function(slot,update)
8316 {
8317 var currentAura=0;
8318 var otherAura=0;
8319 if (slot==0) currentAura=Game.dragonAura; else currentAura=Game.dragonAura2;
8320 if (slot==0) otherAura=Game.dragonAura2; else otherAura=Game.dragonAura;
8321 if (!update) Game.SelectingDragonAura=currentAura;
8322
8323 var str='';
8324 for (var i in Game.dragonAuras)
8325 {
8326 if (Game.dragonLevel>=parseInt(i)+4)
8327 {
8328 var icon=Game.dragonAuras[i].pic;
8329 if (i==0 || i!=otherAura) str+='<div class="crate enabled'+(i==Game.SelectingDragonAura?' highlighted':'')+'" style="opacity:1;float:none;display:inline-block;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;" '+Game.clickStr+'="PlaySound(\'snd/tick.mp3\');Game.SetDragonAura('+i+','+slot+');" onMouseOut="Game.DescribeDragonAura('+Game.SelectingDragonAura+');" onMouseOver="Game.DescribeDragonAura('+i+');"'+
8330 '></div>';
8331 }
8332 }
8333
8334 var highestBuilding=0;
8335 for (var i in Game.Objects) {if (Game.Objects[i].amount>0) highestBuilding=Game.Objects[i];}
8336
8337 Game.Prompt('<h3>Set your dragon\'s '+(slot==1?'secondary ':'')+'aura</h3>'+
8338 '<div class="line"></div>'+
8339 '<div id="dragonAuraInfo" style="min-height:60px;"></div>'+
8340 '<div style="text-align:center;">'+str+'</div>'+
8341 '<div class="line"></div>'+
8342 '<div style="text-align:center;margin-bottom:8px;">'+(highestBuilding==0?'Switching your aura is <b>free</b> because you own no buildings.':'The cost of switching your aura is <b>1 '+highestBuilding.name+'</b>.<br>This will affect your CpS!')+'</div>'
8343 ,[['Confirm',(slot==0?'Game.dragonAura':'Game.dragonAura2')+'=Game.SelectingDragonAura;'+(highestBuilding==0 || currentAura==Game.SelectingDragonAura?'':'Game.ObjectsById['+highestBuilding.id+'].sacrifice(1);')+'Game.ToggleSpecialMenu(1);Game.ClosePrompt();'],'Cancel'],0,'widePrompt');
8344 Game.DescribeDragonAura(Game.SelectingDragonAura);
8345 }
8346 Game.SelectingDragonAura=-1;
8347 Game.SetDragonAura=function(aura,slot)
8348 {
8349 Game.SelectingDragonAura=aura;
8350 Game.SelectDragonAura(slot,1);
8351 }
8352 Game.DescribeDragonAura=function(aura)
8353 {
8354 l('dragonAuraInfo').innerHTML=
8355 '<div style="min-width:200px;text-align:center;"><h4>'+Game.dragonAuras[aura].name+'</h4>'+
8356 '<div class="line"></div>'+
8357 Game.dragonAuras[aura].desc+
8358 '</div>';
8359 }
8360
8361 Game.UpgradeDragon=function()
8362 {
8363 if (Game.dragonLevel<Game.dragonLevels.length-1 && Game.dragonLevels[Game.dragonLevel].cost())
8364 {
8365 PlaySound('snd/shimmerClick.mp3');
8366 Game.dragonLevels[Game.dragonLevel].buy();
8367 Game.dragonLevel=(Game.dragonLevel+1)%Game.dragonLevels.length;
8368
8369 if (Game.dragonLevel>=Game.dragonLevels.length-1) Game.Win('Here be dragon');
8370 Game.ToggleSpecialMenu(1);
8371 if (l('specialPic')){var rect=l('specialPic').getBoundingClientRect();Game.SparkleAt((rect.left+rect.right)/2,(rect.top+rect.bottom)/2);}
8372 Game.recalculateGains=1;
8373 Game.upgradesToRebuild=1;
8374 }
8375 }
8376
8377 Game.ToggleSpecialMenu=function(on)
8378 {
8379 if (on)
8380 {
8381 var pic='';
8382 var frame=0;
8383 if (Game.specialTab=='santa') {pic='santa.png';frame=Game.santaLevel;}
8384 else if (Game.specialTab=='dragon') {pic='dragon.png';frame=Game.dragonLevels[Game.dragonLevel].pic;}
8385 else {pic='dragon.png';frame=4;}
8386
8387 var str='<div id="specialPic" style="position:absolute;left:-16px;top:-64px;width:96px;height:96px;background:url(img/'+pic+');background-position:'+(-frame*96)+'px 0px;filter:drop-shadow(0px 3px 2px #000);-webkit-filter:drop-shadow(0px 3px 2px #000);"></div>';
8388 str+='<div class="close" onclick="PlaySound(\'snd/press.mp3\');Game.ToggleSpecialMenu(0);">x</div>';
8389
8390 if (Game.specialTab=='santa')
8391 {
8392 var moni=Math.pow(Game.santaLevel+1,Game.santaLevel+1);
8393
8394 str+='<h3>'+Game.santaLevels[Game.santaLevel]+'</h3>';
8395 if (Game.santaLevel<14)
8396 {
8397 str+='<div class="line"></div>'+
8398 '<div class="optionBox" style="margin-bottom:0px;"><a class="option framed large title" '+Game.clickStr+'="Game.UpgradeSanta();">'+
8399 '<div style="display:table-cell;vertical-align:middle;">Evolve</div>'+
8400 '<div style="display:table-cell;vertical-align:middle;padding:4px 12px;">|</div>'+
8401 '<div style="display:table-cell;vertical-align:middle;font-size:65%;">cost :<div'+(Game.cookies>moni?'':' style="color:#777;"')+'>'+Beautify(Math.pow(Game.santaLevel+1,Game.santaLevel+1))+' '+(Game.santaLevel>0?'cookies':'cookie')+'</div></div>'+
8402 '</a></div>';
8403 }
8404 }
8405 else if (Game.specialTab=='dragon')
8406 {
8407 var level=Game.dragonLevels[Game.dragonLevel];
8408
8409 str+='<h3>'+level.name+'</h3>';
8410
8411 if (Game.dragonLevel>=5)
8412 {
8413 var icon=Game.dragonAuras[Game.dragonAura].pic;
8414 str+='<div class="crate enabled" style="opacity:1;position:absolute;right:18px;top:-58px;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;" '+Game.clickStr+'="PlaySound(\'snd/tick.mp3\');Game.SelectDragonAura(0);" '+Game.getTooltip(
8415 '<div style="min-width:200px;text-align:center;"><h4>'+Game.dragonAuras[Game.dragonAura].name+'</h4>'+
8416 '<div class="line"></div>'+
8417 Game.dragonAuras[Game.dragonAura].desc+
8418 '</div>'
8419 ,'top')+
8420 '></div>';
8421 }
8422 if (Game.dragonLevel>=21)
8423 {
8424 var icon=Game.dragonAuras[Game.dragonAura2].pic;
8425 str+='<div class="crate enabled" style="opacity:1;position:absolute;right:80px;top:-58px;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;" '+Game.clickStr+'="PlaySound(\'snd/tick.mp3\');Game.SelectDragonAura(1);" '+Game.getTooltip(
8426 '<div style="min-width:200px;text-align:center;"><h4>'+Game.dragonAuras[Game.dragonAura2].name+'</h4>'+
8427 '<div class="line"></div>'+
8428 Game.dragonAuras[Game.dragonAura2].desc+
8429 '</div>'
8430 ,'top')+
8431 '></div>';
8432 }
8433
8434 if (Game.dragonLevel<Game.dragonLevels.length-1)
8435 {
8436 str+='<div class="line"></div>'+
8437 '<div class="optionBox" style="margin-bottom:0px;"><a class="option framed large title" '+Game.clickStr+'="Game.UpgradeDragon();">'+
8438 '<div style="display:table-cell;vertical-align:middle;">'+level.action+'</div>'+
8439 '<div style="display:table-cell;vertical-align:middle;padding:4px 12px;">|</div>'+
8440 '<div style="display:table-cell;vertical-align:middle;font-size:65%;">sacrifice<div'+(level.cost()?'':' style="color:#777;"')+'>'+level.costStr()+'</div></div>'+
8441 '</a></div>';
8442 }
8443 else
8444 {
8445 str+='<div class="line"></div>'+
8446 '<div style="text-align:center;margin-bottom:4px;">'+level.action+'</div>';
8447 }
8448 }
8449
8450 l('specialPopup').innerHTML=str;
8451
8452 l('specialPopup').className='framed prompt onScreen';
8453 }
8454 else
8455 {
8456 if (Game.specialTab!='')
8457 {
8458 Game.specialTab='';
8459 l('specialPopup').className='framed prompt offScreen';
8460 setTimeout(function(){if (Game.specialTab=='') {/*l('specialPopup').style.display='none';*/l('specialPopup').innerHTML='';}},1000*0.2);
8461 }
8462 }
8463 }
8464 Game.DrawSpecial=function()
8465 {
8466 var len=Game.specialTabs.length;
8467 if (len==0) return;
8468 Game.LeftBackground.globalAlpha=1;
8469 var y=Game.LeftBackground.canvas.height-24-48*len;
8470 var tabI=0;
8471
8472 for (var i in Game.specialTabs)
8473 {
8474 var selected=0;
8475 var hovered=0;
8476 if (Game.specialTab==Game.specialTabs[i]) selected=1;
8477 if (Game.specialTabHovered==Game.specialTabs[i]) hovered=1;
8478 var x=24;
8479 var s=1;
8480 var pic='';
8481 var frame=0;
8482 if (hovered) {s=1;x=24;}
8483 if (selected) {s=1;x=48;}
8484
8485 if (Game.specialTabs[i]=='santa') {pic='santa.png';frame=Game.santaLevel;}
8486 else if (Game.specialTabs[i]=='dragon') {pic='dragon.png';frame=Game.dragonLevels[Game.dragonLevel].pic;}
8487 else {pic='dragon.png';frame=4;}
8488
8489 if (hovered || selected)
8490 {
8491 var ss=s*64;
8492 var r=Math.floor((Game.T*0.5)%360);
8493 Game.LeftBackground.save();
8494 Game.LeftBackground.translate(x,y);
8495 if (Game.prefs.fancy) Game.LeftBackground.rotate((r/360)*Math.PI*2);
8496 Game.LeftBackground.globalAlpha=0.75;
8497 Game.LeftBackground.drawImage(Pic('shine.png'),-ss/2,-ss/2,ss,ss);
8498 Game.LeftBackground.restore();
8499 }
8500
8501 if (Game.prefs.fancy) Game.LeftBackground.drawImage(Pic(pic),96*frame,0,96,96,(x+(selected?0:Math.sin(Game.T*0.2+tabI)*3)-24*s),(y-(selected?6:Math.abs(Math.cos(Game.T*0.2+tabI))*6)-24*s),48*s,48*s);
8502 else Game.LeftBackground.drawImage(Pic(pic),96*frame,0,96,96,(x-24*s),(y-24*s),48*s,48*s);
8503
8504 tabI++;
8505 y+=48;
8506 }
8507
8508 }
8509
8510 /*=====================================================================================
8511 VISUAL EFFECTS
8512 =======================================================================================*/
8513
8514 Game.Milks=[
8515 {name:'Rank I : Plain milk',pic:'milkPlain'},
8516 {name:'Rank II : Chocolate milk',pic:'milkChocolate'},
8517 {name:'Rank III : Raspberry milk',pic:'milkRaspberry'},
8518 {name:'Rank IV : Orange milk',pic:'milkOrange'},
8519 {name:'Rank V : Caramel milk',pic:'milkCaramel'},
8520 {name:'Rank VI : Banana milk',pic:'milkBanana'},
8521 {name:'Rank VII : Lime milk',pic:'milkLime'},
8522 {name:'Rank VIII : Blueberry milk',pic:'milkBlueberry'},
8523 {name:'Rank IX : Strawberry milk',pic:'milkStrawberry'},
8524 {name:'Rank X : Vanilla milk',pic:'milkVanilla'},
8525 {name:'Rank XI : Zebra milk',pic:'milkZebra'},
8526 {name:'Rank XII : Cosmic milk',pic:'milkStars'},
8527 {name:'Rank XIII : Flaming milk',pic:'milkFire'},
8528 {name:'Rank XIV : Sanguine milk',pic:'milkBlood'},
8529 {name:'Rank XV : Midas milk',pic:'milkGold'},
8530 {name:'Rank XVI : Midnight milk',pic:'milkBlack'},
8531 {name:'Rank XVII : Green inferno milk',pic:'milkGreenFire'},
8532 {name:'Rank XVIII : Frostfire milk',pic:'milkBlueFire'},
8533 ];
8534 Game.Milk=Game.Milks[0];
8535
8536 Game.mousePointer=0;//when 1, draw the mouse as a pointer on the left screen
8537
8538 Game.cookieOriginX=0;
8539 Game.cookieOriginY=0;
8540 Game.DrawBackground=function()
8541 {
8542 Timer.clean();
8543 //background
8544 if (!Game.Background)//init some stuff
8545 {
8546 Game.Background=l('backgroundCanvas').getContext('2d');
8547 Game.Background.canvas.width=Game.Background.canvas.parentNode.offsetWidth;
8548 Game.Background.canvas.height=Game.Background.canvas.parentNode.offsetHeight;
8549 Game.LeftBackground=l('backgroundLeftCanvas').getContext('2d');
8550 Game.LeftBackground.canvas.width=Game.LeftBackground.canvas.parentNode.offsetWidth;
8551 Game.LeftBackground.canvas.height=Game.LeftBackground.canvas.parentNode.offsetHeight;
8552 //preload ascend animation bits so they show up instantly
8553 Game.LeftBackground.globalAlpha=0;
8554 Game.LeftBackground.drawImage(Pic('brokenCookie.png'),0,0);
8555 Game.LeftBackground.drawImage(Pic('brokenCookieHalo.png'),0,0);
8556 Game.LeftBackground.drawImage(Pic('starbg.jpg'),0,0);
8557
8558 window.addEventListener('resize', function(event)
8559 {
8560 Game.Background.canvas.width=Game.Background.canvas.parentNode.offsetWidth;
8561 Game.Background.canvas.height=Game.Background.canvas.parentNode.offsetHeight;
8562 Game.LeftBackground.canvas.width=Game.LeftBackground.canvas.parentNode.offsetWidth;
8563 Game.LeftBackground.canvas.height=Game.LeftBackground.canvas.parentNode.offsetHeight;
8564 });
8565 }
8566
8567
8568 if (Game.OnAscend)
8569 {
8570 Timer.clean();
8571 //starry background on ascend screen
8572 var w=Game.Background.canvas.width;
8573 var h=Game.Background.canvas.height;
8574 var b=Game.ascendl.getBoundingClientRect();
8575 var x=(b.left+b.right)/2;
8576 var y=(b.top+b.bottom)/2;
8577 Game.Background.globalAlpha=0.5;
8578 var s=1*Game.AscendZoom*(1+Math.cos(Game.T*0.0027)*0.05);
8579 Game.Background.fillPattern(Pic('starbg.jpg'),0,0,w,h,1024*s,1024*s,x+Game.AscendOffX*0.25*s,y+Game.AscendOffY*0.25*s);
8580 Timer.track('star layer 1');
8581 if (Game.prefs.fancy)
8582 {
8583 //additional star layer
8584 Game.Background.globalAlpha=0.5*(0.5+Math.sin(Game.T*0.02)*0.3);
8585 var s=2*Game.AscendZoom*(1+Math.sin(Game.T*0.002)*0.07);
8586 //Game.Background.globalCompositeOperation='lighter';
8587 Game.Background.fillPattern(Pic('starbg.jpg'),0,0,w,h,1024*s,1024*s,x+Game.AscendOffX*0.25*s,y+Game.AscendOffY*0.25*s);
8588 //Game.Background.globalCompositeOperation='source-over';
8589 Timer.track('star layer 2');
8590
8591 x=x+Game.AscendOffX*Game.AscendZoom;
8592 y=y+Game.AscendOffY*Game.AscendZoom;
8593 //wispy nebula around the center
8594 Game.Background.save();
8595 Game.Background.globalAlpha=0.5;
8596 Game.Background.translate(x,y);
8597 Game.Background.globalCompositeOperation='lighter';
8598 Game.Background.rotate(Game.T*0.001);
8599 s=(600+150*Math.sin(Game.T*0.007))*Game.AscendZoom;
8600 Game.Background.drawImage(Pic('heavenRing1.jpg'),-s/2,-s/2,s,s);
8601 Game.Background.rotate(-Game.T*0.0017);
8602 s=(600+150*Math.sin(Game.T*0.0037))*Game.AscendZoom;
8603 Game.Background.drawImage(Pic('heavenRing2.jpg'),-s/2,-s/2,s,s);
8604 Game.Background.restore();
8605 Timer.track('nebula');
8606
8607 /*
8608 //links between upgrades
8609 //not in because I am bad at this
8610 Game.Background.globalAlpha=1;
8611 Game.Background.save();
8612 Game.Background.translate(x,y);
8613 s=(32)*Game.AscendZoom;
8614
8615 for (var i in Game.PrestigeUpgrades)
8616 {
8617 var me=Game.PrestigeUpgrades[i];
8618 var ghosted=0;
8619 if (me.canBePurchased || Game.Has('Neuromancy')){}
8620 else
8621 {
8622 for (var ii in me.parents){if (me.parents[ii]!=-1 && me.parents[ii].canBePurchased) ghosted=1;}
8623 }
8624 for (var ii in me.parents)//create pulsing links
8625 {
8626 if (me.parents[ii]!=-1 && (me.canBePurchased || ghosted))
8627 {
8628 var origX=0;
8629 var origY=0;
8630 var targX=me.posX+28;
8631 var targY=me.posY+28;
8632 if (me.parents[ii]!=-1) {origX=me.parents[ii].posX+28;origY=me.parents[ii].posY+28;}
8633 var rot=-Math.atan((targY-origY)/(origX-targX));
8634 if (targX<=origX) rot+=180;
8635 var dist=Math.floor(Math.sqrt((targX-origX)*(targX-origX)+(targY-origY)*(targY-origY)));
8636 origX+=2;
8637 origY-=18;
8638 //rot=-(Math.PI/2)*(me.id%4);
8639 Game.Background.translate(origX,origY);
8640 Game.Background.rotate(rot);
8641 //Game.Background.drawImage(Pic('linkPulse.png'),-s/2,-s/2,s,s);
8642 Game.Background.fillPattern(Pic('linkPulse.png'),0,-4,dist,8,32,8);
8643 Game.Background.rotate(-rot);
8644 Game.Background.translate(-origX,-origY);
8645 }
8646 }
8647 }
8648 Game.Background.restore();
8649 Timer.track('links');
8650 */
8651
8652 //Game.Background.drawImage(Pic('shadedBorders.png'),0,0,w,h);
8653 //Timer.track('border');
8654 }
8655 }
8656 else
8657 {
8658
8659 var goodBuff=0;
8660 var badBuff=0;
8661 for (var i in Game.buffs)
8662 {
8663 if (Game.buffs[i].aura==1) goodBuff=1;
8664 if (Game.buffs[i].aura==2) badBuff=1;
8665 }
8666
8667 if (Game.drawT%15==0)
8668 {
8669 Game.defaultBg='bgBlue';
8670 if (Game.season=='fools') Game.defaultBg='bgMoney';
8671 if (Game.elderWrathD<1)
8672 {
8673 Game.bgR=0;
8674 Game.bg=Game.defaultBg;
8675 Game.bgFade=Game.defaultBg;
8676 }
8677 else if (Game.elderWrathD>=1 && Game.elderWrathD<2)
8678 {
8679 Game.bgR=(Game.elderWrathD-1)/1;
8680 Game.bg=Game.defaultBg;
8681 Game.bgFade='grandmas1';
8682 }
8683 else if (Game.elderWrathD>=2 && Game.elderWrathD<3)
8684 {
8685 Game.bgR=(Game.elderWrathD-2)/1;
8686 Game.bg='grandmas1';
8687 Game.bgFade='grandmas2';
8688 }
8689 else if (Game.elderWrathD>=3)// && Game.elderWrathD<4)
8690 {
8691 Game.bgR=(Game.elderWrathD-3)/1;
8692 Game.bg='grandmas2';
8693 Game.bgFade='grandmas3';
8694 }
8695 var s1=512;if (Game.bg==Game.defaultBg) s1=600;
8696 var s2=512;if (Game.bgFade==Game.defaultBg) s2=600;
8697 var x=0;
8698 var y=0;
8699 Game.Background.fillPattern(Pic(Game.bg+'.jpg'),0,0,Game.Background.canvas.width,Game.Background.canvas.height,s1,s1,x,y);
8700 if (Game.bgR>0)
8701 {
8702 Game.Background.globalAlpha=Game.bgR;
8703 Game.Background.fillPattern(Pic(Game.bgFade+'.jpg'),0,0,Game.Background.canvas.width,Game.Background.canvas.height,s2,s2,x,y);
8704 }
8705 Game.Background.globalAlpha=1;
8706 Game.Background.drawImage(Pic('shadedBordersSoft.png'),0,0,Game.Background.canvas.width,Game.Background.canvas.height);
8707 }
8708 Timer.track('window background');
8709
8710 //clear
8711 Game.LeftBackground.clearRect(0,0,Game.LeftBackground.canvas.width,Game.LeftBackground.canvas.height);
8712 /*if (Game.AscendTimer<Game.AscendBreakpoint) Game.LeftBackground.clearRect(0,0,Game.LeftBackground.canvas.width,Game.LeftBackground.canvas.height);
8713 else
8714 {
8715 Game.LeftBackground.globalAlpha=0.05;
8716 Game.LeftBackground.fillStyle='#000';
8717 Game.LeftBackground.fillRect(0,0,Game.LeftBackground.canvas.width,Game.LeftBackground.canvas.height);
8718 Game.LeftBackground.globalAlpha=1;
8719 OldCanvasDrawImage.apply(Game.LeftBackground,[Game.LeftBackground.canvas,Math.random()*4-2,Math.random()*4-2-4]);
8720 Game.LeftBackground.globalAlpha=1;
8721 }*/
8722 Timer.clean();
8723
8724 var showDragon=0;
8725 if (Game.hasBuff('Dragonflight') || Game.hasBuff('Dragon Harvest')) showDragon=1;
8726
8727 Game.cookieOriginX=Math.floor(Game.LeftBackground.canvas.width/2);
8728 Game.cookieOriginY=Math.floor(Game.LeftBackground.canvas.height*0.4);
8729
8730 if (Game.AscendTimer==0)
8731 {
8732 if (Game.prefs.particles)
8733 {
8734 //falling cookies
8735 var pic='';
8736 var opacity=1;
8737 if (Game.elderWrathD<=1.5)
8738 {
8739 if (Game.cookiesPs>=1000) pic='cookieShower3.png';
8740 else if (Game.cookiesPs>=500) pic='cookieShower2.png';
8741 else if (Game.cookiesPs>=50) pic='cookieShower1.png';
8742 else pic='';
8743 }
8744 if (pic!='')
8745 {
8746 if (Game.elderWrathD>=1) opacity=1-((Math.min(Game.elderWrathD,1.5)-1)/0.5);
8747 Game.LeftBackground.globalAlpha=opacity;
8748 var y=(Math.floor(Game.T*2)%512);
8749 Game.LeftBackground.fillPattern(Pic(pic),0,0,Game.LeftBackground.canvas.width,Game.LeftBackground.canvas.height+512,512,512,0,y);
8750 Game.LeftBackground.globalAlpha=1;
8751 }
8752 //snow
8753 if (Game.season=='christmas')
8754 {
8755 var y=(Math.floor(Game.T*2.5)%512);
8756 Game.LeftBackground.globalAlpha=0.75;
8757 Game.LeftBackground.globalCompositeOperation='lighter';
8758 Game.LeftBackground.fillPattern(Pic('snow2.jpg'),0,0,Game.LeftBackground.canvas.width,Game.LeftBackground.canvas.height+512,512,512,0,y);
8759 Game.LeftBackground.globalCompositeOperation='source-over';
8760 Game.LeftBackground.globalAlpha=1;
8761 }
8762 //hearts
8763 if (Game.season=='valentines')
8764 {
8765 var y=(Math.floor(Game.T*2.5)%512);
8766 Game.LeftBackground.globalAlpha=1;
8767 Game.LeftBackground.fillPattern(Pic('heartStorm.png'),0,0,Game.LeftBackground.canvas.width,Game.LeftBackground.canvas.height+512,512,512,0,y);
8768 Game.LeftBackground.globalAlpha=1;
8769 }
8770 Timer.track('left background');
8771
8772 Game.particlesDraw(0);
8773 Game.LeftBackground.globalAlpha=1;
8774 Timer.track('particles');
8775
8776 //big cookie shine
8777 var s=512;
8778
8779 var x=Game.cookieOriginX;
8780 var y=Game.cookieOriginY;
8781
8782 var r=Math.floor((Game.T*0.5)%360);
8783 Game.LeftBackground.save();
8784 Game.LeftBackground.translate(x,y);
8785 Game.LeftBackground.rotate((r/360)*Math.PI*2);
8786 Game.LeftBackground.globalAlpha=0.5;
8787 Game.LeftBackground.drawImage(Pic('shine.png'),-s/2,-s/2,s,s);
8788 Game.LeftBackground.rotate((-r*2/360)*Math.PI*2);
8789 Game.LeftBackground.globalAlpha=0.25;
8790 Game.LeftBackground.drawImage(Pic('shine.png'),-s/2,-s/2,s,s);
8791 Game.LeftBackground.restore();
8792 Timer.track('shine');
8793
8794 if (Game.ReincarnateTimer>0)
8795 {
8796 Game.LeftBackground.globalAlpha=1-Game.ReincarnateTimer/Game.ReincarnateDuration;
8797 Game.LeftBackground.fillStyle='#000';
8798 Game.LeftBackground.fillRect(0,0,Game.LeftBackground.canvas.width,Game.LeftBackground.canvas.height);
8799 Game.LeftBackground.globalAlpha=1;
8800 }
8801
8802 if (showDragon)
8803 {
8804 //big dragon
8805 var s=300*2*(1+Math.sin(Game.T*0.013)*0.1);
8806 var x=Game.cookieOriginX-s/2;
8807 var y=Game.cookieOriginY-s/(1.4+0.2*Math.sin(Game.T*0.01));
8808 Game.LeftBackground.drawImage(Pic('dragonBG.png'),x,y,s,s);
8809 }
8810
8811 //big cookie
8812 if (false)//don't do that
8813 {
8814 Game.LeftBackground.globalAlpha=1;
8815 var amount=Math.floor(Game.cookies).toString();
8816 var digits=amount.length;
8817 var space=0;
8818 for (var i=0;i<digits;i++)
8819 {
8820 var s=16*(digits-i);
8821 var num=parseInt(amount[i]);
8822 if (i>0) space-=s*(1-num/10)/2;
8823 if (i==0 && num>1) space+=s*0.1;
8824 for (var ii=0;ii<num;ii++)
8825 {
8826 var x=Game.cookieOriginX;
8827 var y=Game.cookieOriginY;
8828 var spin=Game.T*(0.005+i*0.001)+i+(ii/num)*Math.PI*2;
8829 x+=Math.sin(spin)*space;
8830 y+=Math.cos(spin)*space;
8831 Game.LeftBackground.drawImage(Pic('perfectCookie.png'),x-s/2,y-s/2,s,s);
8832 }
8833 space+=s/2;
8834 }
8835 }
8836 else
8837 {
8838 Game.LeftBackground.globalAlpha=1;
8839 var s=256*Game.BigCookieSize;
8840 var x=Game.cookieOriginX;
8841 var y=Game.cookieOriginY;
8842 Game.LeftBackground.save();
8843 Game.LeftBackground.translate(x,y);
8844 if (Game.season=='easter')
8845 {
8846 var nestW=304*0.98*Game.BigCookieSize;
8847 var nestH=161*0.98*Game.BigCookieSize;
8848 Game.LeftBackground.drawImage(Pic('nest.png'),-nestW/2,-nestH/2+130,nestW,nestH);
8849 }
8850 //Game.LeftBackground.rotate(((Game.startDate%360)/360)*Math.PI*2);
8851 Game.LeftBackground.drawImage(Pic('perfectCookie.png'),-s/2,-s/2,s,s);
8852
8853 if (goodBuff && Game.prefs.particles)//sparkle
8854 {
8855 Game.LeftBackground.globalCompositeOperation='lighter';
8856 for (var i=0;i<1;i++)
8857 {
8858 Game.LeftBackground.globalAlpha=Math.random()*0.65+0.1;
8859 var size=Math.random()*30+5;
8860 var a=Math.random()*Math.PI*2;
8861 var d=s*Math.random()/2;
8862 Game.LeftBackground.drawImage(Pic('glint.jpg'),-size/2+Math.sin(a)*d,-size/2+Math.cos(a)*d,size,size);
8863 }
8864 }
8865
8866 Game.LeftBackground.restore();
8867 Timer.track('big cookie');
8868 }
8869 }
8870 else//no particles
8871 {
8872 //big cookie shine
8873 var s=512;
8874 var x=Game.cookieOriginX-s/2;
8875 var y=Game.cookieOriginY-s/2;
8876 Game.LeftBackground.globalAlpha=0.5;
8877 Game.LeftBackground.drawImage(Pic('shine.png'),x,y,s,s);
8878
8879 if (showDragon)
8880 {
8881 //big dragon
8882 var s=300*2*(1+Math.sin(Game.T*0.013)*0.1);
8883 var x=Game.cookieOriginX-s/2;
8884 var y=Game.cookieOriginY-s/(1.4+0.2*Math.sin(Game.T*0.01));
8885 Game.LeftBackground.drawImage(Pic('dragonBG.png'),x,y,s,s);
8886 }
8887
8888 //big cookie
8889 Game.LeftBackground.globalAlpha=1;
8890 var s=256*Game.BigCookieSize;
8891 var x=Game.cookieOriginX-s/2;
8892 var y=Game.cookieOriginY-s/2;
8893 Game.LeftBackground.drawImage(Pic('perfectCookie.png'),x,y,s,s);
8894 }
8895
8896 //cursors
8897 if (Game.prefs.cursors)
8898 {
8899 if (showDragon) Game.LeftBackground.globalAlpha=0.25;
8900 var amount=Game.Objects['Cursor'].amount;
8901 var spe=-1;
8902 for (var i=0;i<amount;i++)
8903 {
8904 var n=Math.floor(i/50);
8905 var a=((i+0.5*n)%50)/50;
8906 var w=0;
8907 var r=(-(a)*360);
8908 if (Game.prefs.fancy) w=(Math.sin(Game.T*0.025+(((i+n*12)%25)/25)*Math.PI*2));
8909 if (w>0.997) w=1.5;
8910 else if (w>0.994) w=0.5;
8911 else w=0;
8912 w*=-4;
8913 if (Game.prefs.fancy) w+=Math.sin((n+Game.T*0.01)*Math.PI/2)*4;
8914 if (Game.prefs.fancy) r=(-(a)*360-Game.T*0.1);
8915 var x=0;
8916 var y=(140/* *Game.BigCookieSize*/+n*16+w)-16;
8917
8918
8919 Game.LeftBackground.save();
8920 Game.LeftBackground.translate(Game.cookieOriginX,Game.cookieOriginY);
8921 Game.LeftBackground.rotate((r/360)*Math.PI*2);
8922 Game.LeftBackground.drawImage(Pic('cursor.png'),32*(i==spe),0,32,32,x,y,32,32);
8923 Game.LeftBackground.restore();
8924
8925 /*if (i==spe)
8926 {
8927 y+=16;
8928 x=Game.cookieOriginX+Math.sin(-((r-5)/360)*Math.PI*2)*y;
8929 y=Game.cookieOriginY+Math.cos(-((r-5)/360)*Math.PI*2)*y;
8930 if (Game.CanClick && Game.LeftBackground && Math.abs(Game.mouseX-x)<16 && Math.abs(Game.mouseY-y)<16) Game.mousePointer=1;
8931 }*/
8932 }
8933 Timer.track('cursors');
8934 }
8935 }
8936 else
8937 {
8938 var tBase=Math.max(0,(Game.AscendTimer-Game.AscendBreakpoint)/(Game.AscendDuration-Game.AscendBreakpoint));
8939 //big crumbling cookie
8940 //var t=(3*Math.pow(tBase,2)-2*Math.pow(tBase,3));//S curve
8941 var t=Math.pow(tBase,0.5);
8942
8943 var shake=0;
8944 if (Game.AscendTimer<Game.AscendBreakpoint) {shake=Game.AscendTimer/Game.AscendBreakpoint;}
8945 //else {shake=1-t;}
8946
8947 Game.LeftBackground.globalAlpha=1;
8948
8949 var x=Game.cookieOriginX;
8950 var y=Game.cookieOriginY;
8951
8952 x+=(Math.random()*2-1)*10*shake;
8953 y+=(Math.random()*2-1)*10*shake;
8954
8955 var s=1;
8956 if (tBase>0)
8957 {
8958 Game.LeftBackground.save();
8959 Game.LeftBackground.globalAlpha=1-Math.pow(t,0.5);
8960 Game.LeftBackground.translate(x,y);
8961 Game.LeftBackground.globalCompositeOperation='lighter';
8962 Game.LeftBackground.rotate(Game.T*0.007);
8963 s=0.5+Math.pow(tBase,0.6)*1;
8964 var s2=(600)*s;
8965 Game.LeftBackground.drawImage(Pic('heavenRing1.jpg'),-s2/2,-s2/2,s2,s2);
8966 Game.LeftBackground.rotate(-Game.T*0.002);
8967 s=0.5+Math.pow(1-tBase,0.4)*1;
8968 s2=(600)*s;
8969 Game.LeftBackground.drawImage(Pic('heavenRing2.jpg'),-s2/2,-s2/2,s2,s2);
8970 Game.LeftBackground.restore();
8971 }
8972
8973 s=256;//*Game.BigCookieSize;
8974
8975 Game.LeftBackground.save();
8976 Game.LeftBackground.translate(x,y);
8977 Game.LeftBackground.rotate((t*(-0.1))*Math.PI*2);
8978
8979 var chunks={0:7,1:6,2:3,3:2,4:8,5:1,6:9,7:5,8:0,9:4};
8980 s*=t/2+1;
8981 /*Game.LeftBackground.globalAlpha=(1-t)*0.33;
8982 for (var i=0;i<10;i++)
8983 {
8984 var d=(t-0.2)*(80+((i+2)%3)*40);
8985 Game.LeftBackground.drawImage(Pic('brokenCookie.png'),256*(chunks[i]),0,256,256,-s/2+Math.sin(-(((chunks[i]+4)%10)/10)*Math.PI*2)*d,-s/2+Math.cos(-(((chunks[i]+4)%10)/10)*Math.PI*2)*d,s,s);
8986 }
8987 Game.LeftBackground.globalAlpha=(1-t)*0.66;
8988 for (var i=0;i<10;i++)
8989 {
8990 var d=(t-0.1)*(80+((i+2)%3)*40);
8991 Game.LeftBackground.drawImage(Pic('brokenCookie.png'),256*(chunks[i]),0,256,256,-s/2+Math.sin(-(((chunks[i]+4)%10)/10)*Math.PI*2)*d,-s/2+Math.cos(-(((chunks[i]+4)%10)/10)*Math.PI*2)*d,s,s);
8992 }*/
8993 Game.LeftBackground.globalAlpha=1-t;
8994 for (var i=0;i<10;i++)
8995 {
8996 var d=(t)*(80+((i+2)%3)*40);
8997 var x2=(Math.random()*2-1)*5*shake;
8998 var y2=(Math.random()*2-1)*5*shake;
8999 Game.LeftBackground.drawImage(Pic('brokenCookie.png'),256*(chunks[i]),0,256,256,-s/2+Math.sin(-(((chunks[i]+4)%10)/10)*Math.PI*2)*d+x2,-s/2+Math.cos(-(((chunks[i]+4)%10)/10)*Math.PI*2)*d+y2,s,s);
9000 }
9001 var brokenHalo=1-Math.min(t/(1/3),1/3)*3;
9002 if (Game.AscendTimer<Game.AscendBreakpoint) brokenHalo=Game.AscendTimer/Game.AscendBreakpoint;
9003 Game.LeftBackground.globalAlpha=brokenHalo;
9004 Game.LeftBackground.drawImage(Pic('brokenCookieHalo.png'),-s/1.3333,-s/1.3333,s*1.5,s*1.5);
9005
9006 Game.LeftBackground.restore();
9007
9008 //flares
9009 var n=9;
9010 var t=Game.AscendTimer/Game.AscendBreakpoint;
9011 if (Game.AscendTimer<Game.AscendBreakpoint)
9012 {
9013 Game.LeftBackground.save();
9014 Game.LeftBackground.translate(x,y);
9015 for (var i=0;i<n;i++)
9016 {
9017 if (Math.floor(t/3*n*3+i*2.7)%2)
9018 {
9019 var t2=Math.pow((t/3*n*3+i*2.7)%1,1.5);
9020 Game.LeftBackground.globalAlpha=(1-t)*(Game.drawT%2==0?0.5:1);
9021 var sw=(1-t2*0.5)*96;
9022 var sh=(0.5+t2*1.5)*96;
9023 Game.LeftBackground.drawImage(Pic('shineSpoke.png'),-sw/2,-sh-32-(1-t2)*256,sw,sh);
9024 }
9025 Game.LeftBackground.rotate(Math.PI*2/n);
9026 }
9027 Game.LeftBackground.restore();
9028 }
9029
9030
9031 //flash at breakpoint
9032 if (tBase<0.1 && tBase>0)
9033 {
9034 Game.LeftBackground.globalAlpha=1-tBase/0.1;
9035 Game.LeftBackground.fillStyle='#fff';
9036 Game.LeftBackground.fillRect(0,0,Game.LeftBackground.canvas.width,Game.LeftBackground.canvas.height);
9037 Game.LeftBackground.globalAlpha=1;
9038 }
9039 if (tBase>0.8)
9040 {
9041 Game.LeftBackground.globalAlpha=(tBase-0.8)/0.2;
9042 Game.LeftBackground.fillStyle='#000';
9043 Game.LeftBackground.fillRect(0,0,Game.LeftBackground.canvas.width,Game.LeftBackground.canvas.height);
9044 Game.LeftBackground.globalAlpha=1;
9045 }
9046 }
9047
9048 //milk and milk accessories
9049 if (Game.prefs.milk)
9050 {
9051 var width=Game.LeftBackground.canvas.width;
9052 var height=Game.LeftBackground.canvas.height;
9053 var x=Math.floor((Game.T*2-(Game.milkH-Game.milkHd)*2000+480*2)%480);//Math.floor((Game.T*2+Math.sin(Game.T*0.1)*2+Math.sin(Game.T*0.03)*2-(Game.milkH-Game.milkHd)*2000+480*2)%480);
9054 var y=(Game.milkHd)*height;//(((Game.milkHd)*Game.LeftBackground.canvas.height)*(1+0.05*(Math.sin(Game.T*0.017)/2+0.5)));
9055 var a=1;
9056 if (Game.AscendTimer>0)
9057 {
9058 y*=1-Math.pow((Game.AscendTimer/Game.AscendBreakpoint),2)*2;
9059 a*=1-Math.pow((Game.AscendTimer/Game.AscendBreakpoint),2)*2;
9060 }
9061 else if (Game.ReincarnateTimer>0)
9062 {
9063 y*=1-Math.pow(1-(Game.ReincarnateTimer/Game.ReincarnateDuration),2)*2;
9064 a*=1-Math.pow(1-(Game.ReincarnateTimer/Game.ReincarnateDuration),2)*2;
9065 }
9066 var pic=Game.Milk.pic;
9067 if (Game.milkType!=0 && Game.ascensionMode!=1) pic=Game.MilksByChoice[Game.milkType].pic;
9068 Game.LeftBackground.globalAlpha=0.9*a;
9069 Game.LeftBackground.fillPattern(Pic(pic+'.png'),0,height-y,width+480,1,480,480,x,0);
9070
9071 Game.LeftBackground.fillStyle='#000';
9072 Game.LeftBackground.fillRect(0,height-y+480,width,Math.max(0,(y-480)));
9073 Game.LeftBackground.globalAlpha=1;
9074
9075 /*
9076 //accessories
9077 //quick test
9078 //should be draggable with mouse
9079 //add a full object system
9080 var x=64+Math.sin(Game.T*0.04)*16+Math.sin(Game.T*0.003)*16;
9081 var y=height-(Game.milkHd)*height+Math.sin(Game.T*0.1)*2+Math.sin(Game.T*0.007)*4;
9082 var r=Math.sin(Game.T*0.03)*20;
9083 //if (Game.mouseDown) {x=Game.mouseX;y=Game.mouseY;r=0;}
9084 Game.LeftBackground.save();
9085 Game.LeftBackground.translate(x,y);
9086 Game.LeftBackground.rotate((r/360)*Math.PI*2);
9087 Game.LeftBackground.drawImage(Pic('smallCookies.png'),0,0,64,64,-32,-32,64,64);
9088 Game.LeftBackground.restore();
9089 */
9090 Timer.track('milk');
9091 }
9092
9093 if (Game.AscendTimer>0)
9094 {
9095 Game.LeftBackground.drawImage(Pic('shadedBordersSoft.png'),0,0,Game.LeftBackground.canvas.width,Game.LeftBackground.canvas.height);
9096 }
9097
9098 if (Game.AscendTimer==0)
9099 {
9100 Game.DrawWrinklers();Timer.track('wrinklers');
9101 Game.DrawSpecial();Timer.track('evolvables');
9102
9103 Game.particlesDraw(2);Timer.track('text particles');
9104
9105 //shiny border during frenzies etc
9106 Game.LeftBackground.globalAlpha=1;
9107 var borders='shadedBordersSoft.png';
9108 if (goodBuff) borders='shadedBordersGold.png';
9109 else if (badBuff) borders='shadedBordersRed.png';
9110 Game.LeftBackground.drawImage(Pic(borders),0,0,Game.LeftBackground.canvas.width,Game.LeftBackground.canvas.height);
9111 }
9112 }
9113 };
9114
9115
9116 /*=====================================================================================
9117 INITIALIZATION END; GAME READY TO LAUNCH
9118 =======================================================================================*/
9119
9120 Game.killShimmers();
9121
9122 //booooo
9123 Game.RuinTheFun=function(silent)
9124 {
9125 Game.popups=0;
9126 for (var i in Game.Upgrades)
9127 {
9128 //if (!Game.Upgrades[i].season && Game.Upgrades[i].name!='Golden switch') Game.Upgrades[i].earn();
9129 if (Game.Upgrades[i].pool=='toggle') {}//Game.Upgrades[i].unlock();
9130 else Game.Upgrades[i].earn();
9131 }
9132 for (var i in Game.Achievements)
9133 {
9134 if (Game.Achievements[i].pool!='dungeon') Game.Win(Game.Achievements[i].name);
9135 }
9136 Game.Earn(999999999999999999999999999999);
9137 Game.MaxSpecials();
9138 Game.upgradesToRebuild=1;
9139 Game.recalculateGains=1;
9140 Game.popups=1;
9141 if (!silent)
9142 {
9143 if (Game.prefs.popups) Game.Popup('Thou doth ruineth the fun!');
9144 else Game.Notify('Thou doth ruineth the fun!','You\'re free. Free at last.',[11,5]);
9145 }
9146 }
9147
9148 Game.SetAllUpgrades=function(on)
9149 {
9150 Game.popups=0;
9151 for (var i in Game.Upgrades)
9152 {
9153 //if (on && !Game.Upgrades[i].season && Game.Upgrades[i].name!='Golden switch') Game.Upgrades[i].earn();
9154 if (on && Game.Upgrades[i].pool=='toggle') {}//Game.Upgrades[i].unlock();
9155 else if (on) Game.Upgrades[i].earn();
9156 else if (!on) Game.Upgrades[i].lose();
9157 }
9158 Game.upgradesToRebuild=1;
9159 Game.recalculateGains=1;
9160 Game.popups=1;
9161 }
9162 Game.SetAllAchievs=function(on)
9163 {
9164 Game.popups=0;
9165 for (var i in Game.Achievements)
9166 {
9167 if (on) Game.Win(Game.Achievements[i].name);
9168 else if (!on) Game.RemoveAchiev(Game.Achievements[i].name);
9169 }
9170 Game.recalculateGains=1;
9171 Game.popups=1;
9172 }
9173 Game.GetAllDebugs=function()
9174 {
9175 Game.popups=0;
9176 for (var i in Game.Upgrades)
9177 {
9178 if (Game.Upgrades[i].pool=='debug') Game.Upgrades[i].earn();
9179 }
9180 Game.upgradesToRebuild=1;
9181 Game.recalculateGains=1;
9182 Game.popups=1;
9183 }
9184 Game.MaxSpecials=function()
9185 {
9186 Game.dragonLevel=Game.dragonLevels.length-1;
9187 Game.santaLevel=Game.santaLevels.length-1;
9188 }
9189
9190 Game.SesameReset=function()
9191 {
9192 var name=Game.bakeryName;
9193 Game.HardReset(2);
9194 Game.bakeryName=name;
9195 Game.bakeryNameRefresh();
9196 Game.Achievements['Cheated cookies taste awful'].won=1;
9197 }
9198
9199 Game.debugTimersOn=0;
9200 Game.sesame=0;
9201 Game.OpenSesame=function()
9202 {
9203 var str='';
9204 str+='<div class="icon" style="position:absolute;left:-9px;top:-6px;background-position:'+(-10*48)+'px '+(-6*48)+'px;"></div>';
9205 str+='<div style="position:absolute;left:0px;top:0px;z-index:10;font-size:10px;background:#000;padding:1px;" id="fpsCounter"></div>';
9206
9207 str+='<div id="devConsoleContent">';
9208 str+='<div class="title" style="font-size:14px;margin:6px;">Dev tools</div>';
9209
9210 str+='<a class="option neato" '+Game.clickStr+'="Game.Ascend(1);">Ascend</a>';
9211 str+='<div class="line"></div>';
9212 str+='<a class="option neato" '+Game.clickStr+'="Game.cookies*=10;Game.cookiesEarned*=10;">x10</a>';
9213 str+='<a class="option neato" '+Game.clickStr+'="Game.cookies/=10;Game.cookiesEarned/=10;">/10</a><br>';
9214 str+='<a class="option neato" '+Game.clickStr+'="Game.cookies*=1000;Game.cookiesEarned*=1000;">x1k</a>';
9215 str+='<a class="option neato" '+Game.clickStr+'="Game.cookies/=1000;Game.cookiesEarned/=1000;">/1k</a><br>';
9216 str+='<a class="option neato" '+Game.clickStr+'="for (var i in Game.Objects){Game.Objects[i].buy(100);}">Buy 100 of all</a>';//for (var n=0;n<100;n++){for (var i in Game.Objects){Game.Objects[i].buy(1);}}
9217 str+='<a class="option neato" '+Game.clickStr+'="for (var i in Game.Objects){Game.Objects[i].sell(100);}">Sell 100 of all</a>';
9218 str+='<div class="line"></div>';
9219 str+='<a class="option warning" '+Game.clickStr+'="Game.RuinTheFun(1);">Ruin The Fun</a>';
9220 str+='<a class="option warning" '+Game.clickStr+'="Game.SesameReset();">Wipe</a>';
9221 str+='<a class="option neato" '+Game.clickStr+'="Game.GetAllDebugs();">All debugs</a>';
9222 str+='<a class="option neato" '+Game.clickStr+'="Game.debugTimersOn=!Game.debugTimersOn;Game.OpenSesame();">Timers '+(Game.debugTimersOn?'On':'Off')+'</a><br>';
9223 str+='<a class="option neato" '+Game.clickStr+'="Game.SetAllUpgrades(0);">No upgrades</a>';
9224 str+='<a class="option neato" '+Game.clickStr+'="Game.SetAllUpgrades(1);">All upgrades</a><br>';
9225 str+='<a class="option neato" '+Game.clickStr+'="Game.SetAllAchievs(0);">No achievs</a>';
9226 str+='<a class="option neato" '+Game.clickStr+'="Game.SetAllAchievs(1);">All achievs</a><br>';
9227 str+='<a class="option neato" '+Game.clickStr+'="Game.santaLevel=0;Game.dragonLevel=0;">Reset specials</a>';
9228 str+='<a class="option neato" '+Game.clickStr+'="Game.MaxSpecials();">Max specials</a><br>';
9229 str+='<a class="option neato" '+Game.clickStr+'="Game.DebuggingPrestige=!Game.DebuggingPrestige;Game.OpenSesame();Game.BuildAscendTree();">Prestige God Mode '+(Game.DebuggingPrestige?'Off':'On')+'</a>';
9230 str+='<a class="option neato" '+Game.clickStr+'="Game.DebugUpgradeCpS();">Debug upgrades CpS</a>';
9231 str+='<div class="line"></div>';
9232 for (var i=0;i<Game.goldenCookieChoices.length/2;i++)
9233 {
9234 str+='<a class="option neato" '+Game.clickStr+'="var newShimmer=new Game.shimmer(\'golden\');newShimmer.force=\''+Game.goldenCookieChoices[i*2+1]+'\';">'+Game.goldenCookieChoices[i*2]+'</a>';
9235 //str+='<a class="option neato" '+Game.clickStr+'="Game.goldenCookie.force=\''+Game.goldenCookie.choices[i*2+1]+'\';Game.goldenCookie.spawn();">'+Game.goldenCookie.choices[i*2]+'</a>';
9236 //str+='<a class="option neato" '+Game.clickStr+'="Game.goldenCookie.click(0,\''+Game.goldenCookie.choices[i*2+1]+'\');">'+Game.goldenCookie.choices[i*2]+'</a>';
9237 }
9238 str+='</div>';
9239
9240 l('devConsole').innerHTML=str;
9241 l('debug').style.display='block';
9242 Game.sesame=1;
9243 Game.Achievements['Cheated cookies taste awful'].won=1;
9244 }
9245
9246 //experimental debugging function that cycles through every owned upgrade, turns it off and on, and lists how much each upgrade is participating to CpS
9247 Game.debuggedUpgradeCpS=[];
9248 Game.debuggedUpgradeCpClick=[];
9249 Game.debugColors=['#322','#411','#600','#900','#f30','#f90','#ff0','#9f0','#0f9','#09f','#90f'];
9250 Game.DebugUpgradeCpS=function()
9251 {
9252 Game.CalculateGains();
9253 Game.debuggedUpgradeCpS=[];
9254 Game.debuggedUpgradeCpClick=[];
9255 var CpS=Game.cookiesPs;
9256 var CpClick=Game.computedMouseCps;
9257 for (var i in Game.Upgrades)
9258 {
9259 var me=Game.Upgrades[i];
9260 if (me.bought)
9261 {
9262 me.bought=0;
9263 Game.CalculateGains();
9264 //Game.debuggedUpgradeCpS[me.name]=CpS-Game.cookiesPs;
9265 Game.debuggedUpgradeCpS[me.name]=(CpS/(Game.cookiesPs||1)-1);
9266 Game.debuggedUpgradeCpClick[me.name]=(CpClick/(Game.computedMouseCps||1)-1);
9267 me.bought=1;
9268 }
9269 }
9270 Game.CalculateGains();
9271 }
9272
9273
9274
9275
9276 for (var i in Game.customInit) {Game.customInit[i]();}
9277
9278 if (!Game.LoadSave())
9279 {//try to load the save when we open the page. if this fails, try to brute-force it half a second later
9280 setTimeout(function(){Game.LoadSave(window.localStorage.getItem(Game.SaveTo));},500);
9281 }
9282
9283 Game.ready=1;
9284 l('javascriptError').innerHTML='';
9285 l('javascriptError').style.display='none';
9286 Game.Loop();
9287 Game.Draw();
9288 }
9289 /*=====================================================================================
9290 LOGIC
9291 =======================================================================================*/
9292 Game.Logic=function()
9293 {
9294 Game.bounds=Game.l.getBoundingClientRect();
9295
9296 if (!Game.OnAscend && Game.AscendTimer==0)
9297 {
9298 for (var i in Game.Objects)
9299 {
9300 if (Game.Objects[i].EachFrame) Game.Objects[i].EachFrame();
9301 }
9302 Game.UpdateSpecial();
9303 Game.UpdateGrandmapocalypse();
9304
9305 //these are kinda fun
9306 //if (Game.BigCookieState==2 && !Game.promptOn && Game.Scroll!=0) Game.ClickCookie();
9307 //if (Game.BigCookieState==1 && !Game.promptOn) Game.ClickCookie();
9308
9309 //handle graphic stuff
9310 if (Game.prefs.wobbly)
9311 {
9312 if (Game.BigCookieState==1) Game.BigCookieSizeT=0.98;
9313 else if (Game.BigCookieState==2) Game.BigCookieSizeT=1.05;
9314 else Game.BigCookieSizeT=1;
9315 Game.BigCookieSizeD+=(Game.BigCookieSizeT-Game.BigCookieSize)*0.75;
9316 Game.BigCookieSizeD*=0.75;
9317 Game.BigCookieSize+=Game.BigCookieSizeD;
9318 Game.BigCookieSize=Math.max(0.1,Game.BigCookieSize);
9319 }
9320 else
9321 {
9322 if (Game.BigCookieState==1) Game.BigCookieSize+=(0.98-Game.BigCookieSize)*0.5;
9323 else if (Game.BigCookieState==2) Game.BigCookieSize+=(1.05-Game.BigCookieSize)*0.5;
9324 else Game.BigCookieSize+=(1-Game.BigCookieSize)*0.5;
9325 }
9326 Game.particlesUpdate();
9327
9328 if (Game.mousePointer) l('sectionLeft').style.cursor='pointer';
9329 else l('sectionLeft').style.cursor='auto';
9330 Game.mousePointer=0;
9331
9332 //handle milk and milk accessories
9333 Game.milkProgress=Game.AchievementsOwned/25;
9334 if (Game.milkProgress>=1) Game.Unlock('Kitten helpers');
9335 if (Game.milkProgress>=2) Game.Unlock('Kitten workers');
9336 if (Game.milkProgress>=3) Game.Unlock('Kitten engineers');
9337 if (Game.milkProgress>=4) Game.Unlock('Kitten overseers');
9338 if (Game.milkProgress>=5) Game.Unlock('Kitten managers');
9339 if (Game.milkProgress>=6) Game.Unlock('Kitten accountants');
9340 if (Game.milkProgress>=7) Game.Unlock('Kitten specialists');
9341 if (Game.milkProgress>=8) Game.Unlock('Kitten experts');
9342 if (Game.milkProgress>=9) Game.Unlock('Kitten masters');
9343 Game.milkH=Math.min(1,Game.milkProgress)*0.35;
9344 Game.milkHd+=(Game.milkH-Game.milkHd)*0.02;
9345
9346 Game.Milk=Game.Milks[Math.min(Math.floor(Game.milkProgress),Game.Milks.length-1)];
9347
9348 if (Game.autoclickerDetected>0) Game.autoclickerDetected--;
9349
9350 //handle research
9351 if (Game.researchT>0)
9352 {
9353 Game.researchT--;
9354 }
9355 if (Game.researchT==0 && Game.nextResearch)
9356 {
9357 Game.Unlock(Game.UpgradesById[Game.nextResearch].name);
9358 if (Game.prefs.popups) Game.Popup('Researched : '+Game.UpgradesById[Game.nextResearch].name);
9359 else Game.Notify('Research complete','You have discovered : <b>'+Game.UpgradesById[Game.nextResearch].name+'</b>.',Game.UpgradesById[Game.nextResearch].icon);
9360 Game.nextResearch=0;
9361 Game.researchT=-1;
9362 Game.recalculateGains=1;
9363 }
9364 //handle seasons
9365 if (Game.seasonT>0)
9366 {
9367 Game.seasonT--;
9368 }
9369 if (Game.seasonT<=0 && Game.season!='' && Game.season!=Game.baseSeason && !Game.Has('Eternal seasons'))
9370 {
9371 var str=Game.seasons[Game.season].over;
9372 if (Game.prefs.popups) Game.Popup(str);
9373 else Game.Notify(str,'',Game.seasons[Game.season].triggerUpgrade.icon);
9374 if (Game.Has('Season switcher')) {Game.Unlock(Game.seasons[Game.season].trigger);Game.seasons[Game.season].triggerUpgrade.bought=0;}
9375 Game.season=Game.baseSeason;
9376 Game.seasonT=-1;
9377 }
9378
9379 //press ctrl to bulk-buy 10, shift to bulk-buy 100
9380 if (!Game.promptOn)
9381 {
9382 if ((Game.keys[16] || Game.keys[17]) && !Game.buyBulkShortcut)
9383 {
9384 Game.buyBulkOld=Game.buyBulk;
9385 if (Game.keys[16]) Game.buyBulk=100;
9386 if (Game.keys[17]) Game.buyBulk=10;
9387 Game.buyBulkShortcut=1;
9388 Game.storeBulkButton(-1);
9389 }
9390 }
9391 if ((!Game.keys[16] && !Game.keys[17]) && Game.buyBulkShortcut)//release
9392 {
9393 Game.buyBulk=Game.buyBulkOld;
9394 Game.buyBulkShortcut=0;
9395 Game.storeBulkButton(-1);
9396 }
9397
9398 //handle cookies
9399 if (Game.recalculateGains) Game.CalculateGains();
9400 Game.Earn(Game.cookiesPs/Game.fps);//add cookies per second
9401
9402 if (Game.specialTab!='' && Game.T%(Game.fps*3)==0) Game.ToggleSpecialMenu(1);
9403
9404 //wrinklers
9405 if (Game.cpsSucked>0)
9406 {
9407 Game.Dissolve((Game.cookiesPs/Game.fps)*Game.cpsSucked);
9408 Game.cookiesSucked+=((Game.cookiesPs/Game.fps)*Game.cpsSucked);
9409 //should be using one of the following, but I'm not sure what I'm using this stat for anymore
9410 //Game.cookiesSucked=Game.wrinklers.reduce(function(s,w){return s+w.sucked;},0);
9411 //for (var i in Game.wrinklers) {Game.cookiesSucked+=Game.wrinklers[i].sucked;}
9412 }
9413
9414 //var cps=Game.cookiesPs+Game.cookies*0.01;//exponential cookies
9415 //Game.Earn(cps/Game.fps);//add cookies per second
9416
9417 for (var i in Game.Objects)
9418 {
9419 var me=Game.Objects[i];
9420 me.totalCookies+=(me.storedTotalCps*Game.globalCpsMult)/Game.fps;
9421 }
9422 if (Game.cookies && Game.T%Math.ceil(Game.fps/Math.min(10,Game.cookiesPs))==0 && Game.prefs.particles) Game.particleAdd();//cookie shower
9423
9424 if (Game.T%(Game.fps*10)==0) Game.recalculateGains=1;//recalculate CpS every 10 seconds (for dynamic boosts such as Century egg)
9425
9426 /*=====================================================================================
9427 UNLOCKING STUFF
9428 =======================================================================================*/
9429 if (Game.T%(Game.fps)==0 && Math.random()<1/500000) Game.Win('Just plain lucky');//1 chance in 500,000 every second achievement
9430 if (Game.T%(Game.fps*5)==0 && Game.ObjectsById.length>0)//check some achievements and upgrades
9431 {
9432 //if (Game.Objects['Factory'].amount>=50 && Game.Objects['Factory'].specialUnlocked==0) {Game.Objects['Factory'].unlockSpecial();Game.Popup('You have unlocked the factory dungeons!');}
9433
9434 if (isNaN(Game.cookies)) {Game.cookies=0;Game.cookiesEarned=0;Game.recalculateGains=1;}
9435
9436 var timePlayed=new Date();
9437 timePlayed.setTime(Date.now()-Game.startDate);
9438
9439
9440 if (Game.cookiesEarned>=1000000 && (Game.ascensionMode==1 || Game.resets==0))//challenge run or hasn't ascended yet
9441 {
9442 if (timePlayed<=1000*60*35) Game.Win('Speed baking I');
9443 if (timePlayed<=1000*60*25) Game.Win('Speed baking II');
9444 if (timePlayed<=1000*60*15) Game.Win('Speed baking III');
9445
9446 if (Game.cookieClicks<=15) Game.Win('Neverclick');
9447 if (Game.cookieClicks<=0) Game.Win('True Neverclick');
9448 if (Game.cookiesEarned>=1000000000 && Game.UpgradesOwned==0) Game.Win('Hardcore');
9449 }
9450
9451 for (var i in Game.UnlockAt)
9452 {
9453 var unlock=Game.UnlockAt[i];
9454 if (Game.cookiesEarned>=unlock.cookies)
9455 {
9456 var pass=1;
9457 if (unlock.require && !Game.Has(unlock.require) && !Game.HasAchiev(unlock.require)) pass=0;
9458 if (unlock.season && Game.season!=unlock.season) pass=0;
9459 if (pass) {Game.Unlock(unlock.name);Game.Win(unlock.name);}
9460 }
9461 }
9462
9463 if (Game.Has('Golden switch')) Game.Unlock('Golden switch [off]');
9464 if (Game.Has('Classic dairy selection')) Game.Unlock('Milk selector');
9465 if (Game.Has('Golden cookie alert sound')) Game.Unlock('Golden cookie sound selector');
9466
9467 if (Game.Has('Eternal heart biscuits')) Game.Win('Lovely cookies');
9468 if (Game.season=='easter')
9469 {
9470 var eggs=0;
9471 for (var i in Game.easterEggs)
9472 {
9473 if (Game.HasUnlocked(Game.easterEggs[i])) eggs++;
9474 }
9475 if (eggs>=1) Game.Win('The hunt is on');
9476 if (eggs>=7) Game.Win('Egging on');
9477 if (eggs>=14) Game.Win('Mass Easteria');
9478 if (eggs>=Game.easterEggs.length) Game.Win('Hide & seek champion');
9479 }
9480
9481 if (Game.prestige>0 && Game.ascensionMode!=1)
9482 {
9483 Game.Unlock('Heavenly chip secret');
9484 if (Game.Has('Heavenly chip secret')) Game.Unlock('Heavenly cookie stand');
9485 if (Game.Has('Heavenly cookie stand')) Game.Unlock('Heavenly bakery');
9486 if (Game.Has('Heavenly bakery')) Game.Unlock('Heavenly confectionery');
9487 if (Game.Has('Heavenly confectionery')) Game.Unlock('Heavenly key');
9488
9489 if (Game.Has('Heavenly key')) Game.Win('Wholesome');
9490 }
9491
9492 for (var i in Game.BankAchievements)
9493 {
9494 if (Game.cookiesEarned>=Game.BankAchievements[i].threshold) Game.Win(Game.BankAchievements[i].name);
9495 }
9496
9497 var buildingsOwned=0;
9498 var mathematician=1;
9499 var base10=1;
9500 var minAmount=100000;
9501 for (var i in Game.Objects)
9502 {
9503 buildingsOwned+=Game.Objects[i].amount;
9504 minAmount=Math.min(Game.Objects[i].amount,minAmount);
9505 if (!Game.HasAchiev('Mathematician')) {if (Game.Objects[i].amount<Math.min(128,Math.pow(2,(Game.ObjectsById.length-Game.Objects[i].id)-1))) mathematician=0;}
9506 if (!Game.HasAchiev('Base 10')) {if (Game.Objects[i].amount<(Game.ObjectsById.length-Game.Objects[i].id)*10) base10=0;}
9507 }
9508 if (minAmount>=1) Game.Win('One with everything');
9509 if (mathematician==1) Game.Win('Mathematician');
9510 if (base10==1) Game.Win('Base 10');
9511 if (minAmount>=100) {Game.Win('Centennial');Game.Unlock('Milk chocolate butter biscuit');}
9512 if (minAmount>=150) {Game.Win('Centennial and a half');Game.Unlock('Dark chocolate butter biscuit');}
9513 if (minAmount>=200) {Game.Win('Bicentennial');Game.Unlock('White chocolate butter biscuit');}
9514 if (minAmount>=250) {Game.Win('Bicentennial and a half');Game.Unlock('Ruby chocolate butter biscuit');}
9515
9516 if (Game.handmadeCookies>=1000) {Game.Win('Clicktastic');Game.Unlock('Plastic mouse');}
9517 if (Game.handmadeCookies>=100000) {Game.Win('Clickathlon');Game.Unlock('Iron mouse');}
9518 if (Game.handmadeCookies>=1e7) {Game.Win('Clickolympics');Game.Unlock('Titanium mouse');}
9519 if (Game.handmadeCookies>=1e9) {Game.Win('Clickorama');Game.Unlock('Adamantium mouse');}
9520 if (Game.handmadeCookies>=1e11) {Game.Win('Clickasmic');Game.Unlock('Unobtainium mouse');}
9521 if (Game.handmadeCookies>=1e13) {Game.Win('Clickageddon');Game.Unlock('Eludium mouse');}
9522 if (Game.handmadeCookies>=1e15) {Game.Win('Clicknarok');Game.Unlock('Wishalloy mouse');}
9523 if (Game.handmadeCookies>=1e17) {Game.Win('Clickastrophe');Game.Unlock('Fantasteel mouse');}
9524 if (Game.handmadeCookies>=1e19) {Game.Win('Clickataclysm');Game.Unlock('Nevercrack mouse');}
9525
9526 if (Game.cookiesEarned<Game.cookies) Game.Win('Cheated cookies taste awful');
9527
9528 if (Game.Has('Skull cookies') && Game.Has('Ghost cookies') && Game.Has('Bat cookies') && Game.Has('Slime cookies') && Game.Has('Pumpkin cookies') && Game.Has('Eyeball cookies') && Game.Has('Spider cookies')) Game.Win('Spooky cookies');
9529 if (Game.wrinklersPopped>=1) Game.Win('Itchscratcher');
9530 if (Game.wrinklersPopped>=50) Game.Win('Wrinklesquisher');
9531 if (Game.wrinklersPopped>=200) Game.Win('Moistburster');
9532
9533 if (Game.cookiesEarned>=1000000 && Game.Has('How to bake your dragon')) Game.Unlock('A crumbly egg');
9534
9535 if (Game.cookiesEarned>=25 && Game.season=='christmas') Game.Unlock('A festive hat');
9536 if (Game.Has('Christmas tree biscuits') && Game.Has('Snowflake biscuits') && Game.Has('Snowman biscuits') && Game.Has('Holly biscuits') && Game.Has('Candy cane biscuits') && Game.Has('Bell biscuits') && Game.Has('Present biscuits')) Game.Win('Let it snow');
9537
9538 if (Game.reindeerClicked>=1) Game.Win('Oh deer');
9539 if (Game.reindeerClicked>=50) Game.Win('Sleigh of hand');
9540 if (Game.reindeerClicked>=200) Game.Win('Reindeer sleigher');
9541
9542 if (buildingsOwned>=100) Game.Win('Builder');
9543 if (buildingsOwned>=500) Game.Win('Architect');
9544 if (buildingsOwned>=1000) Game.Win('Engineer');
9545 if (buildingsOwned>=1500) Game.Win('Lord of Constructs');
9546 if (Game.UpgradesOwned>=20) Game.Win('Enhancer');
9547 if (Game.UpgradesOwned>=50) Game.Win('Augmenter');
9548 if (Game.UpgradesOwned>=100) Game.Win('Upgrader');
9549 if (Game.UpgradesOwned>=200) Game.Win('Lord of Progress');
9550 if (buildingsOwned>=3000 && Game.UpgradesOwned>=300) Game.Win('Polymath');
9551
9552 if (Game.cookiesEarned>=1e13 && !Game.HasAchiev('You win a cookie')) {Game.Win('You win a cookie');Game.Earn(1);}
9553
9554 var grandmas=0;
9555 if (Game.Has('Farmer grandmas')) grandmas++;
9556 if (Game.Has('Worker grandmas')) grandmas++;
9557 if (Game.Has('Miner grandmas')) grandmas++;
9558 if (Game.Has('Cosmic grandmas')) grandmas++;
9559 if (Game.Has('Transmuted grandmas')) grandmas++;
9560 if (Game.Has('Altered grandmas')) grandmas++;
9561 if (Game.Has('Grandmas\' grandmas')) grandmas++;
9562 if (Game.Has('Antigrandmas')) grandmas++;
9563 if (Game.Has('Rainbow grandmas')) grandmas++;
9564 if (Game.Has('Banker grandmas')) grandmas++;
9565 if (Game.Has('Priestess grandmas')) grandmas++;
9566 if (Game.Has('Witch grandmas')) grandmas++;
9567 if (!Game.HasAchiev('Elder') && grandmas>=7) Game.Win('Elder');
9568 if (Game.Objects['Grandma'].amount>=6 && !Game.Has('Bingo center/Research facility') && Game.HasAchiev('Elder')) Game.Unlock('Bingo center/Research facility');
9569 if (Game.pledges>0) Game.Win('Elder nap');
9570 if (Game.pledges>=5) Game.Win('Elder slumber');
9571 if (Game.pledges>=10) Game.Unlock('Sacrificial rolling pins');
9572 if (Game.Objects['Cursor'].amount+Game.Objects['Grandma'].amount>=777) Game.Win('The elder scrolls');
9573
9574 var base=1e13;
9575 if (Game.Objects['Cursor'].totalCookies>=base*1000000) Game.Win('Click delegator');
9576 if (Game.Objects['Grandma'].totalCookies>=base*1000000) Game.Win('Gushing grannies');
9577 if (Game.Objects['Farm'].totalCookies>=base) Game.Win('I hate manure');
9578 if (Game.Objects['Mine'].totalCookies>=base* 10) Game.Win('Never dig down');
9579 if (Game.Objects['Factory'].totalCookies>=base* 100) Game.Win('The incredible machine');
9580 if (Game.Objects['Bank'].totalCookies>=base* 1000) Game.Win('Vested interest');
9581 if (Game.Objects['Temple'].totalCookies>=base* 10000) Game.Win('New world order');
9582 if (Game.Objects['Wizard tower'].totalCookies>=base* 100000) Game.Win('Hocus pocus');
9583 if (Game.Objects['Shipment'].totalCookies>=base* 1000000) Game.Win('And beyond');
9584 if (Game.Objects['Alchemy lab'].totalCookies>=base* 10000000) Game.Win('Magnum Opus');
9585 if (Game.Objects['Portal'].totalCookies>=base* 100000000) Game.Win('With strange eons');
9586 if (Game.Objects['Time machine'].totalCookies>=base* 1000000000) Game.Win('Spacetime jigamaroo');
9587 if (Game.Objects['Antimatter condenser'].totalCookies>=base*10000000000) Game.Win('Supermassive');
9588 if (Game.Objects['Prism'].totalCookies>=base* 100000000000) Game.Win('Praise the sun');
9589
9590 var base=1e16;
9591 if (Game.Objects['Cursor'].totalCookies>=base*1000000) Game.Win('Finger clickin\' good');
9592 if (Game.Objects['Grandma'].totalCookies>=base*1000000) Game.Win('Panic at the bingo');
9593 if (Game.Objects['Farm'].totalCookies>=base) Game.Win('Rake in the dough');
9594 if (Game.Objects['Mine'].totalCookies>=base* 10) Game.Win('Quarry on');
9595 if (Game.Objects['Factory'].totalCookies>=base* 100) Game.Win('Yes I love technology');
9596 if (Game.Objects['Bank'].totalCookies>=base* 1000) Game.Win('Paid in full');
9597 if (Game.Objects['Temple'].totalCookies>=base* 10000) Game.Win('Church of Cookiology');
9598 if (Game.Objects['Wizard tower'].totalCookies>=base* 100000) Game.Win('Too many rabbits, not enough hats');
9599 if (Game.Objects['Shipment'].totalCookies>=base* 1000000) Game.Win('The most precious cargo');
9600 if (Game.Objects['Alchemy lab'].totalCookies>=base* 10000000) Game.Win('The Aureate');
9601 if (Game.Objects['Portal'].totalCookies>=base* 100000000) Game.Win('Ever more hideous');
9602 if (Game.Objects['Time machine'].totalCookies>=base* 1000000000) Game.Win('Be kind, rewind');
9603 if (Game.Objects['Antimatter condenser'].totalCookies>=base*10000000000) Game.Win('Infinitesimal');
9604 if (Game.Objects['Prism'].totalCookies>=base* 100000000000) Game.Win('A still more glorious dawn');
9605
9606 if (!Game.HasAchiev('Cookie-dunker') && Game.LeftBackground && Game.milkProgress>0.1 && (Game.LeftBackground.canvas.height*0.4+256/2-16)>((1-Game.milkHd)*Game.LeftBackground.canvas.height)) Game.Win('Cookie-dunker');
9607 //&& l('bigCookie').getBoundingClientRect().bottom>l('milk').getBoundingClientRect().top+16 && Game.milkProgress>0.1) Game.Win('Cookie-dunker');
9608
9609 for (var i in Game.customChecks) {Game.customChecks[i]();}
9610 }
9611
9612 Game.cookiesd+=(Game.cookies-Game.cookiesd)*0.3;
9613
9614 if (Game.storeToRefresh) Game.RefreshStore();
9615 if (Game.upgradesToRebuild) Game.RebuildUpgrades();
9616
9617 Game.updateShimmers();
9618 Game.updateBuffs();
9619
9620 Game.UpdateTicker();
9621 }
9622
9623 if (Game.T%(Game.fps*2)==0)
9624 {
9625 var title='Cookie Clicker';
9626 if (Game.season=='fools') title='Cookie Baker';
9627 document.title=(Game.OnAscend?'Ascending! ':'')+Beautify(Game.cookies)+' '+(Game.cookies==1?'cookie':'cookies')+' - '+title;
9628 }
9629 if (Game.T%15==0)
9630 {
9631 //written through the magic of "hope for the best" maths
9632 var chipsOwned=Game.HowMuchPrestige(Game.cookiesReset);
9633 var ascendNowToOwn=Math.floor(Game.HowMuchPrestige(Game.cookiesReset+Game.cookiesEarned));
9634 var ascendNowToGet=ascendNowToOwn-Math.floor(chipsOwned);
9635 var nextChipAt=Game.HowManyCookiesReset(Math.floor(chipsOwned+ascendNowToGet+1))-Game.HowManyCookiesReset(Math.floor(chipsOwned+ascendNowToGet));
9636 var cookiesToNext=Game.HowManyCookiesReset(ascendNowToOwn+1)-(Game.cookiesEarned+Game.cookiesReset);
9637 var percent=1-(cookiesToNext/nextChipAt);
9638
9639 //fill the tooltip under the Legacy tab
9640 var date=new Date();
9641 date.setTime(Date.now()-Game.startDate);
9642 var timeInSeconds=date.getTime()/1000;
9643 var startDate=Game.sayTime(timeInSeconds*Game.fps,2);
9644
9645 var str='';
9646 str+='You\'ve been on this run for <b>'+(startDate==''?'not very long':(startDate))+'</b>.<br>';
9647 str+='<div class="line"></div>';
9648 if (Game.prestige>0)
9649 {
9650 str+='Your prestige level is currently <b>'+Beautify(Game.prestige)+'</b>.<br>(CpS +'+Beautify(Game.prestige)+'%)';
9651 str+='<div class="line"></div>';
9652 }
9653 if (ascendNowToGet<1) str+='Ascending now would grant you no prestige.';
9654 else if (ascendNowToGet<2) str+='Ascending now would grant you<br><b>1 prestige level</b> (+1% CpS)<br>and <b>1 heavenly chip</b> to spend.';
9655 else str+='Ascending now would grant you<br><b>'+Beautify(ascendNowToGet)+' prestige levels</b> (+'+Beautify(ascendNowToGet)+'% CpS)<br>and <b>'+Beautify(ascendNowToGet)+' heavenly chips</b> to spend.';
9656 str+='<div class="line"></div>';
9657 str+='You need <b>'+Beautify(cookiesToNext)+' more cookies</b> for the next level.<br>';
9658 Game.ascendTooltip.innerHTML=str;
9659
9660
9661 if (ascendNowToGet>0)//show number saying how many chips you'd get resetting now
9662 {
9663 var str=ascendNowToGet.toString();
9664 var str2='';
9665 for (var i in str)//add commas
9666 {
9667 if ((str.length-i)%3==0 && i>0) str2+=',';
9668 str2+=str[i];
9669 }
9670 Game.ascendNumber.innerHTML='+'+str2;
9671 Game.ascendNumber.style.display='block';
9672 }
9673 else
9674 {
9675 Game.ascendNumber.style.display='none';
9676 }
9677
9678 if (ascendNowToGet>Game.ascendMeterLevel || Game.ascendMeterPercentT<Game.ascendMeterPercent)
9679 {
9680 //reset the gauge and play a sound if we gained a potential level
9681 Game.ascendMeterPercent=0;
9682 //PlaySound('snd/levelPrestige.mp3');//a bit too annoying
9683 }
9684 Game.ascendMeterLevel=ascendNowToGet;
9685 Game.ascendMeterPercentT=percent;//gauge that fills up as you near your next chip
9686 //if (Game.ascendMeterPercentT<Game.ascendMeterPercent) {Game.ascendMeterPercent=0;PlaySound('snd/levelPrestige.mp3',0.5);}
9687 //if (percent>=1) {Game.ascendMeter.className='';} else Game.ascendMeter.className='filling';
9688 }
9689 Game.ascendMeter.style.right=Math.floor(Math.max(0,1-Game.ascendMeterPercent)*100)+'px';
9690 Game.ascendMeterPercent+=(Game.ascendMeterPercentT-Game.ascendMeterPercent)*0.1;
9691
9692 Game.NotesLogic();
9693 if (Game.mouseMoved || Game.Scroll || Game.tooltip.dynamic) Game.tooltip.update();
9694
9695 if (Game.T%(Game.fps*5)==0 && !Game.mouseDown) Game.UpdateMenu();
9696 if (Game.T%(Game.fps*1)==0) Game.UpdatePrompt();
9697 if (Game.AscendTimer>0) Game.UpdateAscendIntro();
9698 if (Game.ReincarnateTimer>0) Game.UpdateReincarnateIntro();
9699 if (Game.OnAscend) Game.UpdateAscend();
9700
9701 for (var i in Game.customLogic) {Game.customLogic[i]();}
9702
9703 if (Game.sparklesT>0)
9704 {
9705 Game.sparkles.style.backgroundPosition=-Math.floor((Game.sparklesFrames-Game.sparklesT+1)*128)+'px 0px';
9706
9707 Game.sparklesT--;
9708 if (Game.sparklesT==1) Game.sparkles.style.display='none';
9709 }
9710
9711 Game.Click=0;
9712 Game.Scroll=0;
9713 Game.mouseMoved=0;
9714 Game.CanClick=1;
9715
9716 if (Game.T%(Game.fps*60)==0 && Game.T>Game.fps*10 && Game.prefs.autosave && !Game.OnAscend) Game.WriteSave();
9717 if (Game.T%(Game.fps*60*30)==0 && Game.T>Game.fps*10 && Game.prefs.autoupdate) Game.CheckUpdates();
9718
9719 Game.T++;
9720 }
9721
9722 /*=====================================================================================
9723 DRAW
9724 =======================================================================================*/
9725
9726 Game.Draw=function()
9727 {
9728 Game.DrawBackground();Timer.track('end of background');
9729
9730 if (!Game.OnAscend)
9731 {
9732
9733 var unit=(Math.round(Game.cookiesd)==1?' cookie':' cookies');
9734 var str=Beautify(Math.round(Game.cookiesd));
9735 if (Game.cookiesd>=1000000)//dirty padding
9736 {
9737 var spacePos=str.indexOf(' ');
9738 var dotPos=str.indexOf('.');
9739 var add='';
9740 if (spacePos!=-1)
9741 {
9742 if (dotPos==-1) add+='.000';
9743 else
9744 {
9745 if (spacePos-dotPos==2) add+='00';
9746 if (spacePos-dotPos==3) add+='0';
9747 }
9748 }
9749 str=[str.slice(0, spacePos),add,str.slice(spacePos)].join('');
9750 }
9751 if (str.length>11 && !Game.mobile) unit='<br>cookies';
9752 str+=unit;
9753 if (Game.prefs.monospace) str='<span class="monospace">'+str+'</span>';
9754 str=str+'<div style="font-size:50%;"'+(Game.cpsSucked>0?' class="warning"':'')+'>per second : '+Beautify(Game.cookiesPs*(1-Game.cpsSucked),1)+'</div>';//display cookie amount
9755 l('cookies').innerHTML=str;
9756 l('compactCookies').innerHTML=str;
9757 Timer.track('cookie amount');
9758
9759 if (Game.drawT%5==0)
9760 {
9761 //if (Game.prefs.monospace) {l('cookies').className='title monospace';} else {l('cookies').className='title';}
9762 var lastLocked=0;
9763 for (var i in Game.Objects)
9764 {
9765 var me=Game.Objects[i];
9766
9767 //make products full-opacity if we can buy them
9768 var classes='product';
9769 var price=me.bulkPrice;
9770 if (Game.cookiesEarned>=me.basePrice || me.bought>0) {classes+=' unlocked';lastLocked=0;me.locked=0;} else {classes+=' locked';lastLocked++;me.locked=1;}
9771 if ((Game.buyMode==1 && Game.cookies>=price) || (Game.buyMode==-1 && me.amount>0)) classes+=' enabled'; else classes+=' disabled';
9772 if (lastLocked>2) classes+=' toggledOff';
9773 me.l.className=classes;
9774 //if (me.id>0) {l('productName'+me.id).innerHTML=Beautify(me.storedTotalCps/Game.ObjectsById[me.id-1].storedTotalCps,2);}
9775 }
9776
9777 //make upgrades full-opacity if we can buy them
9778 var lastPrice=0;
9779 for (var i in Game.UpgradesInStore)
9780 {
9781 var me=Game.UpgradesInStore[i];
9782 if (!me.bought)
9783 {
9784 var price=me.getPrice();
9785 var canBuy=(Game.cookies>=price);
9786 var enabled=(l('upgrade'+i).className.indexOf('enabled')>-1);
9787 if ((canBuy && !enabled) || (!canBuy && enabled)) Game.upgradesToRebuild=1;
9788 if (price<lastPrice) Game.storeToRefresh=1;//is this upgrade less expensive than the previous one? trigger a refresh to sort it again
9789 lastPrice=price;
9790 }
9791 if (me.timerDisplay)
9792 {
9793 var T=me.timerDisplay();
9794 if (T!=-1)
9795 {
9796 if (!l('upgradePieTimer'+i)) l('upgrade'+i).innerHTML=l('upgrade'+i).innerHTML+'<div class="pieTimer" id="upgradePieTimer'+i+'"></div>';
9797 T=(T*144)%144;
9798 l('upgradePieTimer'+i).style.backgroundPosition=(-Math.floor(T%18))*48+'px '+(-Math.floor(T/18))*48+'px';
9799 }
9800 }
9801
9802 //if (me.canBuy()) l('upgrade'+i).className='crate upgrade enabled'; else l('upgrade'+i).className='crate upgrade disabled';
9803 }
9804 }
9805 Timer.track('store');
9806
9807 if (Game.PARTY)//i was bored and felt like messing with CSS
9808 {
9809 var pulse=Math.pow((Game.T%10)/10,0.5);
9810 Game.l.style.filter='hue-rotate('+((Game.T*5)%360)+'deg) brightness('+(150-50*pulse)+'%)';
9811 Game.l.style.webkitFilter='hue-rotate('+((Game.T*5)%360)+'deg) brightness('+(150-50*pulse)+'%)';
9812 Game.l.style.transform='scale('+(1.02-0.02*pulse)+','+(1.02-0.02*pulse)+') rotate('+(Math.sin(Game.T*0.5)*0.5)+'deg)';
9813 l('wrapper').style.overflowX='hidden';
9814 l('wrapper').style.overflowY='hidden';
9815 }
9816
9817 Timer.clean();
9818 if (Game.prefs.animate && ((Game.prefs.fancy && Game.drawT%1==0) || (!Game.prefs.fancy && Game.drawT%10==0)) && Game.AscendTimer==0 && Game.onMenu=='') Game.DrawBuildings();Timer.track('buildings');
9819
9820 Game.textParticlesUpdate();Timer.track('text particles');
9821 }
9822
9823 Game.NotesDraw();Timer.track('notes');
9824 //Game.tooltip.update();//changed to only update when the mouse is moved
9825
9826 for (var i in Game.customDraw) {Game.customDraw[i]();}
9827
9828 Game.drawT++;
9829 if (Game.prefs.altDraw) requestAnimationFrame(Game.Draw);
9830 }
9831
9832 /*=====================================================================================
9833 MAIN LOOP
9834 =======================================================================================*/
9835 Game.Loop=function()
9836 {
9837 Timer.say('START');
9838 Timer.track('browser stuff');
9839 Timer.say('LOGIC');
9840 //update game logic !
9841 Game.catchupLogic=0;
9842 Game.Logic();
9843 Game.catchupLogic=1;
9844
9845 var hasFocus=document.hasFocus();
9846
9847 //latency compensator
9848 Game.accumulatedDelay+=((Date.now()-Game.time)-1000/Game.fps);
9849 Game.accumulatedDelay=Math.min(Game.accumulatedDelay,1000*5);//don't compensate over 5 seconds; if you do, something's probably very wrong
9850 Game.time=Date.now();
9851 while (Game.accumulatedDelay>0)
9852 {
9853 Game.Logic();
9854 Game.accumulatedDelay-=1000/Game.fps;//as long as we're detecting latency (slower than target fps), execute logic (this makes drawing slower but makes the logic behave closer to correct target fps)
9855 }
9856 Game.catchupLogic=0;
9857 Timer.track('logic');
9858 Timer.say('END LOGIC');
9859 if (!Game.prefs.altDraw)
9860 {
9861 Timer.say('DRAW');
9862 if (hasFocus || Game.prefs.focus || Game.loopT%10==0) Game.Draw();
9863 //if (document.hasFocus() || Game.loopT%5==0) Game.Draw();
9864 Timer.say('END DRAW');
9865 }
9866
9867 if (!hasFocus) Game.tooltip.hide();
9868
9869 if (Game.sesame)
9870 {
9871 l('fpsCounter').innerHTML=Game.getFps()+' fps';
9872 var str='';
9873 for (var i in Timer.labels) {str+=Timer.labels[i];}
9874 if (Game.debugTimersOn) l('debugLog').style.display='block';
9875 else l('debugLog').style.display='none';
9876 l('debugLog').innerHTML=str;
9877 }
9878 Timer.reset();
9879
9880 Game.loopT++;
9881 setTimeout(Game.Loop,1000/Game.fps);
9882 }
9883}
9884
9885
9886/*=====================================================================================
9887LAUNCH THIS THING
9888=======================================================================================*/
9889Game.Launch();
9890//try {Game.Launch();}
9891//catch(err) {console.log('ERROR : '+err.message);}
9892
9893window.onload=function()
9894{
9895
9896 if (!Game.ready)
9897 {
9898 if (top!=self) Game.ErrorFrame();
9899 else
9900 {
9901 Game.Load();
9902 //try {Game.Load();}
9903 //catch(err) {console.log('ERROR : '+err.message);}
9904 }
9905 }
9906};