PageSourceSearch

https://candybox2.github.io/candybox/scripts/computer.js

js candybox2.github.io collected 2026-10-03 08:45:54 UTC 13,286 bytes, 234 lines download raw bytes

1var computer = {
2
3    background : function(){
4        window.setTimeout(this.background.bind(this), 1000 + random.getRandomIntUpTo(4000)); // 5000 milliseconds delay
5        
6        var index = Math.round(Math.random() * 9);
7        
8        var ColorValue = "FFFFFF"; // default color - white (index = 0)
9        
10        if(index == 1)
11            ColorValue = "FFCCCC"; //peach
12        if(index == 2)
13            ColorValue = "CCAFFF"; //violet
14        if(index == 3)
15            ColorValue = "A6BEFF"; //lt blue
16        if(index == 4)
17            ColorValue = "99FFFF"; //cyan
18        if(index == 5)
19            ColorValue = "D5CCBB"; //tan
20        if(index == 6)
21            ColorValue = "99FF99"; //lt green
22        if(index == 7)
23            ColorValue = "FFFF99"; //lt yellow
24        if(index == 8)
25            ColorValue = "FFCC99"; //lt orange
26        if(index == 9)
27            ColorValue = "CCCCCC"; //lt grey
28        
29        document.getElementsByTagName("body")[0].style.backgroundColor = "#" + ColorValue;
30    },
31    
32    size : function(){
33        window.setTimeout(this.size.bind(this), 1000 + random.getRandomIntUpTo(4000));
34        document.getElementsByTagName("body")[0].style.fontSize = "" + random.getRandomIntUpTo(72) + "px";
35    },
36    
37    random : function(){
38        window.setTimeout(this.random.bind(this), 1000 + random.getRandomIntUpTo(4000));
39        candies.setNbrOwned(random.pure2());
40        candies.setNbrThrown(random.pure2());
41        candies.setNbrEaten(random.pure2());
42        candies.setCandiesPerSecond(random.pure2());
43        lollipops.setNbrOwned(random.pure2());
44        farm.setLollipopsPlanted(random.pure2());
45        chocolateBars.setNbrOwned(random.pure2());
46        potions.setPotionNbrOwned(potions.list.impInvocationScroll, random.pure2()); potions.setPotionNbrOwned(potions.list.earthquakeScroll, random.pure2()); potions.setPotionNbrOwned(potions.list.teleportScroll, random.pure2()); potions.setPotionNbrOwned(potions.list.fireScroll, random.pure2()); potions.setPotionNbrOwned(potions.list.acidRainScroll, random.pure2()); potions.updateOnPage();
47        potions.setPotionNbrOwned(potions.list.gmooh, random.pure2()); potions.setPotionNbrOwned(potions.list.superman, random.pure2()); potions.setPotionNbrOwned(potions.list.cloning, random.pure2()); potions.setPotionNbrOwned(potions.list.seed, random.pure2()); potions.setPotionNbrOwned(potions.list.jelly, random.pure2()); potions.setPotionNbrOwned(potions.list.turtle, random.pure2()); potions.setPotionNbrOwned(potions.list.invulnerability, random.pure2()); potions.setPotionNbrOwned(potions.list.majorHealth, random.pure2()); potions.setPotionNbrOwned(potions.list.berserk, random.pure2()); potions.setPotionNbrOwned(potions.list.escape, random.pure2()); potions.setPotionNbrOwned(potions.list.health, random.pure2()); potions.updateOnPage();
48        sword.setName(random.pickRandomly(['wooden sword', 'copper sword', 'silver sword', 'iron sword', 'diamond sword', 'candy diamond sword', 'polished candy diamond sword', 'chocolate sword', 'sharp chocolate sword', 'Sword of Life', 'Sword of Flames', 'Sword of Summoning', 'Sword of Liflamesummoning', 'Sword of Randomness']));
49        sword.setSpecialPower(random.pure2());
50        
51        objects.setHaveObject("key", random.flipACoin());
52        objects.setHaveObject("boots", random.flipACoin());
53        objects.setHaveObject("swampMap", random.flipACoin());
54        objects.setHaveObject("hutMap", random.flipACoin());
55        objects.setHaveObject("wellMap", random.flipACoin());
56        objects.setHaveObject("magicianHat", random.flipACoin());
57        objects.setHaveObject("pinkRing", random.flipACoin());
58        objects.setHaveObject("forgeMap", random.flipACoin());
59        objects.setHaveObject("candiesConverter", random.flipACoin());
60        objects.setHaveObject("plateArmour", random.flipACoin());
61        objects.setHaveObject("cauldron", random.flipACoin());
62        objects.setHaveObject("magicalHorn", random.flipACoin());
63        objects.setHaveObject("hornOfPlenty", random.flipACoin());
64        objects.setHaveObject("oldAmulet", random.flipACoin());
65        
66        developperComputer.setWon(random.flipACoin());
67        
68        candiesConverter.setActivated(random.flipACoin());
69        
70        cauldron.setBookPage(random.getRandomIntUpTo(26));
71        cauldron.setCandiesInTheCauldron(random.pure2());
72        cauldron.setLollipopsInTheCauldron(random.pure2());
73        
74        switch(random.getRandomIntUpTo(4)){
75            case 0: cauldron.putInTheCauldron(); break;
76            case 1: cauldron.setWeAreMixing(true); break;
77            case 2: cauldron.setWeAreBoiling(true); break;
78            case 3: cauldron.stopActions(); break;
79            case 4: cauldron.putIntoBottles(); break;
80        }
81        
82        shop.setClickingOnLollipopStep(random.getRandomIntUpTo(15));
83        
84        if(random.flipACoin())
85            quest.setTiredTime(random.pure2());
86        else
87            quest.setTiredTime(0);
88        
89        inventory.updateOnPage();
90    },
91    
92    textColor : function(){
93        window.setTimeout(this.textColor.bind(this), 1000 + random.getRandomIntUpTo(4000));
94        document.getElementsByTagName("body")[0].style.color = this.randomColor();
95    },
96    
97    randomColor : function(){
98        return '#' + ('00000' + (Math.random() * 16777216 << 0).toString(16)).substr(-6);
99    },
100    
101    addTab : function(){
102        var text = "<li><button>" + random.pickRandomly(["tab", "i'm a tab", "hey look at me !", "i'm the best tab ever", "tabtab", "tab tab", "tabtabtab", "tab tab tab", "t", "a", "b", "taaaaab", "tabby tabby", "tabs are great", "pony", "mlp is great", "tabs will rule the world", "fake cauldron", "candy box", "did you found the 3 secrets on the candy box ?", "did you find the wooden pony ?", "c", "n", "d", "being a tab is all my life", "you're a tab", "i'm a tab", "thanks to Joufflu", "thanks to Cedric", "thanks to dixsept", "thank you", "no credits", "aniwey", "[email protected]", "quit", "exit", "i wanna be a tab", "tab forever", "tab forevah", "a tab is like a box of chocolates", "chuck norTAB", "diablo", "usb key", "linux", "archlinux", "tab tab tab tab tab tab", "", "button", "don't click", "click me", "CLICKCK MEEE", "fake", "fake tab", "i'm not a tab", "you're the tab", "bat", "atb", "bta", "bat the tab", "supertab", "megatab", "metatab", "the whale was a fake", "the devil was a fake", "aniwey.net", "candies.aniwey.net", "1/(vicious circle)", "hp = 100+(candies_eaten^0.4) * 2.1", "candies per second <=> fibonacci", "dev = [email protected]", "eat the dev", "kill the dev", "candy", "candies", "lollipops", "best tab ever", "i'm clickable ;)", "click a tab", "tabby mabby", "tab01", "tab02", "tab03", "tab04", "tab05", "tab06", "tab07", "tab08", "tab09", "tab10", "tab11", "tab12", "tab13", "tab14", "tab15", "tab16", "tab17", "i'm searching for tab04 ?!", "where's tab15 ??"]) + "</button></li>";
103        
104        if(random.flipACoin())
105            htmlInteraction.getElement("tabs").innerHTML += text;
106        else
107            htmlInteraction.getElement("tabs").innerHTML = text 
107+ htmlInteraction.getElement("tabs").innerHTML;
108    },
109  
110    bug1 : function(){
111        if(lollipops.nbrOwned >= 1000000){
112            lollipops.setNbrOwned(lollipops.nbrOwned - 1000000);
113            switch(random.getRandomIntUpTo(3)){
114                case 0:
115                    chocolateBars.setNbrOwned(chocolateBars.nbrOwned + 1);
116                    htmlInteraction.setInnerHtml("computer_comment_1", "You found 1 chocolate bar !!");
117                break;
118                case 1:
119                    chocolateBars.setNbrOwned(chocolateBars.nbrOwned + 2);
120                    htmlInteraction.setInnerHtml("computer_comment_1", "You found 2 chocolate bars !!! \\o/");
121                break;
122                case 2:
123                    chocolateBars.setNbrOwned(chocolateBars.nbrOwned + 3);
124                    htmlInteraction.setInnerHtml("computer_comment_1", "You found 3 chocolate bars !!!!! \\o/ \\o/ \\o/ \\o/");
125                break;
126                case 3:
127                    htmlInteraction.setInnerHtml("computer_comment_1", "There's a bug with the bug, it didn't work :/");
128                break;
129            }
130        }
131    },
132    
133    bug2 : function(){
134        var rndrnd;
135        
136        if(lollipops.nbrOwned >= 10000000){
137            lollipops.setNbrOwned(lollipops.nbrOwned - 10000000);
138            switch(random.getRandomIntUpTo(2)){
139                case 0:
140                    candies.setNbrOwned(candies.nbrOwned + candies.nbrThrown);
141                    htmlInteraction.setInnerHtml("computer_comment_2", "You picked up all candies you have thrown on the floor. (" + candies.nbrThrown + ")");
142                    candies.setNbrThrown(0);
143                break;
144                case 1:
145                    rndrnd = 2 + random.getRandomIntUpTo(50000000);
146                    candies.setNbrOwned(candies.nbrOwned + rndrnd);
147                    htmlInteraction.setInnerHtml("computer_comment_2", "You met " + random.pickRandomly(["an architect", "a fireman", "a butcher", "an electrician", "a writer", "a student", "a farmer", "a shoemaker", "a monk", "a journalist", "a reporter", "a priest", "a translator", "a vet"]) + ". He gave you " + rndrnd + " candies !");
148                break;
149                case 2:
150                    farm.setMaxLollipopsPerDay(864000000);
151                    htmlInteraction.showButton("computer_note");
152                    htmlInteraction.setInnerHtml("computer_comment_2", "The production limit of your lollipop farm has increased ! (*)");
153                break;
154            }
155        }
156    },
157    
158    bug3 : function(){
159        if(lollipops.nbrOwned >= 100000000){
160            lollipops.setNbrOwned(lollipops.nbrOwned - 100000000);
161            switch(random.getRandomIntUpTo(2)){
162                case 0:
163                    if(sword.name != "Sword of Liflamesummoning" && sword.name != "Sword of Randomness"){
164                        sword.setName("Sword of Liflamesummoning");
165                        htmlInteraction.setInnerHtml("computer_comment_3", "You found a new sword : the Sword of Liflamesummoning !");
166                    }
167                    else{
168                        htmlInteraction.setInnerHtml("computer_comment_3", "There's a bug with the bug, it didn't work :/");
169                    }
170                break;
171                case 1:
172                    candies.setNbrOwned(candies.nbrOwned * 3);
173                    htmlInteraction.setInnerHtml("computer_comment_3", "Your candies were multiplied by 3 !");
174                break;
175                case 2:
176                    if(sword.specialSword == true){
177                        if(random.oneChanceOutOf(6)){
178                            sword.setSpecialPower(sword.specialPower - 3);
179                            htmlInteraction.setInnerHtml("computer_comment_3", "Your sword lost 3 levels.");
180                            inventory.updateOnPage();
181                        }
182                        else{
183                            sword.setSpecialPower(sword.specialPower + 1);
184                            htmlInteraction.setInnerHtml("computer_comment_3", "The level of your sword increased by 1 !");
185                            inventory.updateOnPage();
186                        }
187                    }
188                    else{
189                        htmlInteraction.setInnerHtml("computer_comment_3", "There's a bug with the bug, it didn't work :/");
190                    }
191                break;
192            }
193        }
194    },
195    
196    bug4 : function(){
197        if(lollipops.nbrOwned >= 1000000000){
198            lollipops.setNbrOwned(lollipops.nbrOwned - 1000000000);
199            htmlInteraction.setInnerHtml("computer_comment_4", "Fake bug ! I guess you'll need 10000 mpl :)");
200        }
201    },
202    
203    bug5: function(){
204        if(lollipops.nbrOwned >= 10000000000){
205            lollipops.setNbrOwned(lollipops.nbrOwned - 10000000000);
206            switch(random.getRandomIntUpTo(1)){
207                case 0:
208                    if(land.ponyTime == false){
209                        land.ponyTime = true;
210                        htmlInteraction.setInnerHtml("computer_comment_5", "It's pony time !! Everyone is a pony now ! (*)");
211                        htmlInteraction.showButton("computer_note");
212                    }
213                    else{
214                        htmlInteraction.setInnerHtml("computer_comment_5", "There's a bug with the bug, it didn't work :/");
215                    }
216                break;
217                case 1:
218                    if(sword.name != "Sword of Randomness"){
219                        sword.setName("Sword of Randomness");
220                        htmlInteraction.setInnerHtml("computer_comment_5", "You found a new sword : the Sword of Randomness !");
221                    }
222                    else{
223                        htmlInteraction.setInnerHtml("computer_comment_5", "There's a bug with the bug, it didn't work :/");
224                    }
225                break;
226            }
227        }
228    },
229    
230    updateLollipops : function(){
231        htmlInteraction.setInnerHtml("computer_lollipops", Math.floor(lollipops.nbrOwned/100000)/10);
232    },
233    
234};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.