diff --git a/.gitignore b/.gitignore index be4bb06b..35361bde 100644 --- a/.gitignore +++ b/.gitignore @@ -8,9 +8,6 @@ package-lock.json yarn.lock .npmrc -.DS_Store - -*.asc - - public/ + +.DS_Store diff --git a/firebase.json b/firebase.json index 05c3e25b..7638b135 100644 --- a/firebase.json +++ b/firebase.json @@ -20,26 +20,6 @@ "key": "X-Content-Type-Options", "value": "nosniff" }, - { - "key": "X-XSS-Protection", - "value": "1; mode=block; report=https://jakejarvis.report-uri.com/r/d/xss/enforce" - }, - { - "key": "X-Frame-Options", - "value": "SAMEORIGIN" - }, - { - "key": "X-DNS-Prefetch-Control", - "value": "off" - }, - { - "key": "Referrer-Policy", - "value": "no-referrer-when-downgrade" - }, - { - "key": "Content-Security-Policy", - "value": "default-src 'self'; script-src 'self' www.google-analytics.com ssl.google-analytics.com ajax.googleapis.com 'sha256-KhRmfxEAAaZsUM+7gtG8pxaii136UceZCbgie95aRd0=' 'sha256-C84Lc+r0cDvAfbbr1KHi0s1jt0nzfAWH5+bmB/2Ph8s='; style-src 'self' 'unsafe-inline' fonts.googleapis.com; img-src 'self' data: https:; font-src 'self' fonts.gstatic.com; frame-src 'self' www.youtube.com player.vimeo.com drive.google.com www.scribd.com; connect-src 'self' jakejarvis.report-uri.com www.google-analytics.com ssl.google-analytics.com; upgrade-insecure-requests; report-uri https://jakejarvis.report-uri.com/r/d/csp/enforce;" - }, { "key": "Expect-CT", "value": "max-age=0, report-uri=https://jakejarvis.report-uri.com/r/d/ct/reportOnly" @@ -47,7 +27,7 @@ ] }, { - "source" : "**/", + "source" : "**", "headers": [ { "key": "Cache-Control", @@ -56,6 +36,26 @@ { "key": "X-UA-Compatible", "value": "IE=edge" + }, + { + "key": "X-XSS-Protection", + "value": "1; mode=block; report=https://jakejarvis.report-uri.com/r/d/xss/enforce" + }, + { + "key": "Content-Security-Policy", + "value": "default-src 'self'; script-src 'self' www.google-analytics.com ssl.google-analytics.com ajax.googleapis.com 'sha256-KhRmfxEAAaZsUM+7gtG8pxaii136UceZCbgie95aRd0=' 'sha256-C84Lc+r0cDvAfbbr1KHi0s1jt0nzfAWH5+bmB/2Ph8s='; style-src 'self' 'unsafe-inline' fonts.googleapis.com; img-src 'self' data: https:; font-src 'self' fonts.gstatic.com; frame-src 'self' www.youtube.com player.vimeo.com drive.google.com www.scribd.com; connect-src 'self' jakejarvis.report-uri.com www.google-analytics.com ssl.google-analytics.com; upgrade-insecure-requests; report-uri https://jakejarvis.report-uri.com/r/d/csp/enforce;" + }, + { + "key": "Referrer-Policy", + "value": "no-referrer-when-downgrade" + }, + { + "key": "X-Frame-Options", + "value": "SAMEORIGIN" + }, + { + "key": "X-DNS-Prefetch-Control", + "value": "off" } ] }, diff --git a/static/candies/ascii.html b/static/candies/ascii.html new file mode 100755 index 00000000..227a0a72 --- /dev/null +++ b/static/candies/ascii.html @@ -0,0 +1,50 @@ + + + + + candy box! — ascii art credit + + + + +Quests:

+ +The whale: jgs ( found here )
+Castle's entrance: part from -Sst- ( found here )
+The dragon: b'ger ( found here )
+Flowers: jgs ( found here )
+Cactus: jgs ( found here )
+Boat: unknown ( found here )
+Moat: inspired by jgs ( found here )
+ +
+Cauldron:

+ +Book: boba@wwa.com ( found here )
+Cauldron: jgs ( found here )
+ +
+Objects:

+ +Key: jgs ( found here )
+Boots: ajm97 ( found here )
+Pink ring: inspired by jgs ( found here )
+Strong armour: part from jgs ( found here )
+Cauldron: part from jgs ( found here )
+Horns: inspired by rs ( found here )
+Swords: inspired by jgs ( found here )
+ +
+Other:

+ +The candy merchant: snd ( found here )
+The lollipops farm: jgs ( found here )
+Potions: inspired by lbm & ejm97 ( found here )
+Scroll: inspired by hjw ( found here )
+ +


+these ascii artworks will never be used to gain money in any manner. + + + diff --git a/static/candies/design.css b/static/candies/design.css new file mode 100755 index 00000000..86a24448 --- /dev/null +++ b/static/candies/design.css @@ -0,0 +1,161 @@ +body { + background-color:#ffffff; + overflow-y:scroll; + font-family: 'Montserrat', sans-serif; + font-size:16px; + /* disable text highlight */ + -moz-user-select: none; + -webkit-user-select: none; + cursor:default; +} + +pre { + font-size:14px; +} + +a { + color:#000000; + font-weight:bold; +} + +a:hover { + color:#79ad36; +} + +#tabs { + text-align: center; + margin: auto; + padding: 0px; + margin-top: 5px; + margin-bottom:6px; +} + +#tabs li { + list-style: none; + display: inline; +} + +#tabs li button { + color:#282e32; + padding:8px 14px 8px 14px; + text-decoration:none; + font-size:9px; + font-family: 'Montserrat', sans-serif; + font-weight:bold; + text-transform:uppercase; + border:1px solid #464c54; +} + +#tabs li button.active { + background-color:#f8f2b1; + color:#282e32; + border:1px solid #464c54; +} + +#tab_candy_box { + display:block; +} + +#tab_candy_box, #tab_quest, #tab_inventory, #tab_cauldron { + border:2px solid transparent; +} + +#tab_quest, #tab_inventory, #tab_cauldron { + display:none; +} + +.clear { + clear:both; +} + +button { + background-color:#ffffff; + border:1px solid #464c54; + padding:8px 14px; + cursor:pointer; + font-family: 'Montserrat', sans-serif; + font-size:15px; + margin:4px 0px; +} + +button:hover { + border:2px solid #79ad36; + padding:7px 13px; +} + +button:disabled:hover { + cursor:default; + border:1px solid #464c54; + padding:8px 14px; +} + +table { + border-collapse:collapse; +} + +table, th, td { + border: 1px solid black; + padding:3px; +} + +.tooltip { + text-decoration:none; +} + +.tooltip span { + display: none; + white-space: normal; /* To force breaklines in tooltips */ + text-align: left; +} + +.tooltip:hover { + border: 0; + position: relative; + z-index: 500; + text-decoration: none; +} + +.tooltip:hover span { + font-style: normal; + display: block; + position: absolute; + padding: 5px; + margin: 0px 5px; + color: #000; + border: 1px solid #000000; + background: #ffffff; + font-family: monospace; + font-size: 13px; +} + +span.tooltip:hover span { + left: 70px; + width: 300px; +} + +button.tooltip:hover span { + width: 300px; +} + +#tab_quest_left_panel { + margin-right:15px; +} + +div#tab_inventory table { + width:650px; +} + +div#tab_inventory table td { + padding:2px 2px 2px 16px; + width:115px; +} + +div#tab_inventory table td#sword_cell { + width:150px !important; +} + +div#tab_quest button.potion_quest_button { + width:160px; + height:34px; + text-align:left; +} \ No newline at end of file diff --git a/static/candies/faq.html b/static/candies/faq.html new file mode 100755 index 00000000..b23468c4 --- /dev/null +++ b/static/candies/faq.html @@ -0,0 +1,53 @@ + + + + + candy box! — faq + + + + +
+

F.A.Q. (Frequently Asked Questions)

+Hey, you can only eat candies or throw them on the ground, this is stupid! + + Just be patient! ;) + +I have my 5 characters name, but I don't know how to load my game! + + When you click the "Save" button, a link appears next to it. You just have to click this link, and you will load your saved game. You can even put the link in your bookmarks, if you want! + + If you didn't keep the link but you have your 5 characters name, then just use the load button. + +My lollipop production at the farm is stuck.. it's written I should have x/day or x/hour but I don't get anything.. + + Well, you'll get your lollipops, but it's real hours and real days... you should plant more lollipops to reach an x/min production, it will be more efficient! + +I can't find the answer to a question of the frog :'( + + You can ask a friend for help! Answers are often simple, but a little bit twisted. + +I can go to the forge, but all I see is "There's an anvil here.", when can I do ? + + You don't have the appropriate sword yet.. did you answer all the frog's questions? ;) + +I can't buy the 60k spell at the hut! + + The sorceress, since she is a sorceress, can only work on magic swords. This is why you have to enchant your sword before being able to buy this spell! + +I can see the cauldron in my inventory, but I can't have access to it?! + + This bug seems to happen on Chromium-based browsers (Chrome, for example), on some computers. + Even if you don't see the cauldron tab on top of the page, you should still be able to access it with the 'right' key of your keyboard. + +I found a bug! + + Go tell Scrabble in the least annoying way possible and not during instruction time! There may be tickets involved if it's a bug I haven't heard before... + + Real-life bugs are always reported to Cajun, the janitor. Tell him I sent you. + +
+ + + diff --git a/static/candies/favicon.ico b/static/candies/favicon.ico new file mode 100755 index 00000000..0b663267 Binary files /dev/null and b/static/candies/favicon.ico differ diff --git a/static/candies/favicon.png b/static/candies/favicon.png new file mode 100755 index 00000000..fbf4ce2c Binary files /dev/null and b/static/candies/favicon.png differ diff --git a/static/candies/index.html b/static/candies/index.html new file mode 100755 index 00000000..17590674 --- /dev/null +++ b/static/candies/index.html @@ -0,0 +1,508 @@ + + + + + + + + + + + candy box! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+
+ + + + +
+ +
+ +
+

+ +
+
+ +
+ +
+
+ + +
+ + + +
+ + + +

+         
+
+
+
+ + + +
+
+
+ + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + + + + + +

+                    
+                
+ +
+
+
+ + + + + +
+ +
+ +

+                
+            
+            
+ +
+ +

+ + + Destination:

+ +
+ + + + +
+
+
+ + + + + +
+ + +

+                

+            
+

+            

+            

+            

+            
+
+ + + + + + + +
+


+ original game by aniwey © 2013 — + made awesomer & campier with by scribscrab — + ascii art credit — + faq +
+ + + + + + diff --git a/static/candies/readme.md b/static/candies/readme.md new file mode 100755 index 00000000..67ea3ebc --- /dev/null +++ b/static/candies/readme.md @@ -0,0 +1,7 @@ +candies +======= +Scrabble's modifications upon aniwey's online Candy Box game at [candies.aniwey.net](http://candies.aniwey.net). Hosted at [candies.scrabblerocks.com](http://candies.scrabblerocks.com). + +With love, scribscrab. + +![scrabble](http://scrabblerocks.com/img/s.png "scrabble") \ No newline at end of file diff --git a/static/candies/scripts/base_js_additions.js b/static/candies/scripts/base_js_additions.js new file mode 100755 index 00000000..c3febaef --- /dev/null +++ b/static/candies/scripts/base_js_additions.js @@ -0,0 +1,11 @@ +String.prototype.replaceAt = function(index, text){ + return this.substr(0, index) + text + this.substr(index + text.length); +} + +String.prototype.addTagAt = function(index, tagBegin, tagEnd, size){ + return this.substr(0, index) + tagBegin + this.substr(index, size) + tagEnd + this.substr(index + size); +} + +String.prototype.replaceAt_with_size = function(index, text, size){ + return this.substr(0, index) + text + this.substr(index + size); +} diff --git a/static/candies/scripts/buttons.js b/static/candies/scripts/buttons.js new file mode 100755 index 00000000..aa1ffb72 --- /dev/null +++ b/static/candies/scripts/buttons.js @@ -0,0 +1,398 @@ +var buttons = { + + // Variables + + homeButtonsDisabled : false, // Block any enabling home button process when true + + // Functions + + enableHomeButtons : function(){ + if(this.homeButtonsDisabled == true){ + this.homeButtonsDisabled = false; + htmlInteraction.enableButtonClass("home_button"); + this.checkHomeEnabled(); + } + }, + + enableButton : function(name){ + // If the home buttons are enabled or our button isn't a home button + if(this.homeButtonsDisabled == false || htmlInteraction.getElement(name).className != "home_button"){ + htmlInteraction.enableButton(name); + } + }, + + checkEatAndThrowButtons : function(){ + // Show the eat button + if(candies.nbrOwned >= 1){ + htmlInteraction.showButton("eat"); + this.enableButton("eat"); + } + else htmlInteraction.disableButton("eat"); + + // Show the throw button + if(candies.nbrOwned >= 10){ + htmlInteraction.showButton("throw_10"); + this.enableButton("throw_10"); + } + else htmlInteraction.disableButton("throw_10"); + }, + + checkHomeEnabled : function(){ + this.checkEatAndThrowButtons(); + this.checkQuestBuyingButtons(); + this.checkEncrustSwordButton(); + this.checkPolishSwordButton(); + this.checkCoatSwordButton(); + this.checkLollipopsStockShortage(); + this.checkObjects(); + this.checkLollipopsPlantingButtons(); + this.checkQuestTiredTime(); + }, + + checkCandies : function(){ + this.checkEatAndThrowButtons(); + this.checkQuestBuyingButtons(); + this.checkEncrustSwordButton(); + this.checkLollipopsStockShortage(); + this.checkWishingWell(); + }, + + checkSword : function(){ + this.checkQuestBuyingButtons(); + this.checkEncrustSwordButton(); + this.checkPolishSwordButton(); + this.checkCoatSwordButton(); + this.checkTabPanel(); + }, + + checkTabPanel : function(){ + // If we have a sword + if(sword.name != "none"){ + // We enable the tab bar + htmlInteraction.setElementDisplay("tabBar", ""); + // And we enable some tabs + tabs.enable(0); + tabs.enable(1); + tabs.enable(2); + } + }, + + checkQuestBuyingButtons : function(){ + // Enable/disable quest buying buttons (show/hide is handle by sword&shop algorithms) + + // Swords + if(shop.currentSwordButtonId != "none"){ // If the merchant is selling a sword right now + if(candies.nbrOwned >= shop.currentSwordPrice) this.enableButton(shop.currentSwordButtonId); + else htmlInteraction.disableButton(shop.currentSwordButtonId); + } + + // Potions & scrolls + if(candies.nbrOwned >= 600) this.enableButton("buy_health_potion"); + else htmlInteraction.disableButton("buy_health_potion"); + + if(candies.nbrOwned >= 150) this.enableButton("buy_escape_potion"); + else htmlInteraction.disableButton("buy_escape_potion"); + + if(candies.nbrOwned >= 400) this.enableButton("buy_scroll"); + else htmlInteraction.disableButton("buy_scroll"); + }, + + checkEncrustSwordButton : function(){ + // Show the encrust the diamond sword button + if(candies.nbrOwned >= 101 && sword.name == "diamond sword"){ + htmlInteraction.showButton("encrust"); + this.enableButton("encrust"); + htmlInteraction.setElementDisplay("encrust", "inline"); + htmlInteraction.setElementDisplay("polish", "none"); + htmlInteraction.setElementDisplay("coat", "none"); + } + else htmlInteraction.disableButton("encrust"); + }, + + checkPolishSwordButton : function(){ + // Show the polish the diamond sword button + if(lollipops.nbrOwned >= 30 && sword.name == "candy diamond sword"){ + htmlInteraction.showButton("polish"); + this.enableButton("polish"); + htmlInteraction.setElementDisplay("encrust", "none"); + htmlInteraction.setElementDisplay("polish", "inline"); + htmlInteraction.setElementDisplay("coat", "none"); + } + else htmlInteraction.disableButton("polish"); + }, + + checkLollipops : function(){ + this.checkPolishSwordButton(); + this.checkLollipopsPlantingButtons(); + this.checkHut(); + this.checkLollipopsStockShortage(); + this.checkComputer(); + }, + + checkComputer : function(){ + if(lollipops.nbrOwned >= 1000000){ + htmlInteraction.showButton("computer_bug_1"); + htmlInteraction.showButton("computer_comment_1"); + } + else{ + htmlInteraction.hideButton("computer_bug_1"); + } + + if(lollipops.nbrOwned >= 10000000){ + htmlInteraction.showButton("computer_bug_2"); + htmlInteraction.showButton("computer_comment_2"); + } + else{ + htmlInteraction.hideButton("computer_bug_2"); + } + + if(lollipops.nbrOwned >= 100000000){ + htmlInteraction.showButton("computer_bug_3"); + htmlInteraction.showButton("computer_comment_3"); + } + else{ + htmlInteraction.hideButton("computer_bug_3"); + } + + if(lollipops.nbrOwned >= 1000000000){ + htmlInteraction.showButton("computer_bug_4"); + htmlInteraction.showButton("computer_comment_4"); + } + else{ + htmlInteraction.hideButton("computer_bug_4"); + } + + if(lollipops.nbrOwned >= 10000000000){ + htmlInteraction.showButton("computer_bug_5"); + htmlInteraction.showButton("computer_comment_5"); + htmlInteraction.showButton("computer_note"); + } + else{ + htmlInteraction.hideButton("computer_bug_5"); + } + + if(lollipops.nbrOwned >= 100000000000) htmlInteraction.showButton("computer_bug_6"); + else htmlInteraction.hideButton("computer_bug_6"); + + if(lollipops.nbrOwned >= 1000000000000) htmlInteraction.showButton("computer_bug_7"); + else htmlInteraction.hideButton("computer_bug_7"); + + if(lollipops.nbrOwned >= 10000000000000) htmlInteraction.showButton("computer_bug_8"); + else htmlInteraction.hideButton("computer_bug_8"); + }, + + checkCoatSwordButton : function(){ + // Show the coat the diamond blbl sword button + if(chocolateBars.nbrOwned >= 1 && sword.name == "polished candy diamond sword"){ + htmlInteraction.showButton("coat"); + this.enableButton("coat"); + htmlInteraction.setElementDisplay("encrust", "none"); + htmlInteraction.setElementDisplay("polish", "none"); + htmlInteraction.setElementDisplay("coat", "inline"); + } + else htmlInteraction.disableButton("coat"); + }, + + checkChocolateBars : function(){ + this.checkCoatSwordButton(); + }, + + checkLollipopsStockShortage : function(){ + // If the shop is shown + if(shop.shown){ + // If there's a lollipops stock shortage + if(lollipops.stockShortage == true){ + // We show the stock shortage and hide the buttons used to buy lollipops + htmlInteraction.setElementVisibility("lollipops_stock_shortage", true); + htmlInteraction.hideButton("buy_1_lollipop"); + htmlInteraction.hideButton("buy_10_lollipops"); + } + // Else, no lollipops stock shortage + else{ + // We don't show the stock shortage + htmlInteraction.setElementVisibility("lollipops_stock_shortage", false); + // We show and maybe enable the button to buy one lollipop + htmlInteraction.showButton("buy_1_lollipop"); + if(candies.nbrOwned >= shop.oneLollipopPrice) this.enableButton("buy_1_lollipop"); + else htmlInteraction.disableButton("buy_1_lollipop"); + // We maybe show and maybe enable the button to buy 500 lollipops + if(candies.nbrOwned >= shop.tenLollipopsPrice || shop.buy10LollipopsButtonShown){ + shop.setBuy10LollipopsButtonShown(true); + if(htmlInteraction.isElementVisible("buy_10_lollipops") == false){ // If it wasn't shown yet + htmlInteraction.showButton("buy_10_lollipops"); + shop.setMerchantSpeech("There's now a discount on a pack of 10 lollipops! Buy them please... I need candiiiies!"); + } + this.enableButton("buy_10_lollipops"); + } + if(candies.nbrOwned < shop.tenLollipopsPrice) htmlInteraction.disableButton("buy_10_lollipops"); + } + } + }, + + checkObjects : function(){ + // Show the button to go to the swamp map + if(objects.list.swampMap.have){ + htmlInteraction.setElementDisplay("go_to_swamp", "block"); + htmlInteraction.showButton("go_to_swamp"); + this.enableButton("go_to_swamp"); + } + // Show the button to go to the hut + if(objects.list.hutMap.have){ + htmlInteraction.setElementDisplay("go_to_hut", "block"); + htmlInteraction.showButton("go_to_hut"); + this.enableButton("go_to_hut"); + } + // Show the button to go to the wishing well + if(objects.list.wellMap.have){ + htmlInteraction.setElementDisplay("go_to_well", "block"); + htmlInteraction.showButton("go_to_well"); + this.enableButton("go_to_well"); + } + // Show the button to go to the forge + if(objects.list.forgeMap.have){ + htmlInteraction.setElementDisplay("go_to_forge", "block"); + htmlInteraction.showButton("go_to_forge"); + this.enableButton("go_to_forge"); + } + + // Check the farm visibility + farm.checkVisibility(); + + // Check some farm's buttons + this.checkLollipopsPlantingButtons(); + + // Check the candies converter visibility + candiesConverter.checkVisibility(); + + // Check the cauldron visibility + cauldron.checkVisibility(); + }, + + checkLollipopsPlantingButtons : function(){ + // If we have the key of the lollipop farm + if(objects.list.key.have){ + // innerHtml of the lp_buttons span + + // Plant 1000 button + if(lollipops.nbrOwned >= 1000 && farm.plantingButtonsStep < 4){ + farm.setPlantingButtonsStep(4); + } + // Plant 100 button + else if(lollipops.nbrOwned >= 100 && farm.plantingButtonsStep < 3){ + farm.setPlantingButtonsStep(3); + } + // Plant 10 button + else if(lollipops.nbrOwned >= 10 && farm.plantingButtonsStep < 2){ + farm.setPlantingButtonsStep(2); + } + // Plant 1 button + else if(farm.plantingButtonsStep < 1){ + farm.setPlantingButtonsStep(1); + } + + // Buttons activation + + // Plant 1000 button + if(farm.plantingButtonsStep >= 4){ + htmlInteraction.showButton("plant_1000_lp"); + if(lollipops.nbrOwned >= 1000){ + this.enableButton("plant_1000_lp"); + } + else htmlInteraction.disableButton("plant_1000_lp"); + } + // Plant 100 button + if(farm.plantingButtonsStep >= 3){ + htmlInteraction.showButton("plant_100_lp"); + if(lollipops.nbrOwned >= 100){ + this.enableButton("plant_100_lp"); + } + else htmlInteraction.disableButton("plant_100_lp"); + } + // Plant 10 button + if(farm.plantingButtonsStep >= 2){ + htmlInteraction.showButton("plant_10_lp"); + if(lollipops.nbrOwned >= 10){ + this.enableButton("plant_10_lp"); + } + else htmlInteraction.disableButton("plant_10_lp"); + } + // Plant 1 button + if(farm.plantingButtonsStep >= 1){ + htmlInteraction.showButton("plant_1_lp"); + if(lollipops.nbrOwned >= 1){ + this.enableButton("plant_1_lp"); + } + else htmlInteraction.disableButton("plant_1_lp"); + } + } + }, + + checkQuestTiredTime : function(){ + // Buttons related to the quest tired time + if(quest.tiredTime == 0 && quest.weAreQuestingRightNow == false) this.enableButton("quest_button"); + else htmlInteraction.disableButton("quest_button"); + }, + + checkHut : function(){ + if(hut.shown){ + switch(hut.step){ + case 0: + htmlInteraction.showButton("hut_throw_lollipops"); + if(lollipops.nbrOwned >= 10){ + this.enableButton("hut_throw_lollipops"); + } + else htmlInteraction.disableButton("hut_throw_lollipops"); + break; + case 2: + for(var i = 0; i < spells.list.length; i++){ + if(hut.canThisSpellBeUsed(i)){ + this.enableButton("hut_spell_" + i); + } + else htmlInteraction.disableButton("hut_spell_" + i); + } + // Special surpass button + if(quest.maxLandOrder == 7 && yourself.canSurpass == false){ + if(lollipops.nbrOwned >= 1000000) this.enableButton("hut_surpass"); + else htmlInteraction.disableButton("hut_surpass"); + } + break; + } + } + }, + + checkWishingWell : function(){ + if(wishingWell.shown){ + switch(wishingWell.step){ + case 0: + if(candies.nbrOwned >= 1){ + this.enableButton("wishingWell_throw_candy"); + } + else htmlInteraction.disableButton("wishingWell_throw_candy"); + break; + } + } + }, + + checkForge : function(){ + if(forge.shown && forge.step == 1){ + // Health + if(potions.list.health.shown && potions.list.health.nbrOwned >= 1){ + this.enableButton("enchant_health"); + } + else htmlInteraction.disableButton("enchant_health"); + + // Fire + if(potions.list.fireScroll.shown && potions.list.fireScroll.nbrOwned >= 1){ + this.enableButton("enchant_fire"); + } + else htmlInteraction.disableButton("enchant_fire"); + + // Imp invocation + if(potions.list.impInvocationScroll.shown && potions.list.impInvocationScroll.nbrOwned >= 1){ + this.enableButton("enchant_imp_invocation"); + } + else htmlInteraction.disableButton("enchant_imp_invocation"); + } + } + +}; diff --git a/static/candies/scripts/candies.js b/static/candies/scripts/candies.js new file mode 100755 index 00000000..d835b2e2 --- /dev/null +++ b/static/candies/scripts/candies.js @@ -0,0 +1,76 @@ +var candies = { + + // Variables + nbrOwned : 0, + nbrEaten : 0, + nbrThrown : 0, + nbrTotal : 0, // The total number we earned in all times + candiesPerSecond : 1, + + // Functions + onload : function(){ + candies.setNbrOwned(0); // We first have 0 candies + }, + + eat : function(){ + this.setNbrEaten(this.nbrEaten + this.nbrOwned); + this.setNbrOwned(0); + }, + + setNbrTotal : function(value){ + this.nbrTotal = value; + }, + + setNbrOwned : function(value){ + // If this is an increase, we increase nbr total too + if(value > this.nbrOwned){ + this.setNbrTotal(this.nbrTotal + value - this.nbrOwned); + } + + this.nbrOwned = value; + if(this.nbrOwned != 1) htmlInteraction.setInnerHtml("candies", "You have " + numberWithCommas(this.nbrOwned) + " candies!"); + else htmlInteraction.setInnerHtml("candies", "You have 1 candy!"); + buttons.checkCandies(); + shop.check(); + cauldron.updateActionsInfoOnPage(); + }, + + setNbrEaten : function(value){ + this.nbrEaten = value; + if(this.nbrEaten != 1) htmlInteraction.setInnerHtml("candies_eaten", "You have eaten " + numberWithCommas(this.nbrEaten) + " candies!"); + else htmlInteraction.setInnerHtml("candies_eaten", "You have eaten 1 candy!"); + htmlInteraction.setElementVisibility("candies_eaten", true); + }, + + setCandiesPerSecond : function(value){ + this.candiesPerSecond = value; + }, + + setNbrThrown : function(value){ + this.nbrThrown = value; + + // We choose which smiley we want to add at the end of the sentence + if(this.nbrThrown <= 10) smiley = "."; + else if(this.nbrThrown <= 20) smiley = "..."; + else if(this.nbrThrown <= 30) smiley = "...?"; + else if(this.nbrThrown <= 40) smiley = "...? :|"; + else if(this.nbrThrown <= 50) smiley = "...? :/"; + else if(this.nbrThrown <= 60) smiley = "...? :("; + else if(this.nbrThrown <= 70) smiley = "...? :["; + else if(this.nbrThrown <= 80) smiley = "...? :{"; + else if(this.nbrThrown <= 90) smiley = "...? :'("; + else smiley = "...? (;_;)"; + + if(this.nbrThrown != 1) htmlInteraction.setInnerHtml("candies_thrown", "You have thrown " + numberWithCommas(this.nbrThrown) + " candies on the ground" + smiley); + else htmlInteraction.setInnerHtml("candies_thrown", "You have thrown 1 candy on the ground" + smiley); + htmlInteraction.setElementVisibility("candies_thrown", true); + }, + + throw10Candies : function(){ + if(this.nbrOwned >= 10){ // If we have at least 10 candies + this.setNbrOwned(this.nbrOwned - 10); + this.setNbrThrown(this.nbrThrown + 10); + } + } + +}; diff --git a/static/candies/scripts/candiesConverter.js b/static/candies/scripts/candiesConverter.js new file mode 100755 index 00000000..79f5bf5c --- /dev/null +++ b/static/candies/scripts/candiesConverter.js @@ -0,0 +1,56 @@ +var candiesConverter = { + + // Variables + activated : false, // If true, the candiesConverter is activated + speed : 1, // How many candies the converter can convert into lollipops each 1/10 seconds. The more the candies converted without stopping, the more the speed increase. + + // Functions + checkVisibility : function(){ + // If we have the candies conveter + if(objects.list.candiesConverter.have){ + // We show it on the page + htmlInteraction.setElementDisplay("candies_converter", "inline"); + } + }, + + checkedValueChange : function(){ + if(htmlInteraction.getElement("candies_converter_checkbox").checked){ + this.setActivated(true); + } + else{ + this.setActivated(false); + } + }, + + convert : function(){ + var howMany = 0; + + // If we are activated and have candies to convert + if(this.activated && candies.nbrOwned > 0){ + // We calculate how many candies we will convert + if(this.speed > candies.nbrOwned){ + howMany = candies.nbrOwned; + } + else howMany = this.speed; + + // We convert them + candies.setNbrOwned(candies.nbrOwned - howMany); + lollipops.setNbrOwned(lollipops.nbrOwned + howMany); + + // We increment the speed + if(this.speed < 10000) this.speed += 1; + else this.speed *= 2; + } + // Else + else{ + // We reset speed + this.speed = 1; + } + }, + + setActivated : function(value){ + this.activated = value; + htmlInteraction.getElement("candies_converter_checkbox").checked = value; + } + +}; diff --git a/static/candies/scripts/castleEntrance.js b/static/candies/scripts/castleEntrance.js new file mode 100755 index 00000000..e54b20a0 --- /dev/null +++ b/static/candies/scripts/castleEntrance.js @@ -0,0 +1,162 @@ +var castleEntrance = { + + // Variables + + size : 30, + timeSpent : 0, // Time spent since the beginning of the quest + thereIsAMagicBall : false, // True if there's a magic ball right now + magicBallX : 0, // X position of the magic ball + magicBallY : 0, // Y position of the magic ball + + // Functions + + onload : function(){ + land.addLand("Castle's entrance", this.size, 3, this.load.bind(this), this.getText.bind(this), this.move.bind(this)); + }, + + move : function(){ + // Make enemies go toward the left + for(var i = 0; i < quest.things.length; i++){ + if(quest.things[i].type == "mob" && quest.things[i-1].type == "none"){ + quest.things[i-1] = quest.things[i]; + quest.things[i] = quest.makeNoneThing(); + } + } + + // We add ennemies + if(this.timeSpent < 1000){ // We must stop adding ennemies after a while, else the player could be blocked in certain conditions + if(this.timeSpent % 16 == 5){ + // If there's nothing here, we add a knight + if(quest.things[29].type == "none") quest.things[29] = this.makeKnight(); + } + else if(this.timeSpent % 30 == 29){ + // If there's nothing here, we add a guard + if(quest.things[29].type == "none") quest.things[29] = this.makeGuard(); + } + } + + // We handle the magic ball if we spent at least four movements + if(this.timeSpent > 4){ + // If there is already a magic ball + if(this.thereIsAMagicBall){ + var index = quest.getCharacterIndex(); + + // If the magic ball just hit the player ! + if(Math.abs(this.magicBallX - (index*3 + 1)) <= 1 && this.magicBallY == 19){ + // No more magic ball + this.thereIsAMagicBall = false; + + // We teleport the player + quest.things[0] = quest.things[index]; + quest.things[index] = quest.makeNoneThing(); + } + // Else + else{ + // If the magic ball is at the right of the player or is above the steps (it mustn't be above the steps) + if(this.magicBallX > index*3 + 1 || this.magicBallX > 77){ + this.magicBallX -= 1; + } + // Else, if it's at the left + else if(this.magicBallX < index*3 + 1){ + this.magicBallX += 1; + } + // If the magic ball isn't already just above the lawn and we're not too far from the play horizontally + if(this.magicBallY < 19 && Math.abs(this.magicBallX - index*3) < (19 - this.magicBallY)*3){ + this.magicBallY += 1; + } + } + } + // If there is not already a magic ball + else{ + this.thereIsAMagicBall = true; + this.magicBallX = 83; + this.magicBallY = 1; + } + } + + // We increment the time spent + this.timeSpent += 1; + }, + + load : function(){ + // We add some guards on the lawn to slow down the player + quest.things[10] = this.makeGuard(); + quest.things[12] = this.makeGuard(); + quest.things[15] = this.makeGuard(); + quest.things[17] = this.makeGuard(); + + // We reset the time spent + this.timeSpent = 0; + }, + + makeGuard : function(){ + return land.createMob("GUA", 25, 25, "spear", "One of the castle's guards.", [drops.createDrop("candies", random.getRandomIntUpTo(40))]); + }, + + makeKnight : function(){ + return land.createMob("KNI", 70, 70, "sharp sword", "A knight with a huge armor.", [drops.createDrop("candies", 230 + random.getRandomIntUpTo(70)), drops.createDrop("object", "plateArmour", random.oneChanceOutOf(10))]); + }, + + getText : function(){ + var lines = []; + lines = this.text.slice(0); // It will store the lines of the castle entrance + + // We add things to the lines (we use size - 1 to avoid drawing the last position, which is inside the castle) + for(var i = 0; i < this.size - 1; i++){ + // If there's a thing + if(quest.things[i].type != "none"){ + // Before the first step + if(i < 26){ + lines[20] = lines[20].replaceAt(i*3, quest.things[i].text); + } + // On the first step + else if(i == 26){ + lines[19] = lines[19].replaceAt(i*3, quest.things[i].text); + } + // On the second step + else if(i <= 28){ + lines[18] = lines[18].replaceAt(i*3, quest.things[i].text); + } + } + } + + // We add the magic ball + if(this.thereIsAMagicBall){ + lines[this.magicBallY] = lines[this.magicBallY].replaceAt(this.magicBallX, "*"); + } + + // We return the lines + return lines.join(""); + }, + + // Variables + + text : [ +" __\n", +" <*/\n", +" (}\n", +" |\\\n", +" ||| || || || |\n", +" |`\' `\' `\' `\'.|\n", +" : .:;\n", +" \\-..____..:/ _ _\n", +" :--------:_,\' || |\n", +" |] .:| `\' `\n", +" | ,-. .[| _\n", +" | | | .:|\'--\' _\n", +" | |_| .:| \'--\'\n", +" | \'=\' .:|\n", +" | __ .:|\n", +" |\'--\' .:| _\n", +" | .:| \'-\'\n", +" | \'-| _\n", +" ______| _ .:| _ \'--\'\n", +" ___||||||| \'-\' .:| \'-\'\n", +" ___|||||||||;._____.::-------\n", +"\' \" \'\' \" \"\' \"\' \' \" \' \"\' \'\" \' \'\" \"\' \' \'\" \" \' \' \'\" \' \' \'\" \' \'\" \'\" \'\' \' \'\" \" \' \'\" \' \' \" \'\" \" \" \' \'\" \"\' \n", +" \"\' \' \" \' \" \' \" \' \" \' \' \" \' \' \" \' \" \' \' \" \" \" \' \' \" \"\' \'\n", +" \'\" \' \" \' \" \' \" \' \" \' \" \" \' \" \' \" \' \n", +" \' \" \' \' \" \" \' \' \' \" \"\n" +] + +}; diff --git a/static/candies/scripts/castleKeep.js b/static/candies/scripts/castleKeep.js new file mode 100755 index 00000000..7a4794d4 --- /dev/null +++ b/static/candies/scripts/castleKeep.js @@ -0,0 +1,351 @@ +var castleKeep = { + + // Variables + + size : 30, // The size here must be higher than the size of the biggest room + realSize : 0, // This is the real size of the current room, in term of things + roomSize : 0, // Real size of the room in term of ascii + floorPosition : 0, // Where the floor is located in the current room + firstCharacterPosition : 0, // Where the character is located when he enters the room + lastCharacterPosition : 0, // Where the character can exit the room + text : [], + roomNumber : 0, // The current room number. Increase by one each room. + mobsAreMoving : false, // If true, in the current room, mobs should move toward the player + maxRoom : 6, + + // Functions + + onload : function(){ + land.addLand("Castle's keep", this.size, 5, this.load.bind(this), this.getText.bind(this), this.move.bind(this)); + }, + + move : function(){ + // We get the character's index + var index = quest.getCharacterIndex(); + var characterThing = quest.things[index]; + + // If the mobs should move, we make them move + if(this.mobsAreMoving){ + for(var i = 0; i < quest.things.length; i++){ + if(quest.things[i].type == "mob" && quest.things[i-1].type == "none"){ + quest.things[i-1] = quest.things[i]; + quest.things[i] = quest.makeNoneThing(); + } + } + } + + // If the character is just after the exit of the room, we create a new room and put him in it + if(index == this.lastCharacterPosition - this.firstCharacterPosition + 1){ + this.roomNumber += 1; // We increment the room number + // If we aren't yet arrived at the room x + if(this.roomNumber <= this.maxRoom){ + quest.things = quest.fillWithNoneThings(); // Remove all the things + this.createNewRoom(); // Create a new room + quest.things[0] = characterThing; // Put the character at the beginning of the room + } + // Else, we end the quest + else{ + quest.things[this.size-1] = quest.things[index]; + quest.things[index] = quest.makeFakeCharacter(); + } + } + + // If we just killed the dragon + if(this.roomNumber == 6 && index == 16 && quest.things[17].type == "none"){ + // We reload the room without the dragon + this.text = []; + this.createRoomStructure(); + this.createDoorHere(this.firstCharacterPosition); + } + }, + + load : function(){ + this.roomNumber = 0; // We reset the room number + this.createNewRoom(); + }, + + getText : function(){ + var lines = []; + lines = this.text.slice(0); // It will store the lines of the castle keep + + // We add things + for(var i = 0; i < this.realSize; i++){ + if(quest.things[i].type != "none"){ + lines[this.floorPosition] = lines[this.floorPosition].replaceAt(1 + this.firstCharacterPosition*3 + i*3, quest.things[i].text); + } + } + + // We return the lines around the player + return lines.join(""); + }, + + createRoomStructure : function(){ + var line; + + // Create the roof + line = "__"; + for(var i = 0; i < this.roomSize; i++){ + line += "___"; + } + line += "\n"; + this.text.push(line); + // Create the inside + line = "|"; + for(var i = 0; i < this.roomSize; i++){ + line += " "; + } + line += "|\n"; + for(var i = 0; i < this.floorPosition - 1; i++){ + this.text.push(line); + } + // Create the floor + line = "|"; + for(var i = 0; i < this.roomSize; i++){ + line += "___"; + } + line += "|\n"; + this.text.push(line); + }, + + addDragonInRoom : function(){ + var line = ""; + + // Add a line (to store the tail of the dragon) + for(var i = 0; i < this.roomSize; i++){ + line += " "; + } + this.text.push(line); + + for(var i = 0; i < this.asciiDragon.length; i++){ + this.text[i + 1] = this.text[i + 1].replaceAt(54, this.asciiDragon[i]); + } + }, + + createNewRoom : function(){ + this.text = []; + + // If we're not yet at the boss room, we make a random-sized room + if(this.roomNumber < this.maxRoom){ + // Set the size and stuff + this.realSize = 16 + random.getRandomIntUpTo(10); + this.firstCharacterPosition = random.getRandomIntUpTo(2); + this.lastCharacterPosition = this.firstCharacterPosition + this.realSize - 1; + this.floorPosition = 5 + random.getRandomIntUpTo(6); + this.roomSize = this.realSize + this.firstCharacterPosition + random.getRandomIntUpTo(2); + + this.createRoomStructure(); + + // We add the doors at the character's first and last position + this.createDoorHere(this.firstCharacterPosition); + this.createDoorHere(this.lastCharacterPosition); + } + // Else, it's the boss room + else{ + // Set the size and stuff + this.realSize = 26; + this.firstCharacterPosition = 1; + this.lastCharacterPosition = 21; + this.floorPosition = 16; + this.roomSize = this.realSize + this.firstCharacterPosition + 1; + + this.createRoomStructure(); + this.addDragonInRoom(); + + // We add the doors at the character's first and last position + this.createDoorHere(this.firstCharacterPosition); + } + + // By default, mobs are not moving + this.mobsAreMoving = false; + + // We add roomNumber specific stuff + switch(this.roomNumber){ + // Room 0 : we put some guards + case 0: + for(var i = 2; i < this.realSize - 1; i+=3){ + quest.things[i] = castleEntrance.makeGuard(); + } + this.mobsAreMoving = true; + break; + // Rooms 1 to 4 : we put some random ennemies + case 1: case 2: case 3: case 4: + switch(random.getRandomIntUpTo(7)){ + // Knights room + case 0: + for(var i = 2; i < this.realSize - 1; i++){ + if(random.oneChanceOutOf(4)){ + quest.things[i] = castleEntrance.makeKnight(); + } + } + this.mobsAreMoving = true; + break; + // Animals room + case 1: + for(var i = 2; i < this.realSize - 1; i++){ + if(random.oneChanceOutOf(4)){ + switch(random.getRandomIntUpTo(6)){ + case 0: quest.things[i] = castleKeep.makeKomodoDragon(); break; + case 1: quest.things[i] = castleKeep.makeRhinoceros(); break; + case 2: quest.things[i] = castleKeep.makeGaur(); break; + case 3: quest.things[i] = castleKeep.makeDromornisStirtoni(); break; + case 4: quest.things[i] = castleKeep.makeGorilla(); break; + case 5: quest.things[i] = castleKeep.makeCapybara(); break; + case 6: quest.things[i] = castleKeep.makeDoedicurus(); break; + } + } + } + break; + // Ghosts room + case 2: + for(var i = 4; i < this.realSize - 1; i++){ + if(random.oneChanceOutOf(5)){ + quest.things[i] = castleStairs.makeGhost(); + } + } + this.mobsAreMoving = true; + break; + // Walled off zombie warrior room + case 3: + // We add the walls + for(var i = 1; i < this.floorPosition; i++){ + this.text[i] = this.text[i].replaceAt(1 + this.firstCharacterPosition*3 + 7*3, "WAL"); + this.text[i] = this.text[i].replaceAt(1 + this.firstCharacterPosition*3 + 9*3, "WAL"); + } + // We add the mobs (walls and walled off zombie warrior) + quest.things[7] = this.makeStoneWall(); + quest.things[9] = this.makeStoneWall(); + quest.things[8] = this.makeWalledOffZombieWarrior(); + break; + // Fireball room + case 4: + for(var i = this.realSize - 8; i < this.realSize - 1; i++){ + if(random.flipACoin()){ + quest.things[i] = this.makeFireball(); + } + } + this.mobsAreMoving = true; + break; + // Fake door room + case 5: + this.createDoorHere(this.firstCharacterPosition + 8); + quest.things[8] = this.makeFakeDoorMonster(); + break; + // Unicorn room + case 6: + quest.things[2 + random.getRandomIntUpTo(this.realSize - 4)] = this.makeCharlieTheUnicorn(); + quest.things[2 + random.getRandomIntUpTo(this.realSize - 4)] = this.makeUnicorn(); + quest.things[2 + random.getRandomIntUpTo(this.realSize - 4)] = this.makeUnicorn(); + this.mobsAreMoving = true; + break; + // Troll room + case 7: + quest.things[6 + random.getRandomIntUpTo(this.realSize - 8)] = this.makeTroll(); + this.mobsAreMoving = true; + break; + } + break; + // The chests room + case 5: + for(var i = 1; i < this.realSize - 1; i++){ + if(random.oneChanceOutOf(3)){ + quest.things[i] = quest.makeOpenChest(); + } + } + this.mobsAreMoving = false; + break; + // Boss room + case 6: + quest.things[17] = this.makeDragon(); + break; + } + }, + + createDoorHere : function(position){ + this.text[this.floorPosition-2] = this.text[this.floorPosition-2].replaceAt(1 + position*3, " _ "); + this.text[this.floorPosition-1] = this.text[this.floorPosition-1].replaceAt(1 + position*3, "|.|"); + this.text[this.floorPosition] = this.text[this.floorPosition].replaceAt(1 + position*3, "| |"); + }, + + makeKomodoDragon : function(){ + return land.createMob("KOM", 5, 5, "foots and tail", "A Komodo dragon. Did you heard about island gigantism ?", []); + }, + + makeRhinoceros : function(){ + return land.createMob("RHI", 160, 160, "horn", "A " + random.pickRandomly(["white", "black", "indian", "javan", "sumatran"]) + " rhinoceros. Watch out for his horn !", []); + }, + + makeGaur : function(){ + return land.createMob("GAU", 80, 80, "horns", "A Gaur. This large bovine looks like a bison.", []); + }, + + makeDromornisStirtoni : function(){ + return land.createMob("DST", 70, 70, "giant beak", "A Dromornis Stirtoni ! A 400kg flightless bird !", []); + }, + + makeGorilla : function(){ + return land.createMob("GOR", 50, 50, "its fists", "A Gorilla. Gorillas occasionally engage in homosexual interactions.", []); + }, + + makeCapybara : function(){ + return land.createMob("CPY", 20, 20, "its teeth", "A capybara : the largest rodent in the world !", []); + }, + + makeDoedicurus : function(){ + return land.createMob("DOE", 120, 120, "spiky tail", "A Doedicurus : your favorite glyptodont !", []); + }, + + makeStoneWall : function(){ + return land.createMob("WAL", 300, 300, "stone", "A stone wall.", []); + }, + + makeWalledOffZombieWarrior : function(){ + var hp = 150 + random.getRandomIntUpTo(10) * 10; + return land.createMob("WZW", hp, hp, "cursed sword", "A walled off zombie warrior. He probably did something bad to end up here.", [drops.createDrop("candies", random.getRandomIntUpTo(1) * 4000), drops.createDrop("object", "oldAmulet", true)]); + }, + + makeFireball : function(){ + return land.createMob("FBL", 1, 1, "itself", "A fireball !! Watch out !", []); + }, + + makeFakeDoorMonster : function(){ + return land.createMob("| |", 70, 70, "sharp teeth", "It's not a door ! It's a monster ! (an ugly one)", []); + }, + + makeUnicorn : function(){ + return land.createMob("UNI", 100, 100, "magical horn", "A unicorn !! They exist !", []); + }, + + makeCharlieTheUnicorn : function(){ + return land.createMob("UNI", 100, 100, "magical horn", "A unicorn !! It has no kidney.", [drops.createDrop("object", "magicalHorn", true)]); + }, + + makeTroll : function(){ + return land.createMob("TRL", 250, 250, "enormous fist", "A troll. It is huge, but it lacks precision.", []); + }, + + makeDragon : function(){ + return land.createMob(",((", 500, 500, "flames", "A dragon !! Kill him and the castle will be yours.", []); + }, + + asciiDragon : +[ +" _///_,", +" / ` \' \'>", +" o\' __/_\'>", +" / _/ )_\\\'>", +"\"__/ /_/\\_>", +" ____/_/_/_/", +" /,---, _/ /", +"\"\" /_/_/_/", +" /_(_(_(_ \\", +" ( \\_\\_\\\\_ )\\", +" \\\'__\\_\\_\\_\\__ ).\\", +" //____|___\\__) )_/", +" | _ \\\'___\'_( /\'", +" \\_ (-\'\\\'___\'_\\ __,\'_\'", +" __) \\ \\\\___(_ __/.__,\'", +"_,((,-,__\\__\'\", __\\_/. __,\'", +" \'\"./_._._-\'" +] + +}; diff --git a/static/candies/scripts/castleStairs.js b/static/candies/scripts/castleStairs.js new file mode 100755 index 00000000..f04e23de --- /dev/null +++ b/static/candies/scripts/castleStairs.js @@ -0,0 +1,108 @@ +var castleStairs = { + + // Variables + + size : 19, + timeSpent : 0, + + // Functions + + onload : function(){ + land.addLand("Castle's stairs", this.size, 4, this.load.bind(this), this.getText.bind(this), this.move.bind(this)); + }, + + move : function(){ + var index = quest.getCharacterIndex(); + + // Make enemies go toward the left + for(var i = 0; i < this.size-1; i++){ + if(quest.things[i].type == "mob" && quest.things[i-1].type == "none" && quest.things[i].text != "POC"){ + quest.things[i-1] = quest.things[i]; + quest.things[i] = quest.makeNoneThing(); + } + } + + // Add ennemies, summoned by the necromancer ! + if(this.timeSpent > 1){ + // We get a random index where we'll try to add something + var i = index + 2 + random.getRandomIntUpTo(this.size - 1 - (index+2)); + // If there's nothing here + if(i < this.size-1 && quest.things[i].type == "none"){ + // One chance out of x we make a pile of corpses + if(random.oneChanceOutOf(8)){ + quest.things[i] = this.makePileOfCorpses(); + } + // Else we make a ghost + else{ + quest.things[i] = this.makeGhost(); + } + } + } + + // We increase the time spent + this.timeSpent += 1; + }, + + load : function(){ + quest.things[this.size - 1] = this.makeNecromancer(); + + // We reset the time spent + this.timeSpent = 0; + }, + + makeNecromancer : function(){ + return land.createMob("NEC", 150, 150, "magic staff", "A necromancer. She summons ghosts and dead stuff.", [drops.createDrop("object", "candiesConverter", true), drops.createDrop("object", "cauldron", true)]); + }, + + makeGhost : function(){ + return land.createMob("GHO", 5, 5, "spectral magic", "A Ghost. It halves the life of human beings.", []); + }, + + makePileOfCorpses : function(){ + var life = 140; + life += random.getRandomIntUpTo(4) * 20; + + return land.createMob("POC", life, life, "none", "A pile of corpses. It doesn't hurt you, but damn, it's hard to remove !", []); + }, + + getText : function(){ + var lines = []; + lines = this.text.slice(0); // It will store the lines + + // We add things to the lines + for(var i = 0; i < this.size; i++){ + // If there's a thing + if(quest.things[i].type != "none"){ + lines[this.size-1-i] = lines[this.size-1-i].replaceAt(i*3, quest.things[i].text); + } + } + + // We return the lines around the player + return lines.join(""); + }, + + // Variables + + text : [ +" ___\n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +" ___| \n", +"___| \n" +] + +}; diff --git a/static/candies/scripts/cauldron.js b/static/candies/scripts/cauldron.js new file mode 100755 index 00000000..c4c6c3cb --- /dev/null +++ b/static/candies/scripts/cauldron.js @@ -0,0 +1,1469 @@ +var cauldron = { + + // Variables + textCauldron : [], + textBook : [], + textActionsInfo : "", + textActionsPut : "", + textActionsInCauldron : "", + textActions : "", + textLeftPage : [], + textRightPage : [], + cauldronPosX : 10, // X position of the cauldron in the system + cauldronPosY : 7, // Y position of the cauldron in the system + cauldronWidth : 58, // Width of the cauldron
+    cauldronHeight : 16, // Height
+    bookWidth : 58, // Width of the book 
+    bookHeight : 17, // Height
+    smokeBool : false, // If true, there is a smoke right now above the cauldron
+    smokePosX : 0, // X position of this smoke
+    smokePosY : 0, // Y position
+    smokeOrientation : true, // Can be true or false, depending on the smoke orientation (two orientations possible, that's why it's a boolean)
+    bookPosX : 0, // X position of the book
+    bookPosY : 0, // Y position of the book
+    bookPage : 0, // Current book page
+    maxBookPage : 26, // Max book page
+    bookFirstPageNumberPosX : 9, // X position of the first page number of the book (relative to the book)
+    bookFirstPageNumberPosY : 1, // Y
+    bookSecondPageNumberPosX : 43, // X second page
+    bookSecondPageNumberPosY : 1, // Y
+    bookChangePageButtonPosX : 2, // X position of the book's buttons used to change pge
+    bookChangePageButtonPosY : 16, // Y
+    bookLeftPagePosX : 8, // X position of the left page of the book
+    bookLeftPagePosY : 3, // Y
+    bookRightPagePosX : 29, // X right page
+    bookRightPagePosY : 3, // Y
+    candiesInTheCauldron : 0, // Number of candies present in the cauldron
+    lollipopsInTheCauldron : 0, // Idem for lollipops
+    weAreMixing : false, // True if the player is mixing right now
+    weAreBoiling : false, // True if the player is boiling right now
+    candiesWhenWeBeganAction : 0, // Number of candies in the cauldron when we began mixing
+    lollipopsWhenWeBeganAction : 0, // Idem lollipops
+    actionsList : [{type:"none"}, {type:"none"}, {type:"none"}], // List of actions
+    actionTimer : 0, // Count the number of seconds an action lasts
+    
+    // Functions
+    registerAction : function(type, nbrCandies, nbrLollipops, timer){
+        // We add the action to the list
+        this.actionsList.push({type:type, nbrCandies:nbrCandies, nbrLollipops:nbrLollipops, timer:timer});
+        
+        // We delete one action if there's too much actions in the list
+        if(this.actionsList.length > 3){
+            this.actionsList.splice(0, 1);
+        }
+    },
+    
+    onload : function(){
+        this.setBookPage(0);
+    },
+    
+    checkVisibility : function(){
+        if(objects.list.cauldron.have){
+            // Show the cauldron tab, which have to be hidden before this point
+            tabs.enable(3);
+        
+            // And we update everything on page
+            this.updateCauldronOnPage();
+            this.updateBookOnPage();
+            this.updateActionsInfoOnPage();
+            this.updateActionsPutOnPage();
+            this.updateActionsInCauldronOnPage();
+            this.updateActionsOnPage();
+        }
+    },
+    
+    resetCauldronText : function(){
+        // Init the text var by putting lots of blank spaces
+        this.textCauldron = [];
+        for(var i = 0; i < this.cauldronHeight; i++){
+            this.textCauldron.push(""); // We add a line
+            for(var j = 0; j < this.cauldronWidth; j++){
+                this.textCauldron[i] += " "; // We add a blank space in this line
+            }
+            this.textCauldron[i] += "\n"; // We add the end of line
+        }
+    },
+    
+    resetBookText : function(){
+        // Init the text var by putting lots of blank spaces
+        this.textBook = [];
+        for(var i = 0; i < this.bookHeight; i++){
+            this.textBook.push(""); // We add a line
+            for(var j = 0; j < this.bookWidth; j++){
+                this.textBook[i] += " "; // We add a blank space in this line
+            }
+            this.textBook[i] += "\n"; // We add the end of line
+        }
+    },
+    
+    setBookPage : function(value){
+        // If the new value is correct
+        if(value >= 0 && value <= this.maxBookPage){
+            // We set it
+            this.bookPage = value;
+            // We set the text of the pages
+            switch(this.bookPage){
+                case 0:
+                    this.textLeftPage = this.asciiFirstPage;
+                    this.textRightPage = this.asciiSecondPage;
+                break;
+                case 1:
+                    this.textLeftPage = this.asciiThirdPage;
+                    this.textRightPage = this.asciiFourthPage;
+                break;
+                case 2:
+                    this.textLeftPage = this.asciiFifthPage;
+                    this.textRightPage = this.asciiSixthPage;
+                break;
+                case 3:
+                    this.textLeftPage = this.asciiSeventhPage;
+                    this.textRightPage = this.asciiEighthPage;
+                break;
+                case 4:
+                    this.textLeftPage = this.asciiNinthPage;
+                    this.textRightPage = this.asciiTenthPage;
+                break;
+                case 5:
+                    this.textLeftPage = this.asciiMinorHealthPotionP1;
+                    this.textRightPage = this.asciiMinorHealthPotionP2;
+                break;
+                case 6:
+                    this.textLeftPage = this.asciiMinorHealthPotionP3;
+                    this.textRightPage = this.asciiMinorHealthPotionP4;
+                break;
+                case 7:
+                    this.textLeftPage = this.asciiMajorHealthPotionP1;
+                    this.textRightPage = this.asciiMajorHealthPotionP2;
+                break;
+                case 8:
+                    this.textLeftPage = this.asciiMajorHealthPotionP3;
+                    this.textRightPage = this.asciiMajorHealthPotionP4;
+                break;
+                case 9:
+                    this.textLeftPage = this.asciiInvulnerabilityPotionP1;
+                    this.textRightPage = this.asciiInvulnerabilityPotionP2;
+                break;
+                case 10:
+                    this.textLeftPage = this.asciiInvulnerabilityPotionP3;
+                    this.textRightPage = [];
+                break;
+                case 11:
+                    this.textLeftPage = this.asciiTurtlePotionP1;
+                    this.textRightPage = this.asciiTurtlePotionP2;
+                break;
+                case 12:
+                    this.textLeftPage = this.asciiTurtlePotionP3;
+                    this.textRightPage = this.asciiTurtlePotionP4;
+                break;
+                case 13:
+                    this.textLeftPage = this.asciiTurtlePotionP5;
+                    this.textRightPage = this.asciiTurtlePotionP6;
+                break;
+                case 14:
+                    this.textLeftPage = this.asciiCloningPotionP1;
+                    this.textRightPage = this.asciiCloningPotionP2;
+                break;
+                case 15:
+                    this.textLeftPage = this.asciiCloningPotionP3;
+                    this.textRightPage = this.asciiCloningPotionP4;
+                break;
+                case 16:
+                    this.textLeftPage = this.asciiCloningPotionP5;
+                    this.textRightPage = this.asciiCloningPotionP6;
+                break;
+                case 17:
+                    this.textLeftPage = this.asciiGMOOHPotionP1;
+                    this.textRightPage = this.asciiGMOOHPotionP2;
+                break;
+                case 18:
+                    this.textLeftPage = this.asciiGMOOHPotionP3;
+                    this.textRightPage = this.asciiGMOOHPotionP4;
+                break;
+                case 19:
+                    this.textLeftPage = this.asciiSupermanPotionP1;
+                    this.textRightPage = this.asciiSupermanPotionP2;
+                break;
+                case 20:
+                    this.textLeftPage = this.asciiSupermanPotionP3;
+                    this.textRightPage = this.asciiSupermanPotionP4; // je t'aime <3
+                break;
+                case 21:
+                    this.textLeftPage = this.asciiSeedP1;
+                    this.textRightPage = this.asciiSeedP2;
+                break;
+                case 22:
+                    this.textLeftPage = this.asciiSeedP3;
+                    this.textRightPage = this.asciiSeedP4;
+                break;
+                case 23:
+                    this.textLeftPage = this.asciiJellyP1;
+                    this.textRightPage = this.asciiJellyP2;
+                break;
+                case 24:
+                    this.textLeftPage = this.asciiJellyP3;
+                    this.textRightPage = this.asciiJellyP4;
+                break;
+                case 25:
+                    this.textLeftPage = this.asciiJellyP5;
+                    this.textRightPage = [];
+                break;
+                case 26:
+                    this.textLeftPage = this.asciiEndP1;
+                    this.textRightPage = this.asciiEndP2;
+                break;
+                default:
+                    this.textLeftPage = [];
+                    this.textRightPage = [];
+                break;
+            }
+            // We update the book on page
+            this.updateBookOnPage();
+        }
+    },
+    
+    previousPage : function(){
+        this.setBookPage(this.bookPage-1);
+    },
+    
+    nextPage : function(){
+        this.setBookPage(this.bookPage+1);
+    },
+    
+    drawBook : function(){
+        // Draw the book itself
+        for(i = 0; i < this.asciiBook.length; i++){
+            this.textBook[this.bookPosY + i] = this.textBook[this.bookPosY + i].replaceAt(this.bookPosX, this.asciiBook[i]);
+        }
+        
+        // Draw the page numbers
+        this.textBook[this.bookPosY + this.bookFirstPageNumberPosY] = this.textBook[this.bookPosY + this.bookFirstPageNumberPosY].replaceAt(this.bookPosX + this.bookFirstPageNumberPosX, "" + this.bookPage * 2);
+        this.textBook[this.bookPosY + this.bookSecondPageNumberPosY] = this.textBook[this.bookPosY + this.bookSecondPageNumberPosY].replaceAt(this.bookPosX + this.bookSecondPageNumberPosX, "" + (this.bookPage * 2 + 1));
+    
+        // Draw the previous and next page buttons
+        this.textBook[this.bookPosY + this.bookChangePageButtonPosY] = this.textBook[this.bookPosY + this.bookChangePageButtonPosY].replaceAt(this.bookPosX + this.bookChangePageButtonPosX, "                       ");
+    
+        // Draw the left page text
+        for(i = 0; i < this.textLeftPage.length; i++){
+            this.textBook[this.bookLeftPagePosY + i] = this.textBook[this.bookLeftPagePosY + i].replaceAt(this.bookPosX + this.bookLeftPagePosX, this.textLeftPage[i]);
+        }
+        
+        // Idem right
+        for(i = 0; i < this.textRightPage.length; i++){
+            this.textBook[this.bookRightPagePosY + i] = this.textBook[this.bookRightPagePosY + i].replaceAt(this.bookPosX + this.bookRightPagePosX, this.textRightPage[i]);
+        }
+    },
+    
+    drawCauldron : function(){
+        // We draw the cauldron
+        for(i = 0; i < this.asciiCauldron.length; i++){
+            this.textCauldron[this.cauldronPosY + i] = this.textCauldron[this.cauldronPosY + i].replaceAt(this.cauldronPosX, this.asciiCauldron[i]);
+        }
+        
+        // We add the smoke
+        this.drawSmoke();
+    },
+    
+    drawSmoke : function(){
+        // Finally, if there's a smoke, we draw it
+        if(this.smokeBool == true){
+            if(this.smokeOrientation == true){
+                this.textCauldron[this.smokePosY] = this.textCauldron[this.smokePosY].replaceAt(this.smokePosX, "(");
+                this.textCauldron[this.smokePosY-1] = this.textCauldron[this.smokePosY-1].replaceAt(this.smokePosX + 1, ")");
+            }
+            else{
+                this.textCauldron[this.smokePosY] = this.textCauldron[this.smokePosY].replaceAt(this.smokePosX + 1, ")");
+                this.textCauldron[this.smokePosY-1] = this.textCauldron[this.smokePosY-1].replaceAt(this.smokePosX, "(");
+            }
+        }
+    },
+    
+    moveSmoke : function(){
+        // If we have the cauldron
+        if(objects.list.cauldron.have){
+            // If there's no smoke yet, we create one
+            if(this.smokeBool == false){
+                this.smokeBool = true; // Bool is true
+                this.smokePosX = this.cauldronPosX + 7 + random.getRandomIntUpTo(10); // PosX
+                this.smokePosY = this.cauldronPosY; // PosY
+                // Random orientation
+                if(random.flipACoin()) this.smokeOrientation = true;
+                else this.smokeOrientation = false;
+            }
+            // Else, there's a smoke
+            else{
+                // We make it go up
+                this.smokePosY -= 1;
+                // We switch its orientation
+                if(this.smokeOrientation == true) this.smokeOrientation = false;
+                else this.smokeOrientation = true;
+                // If it's too high : there's no smoke anymore
+                if(this.cauldronPosY - this.smokePosY > 3){
+                    this.smokeBool = false;
+                }
+            }
+        }
+        
+        this.updateCauldronOnPage();
+    },
+    
+    drawActionsInfo : function(){
+        this.textActionsInfo = "
What you have :
"; + + // Add candies and lollipops info + this.textActionsInfo += " Candies : " + candies.nbrOwned; + this.textActionsInfo += "
Lollipops : " + lollipops.nbrOwned; + }, + + drawActionsPut : function(){ + this.textActionsPut = "What you want to put in the cauldron :

" + this.textActionsPut += " candies
"; + this.textActionsPut += " lollipops
"; + this.textActionsPut += "
"; + }, + + drawActionsInCauldron : function(){ + this.textActionsInCauldron += "What is in the cauldron :
"; + this.textActionsInCauldron += " Candies : " + this.candiesInTheCauldron; + this.textActionsInCauldron += "
Lollipops : " + this.lollipopsInTheCauldron + "
"; + }, + + drawActions : function(){ + this.textActions += "What you can do with it :
"; + this.textActions += "

"; + this.textActions += ""; + this.textActions += "

"; + this.textActions += ""; + }, + + increaseActionTimer : function(){ + this.setActionTimer(this.actionTimer + 1); + }, + + setActionTimer : function(value){ + // We set the value + this.actionTimer = value; + + // We change on the page + if(this.weAreMixing){ + if(this.actionTimer < 60){ + // If we just began mixing or we're mixing something + if(this.actionTimer < 5 || (this.candiesInTheCauldron != 0 || this.lollipopsInTheCauldron != 0)){ + // We show the timer + htmlInteraction.setInnerHtml("cauldron_timer", this.actionTimer); + } + // Else + else{ + // We show a special message + htmlInteraction.setInnerHtml("cauldron_timer", this.actionTimer + " ... You do realize that you're not mixing anything, right ?"); + } + } + else + htmlInteraction.setInnerHtml("cauldron_timer", "too much mixing, your arms are hurting."); + } + else if(this.weAreBoiling){ + if(this.actionTimer < 3) + htmlInteraction.setInnerHtml("cauldron_timer", "cold."); + else if(this.actionTimer < 6) + htmlInteraction.setInnerHtml("cauldron_timer", "lukewarm."); + else if(this.actionTimer < 9) + htmlInteraction.setInnerHtml("cauldron_timer", "hot.."); + else if(this.actionTimer < 11) + htmlInteraction.setInnerHtml("cauldron_timer", "very hot..."); + else if(this.actionTimer < 13) + htmlInteraction.setInnerHtml("cauldron_timer", "very very hot !"); + else if(this.actionTimer < 14) + htmlInteraction.setInnerHtml("cauldron_timer", "bubbles begin to appear..."); + else if(this.actionTimer < 15) + htmlInteraction.setInnerHtml("cauldron_timer", "bubbles begin to appear... and.."); + else if(this.actionTimer < 32) + htmlInteraction.setInnerHtml("cauldron_timer", "BOILING !"); + else + htmlInteraction.setInnerHtml("cauldron_timer", "the water is burnt ! How is that even possible ?"); + } + }, + + setWeAreMixing : function(value){ + // If we want to stop mixing + if(value == false && this.weAreMixing == true){ + // Then we stop + this.weAreMixing = false; + // We register the mixing + this.registerAction("mix", this.candiesWhenWeBeganAction, this.lollipopsWhenWeBeganAction, this.actionTimer); + } + // Else, if we want to begin mixing + else if(value == true && this.weAreMixing == false){ + // Then we begin + this.weAreMixing = true; + this.disableActionsButtons(); + // We set the text + htmlInteraction.setInnerHtml("cauldron_action_text", "Mixing...

"); + // We set the timer + this.setActionTimer(0); + // We store some info + this.candiesWhenWeBeganAction = this.candiesInTheCauldron; + this.lollipopsWhenWeBeganAction = this.lollipopsInTheCauldron; + } + }, + + setWeAreBoiling : function(value){ + // If we want to stop Boiling + if(value == false && this.weAreBoiling == true){ + // Then we stop + this.weAreBoiling = false; + // We register the Boiling + this.registerAction("boil", this.candiesWhenWeBeganAction, this.lollipopsWhenWeBeganAction, this.actionTimer); + } + // Else, if we want to begin Boiling + else if(value == true && this.weAreBoiling == false){ + // Then we begin + this.weAreBoiling = true; + this.disableActionsButtons(); + // We set the text + htmlInteraction.setInnerHtml("cauldron_action_text", "Boiling...

"); + // We set the timer + this.setActionTimer(0); + // We store some info + this.candiesWhenWeBeganAction = this.candiesInTheCauldron; + this.lollipopsWhenWeBeganAction = this.lollipopsInTheCauldron; + } + }, + + putIntoBottles : function(){ + // We create the vars which will store the results for a final drawing on the page + var resultsList = []; + var resultsText = ""; + + // We store actions into vars for easier use + var lastAc = this.actionsList[this.actionsList.length - 1]; + var lastLastAc = this.actionsList[this.actionsList.length - 2]; + var lastLastLastAc = this.actionsList[this.actionsList.length - 3]; + + // Check for minor health potion + if(lastAc.type == "mix" // Last action was mixing + && lastAc.nbrLollipops == 0 // We mixed no lollipop + && lastAc.nbrCandies > 0 // We mixed at least one candy + && lastAc.nbrCandies % 100 == 0 // The candies we mixed were a multiple of 100 + && lastAc.nbrCandies == this.candiesInTheCauldron && lastAc.nbrLollipops == this.lollipopsInTheCauldron // We didn't add anything while mixing + && lastAc.timer >= 11 && lastAc.timer <= 19){ // It took between 11 and 19 seconds + potions.getPotions(potions.list.health, Math.floor(lastAc.nbrCandies/100)); // We add the potions to our stock + resultsList.push({type:"minor health", nbr:Math.floor(lastAc.nbrCandies/100)}); // We add the result to the list + } + + // Check for major health potion + if(lastAc.type == "mix" // Last action was mixing + && lastAc.nbrLollipops > 0 // We mixed at least one lollipop + && lastAc.nbrLollipops % 100 == 0 // The lollipops we mixed were a multiple of 100 + && lastAc.nbrCandies == 0 // We mixed no candy + && lastAc.nbrLollipops == this.lollipopsInTheCauldron // We didn't add any lollipop while mixing + && this.candiesInTheCauldron == lastAc.nbrLollipops // While mixing, we added as many candies as we had lollipops at the beginning + && lastAc.timer >= 16 && lastAc.timer <= 24){ // It took between 16 and 24 seconds + potions.getPotions(potions.list.majorHealth, Math.floor(lastAc.nbrLollipops/100)); // We add the potions to our stock + resultsList.push({type:"major health", nbr:Math.floor(lastAc.nbrLollipops/100)}); // We add the result to the list + } + + // Check for turtle potion + if( + /* LAST ACTION */ + lastAc.type == "boil" // Last action was boiling + && lastAc.nbrCandies == 0 // We boiled no candy + && lastAc.nbrLollipops > 0 // We boiled at least one lollipop + && lastAc.nbrLollipops % 20000 == 0 // The lollipops we boiled were a multiple of 20000 + && lastAc.nbrLollipops == this.lollipopsInTheCauldron // We didn't add any lollipop while boiling + && lastAc.nbrCandies == this.candiesInTheCauldron // We didn't add any candy while boiling + && lastAc.timer >= 15 && lastAc.timer < 32 // It was boiling when we stopped boiling + /* LAST LAST ACTION */ + && lastLastAc.type == "mix" // Last last action was mixing + /* LAST LAST LAST ACTION */ + && lastLastLastAc.type == "boil" // Last last last action was boiling + && lastLastLastAc.nbrCandies == 0 // We boiled no candy + && lastLastLastAc.nbrLollipops > 0 // We boiled at least one lollipop + && lastLastLastAc.nbrLollipops % 10000 == 0 // The lollipops we boiled were a multiple of 10000 + && lastLastLastAc.timer >= 15 && lastLastLastAc.timer < 32 // It was boiling when we stopped boiling + /* STUFF BETWEEN ACTIONS */ + && lastAc.nbrLollipops == 2 * lastLastLastAc.nbrLollipops){ // We boiled at the end twice more lollipops than what we boiled at first + potions.getPotions(potions.list.turtle, Math.floor(lastAc.nbrLollipops/20000)); // We add the potions to our stock + resultsList.push({type:"turtle", nbr:Math.floor(lastAc.nbrLollipops/20000)}); // We add the result to the list + } + + // Check for invulnerability potion + if(lastAc.type == "mix" // Last action was mixing + && lastAc.nbrLollipops == 0 // We mixed no lollipop + && lastAc.nbrCandies > 0 // We mixed at least one candy + && lastAc.nbrCandies % 2000 == 0 // The candies we mixed were a multiple of 2000 + && lastAc.nbrCandies == this.candiesInTheCauldron && lastAc.nbrLollipops == this.lollipopsInTheCauldron // We didn't add anything while mixing + && lastAc.timer >= 60){ // It took >= 60 seconds + potions.getPotions(potions.list.invulnerability, Math.floor(lastAc.nbrCandies/2000)); // We add the potions to our stock + resultsList.push({type:"invulnerability", nbr:Math.floor(lastAc.nbrCandies/2000)}); // We add the result to the list + } + + // Check for cloning potion + if(lastAc.type == "boil" // Last action was boiling + && lastAc.nbrLollipops == 0 // We boiled no lollipop + && lastAc.nbrCandies == 0 // We boiled no candy + && this.lollipopsInTheCauldron == 0 // We didn't add any lollipop while boiling + && this.convertCandiesToPotionsForTheCloningPotion(this.candiesInTheCauldron) > 0 // With the candies we added while boiling (or after), we can make at least one potion + && lastAc.timer >= 32){ // The water burnt while boiling + potions.getPotions(potions.list.cloning, this.convertCandiesToPotionsForTheCloningPotion(this.candiesInTheCauldron)); // We add the potions to our stock + resultsList.push({type:"cloning", nbr:this.convertCandiesToPotionsForTheCloningPotion(this.candiesInTheCauldron)}); // We add the result to the list + } + + // Check for G.M.O.O.H. potion + if(lastAc.type == "mix" // Last action was mixing + && lastAc.nbrLollipops > 0 // We mixed at least one lollipop + && lastAc.nbrLollipops % 500 == 0 // The lollipops we mixed were a multiple of 500 + && lastAc.nbrCandies == 10000 // We mixed 10000 candies + && this.candiesInTheCauldron == lastAc.nbrCandies // We didn't add any candy while mixing + && this.lollipopsInTheCauldron == lastAc.nbrLollipops){ // We didn't add any lollipop while mixing + potions.getPotions(potions.list.gmooh, Math.floor(lastAc.nbrLollipops/500)); // We add the potions to our stock + resultsList.push({type:"G.M.O.O.H.", nbr:Math.floor(lastAc.nbrLollipops/500)}); // We add the result to the list + } + + // Check for superman potion + if(lastAc.type == "mix" // Last action was mixing + && lastAc.nbrLollipops == 0 // We mixed no lollipop + && lastAc.nbrCandies > 0 // We mixed at least one candy + && lastAc.nbrCandies % 180 == 0 // The candies we mixed were a multiple of 180 + && lastAc.nbrCandies == this.candiesInTheCauldron && lastAc.nbrLollipops == this.lollipopsInTheCauldron){ // We didn't add anything while mixing + potions.getPotions(potions.list.superman, Math.floor(lastAc.nbrCandies/180)); // We add the potions to our stock + resultsList.push({type:"superman", nbr:Math.floor(lastAc.nbrCandies/180)}); // We add the result to the list + } + + // Check for seed + if(lastAc.type == "boil" // Last action was boiling + && lastAc.nbrLollipops == 0 // We boiled no lollipop + && lastAc.nbrCandies == 0 // We boiled no candy + && this.lollipopsInTheCauldron == 0 // We didn't add any lollipop while boiling + && this.candiesInTheCauldron > 0 // We added at least one candy while or after boiling + && this.candiesInTheCauldron % 650 == 0){ // The candies we added while or after boiling are a multiple of 650 + potions.getPotions(potions.list.seed, Math.floor(this.candiesInTheCauldron/650)); // We add the potions to our stock + resultsList.push({type:"seed", nbr:Math.floor(this.candiesInTheCauldron/650), special:true, plural:"seeds"}); // We add the result to the list + } + + // Check for jelly + if( + /* ACTIONS TYPES */ + lastAc.type == "boil" // Last action was boiling + && lastLastAc.type == "mix" // Last last action was mixing + && lastLastLastAc.type == "boil" // Last last last action was boiling + /* LAST LAST LAST ACTION */ + && lastLastLastAc.nbrLollipops == 0 // No lollipop + && lastLastLastAc.nbrCandies > 0 // At least one candy + && lastLastLastAc.nbrCandies % 600 == 0 // Candies multiple of 600 + /* LAST LAST ACTION */ + && lastLastAc.nbrLollipops > 0 // At least one lollipop + && lastLastAc.nbrLollipops % 6000 == 0 // Lollipops mutiple of 6000 + && lastLastAc.nbrLollipops == 10*lastLastLastAc.nbrCandies // Lollipops = 10*candies of last last last action + && lastLastAc.nbrCandies == lastLastLastAc.nbrCandies // As many candies as last last last action + /* LAST ACTION */ + && lastAc.nbrLollipops == lastLastAc.nbrLollipops // As many lollipops as last last action + && lastAc.nbrCandies == lastLastLastAc.nbrCandies*2 // Twice more candies than last last last action + && lastAc.nbrLollipops == this.lollipopsInTheCauldron // We didn't add any lollipop + && lastAc.nbrCandies == this.candiesInTheCauldron){ // We didn't add any candy + potions.getPotions(potions.list.jelly, Math.floor(lastAc.nbrCandies/600)); // We add the potions to our stock + resultsList.push({type:"jelly", nbr:Math.floor(lastAc.nbrCandies/600), special:true, plural:"jellies"}); // We add the result to the list + } + + // We show the result on the page if there's any result + if(resultsList.length > 0){ + for(var i = 0; i < resultsList.length; i++){ + if(resultsList[i].special != true){ + if(resultsList[i].nbr > 1){ + resultsText += "You made " + resultsList[i].nbr + " " + resultsList[i].type + " potions !
"; + } + else{ + resultsText += "You made a " + resultsList[i].type + " potion.
"; + } + } + else{ + if(resultsList[i].nbr > 1){ + resultsText += "You made " + resultsList[i].nbr + " " + resultsList[i].plural + " !
"; + } + else{ + resultsText += "You made a " + resultsList[i].type + ".
"; + } + } + } + htmlInteraction.setInnerHtml("cauldron_results_text", resultsText); + } + else{ + htmlInteraction.setInnerHtml("cauldron_results_text", "You don't manage to get anything interesting with that preparation.
Did you follow the manual's instructions ?"); + } + + // We empty the cauldron + this.setCandiesInTheCauldron(0); + this.setLollipopsInTheCauldron(0); + + // We reset the actions list + this.actionsList = [{type:"none"}, {type:"none"}, {type:"none"}]; + }, + + convertCandiesToPotionsForTheCloningPotion : function(howMuch){ + return Math.floor(howMuch / 1337); + }, + + disableActionsButtons : function(){ + // We disable the mixing button + htmlInteraction.disableButton("cauldron_mix"); + // We disable the put into bottles button + htmlInteraction.disableButton("cauldron_put_into_bottles"); + // We disable the boiling button + htmlInteraction.disableButton("cauldron_boil"); + // We enable the stopping button + htmlInteraction.enableButton("cauldron_stop"); + }, + + enableActionsButtons : function(){ + // We re enable the mixing button + htmlInteraction.enableButton("cauldron_mix"); + // We re enable the put into bottles button + htmlInteraction.enableButton("cauldron_put_into_bottles"); + // We re enable the boiling button + htmlInteraction.enableButton("cauldron_boil"); + // We disable the button + htmlInteraction.disableButton("cauldron_stop"); + }, + + stopActions : function(){ + // Stop all actions + this.setWeAreMixing(false); + this.setWeAreBoiling(false); + + // Re enable buttons + this.enableActionsButtons(); + + // Empty the action text + htmlInteraction.setInnerHtml("cauldron_action_text", ""); + }, + + putInTheCauldron : function(){ + // We get the values of the text inputs + var candiesInput = htmlInteraction.getElement("cauldron_candies_quantity").value; + var lollipopsInput = htmlInteraction.getElement("cauldron_lollipops_quantity").value; + + // We get the quantities + if(candiesInput != ""){ + var candiesQuantity = parseInt(candiesInput); + } + else candiesQuantity = 0; + + if(lollipopsInput != ""){ + var lollipopsQuantity = parseInt(lollipopsInput); + } + else lollipopsQuantity = 0; + + // If the quantities are incorrect + if(isNaN(candiesQuantity) || isNaN(lollipopsQuantity)){ + // If both values are incorrect + if(isNaN(candiesQuantity) && isNaN(lollipopsQuantity)){ + htmlInteraction.setInnerHtml("cauldron_comment", "The values you entered are not numbers."); + } + // If only the candies value is incorrect + else if(isNaN(candiesQuantity)){ + htmlInteraction.setInnerHtml("cauldron_comment", "The value you entered for candies is not a number."); + } + // Else, only the lollipops value is incorrect + else{ + htmlInteraction.setInnerHtml("cauldron_comment", "The value you entered for lollipops is not a number."); + } + } + // Else, if we don't have enough candies or lollipops to put all that in the cauldron + else if(candiesQuantity > candies.nbrOwned || lollipopsQuantity > lollipops.nbrOwned){ + htmlInteraction.setInnerHtml("cauldron_comment", "You don't have enough to put all that in the cauldron !"); + } + // Else, if one if the value is negative + else if(candiesQuantity < 0 || lollipopsQuantity < 0){ + htmlInteraction.setInnerHtml("cauldron_comment", "Don't put negative values !"); + } + // Else, we put all that in the cauldron ! + else{ + htmlInteraction.setInnerHtml("cauldron_comment", ""); // We empty the comment + // We clear the text inputs + htmlInteraction.getElement("cauldron_candies_quantity").value = ""; + htmlInteraction.getElement("cauldron_lollipops_quantity").value = ""; + // We substract candies from our stock + candies.setNbrOwned(candies.nbrOwned - candiesQuantity); + lollipops.setNbrOwned(lollipops.nbrOwned - lollipopsQuantity); + // And we add them in the cauldron + this.setCandiesInTheCauldron(this.candiesInTheCauldron + candiesQuantity); + this.setLollipopsInTheCauldron(this.lollipopsInTheCauldron + lollipopsQuantity); + } + }, + + setCandiesInTheCauldron : function(value){ + this.candiesInTheCauldron = value; + this.updateActionsInCauldronOnPage(); + }, + + setLollipopsInTheCauldron : function(value){ + this.lollipopsInTheCauldron = value; + this.updateActionsInCauldronOnPage(); + }, + + updateCauldronOnPage : function(){ + this.resetCauldronText(); + this.drawCauldron(); + htmlInteraction.setInnerHtml("cauldron_cauldron", this.textCauldron.join("")); + }, + + updateBookOnPage : function(){ + this.resetBookText(); + this.drawBook(); + htmlInteraction.setInnerHtml("cauldron_book", this.textBook.join("")); + }, + + updateActionsInfoOnPage : function(){ + this.textActionsInfo = ""; + this.drawActionsInfo(); + htmlInteraction.setInnerHtml("cauldron_actions_info", this.textActionsInfo); + }, + + updateActionsPutOnPage : function(){ + this.textActionsPut = ""; + this.drawActionsPut(); + htmlInteraction.setInnerHtml("cauldron_actions_put", this.textActionsPut); + }, + + updateActionsInCauldronOnPage : function(){ + this.textActionsInCauldron = ""; + this.drawActionsInCauldron(); + htmlInteraction.setInnerHtml("cauldron_actions_in_cauldron", this.textActionsInCauldron); + }, + + updateActionsOnPage : function(){ + this.textActions = ""; + this.drawActions(); + htmlInteraction.setInnerHtml("cauldron_actions", this.textActions); + }, + + // Ascii + asciiCauldron : +[ +" ___________", +" (___________)", +" / \\", +" / \\", +" | |", +" ____\\ /____", +"()____\'.__ __.\'____()", +" .\'` .\'```\'. `-.", +" ().\'` `\'.()" +], + + asciiBook : +[ +" ___________________ ___________________", +" .-/| ~~**~~ \\ / ~~**~~ |\\-.", +" |||| : ||||", +" |||| : ||||", +" |||| : ||||", +" |||| : ||||", +" |||| : ||||", +" |||| : ||||", +" |||| : ||||", +" |||| : ||||", +" |||| : ||||", +" |||| : ||||", +" |||| : ||||", +" ||||___________________ : ___________________||||", +" ||/====================\\:/====================\\||", +" `---------------------~___~--------------------\'\'" +], + + asciiFirstPage : +[ +"Welcome to the", +"potions brewing", +"manual for", +"beginners !", +"", +" (second edition)", +"", +" __ __ __ __ ", +" )( )( )( )( ", +"(__)(__)(__)(__)" +], + + asciiSecondPage : +[ +"", +"The present", +"manual will focus", +"on potions that", +"require materials", +"such as : ", +" - candies", +" - lollipops", +], + + asciiThirdPage : +[ +" The three rules", +"of potion brewing", +"-----------------", +"", +"1. The effect of", +"a potion depends", +"on its content as", +"well as on the", +"steps followed to", +"prepare it." +], + + asciiFourthPage : +[ +"2. You can do", +"several potions", +"in one go.", +"", +"3. It's possible", +"to mix", +"instructions to", +"brew potions of", +"different types", +"in one go." +], + + asciiFifthPage : +[ +"Table of contents", +"-----------------", +" Pages 10 to 20", +" (Good potions)", +"-----------------", +"", +" 10-13", +"Minor health", +"potion" +], + + asciiSixthPage : +[ +"", +" 14-17", +"Major health", +"potion", +"", +" 18-20", +"Invulnerability", +"potion" +], + + asciiSeventhPage : +[ +"Table of contents", +"-----------------", +" Pages 22 to 41", +"(Strange potions)", +"-----------------", +"", +" 22-27", +"Turtle potion" +], + + asciiEighthPage : +[ +" 28-33", +"Cloning potion", +"", +" 34-37", +"G.M.O.O.H.", +"potion", +"", +" 38-41", +"Superman potion", +], + + asciiNinthPage : +[ +"Table of contents", +"-----------------", +" Pages 42 to 50", +"(Various magical", +"objects you can", +" brew in your", +" cauldron)", +"-----------------" +], + + asciiTenthPage : +[ +"", +"", +" 42-45", +"Magical seed", +"", +"", +" 46-50", +"Magical jelly", +], + + asciiMinorHealthPotionP1 : +[ +"Minor health pot.", +"-----------------", +"The minor health", +"potion is the", +"easiest to brew", +"for beginners.", +"", +"Used during a", +"quest, it will", +"make you recover" +], + + asciiMinorHealthPotionP2 : +[ +"50 health points.", +"", +"For one potion,", +"you will need 100", +"candies.", +"", +"Put them in the", +"cauldron and mix", +"during about 15", +"seconds." +], + + asciiMinorHealthPotionP3 : +[ +"You can mix a", +"little more or", +"less longer, it", +"doesn't matter so", +"much.", +"", +"When you're done,", +"put the resulting", +"mixture into", +"bottles." +], + + asciiMinorHealthPotionP4 : +[ +"Congratulations !", +"You just made", +"your first minor", +"health potion !", +"", +"", +"N.B. : use 200", +"candies for 2", +"potions, 300 for", +"3, etc." +], + + asciiMajorHealthPotionP1 : +[ +"Major health pot.", +"-----------------", +"The major health", +"potion is a bit", +"harder to make", +"than the previous", +"one.", +"", +"But it's also", +"a lot more", +], + + asciiMajorHealthPotionP2 : +[ +"efficient : by", +"drinking it", +"during a quest,", +"you will gain", +"100 health points", +"instead of 50.", +"", +"How to make a", +"major health", +"potion :" +], + + asciiMajorHealthPotionP3 : +[ +"1. Put 100", +"lollipops into", +"your cauldron.", +"", +"2. Begin mixing", +"forcefully.", +"", +"3. While you're", +"mixing, add 100", +"candies into the", +], + + asciiMajorHealthPotionP4 : +[ +"cauldron.", +"", +"4. Stop mixing", +"after 20 seconds.", +"", +"5. Put the result", +"into bottles.", +"", +"6. You're done !" +], + + asciiInvulnerabilityPotionP1 : +[ +" Invulnerability", +" potion", +"-----------------", +"", +"This potion,", +"although being", +"quite easy to", +"brew, require a", +"lot of candies." +], + + asciiInvulnerabilityPotionP2 : +[ +"The recipe is", +"simple : just", +"put 2000 candies", +"inside your", +"cauldron and mix", +"them until your", +"arms hurt.", +"", +"This potion will", +"make you" +], + + asciiInvulnerabilityPotionP3 : +[ +"invincible for", +"some time,", +"during which you", +"won't feel any", +"pain or physical", +"damage." +], + + asciiTurtlePotionP1 : +[ +" Turtle potion", +"-----------------", +"A turtle !", +"A turtle !", +"Do you want to", +"become a turtle ?", +"", +"You'll be able to", +"become one with", +"this fantastic" +], + + asciiTurtlePotionP2 : +[ +"potion !", +"", +"When you will be", +"a turtle, you", +"will resist a lot", +"more to physical", +"damage. But you", +"will be slower,", +"too." +], + + asciiTurtlePotionP3 : +[ +"Now, let's get", +"down to business.", +"", +"Put 10000", +"lollipops in your", +"cauldron. Do not", +"add any candy, or", +"your potion will", +"be a failure." +], + + asciiTurtlePotionP4 : +[ +"Now, heat up the", +"cauldron until", +"your preparation", +"is boiling.", +"", +"When it's boiling,", +"stop heating it", +"up and mix a", +"little bit." +], + + asciiTurtlePotionP5 : +[ +"Add the same", +"quantity of", +"lollipops as you", +"put at the", +"beginning, and,", +"one more time,", +"heat up", +"everything until", +"it's boiling." +], + + asciiTurtlePotionP6 : +[ +"Stop boiling,", +"put into a bottle,", +"begin a quest,", +"drink the potion,", +"you're a turtle !!", +"", +" _ .----.", +" (_\\/ \\_,", +" \'uu----uu~\'" +], + + asciiCloningPotionP1 : +[ +" Cloning potion", +"-----------------", +"There's a little", +"bit of candies in", +"everyone of us.", +"", +"This is actually", +"a physical law of", +"our universe." +], + + asciiCloningPotionP2 : +[ +"Now, candies are", +"a very malleable", +"material.", +"", +"These two facts", +"led us to the", +"realisation of", +"this cloning", +"potion." +], + + asciiCloningPotionP3 : +[ +"The potion will", +"copy your inner", +"structure and", +"make a clone of", +"you almost", +"entirely made", +"of candies", +"(there's a bit of", +"water, too)." +], + + asciiCloningPotionP4 : +[ +"Steps :", +"", +"Burn the water in", +"your cauldron.", +"", +"Then, while it's", +"still burning,", +"add as many", +"candies as you", +"can." +], + + asciiCloningPotionP5 : +[ +"It's simple : the", +"more candies you", +"put, the more", +"potions you'll", +"get !", +"", +"(be sure to put", +" a minimum", +"quantity, though)" +], + + asciiCloningPotionP6 : +[ +" \\o/ -> \\o/", +"", +" ^ |", +" | V", +"", +" \\o/ <- \\o/", +"", +" \"The circle", +" of life\"" +], + + asciiGMOOHPotionP1 : +[ +"G.M.O.O.H. potion", +"-----------------", +"G.M.O.O.H. means", +"\"Get Me Out Of", +"Here\".", +"", +"This potion is to", +"be used in", +"critical", +"situations." +], + + asciiGMOOHPotionP2 : +[ +"It will teleport", +"you to another", +"location.", +"", +"Maybe it will", +"be safer, maybe", +"it won't. Who", +"knows ?", +"Quite exciting", +"isn't it ?" +], + + asciiGMOOHPotionP3 : +[ +"First, put in", +"your cauldron a", +"base quantity of", +"10 000 candies.", +"", +"Then, add 500", +"lollipops for", +"each potion you", +"want to brew." +], + + asciiGMOOHPotionP4 : +[ +"Never change the", +"base quantity of", +"10 000 candies.", +"", +"Then, mix a little", +"bit and put into", +"bottles.", +"", +"Enjoy your random", +"potions !" +], + + asciiSupermanPotionP1 : +[ +" Superman potion", +"-----------------", +"This potion will", +"transform you", +"into Superman,", +"providing you", +"a fantastic cape.", +"", +"Some people say", +"that this isn't" +], + + asciiSupermanPotionP2 : +[ +"useful.", +"", +"We respond them", +"that it is just", +"so cooooool !", +"", +"Anyway, to make", +"one :", +"", +"Put 180 candies" +], + + asciiSupermanPotionP3 : +[ +"in your cauldron.", +"", +"Mix them.", +"", +"Think about", +"Superman.", +"", +"Think once again.", +"", +"Put into bottle." +], + + asciiSupermanPotionP4 : +[ +"You're done !", +"", +" ___________", +" /.\'_______` \\", +" /( <_______`-\'\\", +" `.`.______ \\.\'", +" `..-.___>.\'", +" `.__ .\'", +" `.\'" +], + + asciiSeedP1 : +[ +" Seed", +"-----------------", +"According to an", +"ancient legend,", +"trees would be", +"the source of all", +"candies in the", +"whole world.", +"", +"There would exist" +], + + asciiSeedP2 : +[ +"somewhere in the", +"universe a giant", +"tree, which", +"remains unnamed.", +"", +"This tree would", +"provide its", +"discoverer an", +"infinite flow of", +"candies." +], + + asciiSeedP3 : +[ +"Anyway, we didn't", +"find it yet, but", +"we found that it", +"was possible to", +"craft a magical", +"seed so that it", +"grows a resistant", +"tree. And this", +"can be useful", +"during a quest." +], + + asciiSeedP4 : +[ +"Heat up the water", +"in your cauldron.", +"", +"Add 650 candies,", +"stop boiling and", +"put the seed into", +"a bottle.", +"", +"Now, plant some", +"trees !" +], + + asciiJellyP1 : +[ +" Jelly", +"-----------------", +"Did you ever", +"thought about", +"some kind of bomb", +"that you could", +"use during a", +"quest ? If so,", +"then this magical", +"jelly should" +], + + asciiJellyP2 : +[ +"please you !", +"", +"It is a bit hard", +"to prepare, but", +"it's quite", +"powerful.", +"", +"This jelly", +"explodes on", +"contact and deals" +], + + asciiJellyP3 : +[ +"high damage.", +"", +"There are three", +"peparation steps", +"which correspond", +"to the three", +"layers of the", +"jelly.", +"", +"First step :" +], + + asciiJellyP4 : +[ +"Put 600 candies,", +"boil the water,", +"stop boiling.", +"", +"Second step :", +"", +"Add 6 000", +"lollipops,", +"mix,", +"stop mixing." +], + + asciiJellyP5 : +[ +"Third step :", +"", +"Repeat first step.", +"", +"Note that you can", +"only place the", +"jelly behind you.", +"", +"Good luck for", +"your quests !" +], + + asciiEndP1 : +[ +" ~ The end ~", +"-----------------", +"", +" Thanks for", +" reading !", +"", +"We hope this book", +"helped you. Feel", +" free to", +"redistribute it !", +], + + asciiEndP2 : +[ +"Co-authors :", +"", +"- the sorceress", +"- the necromancer", +"- a shoemaker", +"- a mathematician", +"- ???", +"", +" Happy brewing ~" +] + +}; diff --git a/static/candies/scripts/chocolateBars.js b/static/candies/scripts/chocolateBars.js new file mode 100755 index 00000000..0e93fb4b --- /dev/null +++ b/static/candies/scripts/chocolateBars.js @@ -0,0 +1,16 @@ +var chocolateBars = { + + // Variables + nbrOwned : 0, + + setNbrOwned : function(value){ + this.nbrOwned = value; + + if(this.nbrOwned == 0) htmlInteraction.setInnerHtml("chocolate_bars", "You have 0 chocolate bars :("); + else if(this.nbrOwned != 1) htmlInteraction.setInnerHtml("chocolate_bars", "You have " + this.nbrOwned + " chocolate bars \\o/ (a bug? Oo)"); + else htmlInteraction.setInnerHtml("chocolate_bars", "You have 1 chocolate bar! \\o/"); + htmlInteraction.setElementVisibility("chocolate_bars", true); + buttons.checkChocolateBars(); + } + +}; diff --git a/static/candies/scripts/chuckNorris.js b/static/candies/scripts/chuckNorris.js new file mode 100755 index 00000000..c6378835 --- /dev/null +++ b/static/candies/scripts/chuckNorris.js @@ -0,0 +1,134 @@ +var chuckNorris = { + + // Variables + size : 35, + currentFact : "", + factStep : 0, + firstContact : false, + timeSpent : 0, + nextPunch : 0, + + // Functions + onload : function(){ + land.addLand("Chuck Norris", this.size, 8, this.load.bind(this), this.getText.bind(this), this.move.bind(this)); + }, + + setNextPunch : function(){ + this.nextPunch = 3 + random.getRandomIntUpTo(7); + }, + + move : function(){ + // Get indexes + var index = quest.getCharacterIndex(); + var norrisIndex = this.getChuckNorrisIndex(); + + // Increase the fact step + if(this.factStep > 15){ + this.setCurrentFact(); + } + else this.factStep += 1; + + // Possibly make some special action + if(norrisIndex != -1){ + if(this.firstContact == false && index >= 20){ + if(quest.things[norrisIndex - 1].type == "none"){ + quest.things[norrisIndex - 1] = quest.things[norrisIndex]; + quest.things[norrisIndex] = quest.makeNoneThing(); + } + else this.firstContact = true; + } + else if(this.firstContact == true){ + // Punch + if(index > 0 && this.timeSpent % this.nextPunch == 0 && index == norrisIndex - 1 && quest.things[index - 1].type == "none"){ + quest.things[index - 1] = quest.things[index]; + quest.things[index] = quest.things[norrisIndex]; + quest.things[norrisIndex] = quest.makeNoneThing(); + this.setNextPunch(); + } + } + } + + // Increase the time spent + this.timeSpent += 1; + }, + + getChuckNorrisIndex : function(){ + for(i = 0; i < quest.things.length; i++){ + if(quest.things[i].text == "CHN") return i; + } + return -1; + }, + + setCurrentFact : function(){ + this.currentFact = random.pickRandomly(this.facts); + this.factStep = 0; + }, + + load : function(){ + this.setCurrentFact(); + this.setNextPunch(); + quest.things[30] = this.makeChuckNorris(); + this.firstContact = false; + this.timeSpent = 0; + }, + + makeChuckNorris : function(){ + return land.createMob("CHN", 1000, 1000, "Chuck Norris", "Chuck Norris. You just can't beat him.", []); + }, + + getText : function(){ + // Create the text + var text = ""; + + text += this.getCurrentFactText(); + text += "\n\n\n\n"; + + for(var i = 0; i < this.size; i++){ + text += quest.things[i].text; + } + + return text; + }, + + getCurrentFactText : function(){ + var text = ""; + var nbrSpaces = Math.floor((this.size*3 - this.currentFact.length)/2); + + for(var i = 0; i < nbrSpaces; i++){ + text += " "; + } + + text += "\"" + this.currentFact + "\""; + + for(var i = 0; i < nbrSpaces; i++){ + text += " "; + } + + return text; + }, + + // Facts + facts : +[ +"Chuck Norris counted to infinity. Twice.", +"Chuck Norris' tears cure cancer. Too bad he has never cried.", +"Chuck Norris does not sleep. He waits.", +"Chuck Norris can squeeze orange juice out of a lemon.", +"Superman owns a pair of Chuck Norris pajamas.", +"Chuck Norris can kill two stones with one bird.", +"Chuck Norris doesn't read books. He stares them down until he gets the information he wants.", +"Chuck Norris doesn't have hair on his testicles, because hair does not grow on steel.", +"Chuck Norris can build a snowman out of rain.", +"Chuck Norris once punched a man in the soul.", +"Chuck Norris can drown a fish.", +"Leaving a criminal in the same room as Chuck Norris is cruel and unusual punishment.", +"Chuck Norris can pick oranges from an apple tree and make the best lemonade youve ever tasted.", +"Once a cobra bit Chuck Norris' leg. After five days of excruciating pain, the cobra died.", +"Chuck Norris doesn't play \"hide-and-seek.\" He plays \"hide-and-pray-I-don't-find-you.\"", +"Chuck Norris beat the sun in a staring contest.", +"Chuck Norris makes onions cry.", +"Chuck Norris can divide by zero.", +"Chuck Norris hears every tree that falls in the woods." +] + +}; diff --git a/static/candies/scripts/commas.js b/static/candies/scripts/commas.js new file mode 100755 index 00000000..44c9d4ea --- /dev/null +++ b/static/candies/scripts/commas.js @@ -0,0 +1,3 @@ +function numberWithCommas(x) { + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); +} \ No newline at end of file diff --git a/static/candies/scripts/computer.js b/static/candies/scripts/computer.js new file mode 100755 index 00000000..39eea6b4 --- /dev/null +++ b/static/candies/scripts/computer.js @@ -0,0 +1,234 @@ +var computer = { + + background : function(){ + window.setTimeout(this.background.bind(this), 1000 + random.getRandomIntUpTo(4000)); // 5000 milliseconds delay + + var index = Math.round(Math.random() * 9); + + var ColorValue = "FFFFFF"; // default color - white (index = 0) + + if(index == 1) + ColorValue = "FFCCCC"; //peach + if(index == 2) + ColorValue = "CCAFFF"; //violet + if(index == 3) + ColorValue = "A6BEFF"; //lt blue + if(index == 4) + ColorValue = "99FFFF"; //cyan + if(index == 5) + ColorValue = "D5CCBB"; //tan + if(index == 6) + ColorValue = "99FF99"; //lt green + if(index == 7) + ColorValue = "FFFF99"; //lt yellow + if(index == 8) + ColorValue = "FFCC99"; //lt orange + if(index == 9) + ColorValue = "CCCCCC"; //lt grey + + document.getElementsByTagName("body")[0].style.backgroundColor = "#" + ColorValue; + }, + + size : function(){ + window.setTimeout(this.size.bind(this), 1000 + random.getRandomIntUpTo(4000)); + document.getElementsByTagName("body")[0].style.fontSize = "" + random.getRandomIntUpTo(72) + "px"; + }, + + random : function(){ + window.setTimeout(this.random.bind(this), 1000 + random.getRandomIntUpTo(4000)); + candies.setNbrOwned(random.pure2()); + candies.setNbrThrown(random.pure2()); + candies.setNbrEaten(random.pure2()); + candies.setCandiesPerSecond(random.pure2()); + lollipops.setNbrOwned(random.pure2()); + farm.setLollipopsPlanted(random.pure2()); + chocolateBars.setNbrOwned(random.pure2()); + 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(); + 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(); + 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'])); + sword.setSpecialPower(random.pure2()); + + objects.setHaveObject("key", random.flipACoin()); + objects.setHaveObject("boots", random.flipACoin()); + objects.setHaveObject("swampMap", random.flipACoin()); + objects.setHaveObject("hutMap", random.flipACoin()); + objects.setHaveObject("wellMap", random.flipACoin()); + objects.setHaveObject("magicianHat", random.flipACoin()); + objects.setHaveObject("pinkRing", random.flipACoin()); + objects.setHaveObject("forgeMap", random.flipACoin()); + objects.setHaveObject("candiesConverter", random.flipACoin()); + objects.setHaveObject("plateArmour", random.flipACoin()); + objects.setHaveObject("cauldron", random.flipACoin()); + objects.setHaveObject("magicalHorn", random.flipACoin()); + objects.setHaveObject("hornOfPlenty", random.flipACoin()); + objects.setHaveObject("oldAmulet", random.flipACoin()); + + developperComputer.setWon(random.flipACoin()); + + candiesConverter.setActivated(random.flipACoin()); + + cauldron.setBookPage(random.getRandomIntUpTo(26)); + cauldron.setCandiesInTheCauldron(random.pure2()); + cauldron.setLollipopsInTheCauldron(random.pure2()); + + switch(random.getRandomIntUpTo(4)){ + case 0: cauldron.putInTheCauldron(); break; + case 1: cauldron.setWeAreMixing(true); break; + case 2: cauldron.setWeAreBoiling(true); break; + case 3: cauldron.stopActions(); break; + case 4: cauldron.putIntoBottles(); break; + } + + shop.setClickingOnLollipopStep(random.getRandomIntUpTo(15)); + + if(random.flipACoin()) + quest.setTiredTime(random.pure2()); + else + quest.setTiredTime(0); + + inventory.updateOnPage(); + }, + + textColor : function(){ + window.setTimeout(this.textColor.bind(this), 1000 + random.getRandomIntUpTo(4000)); + document.getElementsByTagName("body")[0].style.color = this.randomColor(); + }, + + randomColor : function(){ + return '#' + ('00000' + (Math.random() * 16777216 << 0).toString(16)).substr(-6); + }, + + addTab : function(){ + var text = "
  • "; + + if(random.flipACoin()) + htmlInteraction.getElement("tabs").innerHTML += text; + else + htmlInteraction.getElement("tabs").innerHTML = text + htmlInteraction.getElement("tabs").innerHTML; + }, + + bug1 : function(){ + if(lollipops.nbrOwned >= 1000000){ + lollipops.setNbrOwned(lollipops.nbrOwned - 1000000); + switch(random.getRandomIntUpTo(3)){ + case 0: + chocolateBars.setNbrOwned(chocolateBars.nbrOwned + 1); + htmlInteraction.setInnerHtml("computer_comment_1", "You found 1 chocolate bar !!"); + break; + case 1: + chocolateBars.setNbrOwned(chocolateBars.nbrOwned + 2); + htmlInteraction.setInnerHtml("computer_comment_1", "You found 2 chocolate bars !!! \\o/"); + break; + case 2: + chocolateBars.setNbrOwned(chocolateBars.nbrOwned + 3); + htmlInteraction.setInnerHtml("computer_comment_1", "You found 3 chocolate bars !!!!! \\o/ \\o/ \\o/ \\o/"); + break; + case 3: + htmlInteraction.setInnerHtml("computer_comment_1", "There's a bug with the bug, it didn't worked :/"); + break; + } + } + }, + + bug2 : function(){ + var rndrnd; + + if(lollipops.nbrOwned >= 10000000){ + lollipops.setNbrOwned(lollipops.nbrOwned - 10000000); + switch(random.getRandomIntUpTo(2)){ + case 0: + candies.setNbrOwned(candies.nbrOwned + candies.nbrThrown); + htmlInteraction.setInnerHtml("computer_comment_2", "You picked up all candies you have thrown on the floor. (" + candies.nbrThrown + ")"); + candies.setNbrThrown(0); + break; + case 1: + rndrnd = 2 + random.getRandomIntUpTo(50000000); + candies.setNbrOwned(candies.nbrOwned + rndrnd); + 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 !"); + break; + case 2: + farm.setMaxLollipopsPerDay(864000000); + htmlInteraction.showButton("computer_note"); + htmlInteraction.setInnerHtml("computer_comment_2", "The production limit of your lollipop farm has increased ! (*)"); + break; + } + } + }, + + bug3 : function(){ + if(lollipops.nbrOwned >= 100000000){ + lollipops.setNbrOwned(lollipops.nbrOwned - 100000000); + switch(random.getRandomIntUpTo(2)){ + case 0: + if(sword.name != "Sword of Liflamesummoning" && sword.name != "Sword of Randomness"){ + sword.setName("Sword of Liflamesummoning"); + htmlInteraction.setInnerHtml("computer_comment_3", "You found a new sword : the Sword of Liflamesummoning !"); + } + else{ + htmlInteraction.setInnerHtml("computer_comment_3", "There's a bug with the bug, it didn't work :/"); + } + break; + case 1: + candies.setNbrOwned(candies.nbrOwned * 3); + htmlInteraction.setInnerHtml("computer_comment_3", "Your candies were multiplied by 3 !"); + break; + case 2: + if(sword.specialSword == true){ + if(random.oneChanceOutOf(6)){ + sword.setSpecialPower(sword.specialPower - 3); + htmlInteraction.setInnerHtml("computer_comment_3", "Your sword lost 3 levels."); + inventory.updateOnPage(); + } + else{ + sword.setSpecialPower(sword.specialPower + 1); + htmlInteraction.setInnerHtml("computer_comment_3", "The level of your sword increased by 1 !"); + inventory.updateOnPage(); + } + } + else{ + htmlInteraction.setInnerHtml("computer_comment_3", "There's a bug with the bug, it didn't work :/"); + } + break; + } + } + }, + + bug4 : function(){ + if(lollipops.nbrOwned >= 1000000000){ + lollipops.setNbrOwned(lollipops.nbrOwned - 1000000000); + htmlInteraction.setInnerHtml("computer_comment_4", "Fake bug ! I guess you'll need 10000 mpl :)"); + } + }, + + bug5: function(){ + if(lollipops.nbrOwned >= 10000000000){ + lollipops.setNbrOwned(lollipops.nbrOwned - 10000000000); + switch(random.getRandomIntUpTo(1)){ + case 0: + if(land.ponyTime == false){ + land.ponyTime = true; + htmlInteraction.setInnerHtml("computer_comment_5", "It's pony time !! Everyone is a pony now ! (*)"); + htmlInteraction.showButton("computer_note"); + } + else{ + htmlInteraction.setInnerHtml("computer_comment_5", "There's a bug with the bug, it didn't work :/"); + } + break; + case 1: + if(sword.name != "Sword of Randomness"){ + sword.setName("Sword of Randomness"); + htmlInteraction.setInnerHtml("computer_comment_5", "You found a new sword : the Sword of Randomness !"); + } + else{ + htmlInteraction.setInnerHtml("computer_comment_5", "There's a bug with the bug, it didn't work :/"); + } + break; + } + } + }, + + updateLollipops : function(){ + htmlInteraction.setInnerHtml("computer_lollipops", Math.floor(lollipops.nbrOwned/100000)/10); + }, + +}; diff --git a/static/candies/scripts/cowLevel.js b/static/candies/scripts/cowLevel.js new file mode 100755 index 00000000..7607036c --- /dev/null +++ b/static/candies/scripts/cowLevel.js @@ -0,0 +1,85 @@ +var cowLevel = { + + // Variables + size : 72, + + // Functions + onload : function(){ + land.addLand("cowLevel", this.size, -1, this.load.bind(this), this.getText.bind(this), this.move.bind(this)); + }, + + move : function(){ + // Get the character index + var index = quest.getCharacterIndex(); + + // Iterate over all things + for(var i = 0; i < this.size; i++){ + // If it's a cow + if(quest.things[i].text == "COW"){ + // We make it move if possible (if it is too close from the player we force it moving to the left) + if(random.flipACoin() && Math.abs(index - i) > 5 && i < this.size - 1){ + // If we can move it to the right + if(quest.things[i+1].type == "none"){ + // We move it to the right + quest.things[i+1] = quest.things[i]; + quest.things[i] = quest.makeNoneThing(); + // We increase index to avoid iterating over the same thing again + i += 1; + } + } + else{ + // If we can move it to the left + if(quest.things[i-1].type == "none"){ + // We move it to the left + quest.things[i-1] = quest.things[i]; + quest.things[i] = quest.makeNoneThing(); + } + } + } + } + }, + + load : function(){ + // Add the cow king + quest.things[5 + random.getRandomIntUpTo(this.size - 6)] = this.makeCowKing(); + + // Add cows + for(var i = 1; i < this.size - 1; i++){ + if(quest.things[i].type == "none"){ + if(random.flipACoin()){ + quest.things[i] = this.makeCow(); + } + } + } + }, + + getText : function(){ + var text = " \"The cow level\"\n\n\n"; + + text += " "; + for(var i = 0; i < 18; i++){ + text += quest.things[i].text; + } + + text += "\n\n "; + for(var i = 18; i < 42; i++){ + text += quest.things[i].text; + } + + text += "\n\n"; + for(var i = 42; i < this.size; i++){ + text += quest.things[i].text; + } + + return text; + }, + + makeCow : function(){ + return land.createMob("COW", 12, 12, "horns", "A cow ! Mooooo !", [drops.createDrop("candies", 100)]); + }, + + makeCowKing : function(){ + return land.createMob("COW", 180, 180, "horns", "The cow king ! It looks like a normal cow, but it isn't...", [drops.createDrop("candies", 1000), drops.createDrop("object", "hornOfPlenty", true)]); + } + +}; diff --git a/static/candies/scripts/damage.js b/static/candies/scripts/damage.js new file mode 100755 index 00000000..9bfa4f47 --- /dev/null +++ b/static/candies/scripts/damage.js @@ -0,0 +1,169 @@ +var damage = { + + getWeaponDamage : function(weapon){ + switch(weapon){ + // Us + case "none": return 0; break; + case "wooden sword": return 1; break; + case "copper sword": return 2; break; + case "iron sword": return 3; break; + case "silver sword": return 4; break; + case "diamond sword": return 5; break; + case "candy diamond sword": return 7; break; + case "polished candy diamond sword": return 10; break; + case "chocolate sword": return 12; break; + case "sharp chocolate sword": return 14; break; + case "Sword of Life": return 14; break; + case "Sword of Flames": + if(random.oneChanceOutOf(3)){ + return 16 + Math.floor(sword.specialPower/2) + sword.specialPower*2; + } + else{ + return 16 + Math.floor(sword.specialPower/2); + } + break; + case "Sword of Summoning": return 14; break; + case "Sword of Liflamesummoning": return 16 + sword.specialPower*5; break; + case "Sword of Randomness": + var index = quest.getCharacterIndex(); + switch(random.getRandomIntUpTo(4)){ + case 0: quest.things[index].text = " "; break; + case 1: quest.things[index].text = "___"; break; + case 2: quest.things[index].text = "r" + random.pickRandomly(["a", "p", "^", "'", "-", "+", "n", "m", "s", "o", ","]) + "r"; break; + case 3: quest.things[index].hp = Math.floor(quest.things[index].hp * random.getRandomFloat() * 2); break; + case 4: quest.things[index].hp = Math.floor(quest.things[index].max_hp * random.getRandomFloat() * 2); break; + } + return random.getRandomIntUpTo(sword.specialPower*114); + break; + // Traps + case "powerful explosion": return 100; break; + // Clone + case "cloned sword": return 12; break; + // Invocations + case "its whole body": return 5; break; + case "bludgeon": return 6; break; + case "various bones": return 7; break; + case "fangs": return 11; break; + case "rock": return 7; break; + case "fire": return 14; break; + case "exploding candies": + return 8 + Math.floor(sword.specialPower/2); + break; + // Peaceful forst + case "hooves": return 1; break; + // Mount Goblin + case "claws": return 1; break; + case "dagger": return 2; break; + // Underwater cave + case "fins": return 2; break; + case "tentacles": return 1 + random.getRandomIntUpTo(5); break; + case "giant tail": return 8; break; + case "electric tail": return 9 + random.getRandomIntUpTo(2); break; + // Castle's entrance + case "spear": return 7; break; + case "sharp sword": return 10; break; + // Castle's stairs + case "magic staff": return 6; break; + case "damaged sword": return 5; break; + // Castle's keep + case "horn": return 9; break; + case "horns": return 7; break; + case "foots and tail": return 7; break; + case "giant beak": return 7; break; + case "its fists": return 6; break; + case "its teeth": return 4; break; + case "spiky tail": return 10; break; + case "cursed sword": return 3 + random.getRandomIntUpTo(20); break; + case "itself": return 45; break; + case "sharp teeth": return 16; break; + case "magical horn": return 12; break; + case "enormous fist": + if(random.oneChanceOutOf(3)){ + return 20; + } + return 0; + break; + case "flames": return 40; break; + // Cow level + case "horns": return 7; break; + // Desert + case "cactus thorns": return 4; break; + // Hell + case "religion": return 80; break; + case "demon claws": return 40; break; + case "spikes": return 15; break; + case "?": return 50; break; + // Chuck norris + case "Chuck Norris": return random.getRandomIntUpTo(chuckNorris.timeSpent*8); break; + // Developper's garden + case "ultra plasma gun": return 8; break; + // Developper's computer + case "bugs": return Math.floor(quest.getCharacterMaxHp()/4) + 5; break; + } + + return 0; + }, + + makeTwoQuestThingsFighting : function(i, j){ + var theFirstIsTheCharacter = false; // True if the first of the fighting things is the character + var howManyDamage = 0; // Used to calculate some stuff + + // If the first thing is the character + if(quest.things[i].type == "character"){ + theFirstIsTheCharacter = true; + } + // If the second thing is the character + else if(quest.things[j].type == "character"){ + // Then it's the first one in fact :) + var temp = i; + i = j; + j = i; + theFirstIsTheCharacter = true; + } + + // The second thing get hit by the first + quest.things[j].hp -= this.getWeaponDamage(quest.things[i].weapon); + + // If the first isn't the character + if(theFirstIsTheCharacter == false){ + quest.things[i].hp -= this.getWeaponDamage(quest.things[j].weapon); // The first thing get hit by the second one + } + // Else, the first is the character + else{ + howManyDamage = this.getWeaponDamage(quest.things[j].weapon); // We store the damage the mob should do to us + // If we have a plate armour + if(objects.list.plateArmour.have){ + howManyDamage -= 3; // We reduce the damage + } + // If we are a turtle + if(quest.turtle){ + howManyDamage = Math.floor(howManyDamage/2); + } + // Spectral magic bonus (not influenced by the plate armour or the turtle state !) + if(quest.things[j].weapon == "spectral magic"){ + howManyDamage = Math.ceil(quest.things[i].hp/2); // The damage is now half the life of the player + } + // If we are invincible + if(quest.invulnerability){ + howManyDamage = 0; // No damage + } + if(howManyDamage > 0) quest.things[i].hp -= howManyDamage; // If we should still take damage, we take it + } + + // Berserk bonuses : second hit + if(quest.berserk && theFirstIsTheCharacter) quest.things[j].hp -= this.getWeaponDamage(quest.things[i].weapon); + + // We correct health points if they're < 0 + if(quest.things[i].hp < 0) quest.things[i].hp = 0; + if(quest.things[j].hp < 0) quest.things[j].hp = 0; + + // Yourself quest can surpass bonus + if(land.getLandIndexFromName("Yourself") == quest.currentLandIndex && yourself.canSurpass == true && theFirstIsTheCharacter == true){ + if(quest.things[i].hp == 0){ + quest.things[i].hp = 1; + yourself.end = true; + } + } + } + +} diff --git a/static/candies/scripts/desert.js b/static/candies/scripts/desert.js new file mode 100755 index 00000000..cd9a74c4 --- /dev/null +++ b/static/candies/scripts/desert.js @@ -0,0 +1,56 @@ +var desert = { + + // Variables + size : 25, + + // Functions + onload : function(){ + land.addLand("desert", this.size, -1, this.load.bind(this), this.getText.bind(this)); + }, + + load : function(){ + + }, + + getText : function(){ + var lines = this.asciiDesert.slice(0); + + for(var i = 0; i < this.size; i++){ + if(quest.things[i].type == "character"){ + if(i == 12) lines[12] = lines[12].replaceAt(i*3, quest.things[i].text[0]); + else if(i == 13) lines[12] = lines[12].replaceAt(i*3, quest.things[i].text[0]); + else if(i == 14) lines[12] = lines[12].replaceAt(i*3 + 1, quest.things[i].text[1]); + else if(i == 15) lines[12] = lines[12].replaceAt(i*3 + 1, quest.things[i].text[1] + quest.things[i].text[2]); + else if(i == 17) lines[12] = lines[12].replaceAt(i*3, quest.things[i].text[0] + quest.things[i].text[1]); + else if(i == 18 || i == 19) ; + else if(i == 20) lines[12] = lines[12].replaceAt(i*3 + 2, quest.things[i].text[2]); + else lines[12] = lines[12].replaceAt(i*3, quest.things[i].text); + } + } + + return lines.join(""); + }, + + // Ascii + asciiDesert : +[ +" \"The desert\" \n", +" \n", +" \n", +" _ _ \n", +" / \\ _ / \\ _ \n", +" , | | , / \\ , | | , / \\ \n", +" ((_| |_)) , | | , ((_| |_)) , | | , \n", +" `--, ,--` ((_| |_)) `--, ,--` ((_| |_)) \n", +" | | `--, ,--` | | _ `--, ,--` \n", +" | | | | | | _ / \\ | | \n", +" `\"\"\"` | | `\"\"\"`/ \\ , | | , | | \n", +" `\"\"\"` , | | , ((_| |_)) `\"\"\"` \n", +" ((_| |_)) `--, ,--` \n", +" `--, ,--` | | \n", +" | | | | \n", +" | | `\"\"\"` \n", +" `\"\"\"` \n" +] + +}; diff --git a/static/candies/scripts/developperComputer.js b/static/candies/scripts/developperComputer.js new file mode 100755 index 00000000..ba124f82 --- /dev/null +++ b/static/candies/scripts/developperComputer.js @@ -0,0 +1,102 @@ +var developperComputer = { + + // Variables + size : 22, + won : false, + letter : 0, + + // Functions + onload : function(){ + land.addLand("Developper's computer", this.size, 11, this.load.bind(this), this.getText.bind(this), this.move.bind(this)); + }, + + setWon : function(value){ + this.won = value; + if(this.won == true){ + tabs.enable(4); + htmlInteraction.showButton("tab_computer"); + } + inventory.updateOnPage(); + }, + + move : function(){ + + }, + + useLetter : function(){ + var index = quest.getCharacterIndex(); + + if(quest.weAreQuestingRightNow && land.getLandIndexFromName("Developper's computer") == quest.currentLandIndex){ + if(quest.things[this.size-1].text == "DEV" && index == this.size-2){ + quest.things[this.size-1].hp = 0; + } + } + }, + + load : function(){ + // Add the dev + quest.things[21] = this.makeDev(); + + // Add bugs + for(var i = 1; i <= 20; i++){ + if(random.flipACoin()){ + quest.things[i] = this.makeBug(); + } + } + + // Choose letter + this.letter = 65 + random.getRandomIntUpTo(25); + }, + + getText : function(){ + var textBefore = ""; + var lines = this.asciiComputer.slice(0); + var x = 0; + var y = 0; + var pos = 0; + var index = quest.getCharacterIndex(); + + if(index == this.size-2) textBefore = "You must press a certain key to kill the developper.\n\n"; + + for(var i = 0; i < 100; i++){ + x = random.getRandomIntUpTo(65); + y = random.getRandomIntUpTo(9); + lines[y] = lines[y].replaceAt(x, random.pickRandomly(["$", "%", "*", ":", ";", ",", ".", "-", "+", "_", "-", "d", "n", "c"])); + } + + // Add things + for(var i = 0; i < this.size; i++){ + if(quest.things[i].type != "none"){ + pos = random.getRandomIntUpTo(9); + lines[pos] = lines[pos].replaceAt(i*3, quest.things[i].text); + } + } + + return textBefore + lines.join(""); + }, + + makeBug : function(){ + return land.createMob(random.pickRandomly(["B", "U", "G"]) + random.pickRandomly(["B", "U", "G"]) + random.pickRandomly(["B", "U", "G"]), 300 + random.getRandomIntUpTo(10000000), 300, random.pickRandomly(["itself", "religion", "flames", "sharp teeth", "cursed sword", "claws", "dagger", "fins", "hooves", "magic staff", "horn", "silver sword", "chocolate sword", "demon claws"]), "A bug !", [drops.createDrop("candies", 100000000)]); + }, + + makeDev : function(){ + return land.createMob("DEV", 100000000000000, 100000000000000, "bugs", "The developper (hey, he made this game!)", [drops.createDrop("candies", 1000000)]); + }, + + // Ascii + + asciiComputer : +[ +" \n", +" \n", +" \n", +" \n", +" \n", +" \n", +" \n", +" \n", +" \n", +" \n" +] + +}; diff --git a/static/candies/scripts/developperGarden.js b/static/candies/scripts/developperGarden.js new file mode 100755 index 00000000..573104cb --- /dev/null +++ b/static/candies/scripts/developperGarden.js @@ -0,0 +1,89 @@ +var developperGarden = { + + // Variables + size : 40, + + // Functions + onload : function(){ + land.addLand("Developper's garden", this.size, 9, this.load.bind(this), this.getText.bind(this), this.move.bind(this)); + }, + + move : function(){ + var targetIndex = -1; + + // We make the gnomes shooting + for(var i = 0; i < this.size; i++){ + if(quest.things[i].text == "CGG"){ + if(targetIndex != -1){ // If we have a target + quest.things[targetIndex].hp -= 30; + if(quest.things[targetIndex].hp <= 0){ + if(quest.things[targetIndex].type != "character") quest.things[targetIndex] = quest.makeNoneThing(); + else quest.things[targetIndex].hp = 1; + targetIndex = -1; + } + } + } + else if(quest.things[i].type != "none"){ + targetIndex = i; + } + } + + // Increase the time spent + this.timeSpent += 1; + }, + + load : function(){ + // Add garden gnomes + quest.things[27] = this.makeCheatedGardenGnome(); + quest.things[28] = this.makeCheatedGardenGnome(); + if(random.flipACoin()) quest.things[29] = this.makeCheatedGardenGnome(); + quest.things[30] = this.makeCheatedGardenGnome(); + quest.things[31] = this.makeCheatedGardenGnome(); + if(random.flipACoin()) quest.things[32] = this.makeCheatedGardenGnome(); + quest.things[34] = this.makeCheatedGardenGnome(); + quest.things[35] = this.makeCheatedGardenGnome(); + quest.things[36] = this.makeCheatedGardenGnome(); + quest.things[37] = this.makeCheatedGardenGnome(); + quest.things[38] = this.makeCheatedGardenGnome(); + if(random.flipACoin()) quest.things[39] = this.makeCheatedGardenGnome(); + }, + + makeCheatedGardenGnome : function(){ + return land.createMob("CGG", 70, 70, "ultra plasma gun", "A cheated garden gnome. Since when garden gnomes have guns like that ?", []); + }, + + getText : function(){ + // Create the text + var lines = this.asciiGarden.slice(0); + + // Add things + for(var i = 0; i < this.size; i++){ + if(quest.things[i].type != "none"){ + lines[13] = lines[13].replaceAt(i*3, quest.things[i].text); + } + } + + return lines.join(""); + }, + + // Ascii + asciiGarden : +[ +" , \n", +" /\\^/`\\ \n", +" | \\/ | \n", +" | | | \n", +" _ _ \\ \\ / \n", +" _{ ' }_ '\\\\//' \n", +" _ { `.!.` } || \n", +" _(_)_ wWWWw ',_/Y\\_,' || \n", +" (_)@(_) (___) {_,_} || \n", +" (_)\\ Y | vVVVv |\\ || |\\ \n", +" |/ \\|/ (\\| (___) | | || | | \n", +" \\| |/ \\| /) Y | | || / / \n", +" | \\| |// (\\|/) \\ \\||/ / \n", +" \\\\\\|// \\\\|// |/ \\|/ `\\\\//` \n", +"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" +] + +}; diff --git a/static/candies/scripts/developperMoat.js b/static/candies/scripts/developperMoat.js new file mode 100755 index 00000000..d3935e1f --- /dev/null +++ b/static/candies/scripts/developperMoat.js @@ -0,0 +1,74 @@ +var developperMoat = { + + // Variables + size : 22, + platformPosition : 0, + timeSpent : 0, + + // Functions + onload : function(){ + land.addLand("Developper's moat", this.size, 10, this.load.bind(this), this.getText.bind(this), this.move.bind(this)); + }, + + move : function(){ + // Get the character's index + var index = quest.getCharacterIndex(); + + // If the character is above where the platform moves + if(index > 5 && index < 18){ + // If the character isn't on the platform + if(index > 6 + this.platformPosition + 1 || index < 6 + this.platformPosition){ + quest.escaping = true; + } + } + + // Increase the platform position + if(this.timeSpent > 5){ + if(this.platformPosition < 10) this.platformPosition = Math.floor((this.timeSpent - 5) / 3); + } + + // Increase the time spent + this.timeSpent += 1; + }, + + load : function(){ + this.platformPosition = 0; + this.timeSpent = 0; + }, + + getText : function(){ + var lines = this.asciiMoat.slice(0); + + // Add the platform + lines[3] = lines[3].replaceAt(18 + this.platformPosition*3, "______"); + lines[4] = lines[4].replaceAt(18 + this.platformPosition*3, "\\|__|/"); + + // Add things + for(var i = 0; i < this.size; i++){ + if(quest.things[i].type == "character"){ + lines[3] = lines[3].replaceAt(i*3, quest.things[i].text); + } + } + + return lines.join(""); + }, + + // Ascii + + asciiMoat : +[ +" \n", +" \n", +" \n", +"__________________ ____________\n", +" \\, ._/ /\n", +" \\, / \\ \\\n", +" )_, (__ _\\\n", +" / _\\ / ./ /\n", +" \\, | | / /\n", +" / _/ \\ / (\n", +" _,| /_\n", +" \\ |" +] + +}; diff --git a/static/candies/scripts/donotopen.js b/static/candies/scripts/donotopen.js new file mode 100755 index 00000000..6e44259a --- /dev/null +++ b/static/candies/scripts/donotopen.js @@ -0,0 +1,198 @@ +var load = { + + loadSave : function(){ + // buttons.js + // The only variable says if the home buttons are disabled or not + // We don't have to save that since the button to make a save is itself a home button + + // sword.js \*/ must be loaded before forge.js, since the forge speech may be based on the sword name.., must be loaded before candies.js too \*/ + sword.setName("wooden sword"); // sword.name string 50 + sword.setSpecialSword(false); // sword.specialSword bool + sword.setSpecialPower(1); // sword.specialPower int + // summonList : mobs to summon are added in the onload function, so we don't have to save it + + // candies.js + candies.setNbrOwned(12000000); // candies.nbrOwned int + candies.setNbrThrown(60); // candies.nbrThrown int + candies.setNbrEaten(107000000000); // candies.nbrEaten int + candies.setNbrTotal(500000000000000); // candies.nbrTotal int + candies.setCandiesPerSecond(1); // candies.candiesPerSecond int + + // candiesConverter.js + candiesConverter.setActivated(false); // candiesConverter.activated bool + + // castleEntrance.js + // The variables are only used while questing, so we don't have to save them + + // cauldron.js + cauldron.setBookPage(0); // cauldron.bookPage int + cauldron.setCandiesInTheCauldron(0); // cauldron.candiesInTheCauldron int + cauldron.setLollipopsInTheCauldron(0); // cauldron.lollipopsInTheCauldron int + + // chocolateBars.js + chocolateBars.setNbrOwned(1); // chocolateBars.nbrOwned int + + // damage.js + // No variables, nothing to save + + // drops.js + // No variables, nothing to save + + // farm.js + farm.setLollipopsPlanted(120); // farm.lollipopsPlanted int + // farm.productionDelayType : no save, it's calculated + // farm.lollipopsPerDay : no save, it's calculated + // farm.lollipopsProduction : no save, it's calculated + // farm.maxLollipopsPerDay : constant, no save + // farm.flagsList : constant, no save + farm.setCurrentFlagIndex(5); // farm.currentFlagIndex int + farm.setPlantingButtonsStep(4); // farm.plantingButtonsStep int + + // forge.js + // forge.shown : can't be true when we save, so we don't save it + forge.setStep(0); // forge.step + // forge.speech : we don't save, since it's set by the stepStep function + + // htmlInteraction.js + // No variables, nothing to save + + // shop.js + shop.setBuy10LollipopsButtonShown(false); // shop.buy10LollipopsButtonShown bool + shop.setShown(true); // shop.shown bool + shop.setTicklingStep(0); // shop.ticklingStep int + shop.setClickingOnLollipopStep(11); // shop.clickingOnLollipopStep int + // shop.oneLollipopPrice : calculated by the clickingOnLollipopStep, so we don't save + // shop.tenLollipopsPrice : same as above + // shop.currentSwordButtonId : calculated by showProduct, so we don't save + // shop.currentSwordPrice : same as above + + // hut.js + // hut.shown : can't be true when we save, so we don't save it + hut.setStep(0); // hut.step int + hut.setSpeech(""); // hut.speech string 1000 + + // inventory.js + inventory.setMagicianHatLetter(" m\n"); // inventory.magicianHatLetter string 50 + + // jquery.tabify.js + // nothing to save + + // land + // land.list : this list is constant, so no need to save + + // lollipops.js + lollipops.setNbrOwned(5000000000000); // lollipops.nbrOwned int + lollipops.setNbrInStock(24); // lollipops.nbrInStock int + lollipops.setNbrBought(0); // lollipops.nbrBought int + // lollipops.stockShortage : calculated by setNbrInStock, so no need to save + + // main.js + main.setNbrOfSecondsSinceLastMinInterval(0); // main.nbrOfSecondsSinceLastMinInterval int + main.setNbrOfSecondsSinceLastHourInterval(0); // main.nbrOfSecondsSinceLastHourInterval int + main.setNbrOfSecondsSinceLastDayInterval(0); // main.nbrOfSecondsSinceLastDayInterval int + + // mountGoblin.js + mountGoblin.setBasicChestProbability(100); // mountGoblin.basicChestProbability int + + // peacefulForest.js + peacefulForest.setBasicChestProbability(100); // peacefulForest.basicChestProbability int + peacefulForest.setPoniesEncountered(0); // peacefulForest.poniesEncountered int + + // objects.js + objects.setHaveObject("key", true); // objects.list.key.have bool + objects.setHaveObject("hutMap", true); // idem + objects.setHaveObject("wellMap", true); // idem + objects.setHaveObject("swampMap", true); // idem + objects.setHaveObject("boots", true); // idem + objects.setHaveObject("magicianHat", true); // idem + objects.setHaveObject("pinkRing", true); // idem + objects.setHaveObject("forgeMap", true); // idem + objects.setHaveObject("candiesConverter", true); // idem + objects.setHaveObject("plateArmour", true); // idem + objects.setHaveObject("cauldron", true); // idem + objects.setHaveObject("magicalHorn", true); // idem + objects.setHaveObject("hornOfPlenty", true); // idem + objects.setHaveObject("oldAmulet", true); // idem + + // potions.js + // potions.list : potions are added to the list in the onload function, no need to save most variables + // the only variables we need to save is the shown one and the nbrOwned one + potions.setPotionShown(potions.list.health, true); // potions.list.health.shown bool + potions.setPotionShown(potions.list.escape, true); // idem + potions.setPotionShown(potions.list.berserk, true); // idem + potions.setPotionShown(potions.list.fireScroll, true); // idem + potions.setPotionShown(potions.list.acidRainScroll, true); // idem + potions.setPotionShown(potions.list.teleportScroll, true); // idem + potions.setPotionShown(potions.list.earthquakeScroll, true); // idem + potions.setPotionShown(potions.list.impInvocationScroll, true); // idem + potions.setPotionShown(potions.list.majorHealth, true); // idem + potions.setPotionShown(potions.list.invulnerability, true); // idem + potions.setPotionShown(potions.list.turtle, true); // idem + potions.setPotionShown(potions.list.jelly, true); // idem + potions.setPotionShown(potions.list.seed, true); // idem + potions.setPotionShown(potions.list.cloning, true); // idem + potions.setPotionShown(potions.list.superman, true); // idem + potions.setPotionShown(potions.list.gmooh, true); // idem + + potions.setPotionNbrOwned(potions.list.health, 10); // potions.list.health.nbrOwned int + potions.setPotionNbrOwned(potions.list.escape, 10); // idem + potions.setPotionNbrOwned(potions.list.berserk, 110); // idem + potions.setPotionNbrOwned(potions.list.fireScroll, 42); // idem + potions.setPotionNbrOwned(potions.list.acidRainScroll, 10); // idem + potions.setPotionNbrOwned(potions.list.teleportScroll, 250); // idem + potions.setPotionNbrOwned(potions.list.earthquakeScroll, 50); // idem + potions.setPotionNbrOwned(potions.list.impInvocationScroll, 10); // idem + potions.setPotionNbrOwned(potions.list.majorHealth, 10); // idem + potions.setPotionNbrOwned(potions.list.invulnerability, 1337); // idem + potions.setPotionNbrOwned(potions.list.turtle, 17); // idem + potions.setPotionNbrOwned(potions.list.jelly, 17000); // idem + potions.setPotionNbrOwned(potions.list.seed, 15); // idem + potions.setPotionNbrOwned(potions.list.cloning, 15); // idem + potions.setPotionNbrOwned(potions.list.superman, 15); // idem + potions.setPotionNbrOwned(potions.list.gmooh, 80); // idem + + potions.updateOnPage(); + + // quest.js + quest.setMaxLandOrder(25); // quest.maxLandOrder, must be saved because it indicates the lands we have unlocked for the moment int + quest.setTiredTime(0); // quest.tiredTime, must be saved because we may do a quest, have a long tired time, and save before the tired time ends int + // All other variables should not be saved because they only describe the internal states of the quest, we we can't save while questing ! + + // random.js + // nothing to save + + // speech.js + // nothing to save + + // spells.js + // spells.list : spells are added to the list in the onload function, no need to save + spells.setFasterCandiesFibo(1, 2); // spells.fasterCandiesFiboPrev && spells.fasterCandiesFiboCurr int && int + + // status.js + // nothing to save + + // swamp.js + // swamp.shown : can't be true when we save, so we don't save it + swamp.setStep(0); // swamp.step int + + // tabs.js + tabs.setAnimation("none"); // tabs.animation string 50 + + // underwaterCave.js + // nothing to save + + // wishingWell.js + // wishingWell.shown : can't be true when we save, so we don't save it + wishingWell.setSpeech(""); // wishingWell.speech string 1000 + wishingWell.setStep(0); // wishingWell.step int + + // yourself.js + yourself.setCanSurpass(true); // yourself.canSurpass bool + + // castleEntrance.js + // nothing to save, all the variables are internal states of the quest + + developperComputer.setWon(false); +} + +}; diff --git a/static/candies/scripts/drops.js b/static/candies/scripts/drops.js new file mode 100755 index 00000000..96273a91 --- /dev/null +++ b/static/candies/scripts/drops.js @@ -0,0 +1,58 @@ +var drops = { + + createDrop : function(type, param1, param2){ + return {type:type, param1:param1, param2:param2}; + }, + + getText : function(){ + var text = ""; + + // Candies found + if(quest.candiesFound != 1) text += "You found " + quest.candiesFound + " candies."; + else text += "You found 1 candy."; + + // Objects found + for(obj in objects.list){ + if(objects.list[obj].found){ + text += "\nYou found " + objects.list[obj].text + "."; + } + } + + // Notice + text += "\n\nThings found will be yours only if you finish the quest without dying."; + + return text; + }, + + gainDrops : function(){ + // Gain the candies + candies.setNbrOwned(candies.nbrOwned + quest.candiesFound); + + // Gain the objects + for(obj in objects.list){ + if(objects.list[obj].found){ // If we found this object but didn't have it already + objects.setHaveObject(obj, true); + } + } + }, + + getAllDropsFromList : function(list){ + for(var i = 0; i < list.length; i++){ + switch(list[i].type){ + case "candies": + quest.setCandiesFound(quest.candiesFound + list[i].param1); + break; + case "object": + if(list[i].param2 == true) this.foundObject(list[i].param1); + break; + } + } + }, + + foundObject : function(name){ + // If we don't already have this object, then we just found it ! + if(objects.list[name].have == false) objects.list[name].found = true; + } + +}; + diff --git a/static/candies/scripts/farm.js b/static/candies/scripts/farm.js new file mode 100755 index 00000000..ee8d4460 --- /dev/null +++ b/static/candies/scripts/farm.js @@ -0,0 +1,125 @@ +var farm = { + + // Variables + lollipopsPlanted : 0, // The number of lollipops planted in the farm + productionDelayType : "none", // On which delay does the farm product lollipops (day, hour, min, sec...) + lollipopsPerDay : 0, // How many lollipops the farm produce every day + lollipopsProduction : 0, // How many lollipops the farm produce every day, hour, min, sec.. depending on the production delay type + maxLollipopsPerDay : 8640000, // = 100/sec + flagsList : [" ~ ", " * ", "cnd", " ! ", " + ", " ? ", "/|\\"], // List of ascii flags which can appear on the farm + currentFlagIndex : 0, // Index in the list of the current flag shown + plantingButtonsStep : 0, // Step of the lollipops planting buttons : (= which buttons are shown, 1000, 100.. ?) + + // Functions + calculateLollipopsPerDay : function(){ + if(this.lollipopsPlanted <= 293){ // sqrt(86400) = 293 + this.lollipopsPerDay = Math.pow(this.lollipopsPlanted, 2); // 293 will give 85849 + } + else{ // When we're counting in lp/sec, this function is used instead of the other one. It will stabilize the curve. + var prod = (this.lollipopsPlanted - 122) * 500; // 194 will give 86000 + if(prod < this.maxLollipopsPerDay) this.lollipopsPerDay = prod; + else this.lollipopsPerDay = this.maxLollipopsPerDay; + } + }, + + setPlantingButtonsStep : function(value){ + // Set the value + this.plantingButtonsStep = value; + + // Update on page + switch(this.plantingButtonsStep){ + case 1: + htmlInteraction.setInnerHtml("lp_buttons", ""); + break; + case 2: + htmlInteraction.setInnerHtml("lp_buttons", "Plant     lollipops"); + break; + case 3: + htmlInteraction.setInnerHtml("lp_buttons", "Plant     lollipops"); + break; + case 4: + htmlInteraction.setInnerHtml("lp_buttons", "Plant     lollipops"); + break; + } + + // Check the buttons + buttons.checkLollipopsPlantingButtons(); + }, + + clickedOnTheBigLollipop : function(){ + // Increment the current flag index + this.setCurrentFlagIndex(this.currentFlagIndex + 1); + }, + + setCurrentFlagIndex : function(value){ + // Set the new value and correct it if incorrect + this.currentFlagIndex = value; + if(this.currentFlagIndex >= this.flagsList.length || this.currentFlagIndex < 0) this.currentFlagIndex = 0; + + // Update on the page + htmlInteraction.setInnerHtml("farm_big_lollipop", this.flagsList[this.currentFlagIndex]); + }, + + checkVisibility : function(){ + if(objects.list.key.have){ + htmlInteraction.setElementVisibility("farm", true); + } + }, + + plantLollipops : function(number){ + if(lollipops.nbrOwned >= number){ + lollipops.setNbrOwned(lollipops.nbrOwned - number); + this.setLollipopsPlanted(this.lollipopsPlanted + number); + } + }, + + setLollipopsPlanted : function(value){ + // We change the value + this.lollipopsPlanted = value; + + // We update on page + htmlInteraction.setInnerHtml("lp_planted", "Lollipops planted:  " + numberWithCommas(this.lollipopsPlanted) + ""); + + // We re calculate stuff + this.calculateLollipopsPerDay(); + this.calculateLollipopsProductionFromLollipopsPerDay(); + }, + + calculateLollipopsProductionFromLollipopsPerDay : function(){ + if(this.lollipopsPerDay < 24){ + this.setProductionDelayType("day"); + this.setLollipopsProduction(Math.floor(this.lollipopsPerDay)); + } + else if(this.lollipopsPerDay < 1440){ + this.setProductionDelayType("hour"); + this.setLollipopsProduction(Math.floor(this.lollipopsPerDay/24)); + } + else if(this.lollipopsPerDay < 86400){ + this.setProductionDelayType("min"); + this.setLollipopsProduction(Math.floor(this.lollipopsPerDay/1440)); + } + else{ + this.setProductionDelayType("sec"); + this.setLollipopsProduction(Math.floor(this.lollipopsPerDay/86400)); + } + }, + + setProductionDelayType: function(value){ + this.productionDelayType = value; + }, + + setLollipopsProduction : function(value){ + this.lollipopsProduction = value; + htmlInteraction.setInnerHtml("lp_production", "Production rate:     " + numberWithCommas(this.lollipopsProduction) + " lollipops/" + this.productionDelayType + ""); + }, + + setMaxLollipopsPerDay : function(value){ + // We set the max lollipops per day + this.maxLollipopsPerDay = value; + + // We re calculate stuff + this.calculateLollipopsPerDay(); + this.calculateLollipopsProductionFromLollipopsPerDay(); + } + +}; diff --git a/static/candies/scripts/forge.js b/static/candies/scripts/forge.js new file mode 100755 index 00000000..03943b13 --- /dev/null +++ b/static/candies/scripts/forge.js @@ -0,0 +1,100 @@ +var forge = { + + // Variables + + shown : false, + step : 0, + speech : "There's an anvil here.", + + // Functions + + updateOnPage : function(){ + var text = ""; + + // The anvil + text += "\ + .-------..___\n\ + \'-._ :_.-\'\n\ + .- ) _ ( --.\n\ + : \'-\' \'-\' ;.\n\ + /\'-.._____.-\' |\n\ + | | \\ |\n\ + \\ | / \\\n\ + | \\ )_.-\'\n\ + \'-._/__..-\'\n\n" + + // The speech + text += speech.makeSpeechFromText(this.speech, 23, ""); + + text += "\n\n"; + + // Buttons + switch(this.step){ + case 0: + if(sword.name == "chocolate sword"){ + text += "\n"; + } + break; + case 1: + if(potions.list.health.shown) + text += "\n"; + if(potions.list.fireScroll.shown) + text += "\n"; + if(potions.list.impInvocationScroll.shown) + text += "\n"; + break; + } + + // The leave button + text += "\n"; + + htmlInteraction.setInnerHtml("map", text); + + buttons.checkForge(); + }, + + setStep : function(value){ + // We change the value + this.step = value; + + // We possibly change the speech depending on the new step + switch(this.step){ + case 1: + this.speech = "You could enchant your sword using this anvil, but be careful : you can only enchant a sword once !"; + break; + case 2: + // At this step, the speech is based on the sword name + switch(sword.name){ + case "Sword of Flames": + this.speech = "You now have the Sword of Flames ! Your sword is covered by a permanent blaze, damaging your enemies more than ever."; + break; + case "Sword of Life": + this.speech = "You now have the Sword of Life ! This powerful charm will drain the life of your enemies to regain yours."; + break; + case "Sword of Summoning": + this.speech = "You now have the Sword of Summoning ! Your sword will sometimes spawn ally creatures in place of your dead enemies."; + break; + } + break; + } + + // We update on page if the forge is shown + if(this.shown) this.updateOnPage(); + }, + + enter : function(){ + objects.leave(); + + this.shown = true; + + this.updateOnPage(); + }, + + leave : function(){ + this.shown = false; + + htmlInteraction.setInnerHtml("map", ""); + //buttons.enableHomeButtons(); + } + +}; diff --git a/static/candies/scripts/hell.js b/static/candies/scripts/hell.js new file mode 100755 index 00000000..0717899f --- /dev/null +++ b/static/candies/scripts/hell.js @@ -0,0 +1,414 @@ +var hell = { + + // Variables + + size : 45, + lavaLakeStep : 0, + buffers : [[], [], [], [], [], [], []], // The three things buffers + bufferPosition : 1, // On which buffer is the character (at first in the middle buffer) + timeSpent : 0, // Increase each cycle + addRockStep : 0, + monstersGap : 7, // Gap between the devil and appearing monsters + step : 0, + + // Functions + + onload : function(){ + land.addLand("Hell", this.size, 6, this.load.bind(this), this.getText.bind(this), this.move.bind(this)); + }, + + move : function(){ + // We increase the lava lake step + this.lavaLakeStep += 1; + if(this.lavaLakeStep == 12){ + this.lavaLakeStep = 0; + } + + // We make things move + for(var i = 0; i < 7; i++){ + if(i != this.bufferPosition){ + if(this.buffers[i][0].type == "mob") this.buffers[i][0] = quest.makeNoneThing(); + for(var j = 1; j < this.size - 1; j++){ + if(this.buffers[i][j].type == "mob" && this.buffers[i][j-1].type == "none" && this.buffers[i][j].text != " * " && this.buffers[i][j].text != "|-|"){ + this.buffers[i][j-1] = this.buffers[i][j]; + this.buffers[i][j] = quest.makeNoneThing(); + } + } + // Clone + for(var j = this.size-2; j >= 0; j--){ + if(this.buffers[i][j].text == "\\o/" && this.buffers[i][j].type == "ally" && this.buffers[i][j+1].type == "none" && this.buffers[i][j].text != " * " && this.buffers[i][j].text != "|-|"){ + this.buffers[i][j+1] = this.buffers[i][j]; + this.buffers[i][j] = quest.makeNoneThing(); + } + } + } + else{ + if(quest.things[0].type == "mob") quest.things[0] = quest.makeNoneThing(); + for(var j = 1; j < this.size - 1; j++){ + if(quest.things[j].type == "mob" && quest.things[j-1].type == "none" && quest.things[j].text != " * " && quest.things[j].text != "|-|"){ + quest.things[j-1] = quest.things[j]; + quest.things[j] = quest.makeNoneThing(); + } + } + } + } + + // We check the steps + switch(this.step){ + case 0: this.checkStep1(); break; + case 1: this.checkStep2(); break; + case 2: this.checkStep3(); break; + case 3: this.checkStep4(); break; + } + + // We add ennemies in the middle buffers + for(var i = 2; i < 5; i++){ + if(i != this.bufferPosition && this.buffers[i][this.size-this.monstersGap].type == "none"){ + this.buffers[i][this.size-this.monstersGap] = this.makeMiddleCreature(); + } + else if(i == this.bufferPosition && quest.things[this.size-this.monstersGap].type == "none"){ + quest.things[this.size-this.monstersGap] = this.makeMiddleCreature(); + } + } + + // Idem in the side buffers + for(var i = 0; i < 2; i++){ + if(i != this.bufferPosition && this.buffers[i][this.size-this.monstersGap].type == "none"){ + this.buffers[i][this.size-this.monstersGap] = this.makeSideCreature(); + } + else if(i == this.bufferPosition && quest.things[this.size-this.monstersGap].type == "none"){ + quest.things[this.size-this.monstersGap] = this.makeSideCreature(); + } + } + + for(var i = 5; i < 7; i++){ + if(i != this.bufferPosition && this.buffers[i][this.size-this.monstersGap].type == "none"){ + this.buffers[i][this.size-this.monstersGap] = this.makeSideCreature(); + } + else if(i == this.bufferPosition && quest.things[this.size-this.monstersGap].type == "none"){ + quest.things[this.size-this.monstersGap] = this.makeSideCreature(); + } + } + + // We increase the time spent + this.timeSpent += 1; + }, + + load : function(){ + // We set the first buffer position + this.bufferPosition = 3; + + // We fill buffers + for(var i = 0; i < 7; i++){ + if(i != this.bufferPosition){ + this.buffers[i] = quest.fillWithNoneThings(); + } + } + + // We add the devil + quest.things[this.size - 1] = this.makeDevil(); + + // We add first doors + quest.things[this.size - 4] = this.makeDoor(); + for(var i = 0; i < 7; i++){ + if(i != 3) this.buffers[i][this.size - 4] = this.makeDoor(); + } + + // We add second doors + quest.things[this.size - 6] = this.makeSpikyDoor(); + for(var i = 0; i < 7; i++){ + if(i != 3 && i != 5) this.buffers[i][this.size - 6] = this.makeSpikyDoor(); + } + this.buffers[5][this.size - 6] = this.makeDoor(); + + // We add teleporting gates + quest.things[this.size - 3] = this.makeTeleportingGate(); + quest.things[this.size - 5] = this.makeTeleportingGate(); + for(var i = 0; i < 7; i++){ + if(i != 3){ + this.buffers[i][this.size - 3] = this.makeTeleportingGate(); + this.buffers[i][this.size - 5] = this.makeTeleportingGate(); + } + } + + // We set the steps + this.addRockStep = 0; + this.step = 0; + + // We set the time spent + this.timeSpent = 0; + }, + + teleportCharacter : function(gatesIndex){ + var index = quest.getCharacterIndex(); + + quest.things[0] = quest.things[index]; + quest.things[index] = quest.makeNoneThing(); + + quest.things[gatesIndex] = quest.makeNoneThing(); + for(var i = 0; i < 7; i++){ + if(i != this.bufferPosition){ + this.buffers[i][gatesIndex] = quest.makeNoneThing(); + } + } + }, + + checkStep1 : function(){ + var index = quest.getCharacterIndex(); + + if(index >= this.size - 7) this.step = 1; + }, + + checkStep2 : function(){ + for(var i = 0; i < 7; i++){ + if((i != this.bufferPosition && this.buffers[i][this.size-5].text != " * ") || (i == this.bufferPosition && quest.things[this.size-5].text != " * ")){ + this.teleportCharacter(this.size-5); + this.step = 2; + break; + } + } + }, + + checkStep3 : function(){ + var index = quest.getCharacterIndex(); + + if(index >= this.size - 5) this.step = 3; + }, + + checkStep4 : function(){ + for(var i = 0; i < 7; i++){ + if((i != this.bufferPosition && this.buffers[i][this.size-3].text != " * ") || (i == this.bufferPosition && quest.things[this.size-3].text != " * ")){ + this.teleportCharacter(this.size-3); + this.step = 4; + this.timeSpent = 0; + break; + } + } + }, + + goDown : function(){ + var pos = this.bufferPosition; + + // If we're questing the hell + if(quest.weAreQuestingRightNow && land.getLandIndexFromName("Hell") == quest.currentLandIndex){ + // If we're not already at the buffer 2 + if(this.bufferPosition != 6){ + // If we were able to swap, change the buffer position + if(this.swapBufferAndQuestThings(pos, pos + 1)){ + this.bufferPosition += 1; + this.checkDevil(); + quest.updateOnPage(); + } + } + } + }, + + goUp : function(){ + var pos = this.bufferPosition; + + // If we're questing the hell + if(quest.weAreQuestingRightNow && land.getLandIndexFromName("Hell") == quest.currentLandIndex){ + // If we're not already at the buffer 0 + if(this.bufferPosition != 0){ + // If we were able to swap, change the buffer position + if(this.swapBufferAndQuestThings(pos, pos - 1)){ + this.bufferPosition -= 1; + this.checkDevil(); + quest.updateOnPage(); + } + } + } + }, + + swapBufferAndQuestThings : function(now, after){ + var index = quest.getCharacterIndex(); + var character = quest.things[index]; + + // If we will be able to move on the "after" buffer, we swap (if we have some hp, too) + if(this.buffers[after][index].type == "none" && character.hp > 0){ + // We save the quest things in the old buffer + this.buffers[now] = quest.things.slice(0); + // We delete the character from the old buffer + this.buffers[now][index] = quest.makeNoneThing(); + // We put the new buffer into the quest things + quest.things = this.buffers[after].slice(0); + // We add the character + quest.things[index] = character; + // We return true + return true; + } + + // Else we return false + return false; + }, + + checkDevil : function(){ + // If the devil isn't on the line of the character + if(quest.things[this.size-1].text != "DEV"){ + // We move it + for(var i = 0; i < 7; i++){ + if(i != this.bufferPosition && this.buffers[i][this.size-1].text == "DEV"){ + quest.things[this.size-1] = this.buffers[i][this.size-1]; + this.buffers[i][this.size-1] = quest.makeNoneThing(); + break; + } + } + } + }, + + makeDevil : function(){ + return land.createMob("DEV", 250, 250, "religion", "It's the devil itself!", [drops.createDrop("candies", 100000)]); + }, + + makeTeleportingGate : function(){ + return land.createMob(" * ", 120, 120, "none", "A teleporting gate, made by the devil itself.", []); + }, + + makeMiddleCreature : function(){ + switch(this.step){ + case 0: + if(random.oneChanceOutOf(3)){ + return this.makeDemon(); + } + break; + case 2: + if(random.oneChanceOutOf(4)){ + return this.makeBanshee(); + } + break; + case 3: + if(random.oneChanceOutOf(3)){ + return castleKeep.makeFireball(); + } + break; + case 4: + if(this.timeSpent < 50 && this.timeSpent % 2 == 0){ + return castleStairs.makeGhost(); + } + else if(this.timeSpent < 70){ + // nothing + } + else if(this.timeSpent < 90){ + if(random.oneChanceOutOf(5)){ + return castleKeep.makeFireball(); + } + } + else if(this.timeSpent < 110){ + if(random.oneChanceOutOf(4)){ + return castleKeep.makeFireball(); + } + } + else if(this.timeSpent < 130){ + if(random.oneChanceOutOf(3)){ + return castleKeep.makeFireball(); + } + } + else if(this.timeSpent < 170){ + if(random.oneChanceOutOf(2)){ + return castleKeep.makeFireball(); + } + } + else{ + return castleKeep.makeFireball(); + } + break; + } + + return quest.makeNoneThing(); + }, + + makeSideCreature : function(){ + switch(this.step){ + case 0: + return this.makeMiddleCreature(); + break; + case 2: + if(random.oneChanceOutOf(5)){ + return castleStairs.makeGhost(); + } + break; + case 3: + if(random.oneChanceOutOf(4)){} // nothing + else{ + return castleStairs.makeGhost(); + } + break; + case 4: + return this.makeMiddleCreature(); + break; + } + + return quest.makeNoneThing(); + }, + + makeDemon : function(){ + return land.createMob("DEM", 90, 90, "demon claws", "A demon.", []); + }, + + makeBanshee : function(){ + return land.createMob("BSH", 160, 160, "?", "A banshee, omen of death.", []); + }, + + makeDoor : function(){ + return land.createMob("|-|", 300, 300, "none", "A strong door. Hard to break.", []); + }, + + makeSpikyDoor : function(){ + return land.createMob("|-|", 300, 300, "spikes", "A strong door. Hard to break. There are spikes on it, it hurts!", []); + }, + + getText : function(){ + // Create the text var + var text = ""; + + // Add the i & k instructions + text += "Press i to go up and k to go down. (if it doesn't work, click on the page to gain focus)"; + + text += "\n"; + + // Open the span + text += ""; + + text += "\n"; + + // We add buffers + for(var i = 0; i < 7; i++){ + if(i != this.bufferPosition){ + for(var j = 0; j < this.size; j++){ + if(this.buffers[i][j].type != "none"){ + text += this.buffers[i][j].text; + } + else text += " "; + } + } + else{ + for(var j = 0; j < this.size; j++){ + if(quest.things[j].type != "none"){ + text += quest.things[j].text; + } + else text += " "; + } + } + + text += "\n"; + } + + // We make the lava lake + for(var i = 0; i < Math.floor(this.size/2); i++){ + switch(this.lavaLakeStep){ + case 0: case 1: text += "_.-'-."; break; + case 2: case 3: text += "._.-'-"; break; + case 4: case 5: text += "-._.-'"; break; + case 6: case 7: text += "'-._.-"; break; + case 8: case 9: text += "-'-._."; break; + case 10: case 11: text += ".-'-._"; break; + } + } + + // Close the span + text += "" + + return text; + } + +}; diff --git a/static/candies/scripts/htmlInteraction.js b/static/candies/scripts/htmlInteraction.js new file mode 100755 index 00000000..82a50be3 --- /dev/null +++ b/static/candies/scripts/htmlInteraction.js @@ -0,0 +1,76 @@ +var htmlInteraction = { + + setElementDisplay : function(id, display){ + document.getElementById(id).style.display = display; + }, + + getElement : function(id){ + return document.getElementById(id); + }, + + setElementVisibility : function(id, bool){ + if(bool) document.getElementById(id).style.visibility = "visible"; + else document.getElementById(id).style.visibility = "hidden"; + }, + + isElementVisible : function(id){ + if(document.getElementById(id).style.visibility == "hidden") return false; + return true; + }, + + setInnerHtml : function(id, value){ + document.getElementById(id).innerHTML = value; + }, + + disableButton : function(id){ + this.getElement(id).disabled = "disabled"; + }, + + disableButtonClass : function(id){ + var arr = document.getElementsByClassName(id); + for(var i = 0; i < arr.length; i++){ + arr[i].disabled = "disabled"; + } + }, + + enableButton : function(id){ + this.getElement(id).disabled = ""; + }, + + enableButtonClass : function(id){ + var arr = document.getElementsByClassName(id); + for(var i = 0; i < arr.length; i++){ + arr[i].disabled = ""; + } + }, + + showButton : function(id){ + htmlInteraction.setElementVisibility(id, true); + }, + + showButtonClass : function(id){ + var arr = document.getElementsByClassName(id); + for(var i = 0; i < arr.length; i++){ + arr[i].style.visibility = "visible"; + } + }, + + hideButton : function(id){ + htmlInteraction.setElementVisibility(id, false); + }, + + hideButtonClass : function(id){ + var arr = document.getElementsByClassName(id); + for(var i = 0; i < arr.length; i++){ + arr[i].style.visibility = "hidden"; + } + }, + + setButtonOnclick : function(id, value){ + this.getElement(id).onclick = value; + }, + + focusElement : function(id){ + this.getElement(id).focus(); + } +}; diff --git a/static/candies/scripts/hut.js b/static/candies/scripts/hut.js new file mode 100755 index 00000000..6f6ff7da --- /dev/null +++ b/static/candies/scripts/hut.js @@ -0,0 +1,155 @@ +var hut = { + + // Variables + shown : false, + speech : "", + step : 0, + + // Functions + throwLollipops : function(){ + if(lollipops.nbrOwned >= 10){ + lollipops.setNbrOwned(lollipops.nbrOwned - 10); + this.setStep(1); + this.setSpeech("I see that you have lollipops... I could cast spells for you, in exchange of some sweets... I looove lollipops!"); + this.updateOnPage(); + } + }, + + acceptProposition : function(){ + this.setStep(2); + this.setSpeech("See for yourself. My prices are high, but the spells are great!"); + this.updateOnPage(); + }, + + setStep : function(value){ + this.step = value; + }, + + setSpeech : function(value){ + this.speech = value; + }, + + updateOnPage : function(){ + var text = ""; + + // Hut drawing + switch(this.step){ + case 0: + text += "\ +/\\)\\))/\\(/|)\\))/((||\\/)\\)\\\n\ +(/((\\///)))/(\\\\(/)\\\\\\\\\\)\\)\n\ +.__/(|_/| |\\_|)/__.\n\ + | |_/| |\\_| |\n\ + | |_/| |\\_| |\n\ +.__| |_/| |\\_| |__.\n\ + |_/| |\\_|\n\ + |_/| |\\_|\n\ +._ |_/|________|\\_| _.\n\ + '-.|_/ \\_|.-'\ +" + + text += "\n\n"; + break; + default: + text += "\ +/\\)\\))/\\(/|)\\))/((||\\/)\\)\\\n\ +(/((\\///)))/(\\\\(/)\\\\\\\\\\)\\)\n\ +.__/(|_/| _|\\_ |\\_|)/__.\n\ + | |_/| (\"} |\\_| |\n\ + | |_/|i_.-@-._|\\_| |\n\ +.__| |_/|8--, .-|\\_| |__.\n\ + |_/|I /==\\ |\\_|\n\ + |_/|I | \\|\\_|\n\ +._ |_/|I__/___\\|\\_| _.\n\ + '-.|_/ \\_|.-'\n\n\ +" + break; + } + + // Speech & spells drawing + switch(this.step){ + case 1: + text += speech.makeSpeechFromText(this.speech, 24, ""); + text += "\n\n"; + break; + case 2: + text += speech.makeSpeechFromText(this.speech, 24, ""); + text += this.getSpellsButtons(); + break; + } + + text += "\n\n"; + + htmlInteraction.setInnerHtml("map", text); + + if(this.step == 0) buttons.checkHut(); + if(this.step == 2) buttons.checkHut(); + }, + + getSpellsButtons : function(){ + var text = "\n"; + + for(var i = 0; i < spells.list.length; i++){ + text += "\n"; + } + + // We maybe add the surpass yourself button + if(quest.maxLandOrder == 7 && yourself.canSurpass == false){ + text += "\n"; + text += "\n"; + } + + return text; + }, + + surpass : function(){ + if(lollipops.nbrOwned >= 1000000){ + lollipops.setNbrOwned(lollipops.nbrOwned - 1000000); + this.setSpeech("You are now able to surpass yourself. Congratulations!"); + yourself.setCanSurpass(true); + this.updateOnPage(); + } + }, + + canThisSpellBeUsed : function(id){ + // Check the conditions, return false if some of the conditions are not met + for(var i = 0; i < spells.list[id].conditions.length; i++){ + switch(spells.list[id].conditions[i]){ + case "specialSword": + if(sword.specialSword == false) return false; + break; + } + } + + // Check the price, return false if the price isn't met + if(spells.list[id].price() > lollipops.nbrOwned) return false; + + return true; + }, + + enter : function(){ + objects.leave(); + + this.shown = true; + + this.updateOnPage(); + }, + + leave : function(){ + this.shown = false; + + htmlInteraction.setInnerHtml("map", ""); + //buttons.enableHomeButtons(); + }, + + useSpell : function(id){ + if(lollipops.nbrOwned >= spells.list[id].price()){ + lollipops.setNbrOwned(lollipops.nbrOwned - spells.list[id].price()); + this.setSpeech(spells.list[id].speech); + spells.list[id].effect(); + this.updateOnPage(); + inventory.updateOnPage(); + } + } + +}; diff --git a/static/candies/scripts/inventory.js b/static/candies/scripts/inventory.js new file mode 100755 index 00000000..b0fef79a --- /dev/null +++ b/static/candies/scripts/inventory.js @@ -0,0 +1,161 @@ +var inventory = { + + // Variables + magicianHatLetter : "", + + // Functions + setMagicianHatLetter : function(value){ + this.magicianHatLetter = value; + }, + + updateOnPage : function(){ + // Check for the magician hat letter : if we have the magician hat but no letter is set yet + if(objects.list.magicianHat.have && this.magicianHatLetter == ""){ + this.setMagicianHatLetter(" " + random.getRandomLetter()); + } + + // Sword + switch(sword.name){ + case "wooden sword": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiWoodenSwordWithoutButton); break; + case "copper sword": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiCopperSwordWithoutButton); break; + case "iron sword": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiIronSwordWithoutButton); break; + case "silver sword": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiSilverSwordWithoutButton); break; + case "diamond sword": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiDiamondSwordWithoutButton); break; + case "candy diamond sword": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiCandyDiamondSword); break; + case "polished candy diamond sword": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiPolishedCandyDiamondSword); break; + case "chocolate sword": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiChocolateSword); break; + case "sharp chocolate sword": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiSharpChocolateSword); break; + case "Sword of Flames": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiSwordOfFlames + "\n\nLevel : " + sword.specialPower); break; + case "Sword of Life": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiSwordOfLife + "\n\nLevel : " + sword.specialPower); break; + case "Sword of Summoning": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiSwordOfSummoning + "\n\nLevel : " + sword.specialPower); break; + case "Sword of Liflamesummoning": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiSwordOfLiflamesummoning + "\n\nLevel : " + sword.specialPower); break; + case "Sword of Randomness": htmlInteraction.setInnerHtml("sword_without_button", sword.asciiSwordOfRandomness + "\n\nLevel : infinite + " + sword.specialPower); break; + } + + // Objects + this.updateObjectOnPage("inventory_key", objects.list.key, this.asciiKey, this.asciiNoObject); + this.updateObjectOnPage("inventory_boots", objects.list.boots, this.asciiBoots, this.asciiNoObject); + this.updateObjectOnPage("inventory_magician_hat", objects.list.magicianHat, this.magicianHatLetter + "\n" + this.asciiMagicianHat, this.asciiNoObject); + this.updateObjectOnPage("inventory_pink_ring", objects.list.pinkRing, this.asciiPinkRing, this.asciiNoObject); + this.updateObjectOnPage("inventory_candies_converter", objects.list.candiesConverter, this.asciiCandiesConverter, this.asciiNoObject); + this.updateObjectOnPage("inventory_plate_armour", objects.list.plateArmour, this.asciiPlateArmour, this.asciiNoObject); + this.updateObjectOnPage("inventory_cauldron", objects.list.cauldron, this.asciiCauldron, this.asciiNoObject); + this.updateObjectOnPage("inventory_magical_horn", objects.list.magicalHorn, this.asciiMagicalHorn, this.asciiNoObject); + this.updateObjectOnPage("inventory_horn_of_plenty", objects.list.hornOfPlenty, this.asciiHornOfPlenty, this.asciiNoObject); + this.updateObjectOnPage("inventory_old_amulet", objects.list.oldAmulet, this.asciiOldAmulet, this.asciiNoObject); + + if(developperComputer.won){ + htmlInteraction.setInnerHtml("inventory_won1", "
    " + this.asciiWon1 + "
    "); + htmlInteraction.setInnerHtml("inventory_won2", "
    " + this.asciiWon2 + "
    "); + htmlInteraction.showButton("hardmode"); + } + else{ + htmlInteraction.setInnerHtml("inventory_won1", "
    " + this.asciiNoObject + "
    "); + htmlInteraction.setInnerHtml("inventory_won2", "
    " + this.asciiNoObject + "
    "); + htmlInteraction.hideButton("hardmode"); + } + + // Maps + this.updateObjectOnPage("inventory_swamp_map", objects.list.swampMap, this.asciiSwampMap, this.asciiNoObject); + this.updateObjectOnPage("inventory_hut_map", objects.list.hutMap, this.asciiHutMap, this.asciiNoObject); + this.updateObjectOnPage("inventory_forge_map", objects.list.forgeMap, this.asciiForgeMap, this.asciiNoObject); + this.updateObjectOnPage("inventory_well_map", objects.list.wellMap, this.asciiWellMap, this.asciiNoObject); + }, + + updateObjectOnPage : function(id, obj, ascii, asciiNoObject){ + if(obj.have){ + htmlInteraction.setInnerHtml(id, "
    " + ascii + "
    " + obj.name + "
    " + obj.description); + } + else{ + htmlInteraction.setInnerHtml(id, "
    " + asciiNoObject + "
    "); + } + }, + + // Ascii art + + asciiKey : " __\n\ +/o \\_____\n\ +\\__/-=\"=\"`", + + asciiBoots : " ____\n\ + \\ _|__\n\ + __)| /\n\ +(___| (__\n\ + (_-___)", + + asciiMagicianHat : " / \\\n\ + / \\\n\ + / \\\n\ + /_______\\", + + asciiPinkRing : " .--.\n\ + // \\\\\n\ + \\\\__//\n\ + \'--\'", + + asciiSwampMap : " _________\n\ +| |\n\ +| SWAMP |\n\ +| ---> |\n\ +|.-._.-._.|", + + asciiHutMap : " _________\n\ +| __ |\n\ +| /lp\\ -> |\n\ +| |__| |\n\ +|._.-._.__|", + + asciiForgeMap : " _________\n\ +/ anvil \\\n\ +| this |\n\ +| <-- way |\n\ +\\_________/", + + asciiWellMap : " .-~-~-~-.\n\ +! ~ ~ !\n\ +!~ ~ !\n\ +! ~ ~ ~ !\n\ + \'-~-~-~-\'", + + asciiCandiesConverter : " ______\n\ + /+| |+\\\n\ + |=={==}==|\n\ + \\_|__|_/", + + asciiPlateArmour : "-;`\\..../`;-\n\ + |...::...|\n\ + /\'\'\'::\'\'\'\\\n\ +/\\ :: /\\\n\ + >._::_.<", + + asciiCauldron : " ________\n\ + (________)\n\ + ) (\n\ + / \\\n\ +| |\n\ +\\__________/", + + asciiMagicalHorn : " \\.\n\ + \\\'.\n\ + \\ \'.\n\ + \\,-\'", + + asciiHornOfPlenty : " .\\\n\ + \\\'.\n\ + \\ \'.\n\ + \\__)", + + asciiOldAmulet : " / \\\n\ + o o\n\ + \\_/\n\ + .^.\n\ + \'cnd\'\n\ + \'. .\'", + + asciiWon1 : "Bravo!\nYou won\nthe game :)\nYou now have\nall the\ncandies in\nthe world.", + + asciiWon2 : "(you can now\nask Scrabble\nfor a real\ncandy, if you\nfind him!)", + + asciiNoObject : " \n \n " + +}; diff --git a/static/candies/scripts/jquery-1.9.1.min.js b/static/candies/scripts/jquery-1.9.1.min.js new file mode 100755 index 00000000..006e9531 --- /dev/null +++ b/static/candies/scripts/jquery-1.9.1.min.js @@ -0,0 +1,5 @@ +/*! jQuery v1.9.1 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license +//@ sourceMappingURL=jquery.min.map +*/(function(e,t){var n,r,i=typeof t,o=e.document,a=e.location,s=e.jQuery,u=e.$,l={},c=[],p="1.9.1",f=c.concat,d=c.push,h=c.slice,g=c.indexOf,m=l.toString,y=l.hasOwnProperty,v=p.trim,b=function(e,t){return new b.fn.init(e,t,r)},x=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,w=/\S+/g,T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,k=/^[\],:{}\s]*$/,E=/(?:^|:|,)(?:\s*\[)+/g,S=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,A=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,j=/^-ms-/,D=/-([\da-z])/gi,L=function(e,t){return t.toUpperCase()},H=function(e){(o.addEventListener||"load"===e.type||"complete"===o.readyState)&&(q(),b.ready())},q=function(){o.addEventListener?(o.removeEventListener("DOMContentLoaded",H,!1),e.removeEventListener("load",H,!1)):(o.detachEvent("onreadystatechange",H),e.detachEvent("onload",H))};b.fn=b.prototype={jquery:p,constructor:b,init:function(e,n,r){var i,a;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof b?n[0]:n,b.merge(this,b.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:o,!0)),C.test(i[1])&&b.isPlainObject(n))for(i in n)b.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(a=o.getElementById(i[2]),a&&a.parentNode){if(a.id!==i[2])return r.find(e);this.length=1,this[0]=a}return this.context=o,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):b.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),b.makeArray(e,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return h.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=b.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return b.each(this,e,t)},ready:function(e){return b.ready.promise().done(e),this},slice:function(){return this.pushStack(h.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(b.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:d,sort:[].sort,splice:[].splice},b.fn.init.prototype=b.fn,b.extend=b.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},u=2),"object"==typeof s||b.isFunction(s)||(s={}),l===u&&(s=this,--u);l>u;u++)if(null!=(o=arguments[u]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(b.isPlainObject(r)||(n=b.isArray(r)))?(n?(n=!1,a=e&&b.isArray(e)?e:[]):a=e&&b.isPlainObject(e)?e:{},s[i]=b.extend(c,a,r)):r!==t&&(s[i]=r));return s},b.extend({noConflict:function(t){return e.$===b&&(e.$=u),t&&e.jQuery===b&&(e.jQuery=s),b},isReady:!1,readyWait:1,holdReady:function(e){e?b.readyWait++:b.ready(!0)},ready:function(e){if(e===!0?!--b.readyWait:!b.isReady){if(!o.body)return setTimeout(b.ready);b.isReady=!0,e!==!0&&--b.readyWait>0||(n.resolveWith(o,[b]),b.fn.trigger&&b(o).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===b.type(e)},isArray:Array.isArray||function(e){return"array"===b.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[m.call(e)]||"object":typeof e},isPlainObject:function(e){if(!e||"object"!==b.type(e)||e.nodeType||b.isWindow(e))return!1;try{if(e.constructor&&!y.call(e,"constructor")&&!y.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||y.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||o;var r=C.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=b.buildFragment([e],t,i),i&&b(i).remove(),b.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=b.trim(n),n&&k.test(n.replace(S,"@").replace(A,"]").replace(E,"")))?Function("return "+n)():(b.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||b.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&b.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(j,"ms-").replace(D,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:v&&!v.call("\ufeff\u00a0")?function(e){return null==e?"":v.call(e)}:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?b.merge(n,"string"==typeof e?[e]:e):d.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(g)return g.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return f.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),b.isFunction(e)?(r=h.call(arguments,2),i=function(){return e.apply(n||this,r.concat(h.call(arguments)))},i.guid=e.guid=e.guid||b.guid++,i):t},access:function(e,n,r,i,o,a,s){var u=0,l=e.length,c=null==r;if("object"===b.type(r)){o=!0;for(u in r)b.access(e,n,u,r[u],!0,a,s)}else if(i!==t&&(o=!0,b.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(b(e),n)})),n))for(;l>u;u++)n(e[u],r,s?i:i.call(e[u],u,n(e[u],r)));return o?e:c?n.call(e):l?n(e[0],r):a},now:function(){return(new Date).getTime()}}),b.ready.promise=function(t){if(!n)if(n=b.Deferred(),"complete"===o.readyState)setTimeout(b.ready);else if(o.addEventListener)o.addEventListener("DOMContentLoaded",H,!1),e.addEventListener("load",H,!1);else{o.attachEvent("onreadystatechange",H),e.attachEvent("onload",H);var r=!1;try{r=null==e.frameElement&&o.documentElement}catch(i){}r&&r.doScroll&&function a(){if(!b.isReady){try{r.doScroll("left")}catch(e){return setTimeout(a,50)}q(),b.ready()}}()}return n.promise(t)},b.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=b.type(e);return b.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=b(o);var _={};function F(e){var t=_[e]={};return b.each(e.match(w)||[],function(e,n){t[n]=!0}),t}b.Callbacks=function(e){e="string"==typeof e?_[e]||F(e):b.extend({},e);var n,r,i,o,a,s,u=[],l=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=u.length,n=!0;u&&o>a;a++)if(u[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,u&&(l?l.length&&c(l.shift()):r?u=[]:p.disable())},p={add:function(){if(u){var t=u.length;(function i(t){b.each(t,function(t,n){var r=b.type(n);"function"===r?e.unique&&p.has(n)||u.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=u.length:r&&(s=t,c(r))}return this},remove:function(){return u&&b.each(arguments,function(e,t){var r;while((r=b.inArray(t,u,r))>-1)u.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?b.inArray(e,u)>-1:!(!u||!u.length)},empty:function(){return u=[],this},disable:function(){return u=l=r=t,this},disabled:function(){return!u},lock:function(){return l=t,r||p.disable(),this},locked:function(){return!l},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!u||i&&!l||(n?l.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},b.extend({Deferred:function(e){var t=[["resolve","done",b.Callbacks("once memory"),"resolved"],["reject","fail",b.Callbacks("once memory"),"rejected"],["notify","progress",b.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return b.Deferred(function(n){b.each(t,function(t,o){var a=o[0],s=b.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&b.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?b.extend(e,r):r}},i={};return r.pipe=r.then,b.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=h.call(arguments),r=n.length,i=1!==r||e&&b.isFunction(e.promise)?r:0,o=1===i?e:b.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?h.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,u,l;if(r>1)for(s=Array(r),u=Array(r),l=Array(r);r>t;t++)n[t]&&b.isFunction(n[t].promise)?n[t].promise().done(a(t,l,n)).fail(o.reject).progress(a(t,u,s)):--i;return i||o.resolveWith(l,n),o.promise()}}),b.support=function(){var t,n,r,a,s,u,l,c,p,f,d=o.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="
    a",n=d.getElementsByTagName("*"),r=d.getElementsByTagName("a")[0],!n||!r||!n.length)return{};s=o.createElement("select"),l=s.appendChild(o.createElement("option")),a=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={getSetAttribute:"t"!==d.className,leadingWhitespace:3===d.firstChild.nodeType,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:"/a"===r.getAttribute("href"),opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:!!a.value,optSelected:l.selected,enctype:!!o.createElement("form").enctype,html5Clone:"<:nav>"!==o.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===o.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},a.checked=!0,t.noCloneChecked=a.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!l.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}a=o.createElement("input"),a.setAttribute("value",""),t.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),t.radioValue="t"===a.value,a.setAttribute("checked","t"),a.setAttribute("name","t"),u=o.createDocumentFragment(),u.appendChild(a),t.appendChecked=a.checked,t.checkClone=u.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;return d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip,b(function(){var n,r,a,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",u=o.getElementsByTagName("body")[0];u&&(n=o.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",u.appendChild(n).appendChild(d),d.innerHTML="
    t
    ",a=d.getElementsByTagName("td"),a[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===a[0].offsetHeight,a[0].style.display="",a[1].style.display="none",t.reliableHiddenOffsets=p&&0===a[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=4===d.offsetWidth,t.doesNotIncludeMarginInBodyOffset=1!==u.offsetTop,e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(o.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="
    ",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(u.style.zoom=1)),u.removeChild(n),n=d=a=r=null)}),n=s=u=l=r=a=null,t}();var O=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,B=/([A-Z])/g;function P(e,n,r,i){if(b.acceptData(e)){var o,a,s=b.expando,u="string"==typeof n,l=e.nodeType,p=l?b.cache:e,f=l?e[s]:e[s]&&s;if(f&&p[f]&&(i||p[f].data)||!u||r!==t)return f||(l?e[s]=f=c.pop()||b.guid++:f=s),p[f]||(p[f]={},l||(p[f].toJSON=b.noop)),("object"==typeof n||"function"==typeof n)&&(i?p[f]=b.extend(p[f],n):p[f].data=b.extend(p[f].data,n)),o=p[f],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[b.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[b.camelCase(n)])):a=o,a}}function R(e,t,n){if(b.acceptData(e)){var r,i,o,a=e.nodeType,s=a?b.cache:e,u=a?e[b.expando]:b.expando;if(s[u]){if(t&&(o=n?s[u]:s[u].data)){b.isArray(t)?t=t.concat(b.map(t,b.camelCase)):t in o?t=[t]:(t=b.camelCase(t),t=t in o?[t]:t.split(" "));for(r=0,i=t.length;i>r;r++)delete o[t[r]];if(!(n?$:b.isEmptyObject)(o))return}(n||(delete s[u].data,$(s[u])))&&(a?b.cleanData([e],!0):b.support.deleteExpando||s!=s.window?delete s[u]:s[u]=null)}}}b.extend({cache:{},expando:"jQuery"+(p+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?b.cache[e[b.expando]]:e[b.expando],!!e&&!$(e)},data:function(e,t,n){return P(e,t,n)},removeData:function(e,t){return R(e,t)},_data:function(e,t,n){return P(e,t,n,!0)},_removeData:function(e,t){return R(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&b.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),b.fn.extend({data:function(e,n){var r,i,o=this[0],a=0,s=null;if(e===t){if(this.length&&(s=b.data(o),1===o.nodeType&&!b._data(o,"parsedAttrs"))){for(r=o.attributes;r.length>a;a++)i=r[a].name,i.indexOf("data-")||(i=b.camelCase(i.slice(5)),W(o,i,s[i]));b._data(o,"parsedAttrs",!0)}return s}return"object"==typeof e?this.each(function(){b.data(this,e)}):b.access(this,function(n){return n===t?o?W(o,e,b.data(o,e)):null:(this.each(function(){b.data(this,e,n)}),t)},null,n,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){b.removeData(this,e)})}});function W(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(B,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:O.test(r)?b.parseJSON(r):r}catch(o){}b.data(e,n,r)}else r=t}return r}function $(e){var t;for(t in e)if(("data"!==t||!b.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}b.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=b._data(e,n),r&&(!i||b.isArray(r)?i=b._data(e,n,b.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=b.queue(e,t),r=n.length,i=n.shift(),o=b._queueHooks(e,t),a=function(){b.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),o.cur=i,i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return b._data(e,n)||b._data(e,n,{empty:b.Callbacks("once memory").add(function(){b._removeData(e,t+"queue"),b._removeData(e,n)})})}}),b.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?b.queue(this[0],e):n===t?this:this.each(function(){var t=b.queue(this,e,n);b._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&b.dequeue(this,e)})},dequeue:function(e){return this.each(function(){b.dequeue(this,e)})},delay:function(e,t){return e=b.fx?b.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=b.Deferred(),a=this,s=this.length,u=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=b._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(u));return u(),o.promise(n)}});var I,z,X=/[\t\r\n]/g,U=/\r/g,V=/^(?:input|select|textarea|button|object)$/i,Y=/^(?:a|area)$/i,J=/^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,G=/^(?:checked|selected)$/i,Q=b.support.getSetAttribute,K=b.support.input;b.fn.extend({attr:function(e,t){return b.access(this,b.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){b.removeAttr(this,e)})},prop:function(e,t){return b.access(this,b.prop,e,t,arguments.length>1)},removeProp:function(e){return e=b.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,u="string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=b.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,u=0===arguments.length||"string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?b.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,r="boolean"==typeof t;return b.isFunction(e)?this.each(function(n){b(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var o,a=0,s=b(this),u=t,l=e.match(w)||[];while(o=l[a++])u=r?u:!s.hasClass(o),s[u?"addClass":"removeClass"](o)}else(n===i||"boolean"===n)&&(this.className&&b._data(this,"__className__",this.className),this.className=this.className||e===!1?"":b._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(X," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=b.isFunction(e),this.each(function(n){var o,a=b(this);1===this.nodeType&&(o=i?e.call(this,n,a.val()):e,null==o?o="":"number"==typeof o?o+="":b.isArray(o)&&(o=b.map(o,function(e){return null==e?"":e+""})),r=b.valHooks[this.type]||b.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=b.valHooks[o.type]||b.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(U,""):null==n?"":n)}}}),b.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,u=0>i?s:o?i:0;for(;s>u;u++)if(n=r[u],!(!n.selected&&u!==i||(b.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&b.nodeName(n.parentNode,"optgroup"))){if(t=b(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n=b.makeArray(t);return b(e).find("option").each(function(){this.selected=b.inArray(b(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attr:function(e,n,r){var o,a,s,u=e.nodeType;if(e&&3!==u&&8!==u&&2!==u)return typeof e.getAttribute===i?b.prop(e,n,r):(a=1!==u||!b.isXMLDoc(e),a&&(n=n.toLowerCase(),o=b.attrHooks[n]||(J.test(n)?z:I)),r===t?o&&a&&"get"in o&&null!==(s=o.get(e,n))?s:(typeof e.getAttribute!==i&&(s=e.getAttribute(n)),null==s?t:s):null!==r?o&&a&&"set"in o&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r):(b.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(w);if(o&&1===e.nodeType)while(n=o[i++])r=b.propFix[n]||n,J.test(n)?!Q&&G.test(n)?e[b.camelCase("default-"+n)]=e[r]=!1:e[r]=!1:b.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!b.support.radioValue&&"radio"===t&&b.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!b.isXMLDoc(e),a&&(n=b.propFix[n]||n,o=b.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):V.test(e.nodeName)||Y.test(e.nodeName)&&e.href?0:t}}}}),z={get:function(e,n){var r=b.prop(e,n),i="boolean"==typeof r&&e.getAttribute(n),o="boolean"==typeof r?K&&Q?null!=i:G.test(n)?e[b.camelCase("default-"+n)]:!!i:e.getAttributeNode(n);return o&&o.value!==!1?n.toLowerCase():t},set:function(e,t,n){return t===!1?b.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&b.propFix[n]||n,n):e[b.camelCase("default-"+n)]=e[n]=!0,n}},K&&Q||(b.attrHooks.value={get:function(e,n){var r=e.getAttributeNode(n);return b.nodeName(e,"input")?e.defaultValue:r&&r.specified?r.value:t},set:function(e,n,r){return b.nodeName(e,"input")?(e.defaultValue=n,t):I&&I.set(e,n,r)}}),Q||(I=b.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&("id"===n||"name"===n||"coords"===n?""!==r.value:r.specified)?r.value:t},set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},b.attrHooks.contenteditable={get:I.get,set:function(e,t,n){I.set(e,""===t?!1:t,n)}},b.each(["width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}})})),b.support.hrefNormalized||(b.each(["href","src","width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return null==r?t:r}})}),b.each(["href","src"],function(e,t){b.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}})),b.support.style||(b.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),b.support.optSelected||(b.propHooks.selected=b.extend(b.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),b.support.enctype||(b.propFix.enctype="encoding"),b.support.checkOn||b.each(["radio","checkbox"],function(){b.valHooks[this]={get:function(e){return null===e.getAttribute("value")?"on":e.value}}}),b.each(["radio","checkbox"],function(){b.valHooks[this]=b.extend(b.valHooks[this],{set:function(e,n){return b.isArray(n)?e.checked=b.inArray(b(e).val(),n)>=0:t}})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}b.event={global:{},add:function(e,n,r,o,a){var s,u,l,c,p,f,d,h,g,m,y,v=b._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=b.guid++),(u=v.events)||(u=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof b===i||e&&b.event.triggered===e.type?t:b.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(w)||[""],l=n.length;while(l--)s=rt.exec(n[l])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),p=b.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=b.event.special[g]||{},d=b.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&b.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=u[g])||(h=u[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),b.event.global[g]=!0;e=null}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,p,f,d,h,g,m=b.hasData(e)&&b._data(e);if(m&&(c=m.events)){t=(t||"").match(w)||[""],l=t.length;while(l--)if(s=rt.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=b.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),u=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));u&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||b.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)b.event.remove(e,d+t[l],n,r,!0);b.isEmptyObject(c)&&(delete m.handle,b._removeData(e,"events"))}},trigger:function(n,r,i,a){var s,u,l,c,p,f,d,h=[i||o],g=y.call(n,"type")?n.type:n,m=y.call(n,"namespace")?n.namespace.split("."):[];if(l=f=i=i||o,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+b.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),u=0>g.indexOf(":")&&"on"+g,n=n[b.expando]?n:new b.Event(g,"object"==typeof n&&n),n.isTrigger=!0,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:b.makeArray(r,[n]),p=b.event.special[g]||{},a||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!a&&!p.noBubble&&!b.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(l=l.parentNode);l;l=l.parentNode)h.push(l),f=l;f===(i.ownerDocument||o)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((l=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(b._data(l,"events")||{})[n.type]&&b._data(l,"handle"),s&&s.apply(l,r),s=u&&l[u],s&&b.acceptData(l)&&s.apply&&s.apply(l,r)===!1&&n.preventDefault();if(n.type=g,!(a||n.isDefaultPrevented()||p._default&&p._default.apply(i.ownerDocument,r)!==!1||"click"===g&&b.nodeName(i,"a")||!b.acceptData(i)||!u||!i[g]||b.isWindow(i))){f=i[u],f&&(i[u]=null),b.event.triggered=g;try{i[g]()}catch(v){}b.event.triggered=t,f&&(i[u]=f)}return n.result}},dispatch:function(e){e=b.event.fix(e);var n,r,i,o,a,s=[],u=h.call(arguments),l=(b._data(this,"events")||{})[e.type]||[],c=b.event.special[e.type]||{};if(u[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=b.event.handlers.call(this,e,l),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((b.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,u),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],u=n.delegateCount,l=e.target;if(u&&l.nodeType&&(!e.button||"click"!==e.type))for(;l!=this;l=l.parentNode||this)if(1===l.nodeType&&(l.disabled!==!0||"click"!==e.type)){for(o=[],a=0;u>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?b(r,this).index(l)>=0:b.find(r,this,null,[l]).length),o[r]&&o.push(i);o.length&&s.push({elem:l,handlers:o})}return n.length>u&&s.push({elem:this,handlers:n.slice(u)}),s},fix:function(e){if(e[b.expando])return e;var t,n,r,i=e.type,a=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new b.Event(a),t=r.length;while(t--)n=r[t],e[n]=a[n];return e.target||(e.target=a.srcElement||o),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,a):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,a,s=n.button,u=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||o,a=i.documentElement,r=i.body,e.pageX=n.clientX+(a&&a.scrollLeft||r&&r.scrollLeft||0)-(a&&a.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(a&&a.scrollTop||r&&r.scrollTop||0)-(a&&a.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&u&&(e.relatedTarget=u===e.target?n.toElement:u),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},click:{trigger:function(){return b.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t}},focus:{trigger:function(){if(this!==o.activeElement&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===o.activeElement&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=b.extend(new b.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?b.event.trigger(i,null,t):b.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},b.removeEvent=o.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},b.Event=function(e,n){return this instanceof b.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&b.extend(this,n),this.timeStamp=e&&e.timeStamp||b.now(),this[b.expando]=!0,t):new b.Event(e,n)},b.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},b.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){b.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj; +return(!i||i!==r&&!b.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),b.support.submitBubbles||(b.event.special.submit={setup:function(){return b.nodeName(this,"form")?!1:(b.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=b.nodeName(n,"input")||b.nodeName(n,"button")?n.form:t;r&&!b._data(r,"submitBubbles")&&(b.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),b._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&b.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return b.nodeName(this,"form")?!1:(b.event.remove(this,"._submit"),t)}}),b.support.changeBubbles||(b.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(b.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),b.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),b.event.simulate("change",this,e,!0)})),!1):(b.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!b._data(t,"changeBubbles")&&(b.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||b.event.simulate("change",this.parentNode,e,!0)}),b._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return b.event.remove(this,"._change"),!Z.test(this.nodeName)}}),b.support.focusinBubbles||b.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){b.event.simulate(t,e.target,b.event.fix(e),!0)};b.event.special[t]={setup:function(){0===n++&&o.addEventListener(e,r,!0)},teardown:function(){0===--n&&o.removeEventListener(e,r,!0)}}}),b.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return b().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=b.guid++)),this.each(function(){b.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,b(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){b.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){b.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?b.event.trigger(e,n,r,!0):t}}),function(e,t){var n,r,i,o,a,s,u,l,c,p,f,d,h,g,m,y,v,x="sizzle"+-new Date,w=e.document,T={},N=0,C=0,k=it(),E=it(),S=it(),A=typeof t,j=1<<31,D=[],L=D.pop,H=D.push,q=D.slice,M=D.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},_="[\\x20\\t\\r\\n\\f]",F="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=F.replace("w","w#"),B="([*^$|!~]?=)",P="\\["+_+"*("+F+")"+_+"*(?:"+B+_+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+O+")|)|)"+_+"*\\]",R=":("+F+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+P.replace(3,8)+")*)|.*)\\)|)",W=RegExp("^"+_+"+|((?:^|[^\\\\])(?:\\\\.)*)"+_+"+$","g"),$=RegExp("^"+_+"*,"+_+"*"),I=RegExp("^"+_+"*([\\x20\\t\\r\\n\\f>+~])"+_+"*"),z=RegExp(R),X=RegExp("^"+O+"$"),U={ID:RegExp("^#("+F+")"),CLASS:RegExp("^\\.("+F+")"),NAME:RegExp("^\\[name=['\"]?("+F+")['\"]?\\]"),TAG:RegExp("^("+F.replace("w","w*")+")"),ATTR:RegExp("^"+P),PSEUDO:RegExp("^"+R),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+_+"*(even|odd|(([+-]|)(\\d*)n|)"+_+"*(?:([+-]|)"+_+"*(\\d+)|))"+_+"*\\)|)","i"),needsContext:RegExp("^"+_+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+_+"*((?:-\\d)?\\d*)"+_+"*\\)|)(?=[^-]|$)","i")},V=/[\x20\t\r\n\f]*[+~]/,Y=/^[^{]+\{\s*\[native code/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,G=/^(?:input|select|textarea|button)$/i,Q=/^h\d$/i,K=/'|\\/g,Z=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,et=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,tt=function(e,t){var n="0x"+t-65536;return n!==n?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(55296|n>>10,56320|1023&n)};try{q.call(w.documentElement.childNodes,0)[0].nodeType}catch(nt){q=function(e){var t,n=[];while(t=this[e++])n.push(t);return n}}function rt(e){return Y.test(e+"")}function it(){var e,t=[];return e=function(n,r){return t.push(n+=" ")>i.cacheLength&&delete e[t.shift()],e[n]=r}}function ot(e){return e[x]=!0,e}function at(e){var t=p.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}}function st(e,t,n,r){var i,o,a,s,u,l,f,g,m,v;if((t?t.ownerDocument||t:w)!==p&&c(t),t=t||p,n=n||[],!e||"string"!=typeof e)return n;if(1!==(s=t.nodeType)&&9!==s)return[];if(!d&&!r){if(i=J.exec(e))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&y(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return H.apply(n,q.call(t.getElementsByTagName(e),0)),n;if((a=i[3])&&T.getByClassName&&t.getElementsByClassName)return H.apply(n,q.call(t.getElementsByClassName(a),0)),n}if(T.qsa&&!h.test(e)){if(f=!0,g=x,m=t,v=9===s&&e,1===s&&"object"!==t.nodeName.toLowerCase()){l=ft(e),(f=t.getAttribute("id"))?g=f.replace(K,"\\$&"):t.setAttribute("id",g),g="[id='"+g+"'] ",u=l.length;while(u--)l[u]=g+dt(l[u]);m=V.test(e)&&t.parentNode||t,v=l.join(",")}if(v)try{return H.apply(n,q.call(m.querySelectorAll(v),0)),n}catch(b){}finally{f||t.removeAttribute("id")}}}return wt(e.replace(W,"$1"),t,n,r)}a=st.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},c=st.setDocument=function(e){var n=e?e.ownerDocument||e:w;return n!==p&&9===n.nodeType&&n.documentElement?(p=n,f=n.documentElement,d=a(n),T.tagNameNoComments=at(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),T.attributes=at(function(e){e.innerHTML="";var t=typeof e.lastChild.getAttribute("multiple");return"boolean"!==t&&"string"!==t}),T.getByClassName=at(function(e){return e.innerHTML="",e.getElementsByClassName&&e.getElementsByClassName("e").length?(e.lastChild.className="e",2===e.getElementsByClassName("e").length):!1}),T.getByName=at(function(e){e.id=x+0,e.innerHTML="
    ",f.insertBefore(e,f.firstChild);var t=n.getElementsByName&&n.getElementsByName(x).length===2+n.getElementsByName(x+0).length;return T.getIdNotName=!n.getElementById(x),f.removeChild(e),t}),i.attrHandle=at(function(e){return e.innerHTML="",e.firstChild&&typeof e.firstChild.getAttribute!==A&&"#"===e.firstChild.getAttribute("href")})?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},T.getIdNotName?(i.find.ID=function(e,t){if(typeof t.getElementById!==A&&!d){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){return e.getAttribute("id")===t}}):(i.find.ID=function(e,n){if(typeof n.getElementById!==A&&!d){var r=n.getElementById(e);return r?r.id===e||typeof r.getAttributeNode!==A&&r.getAttributeNode("id").value===e?[r]:t:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){var n=typeof e.getAttributeNode!==A&&e.getAttributeNode("id");return n&&n.value===t}}),i.find.TAG=T.tagNameNoComments?function(e,n){return typeof n.getElementsByTagName!==A?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},i.find.NAME=T.getByName&&function(e,n){return typeof n.getElementsByName!==A?n.getElementsByName(name):t},i.find.CLASS=T.getByClassName&&function(e,n){return typeof n.getElementsByClassName===A||d?t:n.getElementsByClassName(e)},g=[],h=[":focus"],(T.qsa=rt(n.querySelectorAll))&&(at(function(e){e.innerHTML="",e.querySelectorAll("[selected]").length||h.push("\\["+_+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||h.push(":checked")}),at(function(e){e.innerHTML="",e.querySelectorAll("[i^='']").length&&h.push("[*^$]="+_+"*(?:\"\"|'')"),e.querySelectorAll(":enabled").length||h.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),h.push(",.*:")})),(T.matchesSelector=rt(m=f.matchesSelector||f.mozMatchesSelector||f.webkitMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&at(function(e){T.disconnectedMatch=m.call(e,"div"),m.call(e,"[s!='']:x"),g.push("!=",R)}),h=RegExp(h.join("|")),g=RegExp(g.join("|")),y=rt(f.contains)||f.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},v=f.compareDocumentPosition?function(e,t){var r;return e===t?(u=!0,0):(r=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t))?1&r||e.parentNode&&11===e.parentNode.nodeType?e===n||y(w,e)?-1:t===n||y(w,t)?1:0:4&r?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return u=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:0;if(o===a)return ut(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?ut(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},u=!1,[0,0].sort(v),T.detectDuplicates=u,p):p},st.matches=function(e,t){return st(e,null,null,t)},st.matchesSelector=function(e,t){if((e.ownerDocument||e)!==p&&c(e),t=t.replace(Z,"='$1']"),!(!T.matchesSelector||d||g&&g.test(t)||h.test(t)))try{var n=m.call(e,t);if(n||T.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(r){}return st(t,p,null,[e]).length>0},st.contains=function(e,t){return(e.ownerDocument||e)!==p&&c(e),y(e,t)},st.attr=function(e,t){var n;return(e.ownerDocument||e)!==p&&c(e),d||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):d||T.attributes?e.getAttribute(t):((n=e.getAttributeNode(t))||e.getAttribute(t))&&e[t]===!0?t:n&&n.specified?n.value:null},st.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},st.uniqueSort=function(e){var t,n=[],r=1,i=0;if(u=!T.detectDuplicates,e.sort(v),u){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e};function ut(e,t){var n=t&&e,r=n&&(~t.sourceIndex||j)-(~e.sourceIndex||j);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function lt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function ct(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function pt(e){return ot(function(t){return t=+t,ot(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}o=st.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=o(t);return n},i=st.selectors={cacheLength:50,createPseudo:ot,match:U,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(et,tt),e[3]=(e[4]||e[5]||"").replace(et,tt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||st.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&st.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return U.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:n&&z.test(n)&&(t=ft(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){return"*"===e?function(){return!0}:(e=e.replace(et,tt).toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[e+" "];return t||(t=RegExp("(^|"+_+")"+e+"("+_+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==A&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=st.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!u&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[x]||(m[x]={}),l=c[e]||[],d=l[0]===N&&l[1],f=l[0]===N&&l[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[N,d,f];break}}else if(v&&(l=(t[x]||(t[x]={}))[e])&&l[0]===N)f=l[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[x]||(p[x]={}))[e]=[N,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||st.error("unsupported pseudo: "+e);return r[x]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?ot(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=M.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:ot(function(e){var t=[],n=[],r=s(e.replace(W,"$1"));return r[x]?ot(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:ot(function(e){return function(t){return st(e,t).length>0}}),contains:ot(function(e){return function(t){return(t.textContent||t.innerText||o(t)).indexOf(e)>-1}}),lang:ot(function(e){return X.test(e||"")||st.error("unsupported lang: "+e),e=e.replace(et,tt).toLowerCase(),function(t){var n;do if(n=d?t.getAttribute("xml:lang")||t.getAttribute("lang"):t.lang)return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return Q.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:pt(function(){return[0]}),last:pt(function(e,t){return[t-1]}),eq:pt(function(e,t,n){return[0>n?n+t:n]}),even:pt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:pt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:pt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:pt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})i.pseudos[n]=lt(n);for(n in{submit:!0,reset:!0})i.pseudos[n]=ct(n);function ft(e,t){var n,r,o,a,s,u,l,c=E[e+" "];if(c)return t?0:c.slice(0);s=e,u=[],l=i.preFilter;while(s){(!n||(r=$.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),u.push(o=[])),n=!1,(r=I.exec(s))&&(n=r.shift(),o.push({value:n,type:r[0].replace(W," ")}),s=s.slice(n.length));for(a in i.filter)!(r=U[a].exec(s))||l[a]&&!(r=l[a](r))||(n=r.shift(),o.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?st.error(e):E(e,u).slice(0)}function dt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function ht(e,t,n){var i=t.dir,o=n&&"parentNode"===i,a=C++;return t.first?function(t,n,r){while(t=t[i])if(1===t.nodeType||o)return e(t,n,r)}:function(t,n,s){var u,l,c,p=N+" "+a;if(s){while(t=t[i])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[i])if(1===t.nodeType||o)if(c=t[x]||(t[x]={}),(l=c[i])&&l[0]===p){if((u=l[1])===!0||u===r)return u===!0}else if(l=c[i]=[p],l[1]=e(t,n,s)||r,l[1]===!0)return!0}}function gt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function mt(e,t,n,r,i){var o,a=[],s=0,u=e.length,l=null!=t;for(;u>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),l&&t.push(s));return a}function yt(e,t,n,r,i,o){return r&&!r[x]&&(r=yt(r)),i&&!i[x]&&(i=yt(i,o)),ot(function(o,a,s,u){var l,c,p,f=[],d=[],h=a.length,g=o||xt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:mt(g,f,e,s,u),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,u),r){l=mt(y,d),r(l,[],s,u),c=l.length;while(c--)(p=l[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){l=[],c=y.length;while(c--)(p=y[c])&&l.push(m[c]=p);i(null,y=[],l,u)}c=y.length;while(c--)(p=y[c])&&(l=i?M.call(o,p):f[c])>-1&&(o[l]=!(a[l]=p))}}else y=mt(y===a?y.splice(h,y.length):y),i?i(null,a,y,u):H.apply(a,y)})}function vt(e){var t,n,r,o=e.length,a=i.relative[e[0].type],s=a||i.relative[" "],u=a?1:0,c=ht(function(e){return e===t},s,!0),p=ht(function(e){return M.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;o>u;u++)if(n=i.relative[e[u].type])f=[ht(gt(f),n)];else{if(n=i.filter[e[u].type].apply(null,e[u].matches),n[x]){for(r=++u;o>r;r++)if(i.relative[e[r].type])break;return yt(u>1&>(f),u>1&&dt(e.slice(0,u-1)).replace(W,"$1"),n,r>u&&vt(e.slice(u,r)),o>r&&vt(e=e.slice(r)),o>r&&dt(e))}f.push(n)}return gt(f)}function bt(e,t){var n=0,o=t.length>0,a=e.length>0,s=function(s,u,c,f,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,T=l,C=s||a&&i.find.TAG("*",d&&u.parentNode||u),k=N+=null==T?1:Math.random()||.1;for(w&&(l=u!==p&&u,r=n);null!=(h=C[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,u,c)){f.push(h);break}w&&(N=k,r=++n)}o&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,o&&b!==v){g=0;while(m=t[g++])m(x,y,u,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=L.call(f));y=mt(y)}H.apply(f,y),w&&!s&&y.length>0&&v+t.length>1&&st.uniqueSort(f)}return w&&(N=k,l=T),x};return o?ot(s):s}s=st.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=ft(e)),n=t.length;while(n--)o=vt(t[n]),o[x]?r.push(o):i.push(o);o=S(e,bt(i,r))}return o};function xt(e,t,n){var r=0,i=t.length;for(;i>r;r++)st(e,t[r],n);return n}function wt(e,t,n,r){var o,a,u,l,c,p=ft(e);if(!r&&1===p.length){if(a=p[0]=p[0].slice(0),a.length>2&&"ID"===(u=a[0]).type&&9===t.nodeType&&!d&&i.relative[a[1].type]){if(t=i.find.ID(u.matches[0].replace(et,tt),t)[0],!t)return n;e=e.slice(a.shift().value.length)}o=U.needsContext.test(e)?0:a.length;while(o--){if(u=a[o],i.relative[l=u.type])break;if((c=i.find[l])&&(r=c(u.matches[0].replace(et,tt),V.test(a[0].type)&&t.parentNode||t))){if(a.splice(o,1),e=r.length&&dt(a),!e)return H.apply(n,q.call(r,0)),n;break}}}return s(e,p)(r,t,d,n,V.test(e)),n}i.pseudos.nth=i.pseudos.eq;function Tt(){}i.filters=Tt.prototype=i.pseudos,i.setFilters=new Tt,c(),st.attr=b.attr,b.find=st,b.expr=st.selectors,b.expr[":"]=b.expr.pseudos,b.unique=st.uniqueSort,b.text=st.getText,b.isXMLDoc=st.isXML,b.contains=st.contains}(e);var at=/Until$/,st=/^(?:parents|prev(?:Until|All))/,ut=/^.[^:#\[\.,]*$/,lt=b.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};b.fn.extend({find:function(e){var t,n,r,i=this.length;if("string"!=typeof e)return r=this,this.pushStack(b(e).filter(function(){for(t=0;i>t;t++)if(b.contains(r[t],this))return!0}));for(n=[],t=0;i>t;t++)b.find(e,this[t],n);return n=this.pushStack(i>1?b.unique(n):n),n.selector=(this.selector?this.selector+" ":"")+e,n},has:function(e){var t,n=b(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(b.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e,!1))},filter:function(e){return this.pushStack(ft(this,e,!0))},is:function(e){return!!e&&("string"==typeof e?lt.test(e)?b(e,this.context).index(this[0])>=0:b.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,o=[],a=lt.test(e)||"string"!=typeof e?b(e,t||this.context):0;for(;i>r;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&11!==n.nodeType){if(a?a.index(n)>-1:b.find.matchesSelector(n,e)){o.push(n);break}n=n.parentNode}}return this.pushStack(o.length>1?b.unique(o):o)},index:function(e){return e?"string"==typeof e?b.inArray(this[0],b(e)):b.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?b(e,t):b.makeArray(e&&e.nodeType?[e]:e),r=b.merge(this.get(),n);return this.pushStack(b.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),b.fn.andSelf=b.fn.addBack;function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}b.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return b.dir(e,"parentNode")},parentsUntil:function(e,t,n){return b.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return b.dir(e,"nextSibling")},prevAll:function(e){return b.dir(e,"previousSibling")},nextUntil:function(e,t,n){return b.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return b.dir(e,"previousSibling",n)},siblings:function(e){return b.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return b.sibling(e.firstChild)},contents:function(e){return b.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:b.merge([],e.childNodes)}},function(e,t){b.fn[e]=function(n,r){var i=b.map(this,t,n);return at.test(e)||(r=n),r&&"string"==typeof r&&(i=b.filter(r,i)),i=this.length>1&&!ct[e]?b.unique(i):i,this.length>1&&st.test(e)&&(i=i.reverse()),this.pushStack(i)}}),b.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),1===t.length?b.find.matchesSelector(t[0],e)?[t[0]]:[]:b.find.matches(e,t)},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!b(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(t=t||0,b.isFunction(t))return b.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return b.grep(e,function(e){return e===t===n});if("string"==typeof t){var r=b.grep(e,function(e){return 1===e.nodeType});if(ut.test(t))return b.filter(t,r,!n);t=b.filter(t,r)}return b.grep(e,function(e){return b.inArray(e,t)>=0===n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/\s*$/g,At={option:[1,""],legend:[1,"
    ","
    "],area:[1,"",""],param:[1,"",""],thead:[1,"","
    "],tr:[2,"","
    "],col:[2,"","
    "],td:[3,"","
    "],_default:b.support.htmlSerialize?[0,"",""]:[1,"X
    ","
    "]},jt=dt(o),Dt=jt.appendChild(o.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,b.fn.extend({text:function(e){return b.access(this,function(e){return e===t?b.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(b.isFunction(e))return this.each(function(t){b(this).wrapAll(e.call(this,t))});if(this[0]){var t=b(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return b.isFunction(e)?this.each(function(t){b(this).wrapInner(e.call(this,t))}):this.each(function(){var t=b(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=b.isFunction(e);return this.each(function(n){b(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){b.nodeName(this,"body")||b(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(e,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=0;for(;null!=(n=this[r]);r++)(!e||b.filter(e,[n]).length>0)&&(t||1!==n.nodeType||b.cleanData(Ot(n)),n.parentNode&&(t&&b.contains(n.ownerDocument,n)&&Mt(Ot(n,"script")),n.parentNode.removeChild(n)));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&b.cleanData(Ot(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&b.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return b.clone(this,e,t)})},html:function(e){return b.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!b.support.htmlSerialize&&mt.test(e)||!b.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(b.cleanData(Ot(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){var t=b.isFunction(e);return t||"string"==typeof e||(e=b(e).not(this).detach()),this.domManip([e],!0,function(e){var t=this.nextSibling,n=this.parentNode;n&&(b(this).remove(),n.insertBefore(e,t))})},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=f.apply([],e);var i,o,a,s,u,l,c=0,p=this.length,d=this,h=p-1,g=e[0],m=b.isFunction(g);if(m||!(1>=p||"string"!=typeof g||b.support.checkClone)&&Ct.test(g))return this.each(function(i){var o=d.eq(i);m&&(e[0]=g.call(this,i,n?o.html():t)),o.domManip(e,n,r)});if(p&&(l=b.buildFragment(e,this[0].ownerDocument,!1,this),i=l.firstChild,1===l.childNodes.length&&(l=i),i)){for(n=n&&b.nodeName(i,"tr"),s=b.map(Ot(l,"script"),Ht),a=s.length;p>c;c++)o=l,c!==h&&(o=b.clone(o,!0,!0),a&&b.merge(s,Ot(o,"script"))),r.call(n&&b.nodeName(this[c],"table")?Lt(this[c],"tbody"):this[c],o,c);if(a)for(u=s[s.length-1].ownerDocument,b.map(s,qt),c=0;a>c;c++)o=s[c],kt.test(o.type||"")&&!b._data(o,"globalEval")&&b.contains(u,o)&&(o.src?b.ajax({url:o.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):b.globalEval((o.text||o.textContent||o.innerHTML||"").replace(St,"")));l=i=null}return this}});function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function Ht(e){var t=e.getAttributeNode("type");return e.type=(t&&t.specified)+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function Mt(e,t){var n,r=0;for(;null!=(n=e[r]);r++)b._data(n,"globalEval",!t||b._data(t[r],"globalEval"))}function _t(e,t){if(1===t.nodeType&&b.hasData(e)){var n,r,i,o=b._data(e),a=b._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)b.event.add(t,n,s[n][r])}a.data&&(a.data=b.extend({},a.data))}}function Ft(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!b.support.noCloneEvent&&t[b.expando]){i=b._data(t);for(r in i.events)b.removeEvent(t,r,i.handle);t.removeAttribute(b.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),b.support.html5Clone&&e.innerHTML&&!b.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Nt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}b.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){b.fn[e]=function(e){var n,r=0,i=[],o=b(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),b(o[r])[t](n),d.apply(i,n.get());return this.pushStack(i)}});function Ot(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||b.nodeName(o,n)?s.push(o):b.merge(s,Ot(o,n));return n===t||n&&b.nodeName(e,n)?b.merge([e],s):s}function Bt(e){Nt.test(e.type)&&(e.defaultChecked=e.checked)}b.extend({clone:function(e,t,n){var r,i,o,a,s,u=b.contains(e.ownerDocument,e);if(b.support.html5Clone||b.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(b.support.noCloneEvent&&b.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||b.isXMLDoc(e)))for(r=Ot(o),s=Ot(e),a=0;null!=(i=s[a]);++a)r[a]&&Ft(i,r[a]);if(t)if(n)for(s=s||Ot(e),r=r||Ot(o),a=0;null!=(i=s[a]);a++)_t(i,r[a]);else _t(e,o);return r=Ot(o,"script"),r.length>0&&Mt(r,!u&&Ot(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,u,l,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===b.type(o))b.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),u=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[u]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!b.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!b.support.tbody){o="table"!==u||xt.test(o)?""!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)b.nodeName(l=o.childNodes[i],"tbody")&&!l.childNodes.length&&o.removeChild(l) +}b.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),b.support.appendChecked||b.grep(Ot(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===b.inArray(o,r))&&(a=b.contains(o.ownerDocument,o),s=Ot(f.appendChild(o),"script"),a&&Mt(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,u=b.expando,l=b.cache,p=b.support.deleteExpando,f=b.event.special;for(;null!=(n=e[s]);s++)if((t||b.acceptData(n))&&(o=n[u],a=o&&l[o])){if(a.events)for(r in a.events)f[r]?b.event.remove(n,r):b.removeEvent(n,r,a.handle);l[o]&&(delete l[o],p?delete n[u]:typeof n.removeAttribute!==i?n.removeAttribute(u):n[u]=null,c.push(o))}}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+x+")(.*)$","i"),Yt=RegExp("^("+x+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+x+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===b.css(e,"display")||!b.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=b._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=b._data(r,"olddisplay",un(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&b._data(r,"olddisplay",i?n:b.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}b.fn.extend({css:function(e,n){return b.access(this,function(e,n,r){var i,o,a={},s=0;if(b.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=b.css(e,n[s],!1,o);return a}return r!==t?b.style(e,n,r):b.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){var t="boolean"==typeof e;return this.each(function(){(t?e:nn(this))?b(this).show():b(this).hide()})}}),b.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":b.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=b.camelCase(n),l=e.style;if(n=b.cssProps[u]||(b.cssProps[u]=tn(l,u)),s=b.cssHooks[n]||b.cssHooks[u],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:l[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(b.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||b.cssNumber[u]||(r+="px"),b.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(l[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{l[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,u=b.camelCase(n);return n=b.cssProps[u]||(b.cssProps[u]=tn(e.style,u)),s=b.cssHooks[n]||b.cssHooks[u],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||b.isNumeric(o)?o||0:a):a},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s.getPropertyValue(n)||s[n]:t,l=e.style;return s&&(""!==u||b.contains(e.ownerDocument,e)||(u=b.style(e,n)),Yt.test(u)&&Ut.test(n)&&(i=l.width,o=l.minWidth,a=l.maxWidth,l.minWidth=l.maxWidth=l.width=u,u=s.width,l.width=i,l.minWidth=o,l.maxWidth=a)),u}):o.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s[n]:t,l=e.style;return null==u&&l&&l[n]&&(u=l[n]),Yt.test(u)&&!zt.test(n)&&(i=l.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),l.left="fontSize"===n?"1em":u,u=l.pixelLeft+"px",l.left=i,a&&(o.left=a)),""===u?"auto":u});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=b.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=b.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=b.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=b.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=b.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=b.support.boxSizing&&"border-box"===b.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(b.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function un(e){var t=o,n=Gt[e];return n||(n=ln(e,t),"none"!==n&&n||(Pt=(Pt||b("