Changed PP colour coding #683

This commit is contained in:
Daniël van Noord
2021-03-16 22:28:54 +01:00
parent e3d3f649c3
commit 6caee4d8fb
11 changed files with 106 additions and 158 deletions

File diff suppressed because one or more lines are too long

View File

@@ -18,13 +18,13 @@ Cookie Monster also indicates the time left before being able to buy an upgrade
This index is computed for buildings and upgrades. If the relevant option is enabled, it will color-code each of them based on their value: This index is computed for buildings and upgrades. If the relevant option is enabled, it will color-code each of them based on their value:
* Light Blue: (upgrades) This item has a better PP than any building * Light Blue: (upgrades) This item has a better PP than the best building to buy
* Green: This item has the best PP * Green: This building has the best PP
* Yellow: This item is not the best, but it is closer to best than it is to worst * Yellow: This building is within the top 10 of best PP's
* Orange: This item is not the worst, but it is closer to worst than it is to best * Orange: This building is within the top 20 of best PP's
* Red: This item has the worst PP * Red: This building is within the top 30 of best PP's
* Purple: (upgrades) This item has a worse PP than any building * Purple: This building is worse than the top 10 of best PP's
* Gray: (upgrades) This item has not been calculated and/or cannot be calculated due to no definitive worth. * Gray: This item does not have a PP, often this means that there is no change to CPS
Note: For this index, **lower is better**, meaning a building with a PP of 1 is more interesting than one with a PP of 3. Note: For this index, **lower is better**, meaning a building with a PP of 1 is more interesting than one with a PP of 3.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -4,13 +4,11 @@ import { CMOptions } from '../../Config/VariablesAndData';
import GetWrinkConfigBank from '../../Disp/HelperFunctions/GetWrinkConfigBank'; import GetWrinkConfigBank from '../../Disp/HelperFunctions/GetWrinkConfigBank';
import { ColorGray } from '../../Disp/VariablesAndData'; import { ColorGray } from '../../Disp/VariablesAndData';
import { import {
CacheArrayOfPPs,
CacheMaxPP,
CacheMidPP,
CacheMinPP, CacheMinPP,
CacheObjects1, CacheObjects1,
CacheObjects10, CacheObjects10,
CacheObjects100, CacheObjects100,
CachePPArray,
} from '../VariablesAndData'; } from '../VariablesAndData';
import ColourOfPP from './ColourOfPP'; import ColourOfPP from './ColourOfPP';
@@ -19,16 +17,29 @@ import ColourOfPP from './ColourOfPP';
* It saves all date in CM.Cache.Objects... * It saves all date in CM.Cache.Objects...
* It is called by CM.Cache.CacheBuildingsPP() * It is called by CM.Cache.CacheBuildingsPP()
*/ */
function CacheBuildingsBulkPP(target) { function CacheColor(target, amount) {
Object.keys(target).forEach((i) => { Object.keys(target).forEach((i) => {
target[i].color = ColourOfPP(
target[i],
Game.Objects[i].getSumPrice(amount),
);
// Colour based on excluding certain top-buildings
for (let j = 0; j < CMOptions.PPExcludeTop; j++) {
if (target[i].pp === CachePPArray[j][0]) target[i].color = ColorGray;
}
});
}
function CachePP(target, amount) {
Object.keys(target).forEach((i) => {
const price = Game.Objects[i].getSumPrice(amount);
if (Game.cookiesPs) { if (Game.cookiesPs) {
target[i].pp = target[i].pp =
Math.max(target[i].price - (Game.cookies + GetWrinkConfigBank()), 0) / Math.max(price - (Game.cookies + GetWrinkConfigBank()), 0) /
Game.cookiesPs + Game.cookiesPs +
target[i].price / target[i].bonus; price / target[i].bonus;
} else target[i].pp = target[i].price / target[i].bonus; } else target[i].pp = price / target[i].bonus;
CachePPArray.push([target[i].pp, amount]);
target[i].color = ColourOfPP(target[i], target[i].price);
}); });
} }
@@ -38,91 +49,28 @@ function CacheBuildingsBulkPP(target) {
*/ */
export default function CacheBuildingsPP() { export default function CacheBuildingsPP() {
CacheMinPP = Infinity; CacheMinPP = Infinity;
CacheMaxPP = 1; CachePPArray = [];
CacheArrayOfPPs = [];
if (typeof CMOptions.PPExcludeTop === 'undefined') CMOptions.PPExcludeTop = 0; // Otherwise breaks during initialization if (typeof CMOptions.PPExcludeTop === 'undefined') CMOptions.PPExcludeTop = 0; // Otherwise breaks during initialization
// Calculate PP and colors when compared to purchase of optimal building in single-purchase mode // Calculate PP and colors
if (CMOptions.ColorPPBulkMode === 0 && Game.buyMode > 0) { CachePP(CacheObjects1, 1);
Object.keys(CacheObjects1).forEach((i) => { CachePP(CacheObjects10, 10);
if (Game.cookiesPs) { CachePP(CacheObjects100, 100);
CacheObjects1[i].pp =
Math.max(
Game.Objects[i].getPrice() - (Game.cookies + GetWrinkConfigBank()),
0,
) /
Game.cookiesPs +
Game.Objects[i].getPrice() / CacheObjects1[i].bonus;
} else
CacheObjects1[i].pp =
Game.Objects[i].getPrice() / CacheObjects1[i].bonus;
CacheArrayOfPPs.push([CacheObjects1[i].pp, Game.Objects[i].getPrice()]);
});
// Set CM.Cache.min to best non-excluded buidliung
CacheArrayOfPPs.sort((a, b) => a[0] - b[0]);
if (CMOptions.PPOnlyConsiderBuyable) {
while (CacheArrayOfPPs[0][1] > Game.cookies) {
if (CacheArrayOfPPs.length === 1) {
break;
}
CacheArrayOfPPs.shift();
}
}
CacheMinPP = CacheArrayOfPPs[CMOptions.PPExcludeTop][0];
CacheMaxPP = CacheArrayOfPPs[CacheArrayOfPPs.length - 1][0];
CacheMidPP = (CacheMaxPP - CacheMinPP) / 2 + CacheMinPP;
Object.keys(CacheObjects1).forEach((i) => {
CacheObjects1[i].color = ColourOfPP(
CacheObjects1[i],
Game.Objects[i].getPrice(),
);
// Colour based on excluding certain top-buildings
for (let j = 0; j < CMOptions.PPExcludeTop; j++) {
if (CacheObjects1[i].pp === CacheArrayOfPPs[j][0])
CacheObjects1[i].color = ColorGray;
}
});
// Calculate PP of bulk-buy modes
CacheBuildingsBulkPP(CacheObjects10);
CacheBuildingsBulkPP(CacheObjects100);
} else if (Game.buyMode > 0) {
// Calculate PP and colors when compared to purchase of selected bulk mode
let target;
if (Game.buyBulk === 1) target = CacheObjects1;
else if (Game.buyBulk === 10) target = CacheObjects10;
else if (Game.buyBulk === 100) target = CacheObjects100;
Object.keys(target).forEach((i) => {
if (Game.cookiesPs) {
target[i].pp =
Math.max(
Game.Objects[i].bulkPrice - (Game.cookies + GetWrinkConfigBank()),
0,
) /
Game.cookiesPs +
Game.Objects[i].bulkPrice / target[i].bonus;
} else target[i].pp = Game.Objects[i].bulkPrice / target[i].bonus;
CacheArrayOfPPs.push([target[i].pp, Game.Objects[i].bulkPrice]);
});
// Set CM.Cache.min to best non-excluded buidliung
CacheArrayOfPPs.sort((a, b) => a[0] - b[0]);
if (CMOptions.PPOnlyConsiderBuyable) {
while (CacheArrayOfPPs[0][1] > Game.cookies) {
if (CacheArrayOfPPs.length === 1) {
break;
}
CacheArrayOfPPs.shift();
}
}
CacheMinPP = CacheArrayOfPPs[CMOptions.PPExcludeTop][0];
CacheMaxPP = CacheArrayOfPPs[CacheArrayOfPPs.length - 1][0];
CacheMidPP = (CacheMaxPP - CacheMinPP) / 2 + CacheMinPP;
Object.keys(CacheObjects1).forEach((i) => { // Set CM.Cache.min to best non-excluded buidliung
target[i].color = ColourOfPP(target[i], Game.Objects[i].bulkPrice); CachePPArray.sort((a, b) => a[0] - b[0]);
// Colour based on excluding certain top-buildings let indexOfMin = 0;
for (let j = 0; j < CMOptions.PPExcludeTop; j++) { if (CMOptions.PPOnlyConsiderBuyable) {
if (target[i].pp === CacheArrayOfPPs[j][0]) target[i].color = ColorGray; while (CachePPArray[indexOfMin][1] > Game.cookies) {
if (CachePPArray.length === indexOfMin - 1) {
break;
} }
}); indexOfMin += 1;
} }
}
CacheMinPP = CachePPArray[CMOptions.PPExcludeTop][indexOfMin];
CacheColor(CacheObjects1, 1);
CacheColor(CacheObjects10, 10);
CacheColor(CacheObjects100, 100);
} }

View File

@@ -9,7 +9,7 @@ import {
ColorRed, ColorRed,
ColorYellow, ColorYellow,
} from '../../Disp/VariablesAndData'; } from '../../Disp/VariablesAndData';
import { CacheMaxPP, CacheMidPP, CacheMinPP } from '../VariablesAndData'; import { CacheMinPP, CachePPArray } from '../VariablesAndData';
/** /**
* This functions return the colour assosciated with the given pp value * This functions return the colour assosciated with the given pp value
@@ -24,10 +24,10 @@ export default function ColourOfPP(me, price) {
if (me.pp <= 0 || me.pp === Infinity) color = ColorGray; if (me.pp <= 0 || me.pp === Infinity) color = ColorGray;
else if (me.pp < CacheMinPP) color = ColorBlue; else if (me.pp < CacheMinPP) color = ColorBlue;
else if (me.pp === CacheMinPP) color = ColorGreen; else if (me.pp === CacheMinPP) color = ColorGreen;
else if (me.pp === CacheMaxPP) color = ColorRed; else if (me.pp < CachePPArray[10][0]) color = ColorYellow;
else if (me.pp > CacheMaxPP) color = ColorPurple; else if (me.pp < CachePPArray[20][0]) color = ColorOrange;
else if (me.pp > CacheMidPP) color = ColorOrange; else if (me.pp > CachePPArray[30][0]) color = ColorRed;
else color = ColorYellow; else color = ColorPurple;
// Colour based on price in terms of CPS // Colour based on price in terms of CPS
if (Number(CMOptions.PPSecondsLowerLimit) !== 0) { if (Number(CMOptions.PPSecondsLowerLimit) !== 0) {

View File

@@ -65,10 +65,10 @@ export let CacheSeasonPopShimmer = {};
export let CacheTimeTillNextPrestige = 0; export let CacheTimeTillNextPrestige = 0;
/** Stores lowest PP value */
export let CacheMinPP = 0; export let CacheMinPP = 0;
export let CacheMidPP = 0; /** Stores all PP values of all buildings for all buy settings (1, 10, 100) */
export let CacheMaxPP = 0; export let CachePPArray = [];
export let CacheArrayOfPPs = [];
export let CacheGoldenShimmersByID = {}; export let CacheGoldenShimmersByID = {};
@@ -100,6 +100,7 @@ export let CacheDoRemakeBuildPrices;
export let CacheHadBuildAura; export let CacheHadBuildAura;
/** Store the CPS effect of each god if it was put into each slot */
export let CacheGods = { export let CacheGods = {
0: [0, 0, 0], 0: [0, 0, 0],
1: [0, 0, 0], 1: [0, 0, 0],

View File

@@ -1,4 +1,3 @@
import CachePP from '../Cache/PP/PP';
import CheckNotificationPermissions from '../Config/CheckNotificationPermissions'; import CheckNotificationPermissions from '../Config/CheckNotificationPermissions';
import { ToggleTimerBar, ToggleTimerBarPos } from '../Config/SpecificToggles'; import { ToggleTimerBar, ToggleTimerBarPos } from '../Config/SpecificToggles';
import ToggleBotBar from '../Config/Toggles/ToggleBotBar'; import ToggleBotBar from '../Config/Toggles/ToggleBotBar';
@@ -68,7 +67,11 @@ const Config = {
SortBuildings: new SettingStandard( SortBuildings: new SettingStandard(
'bool', 'bool',
'BarsColors', 'BarsColors',
['Sort Buildings: Default', 'Sort Buildings: PP'], [
'Sort Buildings: Default',
'Sort Buildings: PP of x1 purchase',
'Sort Buildings: PP of selected bulk mode',
],
'Sort the display of buildings in either default order or by PP', 'Sort the display of buildings in either default order or by PP',
false, false,
function () { function () {
@@ -95,19 +98,6 @@ const Config = {
UpdateBuildings(); UpdateBuildings();
}, },
), ),
BulkBuildColor: new SettingStandard(
'bool',
'BarsColors',
[
'Bulk Building Colors (Single Building Color)',
'Bulk Building Colors (Calculated Bulk Color)',
],
'Color code bulk buildings based on single buildings color or calculated bulk value color',
false,
function () {
UpdateBuildings();
},
),
UpBarColor: new SettingStandard( UpBarColor: new SettingStandard(
'bool', 'bool',
'BarsColors', 'BarsColors',
@@ -127,17 +117,17 @@ const Config = {
'BarsColors', 'BarsColors',
{ {
Blue: Blue:
'Color Blue. Used to show better than best PP building, for Click Frenzy bar, and for various labels', 'Color Blue. Used to show upgrades better than best PP building, for Click Frenzy bar, and for various labels',
Green: Green:
'Color Green. Used to show best PP building, for Blood Frenzy bar, and for various labels', 'Color Green. Used to show best PP building, for Blood Frenzy bar, and for various labels',
Yellow: Yellow:
'Color Yellow. Used to show between best and worst PP buildings closer to best, for Frenzy bar, and for various labels', 'Color Yellow. Used to show buildings within the top 10 of PP, for Frenzy bar, and for various labels',
Orange: Orange:
'Color Orange. Used to show between best and worst PP buildings closer to worst, for Next Reindeer bar, and for various labels', 'Color Orange. Used to show buildings within the top 20 of PP, for Next Reindeer bar, and for various labels',
Red: Red:
'Color Red. Used to show worst PP building, for Clot bar, and for various labels', 'Color Red. Used to show buildings within the top 30 of PP, for Clot bar, and for various labels',
Purple: Purple:
'Color Purple. Used to show worse than worst PP building, for Next Cookie bar, and for various labels', 'Color Purple. Used to show buildings outside of the top 30 of PP, for Next Cookie bar, and for various labels',
Gray: Gray:
'Color Gray. Used to show negative or infinity PP, and for Next Cookie/Next Reindeer bar', 'Color Gray. Used to show negative or infinity PP, and for Next Cookie/Next Reindeer bar',
Pink: 'Color Pink. Used for Dragonflight bar', Pink: 'Color Pink. Used for Dragonflight bar',
@@ -206,16 +196,6 @@ const Config = {
'How much time average Cookie Clicks should consider', 'How much time average Cookie Clicks should consider',
false, false,
), ),
ColorPPBulkMode: new SettingStandard(
'bool',
'Calculation',
['Color of PP (Compared to Single)', 'Color of PP (Compared to Bulk)'],
'Color PP-values based on comparison with single purchase or with selected bulk-buy mode',
false,
function () {
CachePP();
},
),
PPExcludeTop: new SettingStandard( PPExcludeTop: new SettingStandard(
'bool', 'bool',
'Calculation', 'Calculation',

View File

@@ -5,18 +5,16 @@ const ConfigDefault = {
TimerBarPos: 0, TimerBarPos: 0,
TimerBarOverlay: 2, TimerBarOverlay: 2,
BuildColor: 1, BuildColor: 1,
BulkBuildColor: 0,
UpBarColor: 1, UpBarColor: 1,
UpgradeBarFixedPos: 1, UpgradeBarFixedPos: 1,
CalcWrink: 0, CalcWrink: 0,
CPSMode: 1, CPSMode: 1,
AvgCPSHist: 3, AvgCPSHist: 3,
AvgClicksHist: 0, AvgClicksHist: 0,
ColorPPBulkMode: 1,
PPExcludeTop: 0, PPExcludeTop: 0,
PPSecondsLowerLimit: 0, PPSecondsLowerLimit: 0,
PPOnlyConsiderBuyable: 0, PPOnlyConsiderBuyable: 0,
ToolWarnBon: 0, ToolWarnBon: 1,
Title: 1, Title: 1,
GeneralSound: 1, GeneralSound: 1,
GCNotification: 0, GCNotification: 0,

View File

@@ -62,7 +62,26 @@ export default function UpdateBuildings() {
// (grid rows are 1-based indexing, and row 1 is the bulk buy/sell options) // (grid rows are 1-based indexing, and row 1 is the bulk buy/sell options)
// This regulates sorting of buildings // This regulates sorting of buildings
if (Game.buyMode === 1 && CMOptions.SortBuildings) { if (Game.buyMode === 1 && CMOptions.SortBuildings) {
const arr = Object.keys(target).map((k) => { let arr;
if (CMOptions.SortBuildings === 1) {
arr = Object.keys(CacheObjects1).map((k) => {
const o = CacheObjects1[k];
o.name = k;
o.id = Game.Objects[k].id;
return o;
});
arr.sort(function (a, b) {
return Colors.indexOf(a.color) > Colors.indexOf(b.color)
? 1
: Colors.indexOf(a.color) < Colors.indexOf(b.color)
? -1
: a.pp < b.pp
? -1
: 0;
});
} else if (CMOptions.SortBuildings === 2) {
arr = Object.keys(target).map((k) => {
const o = target[k]; const o = target[k];
o.name = k; o.name = k;
o.id = Game.Objects[k].id; o.id = Game.Objects[k].id;
@@ -78,6 +97,7 @@ export default function UpdateBuildings() {
? -1 ? -1
: 0; : 0;
}); });
}
for (let x = 0; x < arr.length; x++) { for (let x = 0; x < arr.length; x++) {
Game.Objects[arr[x].name].l.style.gridRow = `${x + 2}/${x + 2}`; Game.Objects[arr[x].name].l.style.gridRow = `${x + 2}/${x + 2}`;

View File

@@ -183,7 +183,8 @@ function CreatePrefOption(config) {
SaveConfig(); SaveConfig();
Game.UpdateMenu(); Game.UpdateMenu();
}; };
JsColor(input, { hash: true, position: 'right', onInput: change }); // eslint-disable-next-line no-new
new JsColor(input, { hash: true, position: 'right', onInput: change });
const label = document.createElement('label'); const label = document.createElement('label');
label.textContent = Config.Colors.desc[Colors[i]]; label.textContent = Config.Colors.desc[Colors[i]];
innerDiv.appendChild(label); innerDiv.appendChild(label);