diff --git a/src/js/economyJS.js b/src/js/economyJS.js index 416b5dc490ee26b9d6bc207dd80a553adadc81e0..88852eb0445e99c94f22b0bf9511c30e71b7da05 100644 --- a/src/js/economyJS.js +++ b/src/js/economyJS.js @@ -1294,12 +1294,14 @@ window.corpValue = function() { // Corporation Share Price // A positive q means adding shares to the market, negative means removing them -window.corpSharePrice = function(q = 0) { +window.corpSharePrice = function(q = 0, personalShares = null, publicShares = null) { const V = State.variables; if (V.corpIncorporated === 0) { return 0; } - return Math.trunc(1000 * (corpValue() / (V.personalShares + V.publicShares + q))); + personalShares = personalShares || V.personalShares; + publicShares = publicShares || V.publicShares; + return Math.trunc(1000 * (corpValue() / (personalShares + publicShares + q))); }; // Corporation Division Slave room diff --git a/src/pregmod/manageCorporation.tw b/src/pregmod/manageCorporation.tw index 0d38e39f5178e52eed764f68c162f2078c21b3a1..f04219aefb3521e7bd0bfcbd9568f49f42229cd9 100644 --- a/src/pregmod/manageCorporation.tw +++ b/src/pregmod/manageCorporation.tw @@ -1377,38 +1377,28 @@ __Dividend__ __Shares__ <br>You own <<print num($personalShares)>> shares while another <<print num($publicShares)>> shares are traded publicly. The going rate on the market for 1000 shares is currently @@.yellowgreen;<<print cashFormat(corpSharePrice())>>.@@ -<br>The corporation can buyback 1000 shares for @@.red;<<print cashFormat(corpSharePrice(-1000))>>@@ or issue 1000 shares and net @@.yellowgreen;<<print cashFormat(corpSharePrice(1000))>>.@@ +<br>The corporation can buyback 1000 shares for @@.red;<<print cashFormat(corpSharePrice(-1000))>>@@ or issue 1000 shares and net @@.yellowgreen;<<print cashFormat(corpSharePrice(1000))>>.@@ The corporation will prefer to round shares to the nearest 1000 and will issue or buy shares toward that goal first. <<if $corpCash > corpSharePrice(-1000)>> <<if $publicShares <= $personalShares - 2000 && $publicShares > 0>> /*It won't buy back player shares if the corporation is entirely owned by the player*/ - <br>The corporation can buyback some of your shares. [[Buyback 1000|Manage Corporation][cashX(corpSharePrice(-1000), "stocksTraded"), $corpCash -= corpSharePrice(-1000), $personalShares -= 1000]] + <<set _persExtraShares = $personalShares % 1000 || 1000>> + <br>The corporation can buyback some of your shares. + <<= "[[Buyback "+ _persExtraShares + "|Manage Corporation][cashX(corpSharePrice(-"+_persExtraShares+"), 'stocksTraded'), $corpCash -= corpSharePrice(-"+_persExtraShares+"), $personalShares -= "+_persExtraShares+"]]">> <<elseif $publicShares >= 1000>> - <br>The corporation can buyback some of the public shares. [[Buyback 1000|Manage Corporation][$corpCash -= corpSharePrice(-1000), $publicShares -= 1000]] + <<set _pubExtraShares = $publicShares % 1000 || 1000>> + <br>The corporation can buyback some of the public shares. + <<= "[[Buyback "+ _pubExtraShares + "|Manage Corporation][$corpCash -= corpSharePrice(-"+_pubExtraShares+"), $publicShares -= "+_pubExtraShares+"]]">> <</if>> <</if>> -/* Splitting shares when they're unwieldy */ -<<set _splitFeeInitial = 10000>> -<<set _singleSplitInitial = 0.01>> -<<set _splitFeeValue = _splitFeeInitial - Math.floor((_splitFeeInitial * ($PC.trading / 100.0) / 2.0) / 1000) * 1000>> -<<set _singleSplitValue = _singleSplitInitial>> -<<set _singleSplitTotal = _singleSplitValue * $publicShares * $personalShares + _splitFeeValue>> - <br>The corporation can perform a 2-for-1 Stock Split for @@.red;<<= cashFormat(_singleSplitValue) >>@@ per share and a market fee of @@.red;<<= cashFormat(_splitFeeValue)>>@@ for a total of @@.red;<<= cashFormat(_singleSplitTotal)>>@@. -<<if _splitFeeValue < _splitFeeInitial>> - //You negotiated lower fees due to your @@.springgreen;business acumen@@.// -<</if>> -<<if $corpSpecTimer > 0>> -//The corporation has restructured too recently.// -<<elseif $corpCash > _singleSplitTotal>> -[[Split Shares|Manage Corporation][$corpCash -= _singleSplitTotal, $publicShares *= 2, $personalShares *= 2, $corpSpecTimer=1]] -<<else>> -//The corporation cannot afford the fees.// -<</if>> - -<<if $cash > corpSharePrice(1000)>> - <br>The corporation can issue 1000 shares to you. [[Issue 1000|Manage Corporation][cashX(forceNeg(corpSharePrice(1000)), "stocksTraded"), $corpCash += corpSharePrice(1000), $personalShares += 1000]] +<<set _persLeftoverShares = 1000 - ($personalShares % 1000)>> +<<if $cash > corpSharePrice(_persLeftoverShares)>> + <br>The corporation can issue <<=_persLeftoverShares>> shares to you. + <<= "[[Issue " + _persLeftoverShares + "|Manage Corporation][cashX(forceNeg(corpSharePrice("+_persLeftoverShares+")), 'stocksTraded'), $corpCash += corpSharePrice("+_persLeftoverShares+"), $personalShares += "+_persLeftoverShares+"]]">> <</if>> +<<set _pubLeftoverShares = 1000 - ($publicShares % 1000)>> <<if $publicShares <= $personalShares - 2000>> - <br>The corporation can issue 1000 shares onto the stock market. [[Issue 1000|Manage Corporation][$corpCash += corpSharePrice(1000), $publicShares += 1000]] + <br>The corporation can issue <<=_pubLeftoverShares>> shares onto the stock market. + <<= "[[Issue " + _pubLeftoverShares + "|Manage Corporation][$corpCash += corpSharePrice("+_pubLeftoverShares+"), $publicShares += "+_pubLeftoverShares+"]]">> <</if>> <<if $publicShares <= $personalShares - 3000>> <br>You can sell some of your shares on the stock market. [[Sell 1000|Manage Corporation][cashX(corpSharePrice(), "stocksTraded"), $personalShares -= 1000, $publicShares += 1000]] @@ -1416,7 +1406,76 @@ __Shares__ <<if $cash > corpSharePrice() && $publicShares >= 1000>> <br>You can buy some shares from the stock market [[Buy 1000|Manage Corporation][cashX(forceNeg(corpSharePrice()), "stocksTraded"), $personalShares += 1000, $publicShares -= 1000]] <</if>> +<br>__Stock Split__ +/* Splitting shares when they're unwieldy */ +<<set _splitFeeInitial = 10000>> +<<set _splitFeeValue = _splitFeeInitial - Math.floor((_splitFeeInitial * ($PC.trading / 100.0) / 2.0) / 1000) * 1000>> +<<set _splitStockConstants = [ +{ + 'newStocks': 3, + 'oldStocks': 2, + 'weeks': 1, + 'cost': 7.5 +}, +{ + 'newStocks': 2, + 'weeks': 1, + 'cost': 10 +}, +{ + 'newStocks': 3, + 'weeks': 2, + 'cost': 12.5 +}, +{ + 'newStocks': 4, + 'weeks': 3, + 'cost': 15 +}, +{ + 'oldStocks': 4, + 'weeks': 1, + 'cost': 15 +}, +{ + 'oldStocks': 10, + 'weeks': 2, + 'cost': 25 +}, +]>> + + <br>The corporation can perform a stock split to increase the number of stocks while maintaining the same owned value. This requires paying a market fee of @@.red;<<= cashFormat(_splitFeeValue)>>@@ plus a per-share fee depending on the type of split being done. + <<if _splitFeeValue < _splitFeeInitial>> + //You negotiated lower fees due to your @@.springgreen;business acumen@@.// + <</if>> +<<if $corpSpecTimer > 0>> + <br>//The corporation has restructured too recently.// +<</if>> +<ul> +<<for _stockType range _splitStockConstants>> + <<set _splitInitial = _stockType['cost']>> + <<set _splitValue = _splitInitial>> + <<set _splitDenom = _stockType['oldStocks'] || 1>> + <<set _splitNumerator = _stockType['newStocks'] || 1>> + <<set _splitMultiplier = _splitNumerator / _splitDenom>> + <<set _splitTotal = _splitValue * ($publicShares + $personalShares) + _splitFeeValue>> + <<set _splitWeek = _stockType['weeks']>> + <li><<= _splitNumerator >>-for-<<= _splitDenom>> <<if _splitDenom > _splitNumerator>>inverse<</if>> stock split at @@.red;<<= cashFormat(_splitValue) >>@@ per share. + Including market fees, this will cost the corporation a total of @@.red;<<= cashFormat(_splitTotal)>>@@, + leaving the going rate for stock at @@.yellowgreen;<<= cashFormat(Math.floor(corpSharePrice(0, $personalShares * _splitMultiplier, $publicShares * _splitMultiplier))) >>@@ per 1000 shares. + <<if $corpSpecTimer == 0>> + <<if $publicShares % _splitDenom != 0 || $personalShares % _splitDenom != 0>> + //The number of shares cannot be evenly split// + <<elseif $corpCash > _splitTotal>> + <<= "[[Split Shares|Manage Corporation][$corpCash -= " + _splitTotal + ", $publicShares *= " + _splitMultiplier + ", $personalShares *= " + _splitMultiplier + ", $corpSpecTimer="+_splitWeek+"]]" >> + <<else>> + //The corporation cannot afford the fees.// + <</if>> + <</if>> + </li> +<</for>> +</ul> <br><br> __Slave specialization__