Guest User

ShMod

a guest
Aug 12th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Shareholders = {};
  2. (function(){
  3. UltimateLib.Research.addRndResearch({
  4.     id: "c0956353-4012-4983-9576-22e515e14f69",
  5.     name: "National Stock Exchange",
  6.     pointsCost: 1000,
  7.     iconUri: "./mods/Shareholders/images/researches/lab/ResearchIMG.png",
  8.     description: "This will unlock the ability to sell shares on the National Stock Exchange and create extra cash for your upcoming projects",
  9.     canResearch: function () {
  10.                             var res = true;
  11.                             res &= GameManager.company.flags.rndLabUnlocked;
  12.  
  13.                         return res;
  14.                 },
  15.     repeatable: false,
  16.     targetZone: 2,
  17.     complete: function () {
  18.            
  19.             var research =  Research.getAllItems().filter(function (f) { return f.id === 'c0956353-4012-4983-9576-22e515e14f69';  });
  20.             if(research){
  21.                 GameManager.company.researchCompleted.push(research);
  22.                 var notification = new Notification({
  23.                     header: "National Stock Exchange",
  24.                     text: "You have now unlocked the ability to sell shares. Click on the screen to go to the National Stock Exchange.",
  25.                     image: "",
  26.                     buttonText: "OK",
  27.                     weeksUntilFired: 0
  28.                 });
  29.                 GameManager.company.notifications.push(notification);
  30.                             // Actions
  31.             }
  32.             else {
  33.                 var notification = new Notification({
  34.                     header: "UME Error",
  35.                     text: "An error occurred on lab research complete callback.",
  36.                     image: "",
  37.                     buttonText: "OK",
  38.                     weeksUntilFired: 0
  39.                 });
  40.                 GameManager.company.notifications.push(notification);
  41.             }
  42.            
  43.     }
  44. })
  45.  
  46.  
  47. var shareValue;
  48. var shareAmount;
  49.  
  50.     UI.SellShares = function (a) {
  51.         Sound.click();
  52.         switch (a.id) {
  53.             case "SellShares":
  54.             sharesSell();
  55.                 break;
  56.             default:
  57.                 return;
  58.         }
  59.     };
  60.        
  61.     var div = $("body");
  62.     div.append('<div id="NatStockEx" class="windowBorder tallWindow" style="overflow:auto;display:none;"> <div id="toNSE" class="windowTitle smallerWindowTitle">National Stock Exchange</div>');
  63.     div = $("#NatStockEx");
  64.    
  65.     div.append('<div id="ShareValue" style="text-align:center;margin-left:50px;width: 450px"></div>');
  66.     div.append('<div id="MaxAmountOfShares" style="text-align:center;margin-left:50px;width: 450px"></div>');
  67.    
  68.     div.append('<div id="AmountOfShares" style="text-align:center;margin-left:50px;width: 450px"></div>');
  69.     div.append('<div class="SAS"></div>');
  70.     div.append('<div id="SellShares" class="selectorButton whiteButton" onclick="UI.SellShares(this)" style="margin-left:50px;width: 450px">Sell shares</div>');
  71.    
  72.    
  73.    
  74.     function valueShares() { // Value of each share
  75.         shareValue = GameManager.company.cash / 500000000 * 20;
  76.         div.find("#ShareValue").html("Value per share: " + shareValue) 
  77.     };
  78.    
  79.     function MaxShares() { // Max amount of shares that can be sold
  80.         var maxAmount = Math.round(GameManager.company.cash / shareValue)
  81.         div.find("#MaxAmountOfShares").html("Maximum amount of shares: " + maxAmount);
  82.     };
  83.    
  84.     function totalShares(z) {
  85.         var amountOfShares = z;
  86.         div.find("#AmountOfShares").html("Amount of shares selected to sell:" + amountOfShares)
  87.     }
  88.        
  89.     function sharesSell() {
  90.         shareValue = GameManager.company.cash / 500000000 * 20;
  91.         var s = amountOfShares * shareValue;
  92.         GameManager.company.adjustCash(s, "Shares Sales")
  93.     };
  94.  
  95.      var OriginalContextMenu = UI.showContextMenu;
  96.         var NewContextMenu = function (b, c, d, h) {
  97.             c.push({
  98.                 label: "National Stock Exchange...",
  99.                 action: function () {
  100.                     Sound.click();
  101.                     GameManager.resume(true);
  102.                     var div = $("#NatStockEx");
  103.                     div.scrollTop()
  104.                     div.gdDialog({
  105.                         popout: !0,
  106.                         close: !0
  107.                     })
  108.  
  109.                 //var shareValue = GameManager.company.cash / 500000000 * 20;
  110.                 }
  111.             });
  112.             var shareAmount = Math.round(GameManager.company.cash / shareValue);
  113.             var maxValue = math.floor(GameManager.company.cash / (GameManager.company.cash / 500000000 * 20)); // line 107
  114.                 div.find(".SAS").slider({
  115.                     min: 1,
  116.                     max: maxValue,
  117.                     range: "min",
  118.                     value: Math.floor(shareAmount),
  119.                     animate: !1,
  120.                     slide: function (a, b) {
  121.                         var c = b.value;
  122.                         totalShares(c);
  123.                     }
  124.                 });
  125.             totalShares(shareAmount);
  126.             OriginalContextMenu(b, c, d, h);
  127.         };
  128.         UI.showContextMenu = NewContextMenu;
  129. })();
Advertisement
Add Comment
Please, Sign In to add comment