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:
2
dist/CookieMonster.js
vendored
2
dist/CookieMonster.js
vendored
File diff suppressed because one or more lines are too long
2
dist/CookieMonster.js.map
vendored
2
dist/CookieMonster.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/CookieMonsterDev.js
vendored
2
dist/CookieMonsterDev.js
vendored
File diff suppressed because one or more lines are too long
2
dist/CookieMonsterDev.js.map
vendored
2
dist/CookieMonsterDev.js.map
vendored
File diff suppressed because one or more lines are too long
18
package-lock.json
generated
18
package-lock.json
generated
@@ -4799,8 +4799,7 @@
|
|||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.2.0.tgz",
|
||||||
"integrity": "sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==",
|
"integrity": "sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"@webpack-cli/info": {
|
"@webpack-cli/info": {
|
||||||
"version": "1.5.0",
|
"version": "1.5.0",
|
||||||
@@ -4815,8 +4814,7 @@
|
|||||||
"version": "1.7.0",
|
"version": "1.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.7.0.tgz",
|
||||||
"integrity": "sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==",
|
"integrity": "sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"@xtuc/ieee754": {
|
"@xtuc/ieee754": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
@@ -4840,8 +4838,7 @@
|
|||||||
"version": "5.3.2",
|
"version": "5.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
|
||||||
"integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
|
"integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"ajv": {
|
"ajv": {
|
||||||
"version": "6.12.6",
|
"version": "6.12.6",
|
||||||
@@ -4859,8 +4856,7 @@
|
|||||||
"version": "3.5.2",
|
"version": "3.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
|
||||||
"integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
|
"integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"ansi-colors": {
|
"ansi-colors": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
@@ -5492,8 +5488,7 @@
|
|||||||
"version": "8.8.0",
|
"version": "8.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz",
|
||||||
"integrity": "sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==",
|
"integrity": "sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
},
|
},
|
||||||
"eslint-import-resolver-node": {
|
"eslint-import-resolver-node": {
|
||||||
"version": "0.3.7",
|
"version": "0.3.7",
|
||||||
@@ -7455,8 +7450,7 @@
|
|||||||
"version": "1.7.6",
|
"version": "1.7.6",
|
||||||
"resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.7.6.tgz",
|
"resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.7.6.tgz",
|
||||||
"integrity": "sha512-FlVvVFA1TX6l3lp8VjDnYYq7R1nyW6x3svAt4nDgrWQ9SBaSh9CnbwgSUTasgfNfOG5HlM1ehugCvM+hjo56LA==",
|
"integrity": "sha512-FlVvVFA1TX6l3lp8VjDnYYq7R1nyW6x3svAt4nDgrWQ9SBaSh9CnbwgSUTasgfNfOG5HlM1ehugCvM+hjo56LA==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -549,6 +549,14 @@ const settings = {
|
|||||||
'Shows a tooltip for plants that have a cookie reward.',
|
'Shows a tooltip for plants that have a cookie reward.',
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
|
TooltipStocks: new settingClasses.SettingStandard(
|
||||||
|
1,
|
||||||
|
'bool',
|
||||||
|
'Tooltip',
|
||||||
|
['Stock market tooltips OFF', 'Stock market tooltips ON'],
|
||||||
|
'Shows additional info in the stock market tooltips.',
|
||||||
|
true,
|
||||||
|
),
|
||||||
TooltipPantheon: new settingClasses.SettingStandard(
|
TooltipPantheon: new settingClasses.SettingStandard(
|
||||||
1,
|
1,
|
||||||
'bool',
|
'bool',
|
||||||
|
|||||||
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])();
|
l('tooltip').innerHTML = Game.ObjectsById[2].minigame.tileTooltip(name[0], name[1])();
|
||||||
// Harvest all button in garden
|
// Harvest all button in garden
|
||||||
else if (type === 'ha') l('tooltip').innerHTML = Game.ObjectsById[2].minigame.toolTooltip(1)();
|
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 === 'wb') l('tooltip').innerHTML = '';
|
||||||
else if (type === 'pag') l('tooltip').innerHTML = Game.Objects.Temple.minigame.godTooltip(name)();
|
else if (type === 'pag') l('tooltip').innerHTML = Game.Objects.Temple.minigame.godTooltip(name)();
|
||||||
else if (type === 'pas')
|
else if (type === 'pas')
|
||||||
@@ -111,6 +113,7 @@ export function CreateTooltip(type, name) {
|
|||||||
type === 'g' ||
|
type === 'g' ||
|
||||||
(type === 'p' && !Game.keys[16]) ||
|
(type === 'p' && !Game.keys[16]) ||
|
||||||
type === 'ha' ||
|
type === 'ha' ||
|
||||||
|
type === 'sm' ||
|
||||||
type === 'wb' ||
|
type === 'wb' ||
|
||||||
type === 'pag' ||
|
type === 'pag' ||
|
||||||
(type === 'pas' && name[1] !== -1)
|
(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 * as Create from './CreateTooltip';
|
||||||
import Building from './TypesOfTooltips/Building';
|
import Building from './TypesOfTooltips/Building';
|
||||||
import GardenPlots from './TypesOfTooltips/GardenPlots';
|
import GardenPlots from './TypesOfTooltips/GardenPlots';
|
||||||
|
import StockMarket from './TypesOfTooltips/StockMarket';
|
||||||
import Grimoire from './TypesOfTooltips/Grimoire';
|
import Grimoire from './TypesOfTooltips/Grimoire';
|
||||||
import HarvestAll from './TypesOfTooltips/HarvestAll';
|
import HarvestAll from './TypesOfTooltips/HarvestAll';
|
||||||
import PantheonGods from './TypesOfTooltips/PantheonGods';
|
import PantheonGods from './TypesOfTooltips/PantheonGods';
|
||||||
@@ -33,6 +34,8 @@ export default function UpdateTooltips() {
|
|||||||
GardenPlots();
|
GardenPlots();
|
||||||
} else if (TooltipType === 'ha') {
|
} else if (TooltipType === 'ha') {
|
||||||
HarvestAll();
|
HarvestAll();
|
||||||
|
} else if (TooltipType === 'sm') {
|
||||||
|
StockMarket();
|
||||||
} else if (TooltipType === 'wb') {
|
} else if (TooltipType === 'wb') {
|
||||||
WrinklerButton();
|
WrinklerButton();
|
||||||
} else if (TooltipType === 'pag' || (TooltipType === 'pas' && TooltipName[1] !== -1)) {
|
} else if (TooltipType === 'pag' || (TooltipType === 'pas' && TooltipName[1] !== -1)) {
|
||||||
|
|||||||
@@ -58,6 +58,21 @@ function ReplaceTooltipGarden() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function replaces the original .onmouseover functions of all stocks
|
||||||
|
*/
|
||||||
|
function ReplaceTooltipMarket() {
|
||||||
|
if (Game.Objects.Bank.minigameLoaded) {
|
||||||
|
for (let i = 0; i < Game.Objects.Bank.minigame.goodsById.length; i++) {
|
||||||
|
l(`bankGood-${i}`).firstChild.onmouseover = function () {
|
||||||
|
Game.tooltip.dynamic = 1;
|
||||||
|
Game.tooltip.draw(this, () => CreateTooltip('sm', i), 'this');
|
||||||
|
Game.tooltip.wobble();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function ReplaceTooltipPantheon() {
|
function ReplaceTooltipPantheon() {
|
||||||
if (Game.Objects.Temple.minigameLoaded) {
|
if (Game.Objects.Temple.minigameLoaded) {
|
||||||
for (let i = 0; i < 11; i += 1) {
|
for (let i = 0; i < 11; i += 1) {
|
||||||
@@ -96,6 +111,7 @@ export default function ReplaceTooltips() {
|
|||||||
LoadMinigames();
|
LoadMinigames();
|
||||||
ReplaceTooltipGarden();
|
ReplaceTooltipGarden();
|
||||||
ReplaceTooltipGrimoire();
|
ReplaceTooltipGrimoire();
|
||||||
|
ReplaceTooltipMarket();
|
||||||
ReplaceTooltipPantheon();
|
ReplaceTooltipPantheon();
|
||||||
ReplaceNativeGrimoire();
|
ReplaceNativeGrimoire();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user