Changed folder structure

This commit is contained in:
Daniël van Noord
2021-04-12 13:02:28 +02:00
parent 1545d9782b
commit 077f0120b7
28 changed files with 122 additions and 128 deletions

View File

@@ -1,4 +1,4 @@
import { FormatTime } from '../Disp/BeautifyAndFormatting/BeautifyFormatting';
import FormatTime from '../Disp/BeautifyAndFormatting/FormatTime';
import GetCPS from '../Disp/HelperFunctions/GetCPS';
import CacheAvgCPS from './CPS/CPS';
import CacheCurrWrinklerCPS from './CPS/CurrWrinklerCPS';

View File

@@ -1,6 +1,6 @@
/** Functions related to the Dragon */
import { Beautify } from '../../Disp/BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../../Disp/BeautifyAndFormatting/Beautify';
import CopyData from '../../Sim/SimulationData/CopyData';
import { SimDoSims, SimObjects } from '../../Sim/VariablesAndData';
import {

View File

@@ -7,12 +7,6 @@ import {
shortScaleAbbreviated,
} from '../../Data/Scales.ts';
import { BackupFunctions } from '../../Main/VariablesAndData';
import {
ColourGreen,
ColourOrange,
ColourRed,
ColourYellow,
} from '../VariablesAndData';
/**
* This function returns formats number based on the Scale setting
@@ -21,7 +15,7 @@ import {
* @param {number} forced Used to force (type 3) in certains cases
* @returns {string} Formatted number
*/
export function Beautify(num, floats, forced) {
export default function Beautify(num, floats, forced) {
const decimals = CMOptions.ScaleDecimals + 1;
if (num === Infinity) {
return 'Infinity';
@@ -93,66 +87,3 @@ export function Beautify(num, floats, forced) {
console.log(`Could not beautify number with Cookie Monster Beautify: ${num}`); // eslint-disable-line no-console
return BackupFunctions.Beautify(num, floats);
}
/**
* This function returns time as a string depending on TimeFormat setting
* @param {number} time Time to be formatted
* @param {number} longFormat 1 or 0
* @returns {string} Formatted time
*/
export function FormatTime(time, longFormat) {
let formattedTime = time;
if (time === Infinity) return time;
if (time < 0) return 'Negative time period';
formattedTime = Math.ceil(time);
const y = Math.floor(formattedTime / 31557600);
const d = Math.floor((formattedTime % 31557600) / 86400);
const h = Math.floor((formattedTime % 86400) / 3600);
const m = Math.floor((formattedTime % 3600) / 60);
const s = Math.floor(formattedTime % 60);
let str = '';
if (CMOptions.TimeFormat) {
if (formattedTime > 3155760000) return 'XX:XX:XX:XX:XX';
str += `${(y < 10 ? '0' : '') + y}:`;
str += `${(d < 10 ? '0' : '') + d}:`;
str += `${(h < 10 ? '0' : '') + h}:`;
str += `${(m < 10 ? '0' : '') + m}:`;
str += (s < 10 ? '0' : '') + s;
} else {
if (formattedTime > 777600000)
return longFormat ? 'Over 9000 days!' : '>9000d';
str +=
y > 0
? `${y + (longFormat ? (y === 1 ? ' year' : ' years') : 'y')}, ` // eslint-disable-line no-nested-ternary
: '';
str +=
d > 0 ? `${d + (longFormat ? (d === 1 ? ' day' : ' days') : 'd')}, ` : ''; // eslint-disable-line no-nested-ternary
if (str.length > 0 || h > 0)
str += `${h + (longFormat ? (h === 1 ? ' hour' : ' hours') : 'h')}, `; // eslint-disable-line no-nested-ternary
if (str.length > 0 || m > 0)
str += `${m + (longFormat ? (m === 1 ? ' minute' : ' minutes') : 'm')}, `; // eslint-disable-line no-nested-ternary
str += s + (longFormat ? (s === 1 ? ' second' : ' seconds') : 's'); // eslint-disable-line no-nested-ternary
}
return str;
}
/**
* This function returns the color to be used for time-strings
* @param {number} time Time to be coloured
* @returns {{string, string}} {text, color} Both the formatted time and color as strings in an array
*/
export function GetTimeColour(time) {
let color;
let text;
if (time <= 0) {
if (CMOptions.TimeFormat) text = '00:00:00:00:00';
else text = 'Done!';
color = ColourGreen;
} else {
text = FormatTime(time);
if (time > 300) color = ColourRed;
else if (time > 60) color = ColourOrange;
else color = ColourYellow;
}
return { text, color };
}

View File

@@ -0,0 +1,43 @@
import { CMOptions } from '../../Config/VariablesAndData';
/**
* This function returns time as a string depending on TimeFormat setting
* @param {number} time Time to be formatted
* @param {number} longFormat 1 or 0
* @returns {string} Formatted time
*/
export default function FormatTime(time, longFormat) {
let formattedTime = time;
if (time === Infinity) return time;
if (time < 0) return 'Negative time period';
formattedTime = Math.ceil(time);
const y = Math.floor(formattedTime / 31557600);
const d = Math.floor((formattedTime % 31557600) / 86400);
const h = Math.floor((formattedTime % 86400) / 3600);
const m = Math.floor((formattedTime % 3600) / 60);
const s = Math.floor(formattedTime % 60);
let str = '';
if (CMOptions.TimeFormat) {
if (formattedTime > 3155760000) return 'XX:XX:XX:XX:XX';
str += `${(y < 10 ? '0' : '') + y}:`;
str += `${(d < 10 ? '0' : '') + d}:`;
str += `${(h < 10 ? '0' : '') + h}:`;
str += `${(m < 10 ? '0' : '') + m}:`;
str += (s < 10 ? '0' : '') + s;
} else {
if (formattedTime > 777600000)
return longFormat ? 'Over 9000 days!' : '>9000d';
str +=
y > 0
? `${y + (longFormat ? (y === 1 ? ' year' : ' years') : 'y')}, ` // eslint-disable-line no-nested-ternary
: '';
str +=
d > 0 ? `${d + (longFormat ? (d === 1 ? ' day' : ' days') : 'd')}, ` : ''; // eslint-disable-line no-nested-ternary
if (str.length > 0 || h > 0)
str += `${h + (longFormat ? (h === 1 ? ' hour' : ' hours') : 'h')}, `; // eslint-disable-line no-nested-ternary
if (str.length > 0 || m > 0)
str += `${m + (longFormat ? (m === 1 ? ' minute' : ' minutes') : 'm')}, `; // eslint-disable-line no-nested-ternary
str += s + (longFormat ? (s === 1 ? ' second' : ' seconds') : 's'); // eslint-disable-line no-nested-ternary
}
return str;
}

View File

@@ -0,0 +1,29 @@
import { CMOptions } from '../../Config/VariablesAndData';
import {
ColourGreen,
ColourOrange,
ColourRed,
ColourYellow,
} from '../VariablesAndData';
import FormatTime from './FormatTime';
/**
* This function returns the color to be used for time-strings
* @param {number} time Time to be coloured
* @returns {{string, string}} {text, color} Both the formatted time and color as strings in an array
*/
export default function GetTimeColour(time) {
let color;
let text;
if (time <= 0) {
if (CMOptions.TimeFormat) text = '00:00:00:00:00';
else text = 'Done!';
color = ColourGreen;
} else {
text = FormatTime(time);
if (time > 300) color = ColourRed;
else if (time > 60) color = ColourOrange;
else color = ColourYellow;
}
return { text, color };
}

View File

@@ -5,7 +5,7 @@ import {
} from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData';
import BuildingSell from '../../Sim/SimulationEvents/SellBuilding';
import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../BeautifyAndFormatting/Beautify';
import { ColoursOrdering, LastTargetBuildings } from '../VariablesAndData';
/**

View File

@@ -4,10 +4,8 @@ import CacheDragonCost from '../../Cache/Dragon/Dragon';
import { CacheCostDragonUpgrade } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData';
import CalculateChangeAura from '../../Sim/SimulationEvents/AuraChange';
import {
Beautify,
FormatTime,
} from '../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../BeautifyAndFormatting/Beautify';
import FormatTime from '../BeautifyAndFormatting/FormatTime';
/**
* This functions adds the two extra lines about CPS and time to recover to the aura picker infoscreen

View File

@@ -1,6 +1,6 @@
import ToggleWrinklerButtons from '../Config/Toggles/ToggleWrinklerButtons';
import { CMOptions } from '../Config/VariablesAndData';
import { Beautify } from './BeautifyAndFormatting/BeautifyFormatting';
import Beautify from './BeautifyAndFormatting/Beautify';
import UpdateBuildings from './BuildingsUpgrades/Buildings';
import UpdateUpgrades from './BuildingsUpgrades/Upgrades';
import { UpdateBotBar } from './InfoBars/BottomBar';

View File

@@ -7,11 +7,10 @@ import {
} from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData';
import { VersionMajor, VersionMinor } from '../../Data/Moddata.ts';
import {
Beautify,
FormatTime,
GetTimeColour,
} from '../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../BeautifyAndFormatting/Beautify';
import FormatTime from '../BeautifyAndFormatting/FormatTime';
import GetTimeColour from '../BeautifyAndFormatting/GetTimeColour';
import GetCPS from '../HelperFunctions/GetCPS';
import GetWrinkConfigBank from '../HelperFunctions/GetWrinkConfigBank';
import {

View File

@@ -16,7 +16,7 @@ import {
import PopAllNormalWrinklers from '../../HelperFunctions/PopWrinklers';
import { ClickTimes, CookieTimes } from '../../VariablesAndData';
import GetCPS from '../../HelperFunctions/GetCPS';
import { Beautify } from '../../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../../BeautifyAndFormatting/Beautify';
import AddMissingAchievements from './CreateMissingAchievements';
/**

View File

@@ -38,15 +38,12 @@ import {
} from '../../../Cache/VariablesAndData';
import { CMOptions } from '../../../Config/VariablesAndData';
import ResetBonus from '../../../Sim/SimulationEvents/ResetAscension';
import {
Beautify,
FormatTime,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../../HelperFunctions/GetCPS';
import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank';
import { ColourGreen, ColourRed, ColourTextPre } from '../../VariablesAndData';
import { StatsListing, StatsHeader, StatsMissDisp } from './CreateDOMElements';
import Beautify from '../../BeautifyAndFormatting/Beautify';
import FormatTime from '../../BeautifyAndFormatting/FormatTime';
/**
* This function creates the "Lucky" section of the stats page

View File

@@ -4,7 +4,7 @@ import {
CacheTimeTillNextPrestige,
} from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData';
import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../BeautifyAndFormatting/Beautify';
/**
* This function creates a header object for tooltips.

View File

@@ -1,8 +1,4 @@
import UpdateTooltips from './UpdateTooltips';
import {
Beautify,
GetTimeColour,
} from '../BeautifyAndFormatting/BeautifyFormatting';
import {
SimpleTooltipElements,
TooltipName,
@@ -10,6 +6,8 @@ import {
} from '../VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData';
import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding';
import GetTimeColour from '../BeautifyAndFormatting/GetTimeColour';
import Beautify from '../BeautifyAndFormatting/Beautify';
/** All general functions related to creating and updating tooltips */

View File

@@ -8,11 +8,9 @@ import {
import { CMOptions } from '../../../Config/VariablesAndData';
import BuyBuildingsBonusIncome from '../../../Sim/SimulationEvents/BuyBuildingBonusIncome';
import { SimObjects } from '../../../Sim/VariablesAndData';
import {
Beautify,
FormatTime,
GetTimeColour,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../../BeautifyAndFormatting/Beautify';
import FormatTime from '../../BeautifyAndFormatting/FormatTime';
import GetTimeColour from '../../BeautifyAndFormatting/GetTimeColour';
import GetCPS from '../../HelperFunctions/GetCPS';
import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank';
import {

View File

@@ -1,5 +1,5 @@
import { CMOptions } from '../../../Config/VariablesAndData';
import { Beautify } from '../../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../../BeautifyAndFormatting/Beautify';
import { TooltipName } from '../../VariablesAndData';
import * as Create from '../CreateTooltip';

View File

@@ -1,9 +1,7 @@
import { CacheNoGoldSwitchCookiesPS } from '../../../Cache/VariablesAndData';
import { CMOptions } from '../../../Config/VariablesAndData';
import {
Beautify,
GetTimeColour,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../../BeautifyAndFormatting/Beautify';
import GetTimeColour from '../../BeautifyAndFormatting/GetTimeColour';
import CalculateGrimoireRefillTime from '../../HelperFunctions/CalculateGrimoireRefillTime';
import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank';
import { ColourTextPre, TooltipName } from '../../VariablesAndData';

View File

@@ -1,5 +1,5 @@
import { CMOptions } from '../../../Config/VariablesAndData';
import { Beautify } from '../../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../../BeautifyAndFormatting/Beautify';
import * as Create from '../CreateTooltip';
/**

View File

@@ -1,6 +1,6 @@
import { CacheGods } from '../../../Cache/VariablesAndData';
import { CMOptions } from '../../../Config/VariablesAndData';
import { Beautify } from '../../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../../BeautifyAndFormatting/Beautify';
import { TooltipName, TooltipType } from '../../VariablesAndData';
import * as Create from '../CreateTooltip';

View File

@@ -3,11 +3,9 @@ import {
CacheUpgrades,
} from '../../../Cache/VariablesAndData';
import { CMOptions } from '../../../Config/VariablesAndData';
import {
Beautify,
FormatTime,
GetTimeColour,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../../BeautifyAndFormatting/Beautify';
import FormatTime from '../../BeautifyAndFormatting/FormatTime';
import GetTimeColour from '../../BeautifyAndFormatting/GetTimeColour';
import GetCPS from '../../HelperFunctions/GetCPS';
import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank';
import {

View File

@@ -2,11 +2,8 @@ import GetCPSBuffMult from '../../../Cache/CPS/GetCPSBuffMult';
import { CacheEdifice, CacheLucky } from '../../../Cache/VariablesAndData';
import ToggleToolWarnPos from '../../../Config/Toggles/ToggleToolWarnPos';
import { CMOptions } from '../../../Config/VariablesAndData';
import {
Beautify,
FormatTime,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../../BeautifyAndFormatting/Beautify';
import FormatTime from '../../BeautifyAndFormatting/FormatTime';
import GetCPS from '../../HelperFunctions/GetCPS';
import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank';
import {

View File

@@ -2,7 +2,7 @@ import {
CacheWrinklersFattest,
CacheWrinklersTotal,
} from '../../../Cache/VariablesAndData';
import { Beautify } from '../../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../../BeautifyAndFormatting/Beautify';
import { TooltipName } from '../../VariablesAndData';
import * as Create from '../CreateTooltip';

View File

@@ -1,6 +1,6 @@
import { CMOptions } from '../../Config/VariablesAndData';
import { SimObjects } from '../../Sim/VariablesAndData';
import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../BeautifyAndFormatting/Beautify';
import {
TooltipWrinkler,
TooltipWrinklerArea,

View File

@@ -1,6 +1,5 @@
import { CMOptions } from '../../Config/VariablesAndData';
import { FormatTime } from '../../Disp/BeautifyAndFormatting/BeautifyFormatting';
import FormatTime from '../../Disp/BeautifyAndFormatting/FormatTime';
import CalculateGrimoireRefillTime from '../../Disp/HelperFunctions/CalculateGrimoireRefillTime';
import {
BackupGrimoireDraw,

View File

@@ -1,9 +1,7 @@
import jscolor from '@eastdesire/jscolor';
import { CMOptions } from '../../Config/VariablesAndData';
import {
Beautify as CMBeautify,
FormatTime,
} from '../../Disp/BeautifyAndFormatting/BeautifyFormatting';
import Beautify from '../../Disp/BeautifyAndFormatting/Beautify';
import FormatTime from '../../Disp/BeautifyAndFormatting/FormatTime';
import { AddAuraInfo, AddDragonLevelUpTooltip } from '../../Disp/Dragon/Dragon';
import AddMenu from '../../Disp/MenuSections/AddMenus';
import UpdateTitle from '../../Disp/TabTitle/TabTitle';
@@ -146,7 +144,7 @@ export default function ReplaceNative() {
let title = 'Cookie Clicker';
if (Game.season === 'fools') title = 'Cookie Baker';
// eslint-disable-next-line no-unused-vars
Title = `${Game.OnAscend ? 'Ascending! ' : ''}${CMBeautify(Game.cookies)} ${
Title = `${Game.OnAscend ? 'Ascending! ' : ''}${Beautify(Game.cookies)} ${
Game.cookies === 1 ? 'cookie' : 'cookies'
} - ${title}`;
UpdateTitle();