-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
77 lines (71 loc) · 4.92 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Game.registerMod('cheatmod',{
/*
what this example mod does:
-double your CpS
-display a little popup for half a second whenever you click the big cookie
-add a little intro text above your bakery name, and generate that intro text at random if you don't already have one
-save and load your intro text
*/
init:function(){
Game.registerHook('reincarnate',function(){Game.mods['cheatmod'].addIntro();});
Game.registerHook('check',function(){if (!Game.playerIntro){Game.mods['cheatmod'].addIntro();}});
Game.registerHook('click',function(){Game.Notify(choose(['A good click.','A solid click.','A mediocre click.','An excellent click!']),'',0,0.5);});
Game.registerHook('cps',function(cps){return cps*2;});
},
save:function(){
//note: we use stringified JSON for ease and clarity but you could store any type of string
return JSON.stringify({text:Game.playerIntro})
},
load:function(str){
var data=JSON.parse(str);
if (data.text) Game.mods['cheatmod'].addIntro(data.text);
},
addIntro:function(text){
//note: this is not a mod hook, just a function that's part of the mod
Game.playerIntro=text||choose(['oh snap, it\'s','watch out, it\'s','oh no! here comes','hide your cookies, for here comes','behold! it\'s']);
if (!l('bakerySubtitle')) l('bakeryName').insertAdjacentHTML('afterend','<div id="bakerySubtitle" class="title" style="text-align:center;position:absolute;left:0px;right:0px;bottom:32px;font-size:12px;pointer-events:none;text-shadow:0px 1px 1px #000,0px 0px 4px #f00;opacity:0.8;"></div>');
l('bakerySubtitle').textContent='~'+Game.playerIntro+'~';
},
});
}
//replacing an existing canvas picture with a new one at runtime : Game.Loader.Replace('perfectCookie.png','imperfectCookie.png');
//upgrades and achievements can use other pictures than icons.png; declare their icon with [posX,posY,'http://example.com/myIcons.png']
//check out the "UNLOCKING STUFF" section to see how unlocking achievs and upgrades is done
/*=====================================================================================
BAKERY NAME
=======================================================================================*/
Game.RandomBakeryName=function()
{
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']);
}
Game.GetBakeryName=function() {return Game.RandomBakeryName();}
Game.bakeryName=Game.GetBakeryName();
Game.bakeryNameL=l('bakeryName');
Game.bakeryNameL.textContent=Game.bakeryName+'\'s bakery';
Game.bakeryNameSet=function(what)
{
Game.bakeryName=what.replace(/\W+/g,' ');
Game.bakeryName=Game.bakeryName.substring(0,28);
Game.bakeryNameRefresh();
}
Game.bakeryNameRefresh=function()
{
var name=Game.bakeryName;
if (name.slice(-1).toLowerCase()=='s') name+='\' bakery'; else name+='\'s bakery';
Game.bakeryNameL.textContent=name;
name=Game.bakeryName.toLowerCase();
if (name=='orteil') Game.Win('God complex');
if (name.indexOf('saysopensesame',name.length-('saysopensesame').length)>0 && !Game.sesame) Game.OpenSesame();
Game.recalculateGains=1;
}
Game.bakeryNamePrompt=function()
{
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']);
l('bakeryNameInput').focus();
l('bakeryNameInput').select();
}
Game.bakeryNamePromptRandom=function()
{
l('bakeryNameInput').value=Game.RandomBakeryName();
}
AddEvent(Game.bakeryNameL,'click',Game.bakeryNamePrompt);