-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
164 additions
and
16 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/Disp/HelperFunctions/CalculateStockNextExpectedValue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* This function calculates a stock's next expected value | ||
* @param {number} value The stock's current value | ||
* @param {number} delta The stock's current delta | ||
* @param {number} restingValue The stock's resting value | ||
* @param {number} mode The stock's current mode | ||
* @param {number} bankLevel The bank building level | ||
* @param {number} dragonBoost The current aura multiplier from Supreme Intellect and Reality Bending | ||
* @returns {number} value + delta The stock's next expected value | ||
*/ | ||
export default function CalculateStockNextExpectedValue( | ||
pValue, | ||
pDelta, | ||
restingValue, | ||
mode, | ||
bankLevel, | ||
dragonBoost, | ||
) { | ||
let value = pValue; | ||
let delta = pDelta; | ||
delta *= 0.97 + 0.01 * dragonBoost; | ||
switch (mode) { | ||
case 0: | ||
delta *= 0.95; | ||
break; | ||
case 1: | ||
delta *= 0.99; | ||
delta += 0.02; | ||
break; | ||
case 2: | ||
delta *= 0.99; | ||
delta -= 0.02; | ||
break; | ||
case 3: | ||
delta += 0.06; | ||
value += 2.5; | ||
break; | ||
case 4: | ||
delta -= 0.06; | ||
value -= 2.5; | ||
break; | ||
default: | ||
break; | ||
} | ||
value += (restingValue - value) * 0.01; | ||
if (mode === 3) value -= 0.582; | ||
if (mode === 4) value += 0.6; | ||
if (value > 100 + (bankLevel - 1) * 3 && delta > 0) delta *= 0.9; | ||
if (value < 5) value += (5 - value) * 0.5; | ||
if (value < 5 && delta < 0) delta *= 0.95; | ||
return Math.max(value + delta, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import Beautify from '../../BeautifyAndFormatting/Beautify'; | ||
import { | ||
TooltipName, | ||
ColourTextPre, | ||
ColourGreen, | ||
ColourYellow, | ||
ColourOrange, | ||
ColourRed, | ||
ColourPurple, | ||
ColourGray, | ||
} from '../../VariablesAndData'; | ||
import CalculateStockNextExpectedValue from '../../HelperFunctions/CalculateStockNextExpectedValue'; | ||
import * as Create from '../CreateTooltip'; | ||
|
||
/** | ||
* This function adds extra info to the stock market | ||
* It adds to the additional information to l('CMTooltipArea') | ||
*/ | ||
export default function StockMarket() { | ||
const { minigame } = Game.Objects.Bank; | ||
if (Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.TooltipStocks) { | ||
const tooltipBox = l('CMTooltipBorder'); | ||
const stock = minigame.goodsById[TooltipName]; | ||
|
||
// Current stock mode | ||
tooltipBox.appendChild(Create.TooltipCreateHeader('Current Mode')); | ||
const stockMode = document.createElement('div'); | ||
stockMode.id = 'CMTooltipMode'; | ||
tooltipBox.appendChild(stockMode); | ||
const modeIndex = stock.mode; | ||
const modes = ['Stable', 'Slow Rise', 'Slow Fall', 'Fast Rise', 'Fast Fall', 'Chaotic']; | ||
stockMode.textContent = modes[modeIndex]; | ||
const colours = [ColourGray, ColourYellow, ColourOrange, ColourGreen, ColourRed, ColourPurple]; | ||
stockMode.className = ColourTextPre + colours[modeIndex]; | ||
|
||
// Current stock delta value | ||
tooltipBox.appendChild(Create.TooltipCreateHeader('Delta')); | ||
const delta = document.createElement('div'); | ||
delta.id = 'CMTooltipDelta'; | ||
tooltipBox.appendChild(delta); | ||
delta.textContent = Beautify(stock.d); | ||
const deltaColour = stock.d < 0 ? ColourRed : ColourGreen; | ||
delta.className = ColourTextPre + deltaColour; | ||
|
||
// Stock resting value | ||
tooltipBox.appendChild(Create.TooltipCreateHeader('Resting Value')); | ||
const restingValue = document.createElement('div'); | ||
restingValue.id = 'CMTooltipRestingValue'; | ||
tooltipBox.appendChild(restingValue); | ||
restingValue.textContent = `$${Beautify(minigame.getRestingVal(stock.id))}`; | ||
restingValue.style.color = 'white'; | ||
|
||
// Next expected value | ||
tooltipBox.appendChild(Create.TooltipCreateHeader('Expected Next Value')); | ||
const expectedNextValue = document.createElement('div'); | ||
expectedNextValue.id = 'CMTooltipExpectedValue'; | ||
tooltipBox.appendChild(expectedNextValue); | ||
const expectedValue = CalculateStockNextExpectedValue( | ||
stock.val, | ||
stock.d, | ||
minigame.getRestingVal(stock.id), | ||
stock.mode, | ||
Game.Objects.Bank.level, | ||
Game.auraMult('Supreme Intellect'), | ||
); | ||
expectedNextValue.textContent = `$${Beautify(expectedValue) + (expectedValue < stock.val ? '\u25bc' : '\u25b2')}`; | ||
const expectedNextValueColour = expectedValue < stock.val ? ColourRed : ColourGreen; | ||
expectedNextValue.className = ColourTextPre + expectedNextValueColour; | ||
|
||
l('CMTooltipArea').appendChild(tooltipBox); | ||
} else l('CMTooltipArea').style.display = 'none'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters