Advertisement
Guest User

Untitled

a guest
Feb 14th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     var d = GDT.getDataStore("FSMPASTRACT").data
  2.  
  3.     d.YPA = []; // create array
  4.  
  5.     var a = function() {
  6.         var b = GameManager.company.getDate(GameManager.company.currentWeek)
  7.         if (b.week == 1 && b.month == 1) { // this block of code should run once a year (on M1 W1)
  8.             d.YPA.push(parseInt(GameManager.company.cash)); // add current cash to the array
  9.             if (d.YPA.length >= 2) { // check if the array contains 2 or more items
  10.                 d.YP = parseInt(d.YPA[d.YPA.length - 1]) - parseInt(d.YPA[d.YPA.length - 2]); // YP is the difference between the latest addition to the array and the one before that (= profit in a year)
  11.                 if (d.ASS > 0 && d.YP > 0) { // if amount of shares sold and yearly profit is higher than 0
  12.                     GameManager.company.adjustCash(-d.YP * 0.2, "a"); // subtract 20% of the yearly profit from current cash
  13.                 }
  14.             }
  15.         }
  16.     }  
  17.     GDT.on(GDT.eventKeys.gameplay.weekProceeded, a); // check every week to see if it's M1 W1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement