daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest Aug 28th, 2016 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. <style>
  3. #game{
  4.     font: 20px Helvetica;
  5.     color:white;
  6.     position:absolute;
  7.     width:500px;
  8.     height:500px;
  9.     top:0px;
  10.     left:0px;
  11.     cursor:default;
  12.     overflow:hidden;
  13.     -webkit-touch-callout: none;
  14.     -webkit-user-select: none;
  15.     -khtml-user-select: none;
  16.     -moz-user-select: none;
  17.     -ms-user-select: none;
  18.     user-select: none;
  19. }
  20. .menuTab{
  21.     width:100px;
  22.     height:30px;
  23.     position:absolute;
  24.     top:0px;
  25.     background-color:#562c09;
  26.     color:white;
  27.     text-align:center;
  28.     padding-top:7px;
  29.     cursor:pointer;
  30. }
  31. .menuTab:hover{
  32.     color:#f9b983;
  33. }
  34. .menuTabSelected{
  35.     width:100px;
  36.     height:30px;
  37.     position:absolute;
  38.     top:0px;
  39.     background-color:#3e1e02;
  40.     color:white;
  41.     text-align:center;
  42.     padding-top:7px;
  43. }
  44. .page{
  45.     width:500px;
  46.     height:463px;
  47.     position:absolute;
  48.     top:37px;
  49.     background-color:#3e1e02;
  50.     color:white;
  51.     display:none;
  52.     overflow:hidden;
  53. }
  54. #drugs{
  55.     position:relative;
  56.     left:0px;
  57.     top:10px;
  58.     border-style:solid;
  59.     border-color:#291500;
  60.     width:150px;
  61.     height:437px;
  62.     border-width:-3px;
  63.     overflow:hidden;
  64. }
  65. .drawnDrug{
  66.     font: 16px Helvetica;
  67.     padding-top:7px;
  68.     position:relative;
  69.     left:0px;
  70.     width:150px;
  71.     height:30px;
  72.     background-color:#562c09;
  73.     text-align:center;
  74.     cursor:pointer;
  75. }
  76. .drawnDrug:hover{
  77.     background-color:#3e1e02;
  78. }
  79. .drugAdder{
  80.     border-style:solid;
  81.     border-color:#291500;
  82.     font: 15px Helvetica;
  83.     padding-top:7px;
  84.     position:absolute;
  85.     top:100px;
  86.     width:100px;
  87.     height:30px;
  88.     background-color:#562c09;
  89.     text-align:center;
  90.     cursor:pointer;
  91. }
  92. .drugAdder:hover{
  93.     background-color:#3e1e02;
  94. }
  95. .amount{
  96.     border-style:solid;
  97.     border-color:#291500;
  98.     font: 12px Helvetica;
  99.     padding-top:7px;
  100.     position:absolute;
  101.     top:139px;
  102.     width:70px;
  103.     height:30px;
  104.     background-color:#562c09;
  105.     text-align:center;
  106.     cursor:pointer;
  107.     color:white;
  108. }
  109. #combine{
  110.     border-style:solid;
  111.     border-color:#291500;
  112.     font: 18px Helvetica;
  113.     padding-top:7px;
  114.     position:absolute;
  115.     top:350px;
  116.     left:275;
  117.     width:100px;
  118.     height:30px;
  119.     text-align:center;
  120.  
  121.     color:white;
  122. }
  123. .comEnabled{
  124.     cursor:pointer;
  125.     background-color:#562c09;
  126. }
  127. .comEnabled:hover{
  128.     background-color:#3e1e02;
  129. }
  130. .comDisabled{
  131.     cursor:default;
  132.     background-color:#473d2f;
  133. }
  134. .drawnDealer{
  135.     font: 17px Helvetica;
  136.     padding-top:7px;
  137.     position:relative;
  138.     left:0px;
  139.     width:500px;
  140.     height:30px;
  141.     background-color:#562c09;
  142. }
  143. .buyBtn{
  144.     border-style:solid;
  145.     border-color:#291500;
  146.     font: 15px Helvetica;
  147.     padding-top:2px;
  148.     left:450px;
  149.     position:relative;
  150.     top:-23px;
  151.     border-width:2px;
  152.     width:40px;
  153.     height:20px;
  154.     background-color:#562c09;
  155.     text-align:center;
  156.     cursor:pointer;
  157. }
  158. .buyBtn:hover{
  159.     background-color:#3e1e02;
  160. }
  161. .notif{
  162.     border-style:solid;
  163.     border-color:#291500;
  164.     font: 20px Helvetica;
  165.     padding-top:25px;
  166.     left:150px;
  167.     position:absolute;
  168.     top: 200px;
  169.     border-width:2px;
  170.     width:200px;
  171.     height:75px;
  172.     background-color:#562c09;
  173.     text-align:center;
  174.     pointer-events:none;
  175. }
  176. .darky{
  177.     opacity:.5;
  178.     background-color:black;
  179.     position:absolute;
  180.     left:0px;
  181.     top:0px;
  182.     width:500px;
  183.     height:500px;
  184.     cursor:pointer;
  185. }
  186. .drawnClient{
  187.     font: 17px Helvetica;
  188.     padding-top:7px;
  189.     position:relative;
  190.     left:0px;
  191.     width:500px;
  192.     height:30px;
  193.     background-color:#562c09;
  194. }
  195. .drawnRecipe{
  196.     font: 17px Helvetica;
  197.     padding-top:7px;
  198.     position:relative;
  199.     left:0px;
  200.     width:500px;
  201.     height:30px;
  202.     text-align:center;
  203.     cursor:default;
  204.     background-color:#562c09;
  205. }
  206. #sellDrugHolder{
  207.     //border-style:solid;
  208.     //border-color:#291500;
  209.     top:30px;
  210.     left:100px;
  211.     width:300px;
  212. }
  213. #info{
  214.     position:absolute;
  215.     left:450px;
  216.     top:450px;
  217.     font-family:comic sans ms;
  218.     width:30px;
  219.     height:30px;
  220.     text-align: center;
  221.     cursor:pointer;
  222.     border: 5px solid;
  223.     border-color:#291500;
  224.     border-radius: 30px;
  225. }
  226. #info:hover{
  227.     background-color:#291500;
  228. }
  229. #money{
  230.     position:absolute;
  231.     left:0px;
  232.     top:470px;
  233.     background-color:#562c09;
  234. }
  235. #level{
  236.     position:absolute;
  237.     left:210px;
  238.     top:470px;
  239.     background-color:#562c09;
  240. }
  241. #shoehorn{
  242.     border-style:solid;
  243.     border-color:#291500;
  244.     font: 18px Helvetica;
  245.     padding-top:7px;
  246.     position:absolute;
  247.     top:300px;
  248.     left:175;
  249.     width:300px;
  250.     height:30px;
  251.     text-align:center;
  252.  
  253.     color:white;
  254. }
  255. #instruct{
  256.     background-color:#562c09;
  257.     position:absolute;
  258.     left:0px;
  259.     top:0px;
  260.     padding-left: 5px;
  261.     padding-right: 5px;
  262.     width:490px;
  263.     height:500px;
  264.     cursor:pointer;
  265.     display:none;
  266. }
  267. #shoehorn2{
  268.     background-color:#562c09;
  269.     position:absolute;
  270.     left:0px;
  271.     top:0px;
  272.     line-height: 200%;
  273.     padding-left: 5px;
  274.     padding-right: 5px;
  275.     width:490px;
  276.     height:500px;
  277.     cursor:pointer;
  278.     display:none;
  279. }
  280. </style>
  281. <div id="game">
  282.     <div id="header">
  283.         <div onclick="tabSwap(this,showBuy)" name="menuTab" class="menuTabSelected" style="left:0px">Buy</div>
  284.         <div onclick="tabSwap(this,showSell)" name="menuTab" class="menuTab" style="left:100px">Sell</div>
  285.         <div onclick="tabSwap(this,showLab)" name="menuTab" class="menuTab" style="left:200px">Lab</div>
  286.         <div onclick="tabSwap(this,showUpgrades)" name="menuTab" class="menuTab" style="left:300px">Upgrades</div>
  287.         <div onclick="tabSwap(this,showRecipes)" name="menuTab" class="menuTab" style="left:400px">Recipes</div>
  288.     </div>
  289.     <div id="pages">
  290.         <div class="page" id="buy">
  291.             <div y=0 oldY="undefined" name="scrolly" style="position:relative" onblur="stopScroll(this)" onmousemove="scrollMM(event,this)" onmousedown="this.setAttribute('down',true)" onmouseup="stopScroll(this)" id="dealerHolder"></div>
  292.         </div>
  293.         <div class="page" id="sell">
  294.             <div y=0 oldY="undefined" name="scrolly" style="position:relative" onblur="stopScroll(this)" onmousemove="scrollMM(event,this)" onmousedown="this.setAttribute('down',true)" onmouseup="stopScroll(this)" id="clientHolder"></div>
  295.         </div>
  296.         <div class="page" id="lab">
  297.             <div id="drugs">
  298.                 <div y=0 oldY="undefined" name="scrolly"style="position:relative" onblur="stopScroll(this)" onmousemove="scrollMM(event,this)" onmousedown="this.setAttribute('down',true)" onmouseup="stopScroll(this)" id="drugHolder"></div>
  299.             </div>
  300.            
  301.  
  302.             <div class="amount" style="left:215px;"><div contenteditable="true">0</div>grams</div>
  303.             <div onclick="clearSlot(this,0)" style="left:200px;" class="drugadder">Select Drug</div>
  304.            
  305.             <div class="amount" style="left:365px;"><div contenteditable="true">0</div>grams</div>
  306.             <div onclick="clearSlot(this,1)" style="left:350px;" class="drugadder">Select Drug</div>
  307.             <div id="shoehorn">Ancient Easy Bake Meth Lab</div>
  308.             <div class="comDisabled" id="combine">Combine</div>
  309.         </div>
  310.         <div class="page" id="upgrade">
  311.             <div y=0 oldY="undefined" name="scrolly" style="position:relative" onblur="stopScroll(this)" onmousemove="scrollMM(event,this)" onmousedown="this.setAttribute('down',true)" onmouseup="stopScroll(this)" id="upgradeHolder"></div>
  312.         </div>
  313.         <div class="page" id="recipe">
  314.             <div y=0 oldY="undefined" name="scrolly" style="position:relative" onblur="stopScroll(this)" onmousemove="scrollMM(event,this)" onmousedown="this.setAttribute('down',true)" onmouseup="stopScroll(this)" id="recipeHolder"></div>
  315.         </div>
  316.     </div>
  317.     <div id="stats">
  318.         <div id="info" onclick="show(document.getElementById('instruct'))">I</div>
  319.         <div id="money">$10</div>
  320.         <div id="level">Level 1</div>
  321.     </div>
  322.     <div id="instruct" onclick="hide(this)">
  323.         <center><h1>General Help</h1></center>
  324.         <p>Click on drugs to add them to the combination queue.</p>
  325.         <p>Click on queued drugs to remove them from the queue.</p>
  326.         <p>Make sure to see what your buyers want before wasting all your drugs.</p>
  327.         <p>Combining drugs yields a general loss in created material. This can be changed with upgrades.</p>
  328.         <p>Upgrade your level to make better drugs and unlock another base drug.</p>
  329.         <p>Game made in 48 hours for LD 36, theme Ancient Technology.</p>
  330.         <p>This game should autosave on reload/close.</p>
  331.     </div>
  332.     <div id="shoehorn2" onclick="hide(this)">
  333.         <center><h1>Drug Maker Extreme</h1></center>
  334.         <p>Recently you were sleeping outside of a museum inside of its dumpster and you found dumped in upon you a rickety old chest. This chest you noted would be an appropriate place to hide your drug stash.</p><p> Little did you know that the chest was the Ancient Easy Bake Meth Lab of Venix The Pirate. Now you have realized that it combines drugs and forms more potent ones. You intend to use this chest to make bank and stay off the street.</p>
  335.     </div>
  336. </div>
  337. <script>
  338. /*
  339. ketamine
  340. cocaine
  341. marijuana 12131415
  342. codeine
  343. methamphetamene
  344. nicotine
  345. novacaine
  346. amphetamine
  347. morphine
  348.  
  349.  
  350. remove double is in drug names
  351. NEVER PUSH A DRUG DIRECTLY TO SAVE DRUG ARRAY!!! (I cant recall how to do it anymore but there are functions that make it safe) - ok i made a function to do it safe, thanks for the reminder, bro
  352. */
  353. window.onbeforeunload=function (evt) {
  354. if (typeof evt == 'undefined') {
  355. evt = window.event;
  356. }
  357. localStorage.drugSave=JSON.stringify(save);
  358. }
  359.  
  360. window.onclick=function(){
  361.     safeGram()
  362.     for(i=0;i<scrollies.length;i++){
  363.         stopScroll(scrollies[i]);
  364.     }
  365. }
  366. window.onload=function(){
  367.     init();
  368. };
  369. var pages = document.getElementsByClassName('page');
  370. var adders = document.getElementsByClassName('drugAdder');
  371. var amounts = document.getElementsByClassName('amount');
  372. var tabs = document.getElementsByName('menuTab');
  373. var scrollies = document.getElementsByName('scrolly');
  374. var drawnDrugs = document.getElementsByClassName('drawnDrug');
  375. var drawnDealers = document.getElementsByClassName('drawnDealers');
  376. pages[0].style.display="block";
  377. var minGrams = 2;
  378. var drugs = ["go","ta","lo","du","me","ve","ni","de","mo","do","ne","co","ma","ri","jua","na","me","ine","ca","no","va","he","ro","in","tu","phe","tam","ti","ke","to","mor","phi","am"];
  379. var selected = [];
  380. var scrolled;
  381. var MARIJUANA = "12131415";
  382. var NICOTINE = "06112710";
  383. var NOVACAINE = "19201817";
  384. var KETAMINE = "282617";
  385. var CODEINE = "110717";
  386. var HEROIN = "212223";
  387. var MORPHINE = "303110";
  388. var AMPHETAMINE = "32252617";
  389. var COCAINE = "111817";
  390.  
  391.  
  392. var madeDrugs=[MARIJUANA,NICOTINE,NOVACAINE,KETAMINE,CODEINE,HEROIN,MORPHINE,AMPHETAMINE,COCAINE,HEROIN];
  393. var titles = ["Stoner", "Homie","Junkie","Smoker","Addict","Buddy","Client","Hippie"];
  394. var names = ["Henry","Joe","Sam","Bob","Caleb","Artie","Steve","Nick","Harrell"];
  395.  
  396. var dealers=[null, new Dealer("Homie Harrell",makeDrug(1,MARIJUANA,1)),new Dealer("Smoker Sam",makeDrug(2,NICOTINE,1)),new Dealer("Dentist Dave",makeDrug(3,NOVACAINE,1)),new Dealer("Vet Victor",makeDrug(4,KETAMINE,1)),new Dealer("Dealer Dyrel",makeDrug(5,CODEINE,1)),new Dealer("Gangster George",makeDrug(6,HEROIN,1)),new Dealer("Addict Artie",makeDrug(7,MORPHINE,1)),new Dealer("Junkie Jack",makeDrug(8,AMPHETAMINE,1)),new Dealer("Killer Kevin",makeDrug(9,COCAINE,1))]
  397.  
  398. save = {
  399.     drugs:[],
  400.     dealers:[],
  401.     clients:[],
  402.     upgrades:[new Upgrade("Level Up","Unlocks new dealers and allows for better drug <br> &nbspcrafting.","lvlUp",10),new Upgrade("Advertising","Adds 5-10 new clients.","addClients",5),new Upgrade("Boosted Yield","Boosts yield of new drug when combining.","yieldUp",10)],
  403.     recipes:[],
  404.     money:10,
  405.     level:1,
  406. }
  407.  
  408. function init(){
  409.     Demo();
  410.     if(localStorage.drugSave!=undefined){
  411.         var goodSave = JSON.parse(localStorage.drugSave);
  412.         if(goodSave.clients[0]!=undefined&&goodSave.dealers[0]!=undefined&&goodSave.drugs[0]!=undefined){
  413.         save = JSON.parse(localStorage.drugSave);
  414.         document.getElementById('level').innerHTML = "Level " + save.level;
  415.         document.getElementById('money').innerHTML = "$" + save.money;
  416.         tabs[2].click();
  417.         return;
  418.     }
  419.     }
  420.     save.drugs.push(makeDrug(1,MARIJUANA,10));
  421.     save.dealers.push(dealers[save.level]);
  422.     save.clients.push(new Dealer("Stoner Steve", makeDrug(1,MARIJUANA,1,1)));
  423.     save.clients.push(new Dealer("Dude Duke", makeDrug(1,32163216,1,4)));
  424.     save.clients.push(new Dealer("Junkie Joe", makeDrug(4,MARIJUANA,1,2)));
  425.     show(document.getElementById('shoehorn2'));
  426.     tabs[2].click();
  427.  
  428. }
  429.  
  430. function upgradeGeneral(upg){
  431.     var cost = (upg.level+1)*(upg.level+1)*upg.cScale;
  432.     if(save.money<cost){
  433.         uiPopup("You can't afford this upgrade.");
  434.         return false;
  435.     }
  436.     changeMoney(-cost);
  437.     upg.level++;
  438.     redrawUpgrades();
  439.     uiPopup("Bought!");
  440.     return true;
  441. }
  442.  
  443. function lvlUp(upg){
  444.     if(upgradeGeneral(upg)){
  445.         save.level++;
  446.         if(save.level<dealers.length){
  447.             save.dealers.push(dealers[save.level]);
  448.         }
  449.         document.getElementById('level').innerHTML= "Level " +save.level;
  450.     }
  451. }
  452. function yieldUp(upg){
  453.     if(upgradeGeneral(upg)){
  454.     }
  455. }
  456.  
  457. function addClients(upg){
  458.    
  459.     if(upgradeGeneral(upg)){
  460.         var runs = Math.floor(Math.random()*6)+5;
  461.         for(l=0;l<runs;l++){
  462.         var title = titles[Math.floor(Math.random()*titles.length)];
  463.         var name = names[Math.floor(Math.random()*names.length)];
  464.         var type = Math.floor(Math.random()*3)+1;
  465.         var drug = 11121314;
  466.         var lvl = 1;
  467.         var grams = Math.floor(Math.random()*5)+1;
  468.         switch(type){
  469.             case 1:
  470.                 var parts=[];
  471.                 parts.push(String(Math.floor(Math.random()*drugs.length)));
  472.                 parts.push(String(Math.floor(Math.random()*drugs.length)));
  473.                 parts.push(String(Math.floor(Math.random()*drugs.length)));
  474.                 parts.push(String(Math.floor(Math.random()*drugs.length)));
  475.                 for(j=0;j<parts.length;j++){
  476.                     if(parts[j].length==1){
  477.                         parts[j] = "0" + parts[j];
  478.                     }
  479.                 }
  480.                 drug = parts[0]+parts[1]+parts[2];
  481.                 if(Math.floor(Math.random()*3)!=0){
  482.                     drug +=parts[3];
  483.                 }
  484.             break;
  485.             case 2:
  486.                 var lvl = save.level*(Math.floor(Math.random()*5)+1)
  487.             break;
  488.             case 3:
  489.                 var grams = (Math.floor(Math.random()*save.level)+1)*10;
  490.             break;
  491.         }
  492.         save.clients.push(new Dealer(title + " " + name, makeDrug(lvl,drug,grams,type)));
  493.         }
  494.     }
  495.  
  496. }
  497.  
  498. function makeDrug(lvl,data,grams,type){
  499.     data=String(data);
  500.     var drug = new Drug(lvl,data,grams)
  501.     drug.type=type;
  502.     drug.name = "";
  503.     for(i=0;i<data.length;i+=2){
  504.         drug.name += drugs[Number(data[i]+data[i+1])];
  505.     }
  506.     drug.cost = Math.round(Number(data[Math.round(data.length*.75)])+Number(data[Math.round(data.length*.25)]) * (lvl/2));
  507.     if(drug.cost==0){
  508.         drug.cost = 6*(lvl/2);
  509.     }
  510.     drug.yield = 50 - (Number(data[Math.round(data.length*.66)]) + Number(data[Math.round(data.length*.33)]) + Number(data[Math.round(data.length/5)]))
  511.     if(drug.yield>40&&Number(data[Math.round(data.length*.66)])<3){
  512.         drug.yield-=10;
  513.     }
  514.     drug.yield*=.01;
  515.     drug.name=drug.name.charAt(0).toUpperCase() + drug.name.slice(1);
  516.     return drug;
  517. }
  518.  
  519. function changeMoney(change){
  520.     save.money+=change;
  521.     document.getElementById('money').innerHTML ="$" + save.money;
  522. }
  523.  
  524. function scrollMM(event,ele){
  525.     if(ele.getAttribute('down')=="true"){
  526.     if(ele.getAttribute('oldY')!="undefined"){
  527.         var tempY= event.clientY - Number(ele.getAttribute('oldY'));
  528.         var otempY=Number(ele.getAttribute('y')) +tempY
  529.         ele.setAttribute('y',otempY);
  530.         ele.style.top = otempY + "px";
  531.  
  532.     }
  533.     ele.setAttribute('oldY',event.clientY)
  534.     }
  535. }
  536.  
  537.  
  538. function stopScroll(ele){
  539.     scrolled = true;
  540.     ele.setAttribute('down',false);
  541.     ele.setAttribute('oldY',undefined);
  542. }
  543.  
  544. function clearSlot(ele,index){
  545.     ele.innerHTML = "Select Drug"
  546.     amounts[index].childNodes[0].innerHTML="0";
  547.     selected[index] = null;
  548.     disableCombine();
  549. }
  550.  
  551. function disableCombine(){
  552. document.getElementById('combine').removeEventListener("click",combine);
  553. document.getElementById('combine').className="comDisabled";
  554. }
  555. function enableCombine(){
  556. document.getElementById('combine').addEventListener("click",combine);
  557. document.getElementById('combine').className="comEnabled";
  558. }
  559.  
  560. function safeGram(){
  561.     for(i=0;i<amounts.length;i++){
  562.         ele = amounts[i].childNodes[0]
  563.         if(ele.innerHTML.length>9){
  564.             ele.innerHTML = minGrams;
  565.         } else if(isNaN(Number(ele.innerHTML))){
  566.             ele.innerHTML = minGrams;
  567.         } else if(Number(ele.innerHTML)<minGrams){
  568.             ele.innerHTML = minGrams;
  569.         } else if(selected[i]!=null){
  570.             if(Number(ele.innerHTML)>selected[i].grams){
  571.                 ele.innerHTML = selected[i].grams;
  572.             }
  573.         }
  574.     }
  575.     if(selected[0]!=null&&selected[1]!=null){
  576.         if(selected[0]==selected[1]){
  577.             if(Number(amounts[0].childNodes[0].innerHTML)+Number(amounts[1].childNodes[0].innerHTML)>selected[0].grams){
  578.                 amounts[0].childNodes[0].innerHTML = minGrams;
  579.                 amounts[0].childNodes[0].innerHTML = minGrams;
  580.             }
  581.         }
  582.     }
  583.    
  584. }
  585.  
  586. String.prototype.replaceAt=function(index, character) {
  587.     return this.substr(0, index) + character + this.substr(index+character.length); // thats right bitch
  588. }
  589.  
  590. function combine(){
  591.     var newData = String(Number(selected[0].data) + Number(selected[1].data));
  592.     badData = true;
  593.     while(badData){
  594.     badData = false;
  595.     for(i=0;i<newData.length;i+=2){
  596.  
  597.         if(Number(newData[i]+newData[i+1])>drugs.length-1){
  598.             var newnums=Number(newData[i]+newData[i+1]) - (drugs.length-1);
  599.             var newnums=String(newnums);
  600.             if(newnums.length<2){
  601.                 newnums = "0" + newnums;
  602.             }
  603.             var newnums = String(newnums);
  604.            
  605.             newData = newData.replaceAt(i,newnums[0]);
  606.             newData = newData.replaceAt(i+1,newnums[1])
  607.             if(newData.length%2!=0){
  608.                 newData+="6"
  609.             }
  610.             badData = true;
  611.         }
  612.     }
  613.     }
  614.     var newGrams = Math.round((Number(amounts[0].childNodes[0].innerHTML) + Number(amounts[1].childNodes[0].innerHTML) * (selected[0].yield + selected[1].yield + (save.upgrades[2].level-1)*.03)));
  615.     var newLevel = Math.round((selected[0].level + selected[1].level) /2) + 1;
  616.     var newDrug = makeDrug(newLevel,newData,newGrams)
  617.     var names = [];
  618.     for(i=0;i<save.drugs.length;i++){
  619.         names.push(save.drugs[i].name)
  620.     }
  621.     if(names.indexOf(newDrug.name)>-1){
  622.         if(save.drugs[names.indexOf(newDrug.name)].level == newDrug.level){
  623.             save.drugs[names.indexOf(newDrug.name)].grams += newDrug.grams
  624.         } else {
  625.             save.drugs.push(newDrug);
  626.         }
  627.     } else {
  628.         save.drugs.push(newDrug);
  629.     }
  630.     selected[0].grams -= Number(amounts[0].childNodes[0].innerHTML);
  631.     selected[1].grams -= Number(amounts[1].childNodes[0].innerHTML);
  632.     var recipe = selected[0].name + " + " + selected[1].name + " = " + newDrug.name;
  633.     if(save.recipes.indexOf(recipe)==-1){
  634.         save.recipes.push(recipe);
  635.     }
  636.     selected =[];
  637.     clearSlot(adders[0],0);
  638.     clearSlot(adders[1],1);
  639.     disableCombine();
  640.     redrawDrugs();
  641. }
  642.  
  643. function safeDrug(newDrug){
  644.     var names = [];
  645.     for(i=0;i<save.drugs.length;i++){
  646.         names.push(save.drugs[i].name)
  647.     }
  648.     if(names.indexOf(newDrug.name)>-1){
  649.         if(save.drugs[names.indexOf(newDrug.name)].level == newDrug.level){
  650.             save.drugs[names.indexOf(newDrug.name)].grams += newDrug.grams
  651.         } else {
  652.             save.drugs.push(newDrug);
  653.         }
  654.     } else {
  655.         save.drugs.push(newDrug);
  656.     }
  657. }
  658.  
  659. function Drug(level,data,grams,yield,cost,name,type){
  660.     this.name = name;
  661.     this.data = data;
  662.     this.cost = cost;
  663.     this.yield = yield;
  664.     this.grams = grams;
  665.     this.level = level;
  666.     this.type = type;
  667. }
  668.  
  669. function Dealer(name, item){
  670.     this.name = name;
  671.     this.item = item;
  672. }
  673.  
  674. function Upgrade(name, info, call,cScale){
  675.     this.name = name;
  676.     this.info = info;
  677.     this.call = call;
  678.     this.level = 1;
  679.     this.cScale=cScale;
  680. }
  681.  
  682. /*function sellDrugs(drug){
  683.     var hits = [];
  684.     for(i=0;i<save.drugs.length;i++){
  685.         if(save.drugs[i].name==drug.name){
  686.             hits.push(save.drugs[i]);
  687.         }
  688.     }
  689.     if(hits[0] == undefined){
  690.         uiPopup("You lack that drug.");
  691.         return;
  692.     }
  693.     var failed = true;
  694.     for(i=0;i<hits.length;i++){
  695.         if(drug.grams<=hits[i].grams){
  696.             failed = false;
  697.         } else {
  698.             hits.splice(i,1);
  699.             i++;
  700.         }
  701.     }
  702.     if(failed){
  703.         uiPopup("You lack enough of that drug.");
  704.         return;
  705.     }
  706.     hits[0].grams-=drug.grams;
  707.     save.money+=hits[0].cost;
  708.  
  709. }*/
  710. function sellDrugs(drug,yourDrug){
  711.     console.log(drug)
  712.     switch(drug.type){
  713.         case 1:
  714.             if(drug.name==yourDrug.name){
  715.                 if(yourDrug.grams>=drug.grams){
  716.                     yourDrug.grams-=drug.grams;
  717.                     changeMoney(yourDrug.cost*drug.grams);
  718.                 } else {
  719.                     uiPopup('Not enough of that drug!');
  720.                     return;
  721.                 }
  722.             }else {
  723.                 return;
  724.             }
  725.         break;
  726.         case 2:// level ==
  727.             if(drug.level == yourDrug.level){
  728.                 if(yourDrug.grams>=drug.grams){
  729.                     yourDrug.grams-=drug.grams;
  730.                     changeMoney(yourDrug.cost*drug.grams);
  731.                 } else {
  732.                     uiPopup('Not enough of that drug!');
  733.                     return;
  734.                 }
  735.             } else {
  736.                 return;
  737.             }
  738.         break;
  739.         case 3://quanity match
  740.             if(yourDrug.grams>=drug.grams){
  741.                     yourDrug.grams-=drug.grams;
  742.                     changeMoney((yourDrug.cost*drug.grams).round(2));
  743.                 } else {
  744.                     uiPopup('Not enough of that drug!');
  745.                     return;
  746.                 }
  747.         break;
  748.         case 4:
  749.             if(yourDrug.grams>=drug.grams){
  750.                     yourDrug.grams-=drug.grams;
  751.                     changeMoney(yourDrug.cost*drug.grams/8);
  752.                 } else {
  753.                     uiPopup('Not enough of that drug!');
  754.                     return;
  755.                 }
  756.         break;
  757.         default:
  758.             uiPopup('Whatever this client is supposed to be buying, it broke.');
  759.         break;
  760.     }
  761.     document.getElementsByClassName('darky')[0].click();
  762.     uiPopup('Sold!')
  763. }
  764. Number.prototype.round = function(places) {
  765. return +(Math.round(this + "e+" + places)  + "e-" + places);
  766. }
  767.  
  768. function buyDrugs(drug){
  769.     if(save.money<drug.cost){
  770.         uiPopup("You need " + String(Number(drug.cost)-Number(save.money)) + " more dollars to buy that.");
  771.         return;
  772.     }
  773.     changeMoney(-drug.cost);
  774.     safeDrug(makeDrug(drug.level,drug.data,drug.grams))
  775.     uiPopup('Bought!')
  776. }
  777.  
  778. function addDrug(drug){
  779.     var addTo;
  780.     if(save.drugs[Number(drug.getAttribute('index'))].level>save.level*5){
  781.         uiPopup('Drug is too much higher than your level.');
  782.         return;
  783.     }
  784.     if(selected[0]==null){
  785.         var addTo = 0;
  786.     } else if(selected[1]==null){
  787.         var addTo = 1;
  788.     }
  789.     if(addTo!=undefined){
  790.         var filled;
  791.         if(selected[0]!=null){
  792.             filled = 0;
  793.         } else if(selected[1]!=null){
  794.             filled = 1;
  795.         }
  796.         if(filled!=undefined){
  797.             if(selected[filled]==save.drugs[Number(drug.getAttribute('index'))]){
  798.                 if(selected[filled].grams - Number(amounts[addTo].childNodes[0].innerHTML) < minGrams){
  799.                     uiPopup("You lack the required " + minGrams + " grams to combine.")
  800.                     return;
  801.                 }
  802.             }
  803.         }
  804.         if(save.drugs[Number(drug.getAttribute('index'))].grams>=minGrams){
  805.             amounts[addTo].childNodes[0].innerHTML=minGrams;
  806.         } else {
  807.             uiPopup("You lack the required " + minGrams + " grams to combine.")
  808.             return;
  809.         }
  810.         selected[addTo]=save.drugs[Number(drug.getAttribute('index'))];
  811.         adders[addTo].innerHTML=selected[addTo].name;
  812.         if(selected[0]!=null && selected[1]!=null){
  813.             enableCombine();
  814.         }
  815.  
  816.        
  817.     }
  818. }
  819. function show(ele){
  820.     ele.style.display="block";
  821. }
  822. function hide(ele){
  823.     ele.style.display="none";
  824. }
  825.  
  826. function uiPopup(message){
  827.     var darko=document.createElement('div');
  828.     darko.className="darky";
  829.     var pup = document.createElement('div');
  830.     pup.className="notif";
  831.     pup.innerHTML = message;
  832.     darko.onclick=function(){this.remove();pup.remove()};
  833.     document.getElementById('game').appendChild(darko);
  834.     document.getElementById('game').appendChild(pup);
  835. }
  836.  
  837. function tabSwap(tab,action){
  838.     for(i=0;i<tabs.length;i++){
  839.         tabs[i].className="menuTab";
  840.     }
  841.     tab.className="menuTabSelected";
  842.     for(i=0;i<pages.length;i++){
  843.         hide(pages[i]);
  844.     }
  845.     action();
  846. }
  847.  
  848. function showBuy(){
  849.     show(pages[0]);
  850.         redrawDealers();
  851. }
  852. function showSell(){
  853.     show(pages[1]);
  854.     redrawClients();
  855. }
  856. function showLab(){
  857.     show(pages[2]);
  858.         redrawDrugs();//might lead to issues with selling off all of an old drug and buying a new one to replace
  859. }
  860. function showUpgrades(){
  861.     show(pages[3]);
  862.     redrawUpgrades();
  863. }
  864. function showRecipes(){
  865.     show(pages[4]);
  866.     redrawRecipes();
  867. }
  868.  
  869. function showDrugs(item){
  870.     var darko=document.createElement('div');
  871.     darko.className="darky";
  872.     document.getElementById('game').appendChild(darko);
  873.     var dShow=document.createElement('div');
  874.     dShow.innerHTML='<div y=0 oldY="undefined" name="scrolly" style="position:relative" onblur="stopScroll(this)" onmousemove="scrollMM(event,this)" onmousedown="this.setAttribute(\'down\',true)" onmouseup="stopScroll(this)" id="sellDrugHolder"></div>';
  875.     document.getElementById('game').appendChild(dShow);
  876.     dShow.childNodes[0].innerHTML="";
  877.     var draw = document.createElement('div');
  878.         draw.className="drawnDrug";
  879.         //draw.style.left="100px";
  880.         draw.style.width="300px";
  881.         draw.innerHTML ="Drugs To Sell";
  882.         dShow.childNodes[0].appendChild(draw);
  883.         darko.onclick=function(){dShow.remove();darko.remove();}
  884.        
  885.     for(i=0;i<save.drugs.length;i++){
  886.         if(save.drugs[i].grams>=item.grams){
  887.         var draw = document.createElement('div');
  888.         draw.className="drawnDrug";
  889.         //draw.style.left="100px";
  890.         draw.style.width="300px";
  891.         if(item.type!=4){
  892.         draw.innerHTML=item.grams + "g " + save.drugs[i].name + ", hardness " +save.drugs[i].level + " for $" + save.drugs[i].cost*item.grams;
  893.         } else{
  894.         draw.innerHTML=item.grams + "g " + save.drugs[i].name + ", hardness " +save.drugs[i].level + " for $" + save.drugs[i].cost*item.grams/8;   
  895.         }
  896.         draw.setAttribute('index',i);
  897.         draw.onmousedown=function(){scrolled=dShow.childNodes[0].getAttribute('y')}
  898.         draw.onmouseup=function(){if(scrolled==dShow.childNodes[0].getAttribute('y')){sellDrugs(item,save.drugs[Number(this.getAttribute('index'))])}}
  899.         dShow.childNodes[0].appendChild(draw);
  900.         }
  901.     }
  902. }
  903.  
  904. function redrawDrugs(){
  905.     document.getElementById('drugHolder').innerHTML="";
  906.     for(i=0;i<save.drugs.length;i++){
  907.         var draw = document.createElement('div');
  908.         draw.className="drawnDrug";
  909.         draw.innerHTML=save.drugs[i].grams + "g " + save.drugs[i].name;
  910.         draw.setAttribute('index',i);
  911.         if(save.drugs[i].level>save.level*5||save.drugs[i].grams<minGrams){
  912.             draw.style.color = "#ff4c4c";
  913.         }
  914.         draw.onmousedown=function(){scrolled=document.getElementById('drugHolder').getAttribute('y')}
  915.         draw.onmouseup=function(){if(scrolled==document.getElementById('drugHolder').getAttribute('y')){addDrug(this)}}
  916.         document.getElementById('drugHolder').appendChild(draw);
  917.     }
  918. }
  919. function redrawDealers(){
  920.     document.getElementById('dealerHolder').innerHTML="";
  921.     for(i=0;i<save.dealers.length;i++){
  922.         var draw = document.createElement('div');
  923.         draw.className="drawnDealer";
  924.         draw.innerHTML="&nbsp<b>" + save.dealers[i].name + "</b> 1 g of " + save.dealers[i].item.name + " for " + save.dealers[i].item.cost + " dollars";
  925.         var buy = document.createElement("div");
  926.         buy.className="buyBtn";
  927.         buy.innerHTML="Buy";
  928.         buy.onclick=function(){
  929.             buyDrugs(save.dealers[Number(this.parentNode.getAttribute('index'))].item);
  930.         }
  931.         draw.appendChild(buy);
  932.         draw.setAttribute('index',i);
  933.         document.getElementById('dealerHolder').appendChild(draw);
  934.  
  935.     }
  936. }
  937. function redrawUpgrades(){
  938.     document.getElementById('upgradeHolder').innerHTML="";
  939.     for(i=0;i<save.upgrades.length;i++){
  940.         var draw = document.createElement('div');
  941.         draw.className="drawnDealer";
  942.         draw.innerHTML="&nbsp<b>" + save.upgrades[i].name + "</b>: " + save.upgrades[i].info;
  943.         var buy = document.createElement("div");
  944.         draw.style.height = "80px";
  945.         buy.className="buyBtn";
  946.         buy.style.left="300px"
  947.         buy.style.top = "10px";
  948.         buy.innerHTML="$" + (save.upgrades[i].level+1)*(save.upgrades[i].level+1)*save.upgrades[i].cScale;
  949.         buy.style.width=buy.innerHTML.length*15 + "px";
  950.         buy.onclick=function(){
  951.             //buyUpgrades(save.dealers[Number(this.parentNode.getAttribute('index'))].item);
  952.             window[save.upgrades[Number(this.parentNode.getAttribute('index'))].call](save.upgrades[Number(this.parentNode.getAttribute('index'))]);
  953.         }
  954.         draw.appendChild(buy);
  955.         draw.setAttribute('index',i);
  956.         document.getElementById('upgradeHolder').appendChild(draw);
  957.  
  958.     }
  959. }
  960. function redrawClients(){
  961.     document.getElementById('clientHolder').innerHTML="";
  962.     for(i=0;i<save.clients.length;i++){
  963.         var draw = document.createElement('div');
  964.         draw.className="drawnClient";
  965.         switch(save.clients[i].item.type){
  966.             case 1:
  967.                 draw.innerHTML="&nbsp<b>" + save.clients[i].name + "</b> Yo homie hit me wit " +  save.clients[i].item.grams +"g of "+ save.clients[i].item.name +".";
  968.             break;
  969.             case 2:
  970.                 draw.innerHTML="&nbsp<b>" + save.clients[i].name + "</b> Lookin for " + save.clients[i].item.grams +"g of that " + save.clients[i].item.level + " hardness.";
  971.             break;
  972.             case 3:
  973.                 draw.innerHTML="&nbsp<b>" + save.clients[i].name + "</b> I'll take " + save.clients[i].item.grams + "g of whatever.";
  974.             break;
  975.             case 4:
  976.                 draw.innerHTML="&nbsp<b>" + save.clients[i].name + "</b> Gimme " + save.clients[i].item.grams + "g of anything, I pay 1/8 the price.";
  977.             break;
  978.             default:
  979.                 draw.innerHTML="Customer type beyond limit";
  980.             break;
  981.         }
  982.         var buy = document.createElement("div");
  983.         buy.style.left="450px";
  984.         buy.className="buyBtn";
  985.         buy.innerHTML="Sell";
  986.         buy.onclick=function(){
  987.             showDrugs(save.clients[Number(this.parentNode.getAttribute('index'))].item);
  988.             //sellDrugs(save.dealers[Number(this.parentNode.getAttribute('index'))].item);
  989.         }
  990.         draw.appendChild(buy);
  991.         draw.setAttribute('index',i);
  992.         document.getElementById('clientHolder').appendChild(draw);
  993.  
  994.     }
  995. }
  996. function redrawRecipes(){
  997.     document.getElementById('recipeHolder').innerHTML="";
  998.     for(i=0;i<save.recipes.length;i++){
  999.         var draw = document.createElement('div');
  1000.         draw.className="drawnRecipe";
  1001.         draw.innerHTML=save.recipes[i];
  1002.         draw.setAttribute('index',i);
  1003.         document.getElementById('recipeHolder').appendChild(draw);
  1004.     }
  1005. }
  1006.  
  1007. </script>
  1008. <link href='https://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
  1009. <canvas style="position:absolute;left:0px;top:0px;opacity:1;" width="500" height="500" id="dgames">Your browser doesn't support the basic HTML5 Canvas. Get bent.</canvas>
  1010. <script>
  1011. var dgames=document.getElementById('dgames')
  1012. dtx=dgames.getContext('2d')
  1013. var fallings=[]
  1014. var slidings=[]
  1015. var bullets=[]
  1016. var tough=0;
  1017. var startCount=0;
  1018. var dposx=0;
  1019. var splash;
  1020. var fireoff=false;
  1021. var pletters=["D","e","m","o","g","o","r","g","o","n"]
  1022.  
  1023.  
  1024. function Demo(){
  1025. dtx.fillStyle="black"
  1026. dtx.fillRect(0,0,dgames.width,dgames.height)
  1027. dtx.font = "60px Inconsolata";
  1028.  
  1029. splash=setInterval(function(){
  1030. tough++
  1031. if(bullets==""&&fallings==""){
  1032. //console.log(tough/60)
  1033. }
  1034. addem();
  1035. moveem();
  1036. slideem();
  1037. bulletTime();
  1038. rendem()
  1039. },16.66666666)
  1040.  
  1041. }
  1042.  
  1043.  
  1044. function bulletTime(){
  1045. for(i=0;i<bullets.length;i++){
  1046. var nom=bullets[i].goN
  1047. var denom=bullets[i].goD
  1048. if(nom<0){
  1049. var nommod = -1
  1050. } else {
  1051. var nommod=1
  1052. }
  1053. if(denom<0){
  1054. var denommod = -1
  1055. } else {
  1056. var denommod=1
  1057. }
  1058. denommod*=-1
  1059. nommod*=-1
  1060. var newnom=Math.abs(nom)/(Math.abs(nom)+Math.abs(denom))
  1061. var topped=(bullets[i].konstant*newnom)
  1062. var bully=bullets[i].y + (topped*nommod)
  1063. bullets[i].y=bully
  1064. var bully=bullets[i].x + (denommod * (bullets[i].konstant-topped))
  1065. bullets[i].x=bully
  1066. if(bullets[i].x>dgames.width+100||bullets[i].x<-1*(dgames.width+100)||bullets[i].y>dgames.height||bullets[i].y<-1*(dgames.height+100)){
  1067. bullets.splice(i,1)
  1068. i++
  1069. }
  1070. //bullets[i].konstant=bullets[i].maxKonstant
  1071. }
  1072. }
  1073.  
  1074. function slideem(){
  1075. if(!fireoff){
  1076. for(i=0;i<slidings.length;i++){
  1077. if(slidings[i].x!=slidings[i].xlim){
  1078. slidings[i].x+=slidings[i].xmod
  1079. }
  1080. if(slidings[i].y>slidings[i].ylim){
  1081. slidings[i].y+=slidings[i].ymod
  1082. }
  1083. }
  1084. }
  1085. }
  1086.  
  1087. function moveem(){
  1088. if(!fireoff){
  1089. for(i=0;i<fallings.length;i++){
  1090. switch(fallings[i].stage){
  1091.  
  1092. case 1:
  1093. if(fallings[i].y<dgames.height/1.5){
  1094. fallings[i].y+=fallings[i].acc
  1095. fallings[i].acc+=.1
  1096. } else {
  1097. fallings[i].acc;
  1098. fallings[i].stage++
  1099. }
  1100. break;
  1101. case 2:
  1102. if(fallings[i].y>dgames.height/4){
  1103. fallings[i].y-=fallings[i].acc
  1104. fallings[i].acc-=.13
  1105. }else {
  1106. fallings[i].acc=.1
  1107. fallings[i].stage++
  1108. }
  1109. break;
  1110. case 3:
  1111. if(fallings[i].y<dgames.height/1.8){
  1112. fallings[i].y+=fallings[i].acc
  1113. fallings[i].acc+=.1
  1114. } else {
  1115. fallings[i].acc;//=.1
  1116. fallings[i].stage++
  1117. }
  1118. break;
  1119. case 4:
  1120. if(fallings[i].y>dgames.height/2.5){
  1121. fallings[i].y-=fallings[i].acc
  1122. fallings[i].acc-=.2
  1123. }else {
  1124. fallings[i].acc=.1
  1125. fallings[i].stage++
  1126. }
  1127. break;
  1128. }
  1129. }
  1130. }
  1131. }
  1132. function addem(){
  1133. if(dposx/40<pletters.length){
  1134. if(tough%5==0){
  1135. fallings.push(new Letters(dposx+50,-30,pletters[dposx/40],"cyst"))
  1136. dposx+=40
  1137. }
  1138. }
  1139. if(fallings!=""){
  1140. if(fallings[fallings.length-1].stage==5){
  1141. //go
  1142. slidings.push(new Letters(-40,265,"es",5,0,300,0))
  1143. slidings[slidings.length-1].color="#F2D95C"
  1144. slidings.push(new Letters(dgames.width+40,265,"Ga",-5,0,200,0))
  1145. slidings[slidings.length-1].color="#F2D95C"
  1146. slidings.push(new Letters(265,dgames.height+30,"m",0,-6,0,270))
  1147. slidings[slidings.length-1].color="#F2D95C"
  1148. fallings[fallings.length-1].stage=6
  1149. }
  1150. }
  1151. if(slidings!=""){
  1152. if(slidings[0].x==slidings[0].xlim){
  1153. startCount++
  1154. if(startCount>60){
  1155. var fireoff=true
  1156. for(i=0;i<fallings.length;i++){
  1157. bullets.push(fallings[i])
  1158. }
  1159. fallings=[]
  1160. for(i=0;i<slidings.length;i++){
  1161. bullets.push(slidings[i])
  1162. }
  1163. slidings=[]
  1164. }
  1165. }
  1166. }
  1167. }
  1168. function Letters(x,y,content,xmod,ymod,xlim,ylim){
  1169. this.x=x
  1170. this.y=y
  1171. this.content=content
  1172. this.stage=1;
  1173. this.acc=.1;
  1174. this.xmod=xmod;
  1175. this.ymod=ymod;
  1176. this.xlim=xlim;
  1177. this.ylim=ylim;
  1178. this.goN=250-this.y
  1179. this.goD=250-this.x
  1180. this.konstant=8
  1181. this.color="#048ABF"
  1182. }
  1183. function rendem(){
  1184. //dtx.clearRect(0,0,dgames.width,dgames.height)
  1185. dtx.globalAlpha=.15;
  1186. dtx.fillStyle="black"
  1187. dtx.fillRect(0,0,dgames.width,dgames.height)
  1188. dtx.globalAlpha=1;
  1189. dtx.fillStyle="#048ABF"
  1190. for(i=0;i<fallings.length;i++){
  1191. dtx.fillText(fallings[i].content,fallings[i].x,fallings[i].y)
  1192. }
  1193. dtx.fillStyle="#F2D95C"
  1194. for(i=0;i<slidings.length;i++){
  1195. dtx.fillText(slidings[i].content,slidings[i].x,slidings[i].y)
  1196. }
  1197. for(i=0;i<bullets.length;i++){
  1198. dtx.fillStyle=bullets[i].color
  1199. dtx.fillText(bullets[i].content,bullets[i].x,bullets[i].y)
  1200. }
  1201. if(bullets!=""){
  1202. var temp=Number(dgames.style.opacity)
  1203. temp-=.02
  1204. dgames.style.opacity=temp
  1205. }
  1206. if(temp<=0){
  1207.     clearInterval(splash);
  1208.     dgames.remove();
  1209. }
  1210. }
  1211. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand