Add stock market tooltip info (#1189)
* Add info to stock market tooltips * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add up and down arrows to expected value --------- Co-authored-by: srs42006 <45675882+srs42006@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
52
src/Disp/HelperFunctions/CalculateStockNextExpectedValue.js
Normal file
52
src/Disp/HelperFunctions/CalculateStockNextExpectedValue.js
Normal file
@@ -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);
|
||||
}
|
||||
@@ -98,6 +98,8 @@ export function CreateTooltip(type, name) {
|
||||
l('tooltip').innerHTML = Game.ObjectsById[2].minigame.tileTooltip(name[0], name[1])();
|
||||
// Harvest all button in garden
|
||||
else if (type === 'ha') l('tooltip').innerHTML = Game.ObjectsById[2].minigame.toolTooltip(1)();
|
||||
// Stock market
|
||||
else if (type === 'sm') l('tooltip').innerHTML = Game.Objects.Bank.minigame.goodTooltip(name)();
|
||||
else if (type === 'wb') l('tooltip').innerHTML = '';
|
||||
else if (type === 'pag') l('tooltip').innerHTML = Game.Objects.Temple.minigame.godTooltip(name)();
|
||||
else if (type === 'pas')
|
||||
@@ -111,6 +113,7 @@ export function CreateTooltip(type, name) {
|
||||
type === 'g' ||
|
||||
(type === 'p' && !Game.keys[16]) ||
|
||||
type === 'ha' ||
|
||||
type === 'sm' ||
|
||||
type === 'wb' ||
|
||||
type === 'pag' ||
|
||||
(type === 'pas' && name[1] !== -1)
|
||||
|
||||
72
src/Disp/Tooltips/TypesOfTooltips/StockMarket.js
Normal file
72
src/Disp/Tooltips/TypesOfTooltips/StockMarket.js
Normal file
@@ -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';
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { TooltipName, TooltipType } from '../VariablesAndData';
|
||||
import * as Create from './CreateTooltip';
|
||||
import Building from './TypesOfTooltips/Building';
|
||||
import GardenPlots from './TypesOfTooltips/GardenPlots';
|
||||
import StockMarket from './TypesOfTooltips/StockMarket';
|
||||
import Grimoire from './TypesOfTooltips/Grimoire';
|
||||
import HarvestAll from './TypesOfTooltips/HarvestAll';
|
||||
import PantheonGods from './TypesOfTooltips/PantheonGods';
|
||||
@@ -33,6 +34,8 @@ export default function UpdateTooltips() {
|
||||
GardenPlots();
|
||||
} else if (TooltipType === 'ha') {
|
||||
HarvestAll();
|
||||
} else if (TooltipType === 'sm') {
|
||||
StockMarket();
|
||||
} else if (TooltipType === 'wb') {
|
||||
WrinklerButton();
|
||||
} else if (TooltipType === 'pag' || (TooltipType === 'pas' && TooltipName[1] !== -1)) {
|
||||
|
||||
Reference in New Issue
Block a user