js/index.js
//Sell cargo, check if legal, update cash and cost
Sell cargo, check if legal, update cash and cost
Sell cargo check if legal update cash and cost
function sellCargo(hld) {
  switch (cargo[hld]) {
    case 0:
    case undefined:
      alert("That hold is empty.");
      break;
    default:
      var sellPrice = portInfo[nowPort][cargo[hld]] * (1-portInfo[nowPort][0]);
      cash += Math.round(sellPrice);
      document.getElementById("cash").innerHTML = "$" + cash;
      portInfo[nowPort][cargo[hld]] = Math.round(portInfo[nowPort][cargo[hld]]*(Math.random()*5+95)/100);
      cargo.pop(cargo[hld]);
      listPort();
      break;
  }
  listCargo();
}
function sellCargo ( hld ) { switch ( cargo [ hld ] ) { case 0 : case undefined : alert ( "That hold is empty." ) ; break ; default : var sellPrice = portInfo [ nowPort ] [ cargo [ hld ] ] * ( 1 - portInfo [ nowPort ] [ 0 ] ) ; cash += Math . round ( sellPrice ) ; document . getElementById ( "cash" ) . innerHTML = "$" + cash ; portInfo [ nowPort ] [ cargo [ hld ] ] = Math . round ( portInfo [ nowPort ] [ cargo [ hld ] ] * ( Math . random ( ) * 5 + 95 ) / 100 ) ; cargo . pop ( cargo [ hld ] ) ; listPort ( ) ; break ; } listCargo ( ) ; }
Sell cargo, check if legal, update cash and cost
Sell cargo check if legal update cash and cost
//sell produce in the selected hold, add to cash price - landing tax //set hold to undefined (to be filled on buy) //price will drop 0-5%