Merge pull request #769 from DanielNoord/tests

Tests
This commit is contained in:
Daniël van Noord authored and GitHub committed 2021-04-12 21:30:32 +02:00
commit bf5e44ed9e
38 files changed
+1555 -3570

No files matched your search

-46
View File
@@ -1,46 +0,0 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
globals: {
Game: 'writable',
l: 'readonly',
b64_to_utf8: 'readonly',
utf8_to_b64: 'readonly',
BeautifyAll: 'readonly',
PlaySound: 'readonly',
},
extends: ['airbnb-base', 'plugin:prettier/recommended'],
parserOptions: {
ecmaVersion: 12,
},
plugins: ['@typescript-eslint'],
overrides: [
{
files: ['src/**/*.{ts,tsx}'],
extends: ['plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
rules: {
'import/extensions': 'off', // To allow importing .ts without errors
'import/no-unresolved': 'off', // To allow importing .ts without errors
},
},
],
ignorePatterns: ['*CookieMonster*.js', 'dist/*', 'node_modules/*'],
rules: {
'import/no-mutable-exports': 'off', // We need to this throughout Cookie Monster
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'func-names': 'off', // To allow unnamed arrow functions
'prefer-destructuring': ['error', { object: true, array: false }], // Importing arrays and then destructuring them seems to fail
'max-len': [
1,
{
code: 100,
ignoreComments: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
},
],
},
};
+70
View File
@@ -0,0 +1,70 @@
{
"env": {
"browser": true,
"es2021": true
},
"globals": {
"Game": "writable",
"l": "readonly",
"b64_to_utf8": "readonly",
"utf8_to_b64": "readonly",
"BeautifyAll": "readonly",
"PlaySound": "readonly"
},
"extends": [
"airbnb-base",
"plugin:prettier/recommended"
],
"parserOptions": {
"ecmaVersion": 12
},
"plugins": [
"@typescript-eslint"
],
"overrides": [
{
"files": [
"src/**/*.{ts,tsx}"
],
"extends": [
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"rules": {
"import/extensions": "off", // To allow importing .ts without errors
"import/no-unresolved": "off" // To allow importing .ts without errors
}
}
],
"ignorePatterns": [
"*CookieMonster*.js",
"dist/*",
"node_modules/*"
],
"rules": {
"import/no-mutable-exports": "off", // We need to this throughout Cookie Monster
"no-plusplus": [
"error",
{
"allowForLoopAfterthoughts": true
}
],
"func-names": "off", // To allow unnamed arrow functions
"prefer-destructuring": [
"error",
{
"object": true,
"array": false
}
], // Importing arrays and then destructuring them seems to fail
"max-len": [
1,
{
"code": 100,
"ignoreComments": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true
}
]
}
}
+12 -14
View File
@@ -1,31 +1,29 @@
name: CI name: CI
on: pull_request on: pull_request
jobs: jobs:
Check_ESLint: Check_linting_test_and_build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - name: Check out repository code
uses: actions/checkout@v2
- name: Install dependencies
run: npm ci
- name: Run ESLint - name: Run ESLint
run: | run: npx eslint src
npm install - name: Run Mocha tests
npx eslint src run: npx mocha
Check_main_file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check if CookieMonster.js is built correctly - name: Check if CookieMonster.js is built correctly
run: | run: |
npm install npx webpack -o ./tmp --env production
npx webpack -o ./test --env production if cmp <(head -n 2 dist/CookieMonster.js) <(head -n 2 tmp/CookieMonster.js); then
if cmp <(head -n 2 dist/CookieMonster.js) <(head -n 2 test/CookieMonster.js); then
echo '### SUCCESS: CookieMonster is correctly built! ###' echo '### SUCCESS: CookieMonster is correctly built! ###'
else else
echo '### WARNING: CookieMonster.js does not seem to be correct. Make sure to run "npm run build" after saving all your changes! ###' echo '### WARNING: CookieMonster.js does not seem to be correct. Make sure to run "npm run build" after saving all your changes! ###'
exit 1 exit 1
fi fi
if cmp <(head -n 2 CookieMonster.js) <(head -n 2 test/CookieMonster.js); then if cmp <(head -n 2 CookieMonster.js) <(head -n 2 tmp/CookieMonster.js); then
echo '### SUCCESS: CookieMonster is correctly built! ###' echo '### SUCCESS: CookieMonster is correctly built! ###'
else else
echo '### WARNING: Make sure to move the file from the /dist folder to the main folder. Otherwise Github Pages won't notice it ###' echo '### WARNING: CookieMonster.js does not seem to be correct. Make sure to run "npm run build" after saving all your changes! ###'
exit 1 exit 1
fi fi
+4
View File
@@ -0,0 +1,4 @@
{
"recursive": true,
"require": "esm"
}
+1 -1
View File
@@ -1,2 +1,2 @@
/*! For license information please see CookieMonster.js.LICENSE.txt */ /*! For license information please see CookieMonster.js.LICENSE.txt */
(()=>{var e={877:function(e){!function(t,o){"use strict";"object"!=typeof e.exports?o(t):e.exports=t.document?o(t):function(e){if(!e.document)throw new Error("jscolor needs a window with document");return o(e)}}("undefined"!=typeof window?window:this,(function(e){"use strict";var t,o,n,i,a=((i={initialized:!1,instances:[],readyQueue:[],register:function(){void 0!==e&&e.document&&e.document.addEventListener("DOMContentLoaded",i.pub.init,!1)},installBySelector:function(t,o){if(!(o=o?i.node(o):e.document))throw new Error("Missing root node");for(var n=o.querySelectorAll(t),a=new RegExp("(^|\\s)("+i.pub.lookupClass+")(\\s*(\\{[^}]*\\})|\\s|$)","i"),r=0;r<n.length;r+=1){var l,s;if(!(n[r].jscolor&&n[r].jscolor instanceof i.pub)&&(void 0===n[r].type||"color"!=n[r].type.toLowerCase()||!i.isColorAttrSupported)&&(null!==(l=i.getDataAttr(n[r],"jscolor"))||n[r].className&&(s=n[r].className.match(a)))){var c=n[r],d="";null!==l?d=l:s&&(console.warn('Installation using class name is DEPRECATED. Use data-jscolor="" attribute instead.'+i.docsRef),s[4]&&(d=s[4]));var p=null;if(d.trim())try{p=i.parseOptionsStr(d)}catch(e){console.warn(e+"\n"+d)}try{new i.pub(c,p)}catch(e){console.warn(e)}}}},parseOptionsStr:function(e){var t=null;try{t=JSON.parse(e)}catch(o){if(!i.pub.looseJSON)throw new Error("Could not parse jscolor options as JSON: "+o);try{t=new Function("var opts = ("+e+'); return typeof opts === "object" ? opts : {};')()}catch(e){throw new Error("Could not evaluate jscolor options: "+e)}}return t},getInstances:function(){for(var e=[],t=0;t<i.instances.length;t+=1)i.instances[t]&&i.instances[t].targetElement&&e.push(i.instances[t]);return e},createEl:function(t){var o=e.document.createElement(t);return i.setData(o,"gui",!0),o},node:function(t){if(!t)return null;if("string"==typeof t){var o=t,n=null;try{n=e.document.querySelector(o)}catch(e){return console.warn(e),null}return n||console.warn("No element matches the selector: %s",o),n}return i.isNode(t)?t:(console.warn("Invalid node of type %s: %s",typeof t,t),null)},isNode:function(e){return"object"==typeof Node?e instanceof Node:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},nodeName:function(e){return!(!e||!e.nodeName)&&e.nodeName.toLowerCase()},removeChildren:function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},isTextInput:function(e){return e&&"input"===i.nodeName(e)&&"text"===e.type.toLowerCase()},isButton:function(e){if(!e)return!1;var t=i.nodeName(e);return"button"===t||"input"===t&&["button","submit","reset"].indexOf(e.type.toLowerCase())>-1},isButtonEmpty:function(e){switch(i.nodeName(e)){case"input":return!e.value||""===e.value.trim();case"button":return""===e.textContent.trim()}return null},isPassiveEventSupported:function(){var t=!1;try{var o=Object.defineProperty({},"passive",{get:function(){t=!0}});e.addEventListener("testPassive",null,o),e.removeEventListener("testPassive",null,o)}catch(e){}return t}(),isColorAttrSupported:(n=e.document.createElement("input"),!(!n.setAttribute||(n.setAttribute("type","color"),"color"!=n.type.toLowerCase()))),dataProp:"_data_jscolor",setData:function(){var e=arguments[0];if(3===arguments.length){var t=e.hasOwnProperty(i.dataProp)?e[i.dataProp]:e[i.dataProp]={},o=arguments[2];return t[a=arguments[1]]=o,!0}if(2===arguments.length&&"object"==typeof arguments[1]){t=e.hasOwnProperty(i.dataProp)?e[i.dataProp]:e[i.dataProp]={};var n=arguments[1];for(var a in n)n.hasOwnProperty(a)&&(t[a]=n[a]);return!0}throw new Error("Invalid arguments")},removeData:function(){var e=arguments[0];if(!e.hasOwnProperty(i.dataProp))return!0;for(var t=1;t<arguments.length;t+=1){var o=arguments[t];delete e[i.dataProp][o]}return!0},getData:function(e,t,o){if(!e.hasOwnProperty(i.dataProp)){if(void 0===o)return;e[i.dataProp]={}}var n=e[i.dataProp];return n.hasOwnProperty(t)||void 0===o||(n[t]=o),n[t]},getDataAttr:function(e,t){var o="data-"+t;return e.getAttribute(o)},setDataAttr:function(e,t,o){var n="data-"+t;e.setAttribute(n,o)},_attachedGroupEvents:{},attachGroupEvent:function(e,t,o,n){i._attachedGroupEvents.hasOwnProperty(e)||(i._attachedGroupEvents[e]=[]),i._attachedGroupEvents[e].push([t,o,n]),t.addEventListener(o,n,!1)},detachGroupEvents:function(e){if(i._attachedGroupEvents.hasOwnProperty(e)){for(var t=0;t<i._attachedGroupEvents[e].length;t+=1){var o=i._attachedGroupEvents[e][t];o[0].removeEventListener(o[1],o[2],!1)}delete i._attachedGroupEvents[e]}},preventDefault:function(e){e.preventDefault&&e.preventDefault(),e.returnValue=!1},captureTarget:function(e){e.setCapture&&(i._capturedTarget=e,i._capturedTarget.setCapture())},releaseTarget:function(){i._capturedTarget&&(i._capturedTarget.releaseCapture(),i._capturedTarget=null)},triggerEvent:function(t,o,n,a){if(t){var r=null;return"function"==typeof Event?r=new Event(o,{bubbles:n,cancelable:a}):(r=e.document.createEvent("Event")).initEvent(o,n,a),!!r&&(i.setData(r,"internal",!0),t.dispatchEvent(r),!0)}},triggerInputEvent:function(e,t,o,n){e&&i.isTextInput(e)Line truncated (()=>{var e={877:function(e){!function(t,o){"use strict";"object"!=typeof e.exports?o(t):e.exports=t.document?o(t):function(e){if(!e.document)throw new Error("jscolor needs a window with document");return o(e)}}("undefined"!=typeof window?window:this,(function(e){"use strict";var t,o,n,i,a=((i={initialized:!1,instances:[],readyQueue:[],register:function(){void 0!==e&&e.document&&e.document.addEventListener("DOMContentLoaded",i.pub.init,!1)},installBySelector:function(t,o){if(!(o=o?i.node(o):e.document))throw new Error("Missing root node");for(var n=o.querySelectorAll(t),a=new RegExp("(^|\\s)("+i.pub.lookupClass+")(\\s*(\\{[^}]*\\})|\\s|$)","i"),r=0;r<n.length;r+=1){var l,s;if(!(n[r].jscolor&&n[r].jscolor instanceof i.pub)&&(void 0===n[r].type||"color"!=n[r].type.toLowerCase()||!i.isColorAttrSupported)&&(null!==(l=i.getDataAttr(n[r],"jscolor"))||n[r].className&&(s=n[r].className.match(a)))){var c=n[r],d="";null!==l?d=l:s&&(console.warn('Installation using class name is DEPRECATED. Use data-jscolor="" attribute instead.'+i.docsRef),s[4]&&(d=s[4]));var p=null;if(d.trim())try{p=i.parseOptionsStr(d)}catch(e){console.warn(e+"\n"+d)}try{new i.pub(c,p)}catch(e){console.warn(e)}}}},parseOptionsStr:function(e){var t=null;try{t=JSON.parse(e)}catch(o){if(!i.pub.looseJSON)throw new Error("Could not parse jscolor options as JSON: "+o);try{t=new Function("var opts = ("+e+'); return typeof opts === "object" ? opts : {};')()}catch(e){throw new Error("Could not evaluate jscolor options: "+e)}}return t},getInstances:function(){for(var e=[],t=0;t<i.instances.length;t+=1)i.instances[t]&&i.instances[t].targetElement&&e.push(i.instances[t]);return e},createEl:function(t){var o=e.document.createElement(t);return i.setData(o,"gui",!0),o},node:function(t){if(!t)return null;if("string"==typeof t){var o=t,n=null;try{n=e.document.querySelector(o)}catch(e){return console.warn(e),null}return n||console.warn("No element matches the selector: %s",o),n}return i.isNode(t)?t:(console.warn("Invalid node of type %s: %s",typeof t,t),null)},isNode:function(e){return"object"==typeof Node?e instanceof Node:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},nodeName:function(e){return!(!e||!e.nodeName)&&e.nodeName.toLowerCase()},removeChildren:function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},isTextInput:function(e){return e&&"input"===i.nodeName(e)&&"text"===e.type.toLowerCase()},isButton:function(e){if(!e)return!1;var t=i.nodeName(e);return"button"===t||"input"===t&&["button","submit","reset"].indexOf(e.type.toLowerCase())>-1},isButtonEmpty:function(e){switch(i.nodeName(e)){case"input":return!e.value||""===e.value.trim();case"button":return""===e.textContent.trim()}return null},isPassiveEventSupported:function(){var t=!1;try{var o=Object.defineProperty({},"passive",{get:function(){t=!0}});e.addEventListener("testPassive",null,o),e.removeEventListener("testPassive",null,o)}catch(e){}return t}(),isColorAttrSupported:(n=e.document.createElement("input"),!(!n.setAttribute||(n.setAttribute("type","color"),"color"!=n.type.toLowerCase()))),dataProp:"_data_jscolor",setData:function(){var e=arguments[0];if(3===arguments.length){var t=e.hasOwnProperty(i.dataProp)?e[i.dataProp]:e[i.dataProp]={},o=arguments[2];return t[a=arguments[1]]=o,!0}if(2===arguments.length&&"object"==typeof arguments[1]){t=e.hasOwnProperty(i.dataProp)?e[i.dataProp]:e[i.dataProp]={};var n=arguments[1];for(var a in n)n.hasOwnProperty(a)&&(t[a]=n[a]);return!0}throw new Error("Invalid arguments")},removeData:function(){var e=arguments[0];if(!e.hasOwnProperty(i.dataProp))return!0;for(var t=1;t<arguments.length;t+=1){var o=arguments[t];delete e[i.dataProp][o]}return!0},getData:function(e,t,o){if(!e.hasOwnProperty(i.dataProp)){if(void 0===o)return;e[i.dataProp]={}}var n=e[i.dataProp];return n.hasOwnProperty(t)||void 0===o||(n[t]=o),n[t]},getDataAttr:function(e,t){var o="data-"+t;return e.getAttribute(o)},setDataAttr:function(e,t,o){var n="data-"+t;e.setAttribute(n,o)},_attachedGroupEvents:{},attachGroupEvent:function(e,t,o,n){i._attachedGroupEvents.hasOwnProperty(e)||(i._attachedGroupEvents[e]=[]),i._attachedGroupEvents[e].push([t,o,n]),t.addEventListener(o,n,!1)},detachGroupEvents:function(e){if(i._attachedGroupEvents.hasOwnProperty(e)){for(var t=0;t<i._attachedGroupEvents[e].length;t+=1){var o=i._attachedGroupEvents[e][t];o[0].removeEventListener(o[1],o[2],!1)}delete i._attachedGroupEvents[e]}},preventDefault:function(e){e.preventDefault&&e.preventDefault(),e.returnValue=!1},captureTarget:function(e){e.setCapture&&(i._capturedTarget=e,i._capturedTarget.setCapture())},releaseTarget:function(){i._capturedTarget&&(i._capturedTarget.releaseCapture(),i._capturedTarget=null)},triggerEvent:function(t,o,n,a){if(t){var r=null;return"function"==typeof Event?r=new Event(o,{bubbles:n,cancelable:a}):(r=e.document.createEvent("Event")).initEvent(o,n,a),!!r&&(i.setData(r,"internal",!0),t.dispatchEvent(r),!0)}},triggerInputEvent:function(e,t,o,n){e&&i.isTextInput(e)Line truncated
-3369
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -1,2 +1,2 @@
/*! For license information please see CookieMonster.js.LICENSE.txt */ /*! For license information please see CookieMonster.js.LICENSE.txt */
(()=>{var e={877:function(e){!function(t,o){"use strict";"object"!=typeof e.exports?o(t):e.exports=t.document?o(t):function(e){if(!e.document)throw new Error("jscolor needs a window with document");return o(e)}}("undefined"!=typeof window?window:this,(function(e){"use strict";var t,o,n,i,a=((i={initialized:!1,instances:[],readyQueue:[],register:function(){void 0!==e&&e.document&&e.document.addEventListener("DOMContentLoaded",i.pub.init,!1)},installBySelector:function(t,o){if(!(o=o?i.node(o):e.document))throw new Error("Missing root node");for(var n=o.querySelectorAll(t),a=new RegExp("(^|\\s)("+i.pub.lookupClass+")(\\s*(\\{[^}]*\\})|\\s|$)","i"),r=0;r<n.length;r+=1){var l,s;if(!(n[r].jscolor&&n[r].jscolor instanceof i.pub)&&(void 0===n[r].type||"color"!=n[r].type.toLowerCase()||!i.isColorAttrSupported)&&(null!==(l=i.getDataAttr(n[r],"jscolor"))||n[r].className&&(s=n[r].className.match(a)))){var c=n[r],d="";null!==l?d=l:s&&(console.warn('Installation using class name is DEPRECATED. Use data-jscolor="" attribute instead.'+i.docsRef),s[4]&&(d=s[4]));var p=null;if(d.trim())try{p=i.parseOptionsStr(d)}catch(e){console.warn(e+"\n"+d)}try{new i.pub(c,p)}catch(e){console.warn(e)}}}},parseOptionsStr:function(e){var t=null;try{t=JSON.parse(e)}catch(o){if(!i.pub.looseJSON)throw new Error("Could not parse jscolor options as JSON: "+o);try{t=new Function("var opts = ("+e+'); return typeof opts === "object" ? opts : {};')()}catch(e){throw new Error("Could not evaluate jscolor options: "+e)}}return t},getInstances:function(){for(var e=[],t=0;t<i.instances.length;t+=1)i.instances[t]&&i.instances[t].targetElement&&e.push(i.instances[t]);return e},createEl:function(t){var o=e.document.createElement(t);return i.setData(o,"gui",!0),o},node:function(t){if(!t)return null;if("string"==typeof t){var o=t,n=null;try{n=e.document.querySelector(o)}catch(e){return console.warn(e),null}return n||console.warn("No element matches the selector: %s",o),n}return i.isNode(t)?t:(console.warn("Invalid node of type %s: %s",typeof t,t),null)},isNode:function(e){return"object"==typeof Node?e instanceof Node:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},nodeName:function(e){return!(!e||!e.nodeName)&&e.nodeName.toLowerCase()},removeChildren:function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},isTextInput:function(e){return e&&"input"===i.nodeName(e)&&"text"===e.type.toLowerCase()},isButton:function(e){if(!e)return!1;var t=i.nodeName(e);return"button"===t||"input"===t&&["button","submit","reset"].indexOf(e.type.toLowerCase())>-1},isButtonEmpty:function(e){switch(i.nodeName(e)){case"input":return!e.value||""===e.value.trim();case"button":return""===e.textContent.trim()}return null},isPassiveEventSupported:function(){var t=!1;try{var o=Object.defineProperty({},"passive",{get:function(){t=!0}});e.addEventListener("testPassive",null,o),e.removeEventListener("testPassive",null,o)}catch(e){}return t}(),isColorAttrSupported:(n=e.document.createElement("input"),!(!n.setAttribute||(n.setAttribute("type","color"),"color"!=n.type.toLowerCase()))),dataProp:"_data_jscolor",setData:function(){var e=arguments[0];if(3===arguments.length){var t=e.hasOwnProperty(i.dataProp)?e[i.dataProp]:e[i.dataProp]={},o=arguments[2];return t[a=arguments[1]]=o,!0}if(2===arguments.length&&"object"==typeof arguments[1]){t=e.hasOwnProperty(i.dataProp)?e[i.dataProp]:e[i.dataProp]={};var n=arguments[1];for(var a in n)n.hasOwnProperty(a)&&(t[a]=n[a]);return!0}throw new Error("Invalid arguments")},removeData:function(){var e=arguments[0];if(!e.hasOwnProperty(i.dataProp))return!0;for(var t=1;t<arguments.length;t+=1){var o=arguments[t];delete e[i.dataProp][o]}return!0},getData:function(e,t,o){if(!e.hasOwnProperty(i.dataProp)){if(void 0===o)return;e[i.dataProp]={}}var n=e[i.dataProp];return n.hasOwnProperty(t)||void 0===o||(n[t]=o),n[t]},getDataAttr:function(e,t){var o="data-"+t;return e.getAttribute(o)},setDataAttr:function(e,t,o){var n="data-"+t;e.setAttribute(n,o)},_attachedGroupEvents:{},attachGroupEvent:function(e,t,o,n){i._attachedGroupEvents.hasOwnProperty(e)||(i._attachedGroupEvents[e]=[]),i._attachedGroupEvents[e].push([t,o,n]),t.addEventListener(o,n,!1)},detachGroupEvents:function(e){if(i._attachedGroupEvents.hasOwnProperty(e)){for(var t=0;t<i._attachedGroupEvents[e].length;t+=1){var o=i._attachedGroupEvents[e][t];o[0].removeEventListener(o[1],o[2],!1)}delete i._attachedGroupEvents[e]}},preventDefault:function(e){e.preventDefault&&e.preventDefault(),e.returnValue=!1},captureTarget:function(e){e.setCapture&&(i._capturedTarget=e,i._capturedTarget.setCapture())},releaseTarget:function(){i._capturedTarget&&(i._capturedTarget.releaseCapture(),i._capturedTarget=null)},triggerEvent:function(t,o,n,a){if(t){var r=null;return"function"==typeof Event?r=new Event(o,{bubbles:n,cancelable:a}):(r=e.document.createEvent("Event")).initEvent(o,n,a),!!r&&(i.setData(r,"internal",!0),t.dispatchEvent(r),!0)}},triggerInputEvent:function(e,t,o,n){e&&i.isTextInput(e)Line truncated (()=>{var e={877:function(e){!function(t,o){"use strict";"object"!=typeof e.exports?o(t):e.exports=t.document?o(t):function(e){if(!e.document)throw new Error("jscolor needs a window with document");return o(e)}}("undefined"!=typeof window?window:this,(function(e){"use strict";var t,o,n,i,a=((i={initialized:!1,instances:[],readyQueue:[],register:function(){void 0!==e&&e.document&&e.document.addEventListener("DOMContentLoaded",i.pub.init,!1)},installBySelector:function(t,o){if(!(o=o?i.node(o):e.document))throw new Error("Missing root node");for(var n=o.querySelectorAll(t),a=new RegExp("(^|\\s)("+i.pub.lookupClass+")(\\s*(\\{[^}]*\\})|\\s|$)","i"),r=0;r<n.length;r+=1){var l,s;if(!(n[r].jscolor&&n[r].jscolor instanceof i.pub)&&(void 0===n[r].type||"color"!=n[r].type.toLowerCase()||!i.isColorAttrSupported)&&(null!==(l=i.getDataAttr(n[r],"jscolor"))||n[r].className&&(s=n[r].className.match(a)))){var c=n[r],d="";null!==l?d=l:s&&(console.warn('Installation using class name is DEPRECATED. Use data-jscolor="" attribute instead.'+i.docsRef),s[4]&&(d=s[4]));var p=null;if(d.trim())try{p=i.parseOptionsStr(d)}catch(e){console.warn(e+"\n"+d)}try{new i.pub(c,p)}catch(e){console.warn(e)}}}},parseOptionsStr:function(e){var t=null;try{t=JSON.parse(e)}catch(o){if(!i.pub.looseJSON)throw new Error("Could not parse jscolor options as JSON: "+o);try{t=new Function("var opts = ("+e+'); return typeof opts === "object" ? opts : {};')()}catch(e){throw new Error("Could not evaluate jscolor options: "+e)}}return t},getInstances:function(){for(var e=[],t=0;t<i.instances.length;t+=1)i.instances[t]&&i.instances[t].targetElement&&e.push(i.instances[t]);return e},createEl:function(t){var o=e.document.createElement(t);return i.setData(o,"gui",!0),o},node:function(t){if(!t)return null;if("string"==typeof t){var o=t,n=null;try{n=e.document.querySelector(o)}catch(e){return console.warn(e),null}return n||console.warn("No element matches the selector: %s",o),n}return i.isNode(t)?t:(console.warn("Invalid node of type %s: %s",typeof t,t),null)},isNode:function(e){return"object"==typeof Node?e instanceof Node:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},nodeName:function(e){return!(!e||!e.nodeName)&&e.nodeName.toLowerCase()},removeChildren:function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},isTextInput:function(e){return e&&"input"===i.nodeName(e)&&"text"===e.type.toLowerCase()},isButton:function(e){if(!e)return!1;var t=i.nodeName(e);return"button"===t||"input"===t&&["button","submit","reset"].indexOf(e.type.toLowerCase())>-1},isButtonEmpty:function(e){switch(i.nodeName(e)){case"input":return!e.value||""===e.value.trim();case"button":return""===e.textContent.trim()}return null},isPassiveEventSupported:function(){var t=!1;try{var o=Object.defineProperty({},"passive",{get:function(){t=!0}});e.addEventListener("testPassive",null,o),e.removeEventListener("testPassive",null,o)}catch(e){}return t}(),isColorAttrSupported:(n=e.document.createElement("input"),!(!n.setAttribute||(n.setAttribute("type","color"),"color"!=n.type.toLowerCase()))),dataProp:"_data_jscolor",setData:function(){var e=arguments[0];if(3===arguments.length){var t=e.hasOwnProperty(i.dataProp)?e[i.dataProp]:e[i.dataProp]={},o=arguments[2];return t[a=arguments[1]]=o,!0}if(2===arguments.length&&"object"==typeof arguments[1]){t=e.hasOwnProperty(i.dataProp)?e[i.dataProp]:e[i.dataProp]={};var n=arguments[1];for(var a in n)n.hasOwnProperty(a)&&(t[a]=n[a]);return!0}throw new Error("Invalid arguments")},removeData:function(){var e=arguments[0];if(!e.hasOwnProperty(i.dataProp))return!0;for(var t=1;t<arguments.length;t+=1){var o=arguments[t];delete e[i.dataProp][o]}return!0},getData:function(e,t,o){if(!e.hasOwnProperty(i.dataProp)){if(void 0===o)return;e[i.dataProp]={}}var n=e[i.dataProp];return n.hasOwnProperty(t)||void 0===o||(n[t]=o),n[t]},getDataAttr:function(e,t){var o="data-"+t;return e.getAttribute(o)},setDataAttr:function(e,t,o){var n="data-"+t;e.setAttribute(n,o)},_attachedGroupEvents:{},attachGroupEvent:function(e,t,o,n){i._attachedGroupEvents.hasOwnProperty(e)||(i._attachedGroupEvents[e]=[]),i._attachedGroupEvents[e].push([t,o,n]),t.addEventListener(o,n,!1)},detachGroupEvents:function(e){if(i._attachedGroupEvents.hasOwnProperty(e)){for(var t=0;t<i._attachedGroupEvents[e].length;t+=1){var o=i._attachedGroupEvents[e][t];o[0].removeEventListener(o[1],o[2],!1)}delete i._attachedGroupEvents[e]}},preventDefault:function(e){e.preventDefault&&e.preventDefault(),e.returnValue=!1},captureTarget:function(e){e.setCapture&&(i._capturedTarget=e,i._capturedTarget.setCapture())},releaseTarget:function(){i._capturedTarget&&(i._capturedTarget.releaseCapture(),i._capturedTarget=null)},triggerEvent:function(t,o,n,a){if(t){var r=null;return"function"==typeof Event?r=new Event(o,{bubbles:n,cancelable:a}):(r=e.document.createEvent("Event")).initEvent(o,n,a),!!r&&(i.setData(r,"internal",!0),t.dispatchEvent(r),!0)}},triggerInputEvent:function(e,t,o,n){e&&i.isTextInput(e)Line truncated
+1 -1
View File
@@ -1 +1 @@
{"version":3,"sources":["webpack://cookiemonster-mod/./node_modules/@eastdesire/jscolor/jscolor.js","webpack://cookiemonster-mod/webpack/bootstrap","webpack://cookiemonster-mod/webpack/runtime/compat get default export","webpack://cookiemonster-mod/webpack/runtime/define property getters","webpack://cookiemonster-mod/webpack/runtime/hasOwnProperty shorthand","webpack://cookiemonster-mod/./src/Config/VariablesAndData.js","webpack://cookiemonster-mod/./src/Config/Toggles/ToggleWrinklerButtons.js","webpack://cookiemonster-mod/./src/Data/Scales.ts","webpack://cookiemonster-mod/./src/Main/VariablesAndData.js","webpack://cookiemonster-mod/./src/Disp/VariablesAndData.js","webpack://cookiemonster-mod/./src/Disp/BeautifyAndFormatting/BeautifyFormatting.js","webpack://cookiemonster-mod/./src/Cache/VariablesAndData.js","webpack://cookiemonster-mod/./src/Sim/VariablesAndData.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimAuraMult.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimGetSellMultiplier.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimEff.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimHas.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimHasGod.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimModifyBuidlingPrice.js","webpack://cookiemonster-mod/./src/Sim/SimulationEvents/SellBuilding.js","webpack://cookiemonster-mod/./src/Disp/BuildingsUpgrades/Buildings.js","webpack://cookiemonster-mod/./src/Disp/BuildingsUpgrades/Upgrades.js","webpack://cookiemonster-mod/./src/Disp/HelperFunctions/GetCPS.js","webpack://cookiemonster-mod/./src/Disp/HelperFunctions/GetWrinkConfigBank.js","webpack://cookiemonster-mod/./src/Disp/InfoBars/CreateDOMElements.js","webpack://cookiemonster-mod/./src/Disp/InfoBars/BottomBar.js","webpack://cookiemonster-mod/./src/Disp/HelperFunctions/UpdateBackground.js","webpack://cookiemonster-mod/./src/Config/SpecificToggles.js","webpack://cookiemonster-mod/./src/Cache/Dragon/CacheDragonAuras.js","webpack://cookiemonster-mod/./src/Sim/InitializeData/InitAchievement.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimGetTieredCpsMult.js","webpack://cookiemonster-mod/./src/Sim/InitializeData/InitialBuildingData.js","webpack://cookiemonster-mod/./src/Sim/InitializeData/InitUpgrade.js","webpack://cookiemonster-mod/./src/Sim/SimulationData/CopyData.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/CreateTooltip.js","webpack://cookiemonster-mod/./src/Disp/HelperFunctions/CalculateGrimoireRefillTime.js","webpack://cookiemonster-mod/./src/Cache/CPS/GetCPSBuffMult.js","webpack://cookiemonster-mod/./src/Config/Toggles/ToggleToolWarnPos.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/UpdateTooltips.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/Building.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/Upgrade.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/SugarLump.js","webpack://cookiemonster-mod/./src/Disp/HelperFunctions/GetLumpColour.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/Grimoire.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/GardenPlots.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/HarvestAll.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/WrinklerButton.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/PantheonGods.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/Warnings.js","webpack://cookiemonster-mod/./src/Disp/DrawHook.js","webpack://cookiemonster-mod/./src/Disp/InfoBars/TimerBar.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/WrinklerTooltips.js","webpack://cookiemonster-mod/./src/Disp/MenuSections/Refreshmenu.js","webpack://cookiemonster-mod/./src/Main/ClickHook.js","webpack://cookiemonster-mod/./src/Cache/CPS/AverageQueue.js","webpack://cookiemonster-mod/./src/Cache/CPS/CPS.js","webpack://cookiemonster-mod/./src/Cache/PP/ColourOfPP.js","webpack://cookiemonster-mod/./src/Cache/PP/Building.js","webpack://cookiemonster-mod/./src/Cache/PP/PP.js","webpack://cookiemonster-mod/./src/Cache/PP/Upgrade.js","webpack://cookiemonster-mod/./src/Sim/SimulationEvents/BuyBuilding.js","webpack://cookiemonster-mod/./src/Sim/SimulationData/SimWin.js","webpack://cookiemonster-mod/./src/Sim/Calculations/CalculateGains.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimGetHeavenlyMultiplier.js","webpack://cookiemonster-mod/./src/Data/Gamedata.ts","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimHasAchiev.js","webpack://cookiemonster-mod/./src/Sim/Calculations/CheckOtherAchiev.js","webpack://cookiemonster-mod/./src/Sim/SimulationEvents/BuyBuildingBonusIncome.js","webpack://cookiemonster-mod/./src/Cache/PriceAndIncome/PriceAndIncome.js","webpack://cookiemonster-mod/./src/Sim/SimulationEvents/BuyUpgrades.js","webpack://cookiemonster-mod/./src/Cache/StLine truncated {"version":3,"sources":["webpack://cookiemonster-mod/./node_modules/@eastdesire/jscolor/jscolor.js","webpack://cookiemonster-mod/webpack/bootstrap","webpack://cookiemonster-mod/webpack/runtime/compat get default export","webpack://cookiemonster-mod/webpack/runtime/define property getters","webpack://cookiemonster-mod/webpack/runtime/hasOwnProperty shorthand","webpack://cookiemonster-mod/./src/Config/VariablesAndData.js","webpack://cookiemonster-mod/./src/Config/Toggles/ToggleWrinklerButtons.js","webpack://cookiemonster-mod/./src/Data/Scales.ts","webpack://cookiemonster-mod/./src/Main/VariablesAndData.js","webpack://cookiemonster-mod/./src/Disp/BeautifyAndFormatting/Beautify.js","webpack://cookiemonster-mod/./src/Cache/VariablesAndData.js","webpack://cookiemonster-mod/./src/Sim/VariablesAndData.js","webpack://cookiemonster-mod/./src/Disp/VariablesAndData.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimAuraMult.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimGetSellMultiplier.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimEff.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimHas.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimHasGod.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimModifyBuidlingPrice.js","webpack://cookiemonster-mod/./src/Sim/SimulationEvents/SellBuilding.js","webpack://cookiemonster-mod/./src/Disp/BuildingsUpgrades/Buildings.js","webpack://cookiemonster-mod/./src/Disp/BuildingsUpgrades/Upgrades.js","webpack://cookiemonster-mod/./src/Disp/BeautifyAndFormatting/FormatTime.js","webpack://cookiemonster-mod/./src/Disp/BeautifyAndFormatting/GetTimeColour.js","webpack://cookiemonster-mod/./src/Disp/HelperFunctions/GetCPS.js","webpack://cookiemonster-mod/./src/Disp/HelperFunctions/GetWrinkConfigBank.js","webpack://cookiemonster-mod/./src/Disp/InfoBars/CreateDOMElements.js","webpack://cookiemonster-mod/./src/Disp/InfoBars/BottomBar.js","webpack://cookiemonster-mod/./src/Disp/HelperFunctions/UpdateBackground.js","webpack://cookiemonster-mod/./src/Config/SpecificToggles.js","webpack://cookiemonster-mod/./src/Cache/Dragon/CacheDragonAuras.js","webpack://cookiemonster-mod/./src/Sim/InitializeData/InitAchievement.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimGetTieredCpsMult.js","webpack://cookiemonster-mod/./src/Sim/InitializeData/InitialBuildingData.js","webpack://cookiemonster-mod/./src/Sim/InitializeData/InitUpgrade.js","webpack://cookiemonster-mod/./src/Sim/SimulationData/CopyData.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/CreateTooltip.js","webpack://cookiemonster-mod/./src/Cache/PP/ColourOfPP.js","webpack://cookiemonster-mod/./src/Cache/CPS/GetCPSBuffMult.js","webpack://cookiemonster-mod/./src/Sim/SimulationData/SimWin.js","webpack://cookiemonster-mod/./src/Sim/Calculations/CalculateGains.js","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimGetHeavenlyMultiplier.js","webpack://cookiemonster-mod/./src/Data/Gamedata.ts","webpack://cookiemonster-mod/./src/Sim/ReplacedGameFunctions/SimHasAchiev.js","webpack://cookiemonster-mod/./src/Sim/Calculations/CheckOtherAchiev.js","webpack://cookiemonster-mod/./src/Sim/SimulationEvents/BuyBuildingBonusIncome.js","webpack://cookiemonster-mod/./src/Disp/HelperFunctions/CalculateGrimoireRefillTime.js","webpack://cookiemonster-mod/./src/Config/Toggles/ToggleToolWarnPos.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/UpdateTooltips.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/Building.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/Upgrade.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/SugarLump.js","webpack://cookiemonster-mod/./src/Disp/HelperFunctions/GetLumpColour.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/Grimoire.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/GardenPlots.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/HarvestAll.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/WrinklerButton.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/PantheonGods.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/TypesOfTooltips/Warnings.js","webpack://cookiemonster-mod/./src/Disp/DrawHook.js","webpack://cookiemonster-mod/./src/Disp/InfoBars/TimerBar.js","webpack://cookiemonster-mod/./src/Disp/Tooltips/WrinklerTooltips.js","webpack://cookiemonster-mod/./src/Disp/MenuSections/Refreshmenu.js","webpack://cookiemonster-mod/./src/Main/ClickHook.js","webpack://cookiemonster-mod/./src/Cache/CPS/AverageQueue.js","webpack://cookiemonster-mod/./src/Cache/CPS/CPS.js","webpack://cookiemonster-mod/./src/Cache/PP/Building.js","webpack://cookiemonster-mod/./src/Cache/PP/PP.js","webpack://cookiemonster-mod/./src/Cache/PP/Upgrade.js","webpack://cookiemonster-mod/./src/Sim/SimulationEvents/BuyBuilding.js","webpack://cookiemonster-mod/./src/Cache/PrLine truncated
+1205 -6
View File
File diff suppressed because it is too large. Load diff
+7 -2
View File
@@ -13,11 +13,12 @@
"scripts": { "scripts": {
"copy-file": "cp dist/CookieMonster.js CookieMonster.js", "copy-file": "cp dist/CookieMonster.js CookieMonster.js",
"eslint-src": "eslint src", "eslint-src": "eslint src",
"build": "run-s eslint-src pack-prod remove-comment copy-file", "build": "run-s eslint-src pack-prod remove-comment copy-file test",
"build-test": "run-s pack-dev", "build-test": "run-s pack-dev",
"pack-prod": "webpack --env production", "pack-prod": "webpack --env production",
"pack-dev": "webpack", "pack-dev": "webpack",
"remove-comment": "sed -i '' -e '/\\/\\/# sourceMappingURL.*/d' dist/CookieMonster.js" "remove-comment": "sed -i '' -e '/\\/\\/# sourceMappingURL.*/d' dist/CookieMonster.js",
"test": "mocha"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -46,13 +47,17 @@
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.21.0", "@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0", "@typescript-eslint/parser": "^4.21.0",
"chai": "^4.3.4",
"eslint": "^7.23.0", "eslint": "^7.23.0",
"eslint-config-airbnb-base": "^14.2.1", "eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.1.0", "eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1", "eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.3.1", "eslint-plugin-prettier": "^3.3.1",
"esm": "^3.2.25",
"mocha": "^8.3.2",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "2.2.1", "prettier": "2.2.1",
"sinon": "^10.0.0",
"ts-loader": "^8.1.0", "ts-loader": "^8.1.0",
"typescript": "^4.2.3", "typescript": "^4.2.3",
"webpack": "^5.24.4", "webpack": "^5.24.4",
+2
View File
@@ -15,6 +15,7 @@ import {
CacheGoldenAndWrathCookiesMults, CacheGoldenAndWrathCookiesMults,
CacheStatsCookies, CacheStatsCookies,
} from './Stats/Stats'; } from './Stats/Stats';
import AllAmountTillNextAchievement from './TillNextAchievement/AllAmountTillNextAchievement';
import { import {
CacheAverageCookiesFromClicks, CacheAverageCookiesFromClicks,
HeavenlyChipsDiff, HeavenlyChipsDiff,
@@ -39,6 +40,7 @@ export default function InitCache() {
ClickTimes[ClickTimes.length - 1] * 20, ClickTimes[ClickTimes.length - 1] * 20,
); );
CacheHeavenlyChipsPS(); CacheHeavenlyChipsPS();
AllAmountTillNextAchievement();
CacheAvgCPS(); CacheAvgCPS();
CacheIncome(); CacheIncome();
CacheBuildingsPrices(); CacheBuildingsPrices();
+1 -1
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 GetCPS from '../Disp/HelperFunctions/GetCPS';
import CacheAvgCPS from './CPS/CPS'; import CacheAvgCPS from './CPS/CPS';
import CacheCurrWrinklerCPS from './CPS/CurrWrinklerCPS'; import CacheCurrWrinklerCPS from './CPS/CurrWrinklerCPS';
+1 -1
View File
@@ -1,6 +1,6 @@
/** Functions related to the Dragon */ /** Functions related to the Dragon */
import { Beautify } from '../../Disp/BeautifyAndFormatting/BeautifyFormatting'; import Beautify from '../../Disp/BeautifyAndFormatting/Beautify';
import CopyData from '../../Sim/SimulationData/CopyData'; import CopyData from '../../Sim/SimulationData/CopyData';
import { SimDoSims, SimObjects } from '../../Sim/VariablesAndData'; import { SimDoSims, SimObjects } from '../../Sim/VariablesAndData';
import { import {
@@ -12,6 +12,7 @@ import {
CacheObjects1, CacheObjects1,
CacheObjects10, CacheObjects10,
CacheObjects100, CacheObjects100,
CacheObjectsNextAchievement,
CacheUpgrades, CacheUpgrades,
} from '../VariablesAndData'; } from '../VariablesAndData';
@@ -82,6 +83,13 @@ export function CacheBuildingsPrices() {
Game.Objects[i].free, Game.Objects[i].free,
100, 100,
); );
CacheObjectsNextAchievement[i].price = BuildingGetPrice(
Game.Objects[i],
Game.Objects[i].basePrice,
Game.Objects[i].amount,
Game.Objects[i].free,
CacheObjectsNextAchievement[i].AmountNeeded,
);
}); });
} }
@@ -7,12 +7,6 @@ import {
shortScaleAbbreviated, shortScaleAbbreviated,
} from '../../Data/Scales.ts'; } from '../../Data/Scales.ts';
import { BackupFunctions } from '../../Main/VariablesAndData'; import { BackupFunctions } from '../../Main/VariablesAndData';
import {
ColourGreen,
ColourOrange,
ColourRed,
ColourYellow,
} from '../VariablesAndData';
/** /**
* This function returns formats number based on the Scale setting * 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 * @param {number} forced Used to force (type 3) in certains cases
* @returns {string} Formatted number * @returns {string} Formatted number
*/ */
export function Beautify(num, floats, forced) { export default function Beautify(num, floats, forced) {
const decimals = CMOptions.ScaleDecimals + 1; const decimals = CMOptions.ScaleDecimals + 1;
if (num === Infinity) { if (num === Infinity) {
return '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 console.log(`Could not beautify number with Cookie Monster Beautify: ${num}`); // eslint-disable-line no-console
return BackupFunctions.Beautify(num, floats); 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 };
}
@@ -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 / 31536000);
const d = Math.floor((formattedTime % 31536000) / 86400);
const h = Math.floor(((formattedTime % 31536000) % 86400) / 3600);
const m = Math.floor((((formattedTime % 31536000) % 86400) % 3600) / 60);
const s = Math.floor((((formattedTime % 31536000) % 86400) % 3600) % 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
: '';
if (str.length > 0 || d > 0)
str += `${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;
}
@@ -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 };
}
+1 -1
View File
@@ -5,7 +5,7 @@ import {
} from '../../Cache/VariablesAndData'; } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import BuildingSell from '../../Sim/SimulationEvents/SellBuilding'; import BuildingSell from '../../Sim/SimulationEvents/SellBuilding';
import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting'; import Beautify from '../BeautifyAndFormatting/Beautify';
import { ColoursOrdering, LastTargetBuildings } from '../VariablesAndData'; import { ColoursOrdering, LastTargetBuildings } from '../VariablesAndData';
/** /**
+2 -4
View File
@@ -4,10 +4,8 @@ import CacheDragonCost from '../../Cache/Dragon/Dragon';
import { CacheCostDragonUpgrade } from '../../Cache/VariablesAndData'; import { CacheCostDragonUpgrade } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import CalculateChangeAura from '../../Sim/SimulationEvents/AuraChange'; import CalculateChangeAura from '../../Sim/SimulationEvents/AuraChange';
import { import Beautify from '../BeautifyAndFormatting/Beautify';
Beautify, import FormatTime from '../BeautifyAndFormatting/FormatTime';
FormatTime,
} from '../BeautifyAndFormatting/BeautifyFormatting';
/** /**
* This functions adds the two extra lines about CPS and time to recover to the aura picker infoscreen * This functions adds the two extra lines about CPS and time to recover to the aura picker infoscreen
+1 -1
View File
@@ -1,6 +1,6 @@
import ToggleWrinklerButtons from '../Config/Toggles/ToggleWrinklerButtons'; import ToggleWrinklerButtons from '../Config/Toggles/ToggleWrinklerButtons';
import { CMOptions } from '../Config/VariablesAndData'; import { CMOptions } from '../Config/VariablesAndData';
import { Beautify } from './BeautifyAndFormatting/BeautifyFormatting'; import Beautify from './BeautifyAndFormatting/Beautify';
import UpdateBuildings from './BuildingsUpgrades/Buildings'; import UpdateBuildings from './BuildingsUpgrades/Buildings';
import UpdateUpgrades from './BuildingsUpgrades/Upgrades'; import UpdateUpgrades from './BuildingsUpgrades/Upgrades';
import { UpdateBotBar } from './InfoBars/BottomBar'; import { UpdateBotBar } from './InfoBars/BottomBar';
+4 -5
View File
@@ -7,11 +7,10 @@ import {
} from '../../Cache/VariablesAndData'; } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { VersionMajor, VersionMinor } from '../../Data/Moddata.ts'; import { VersionMajor, VersionMinor } from '../../Data/Moddata.ts';
import { import Beautify from '../BeautifyAndFormatting/Beautify';
Beautify, import FormatTime from '../BeautifyAndFormatting/FormatTime';
FormatTime, import GetTimeColour from '../BeautifyAndFormatting/GetTimeColour';
GetTimeColour,
} from '../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../HelperFunctions/GetCPS'; import GetCPS from '../HelperFunctions/GetCPS';
import GetWrinkConfigBank from '../HelperFunctions/GetWrinkConfigBank'; import GetWrinkConfigBank from '../HelperFunctions/GetWrinkConfigBank';
import { import {
@@ -16,7 +16,7 @@ import {
import PopAllNormalWrinklers from '../../HelperFunctions/PopWrinklers'; import PopAllNormalWrinklers from '../../HelperFunctions/PopWrinklers';
import { ClickTimes, CookieTimes } from '../../VariablesAndData'; import { ClickTimes, CookieTimes } from '../../VariablesAndData';
import GetCPS from '../../HelperFunctions/GetCPS'; import GetCPS from '../../HelperFunctions/GetCPS';
import { Beautify } from '../../BeautifyAndFormatting/BeautifyFormatting'; import Beautify from '../../BeautifyAndFormatting/Beautify';
import AddMissingAchievements from './CreateMissingAchievements'; import AddMissingAchievements from './CreateMissingAchievements';
/** /**
@@ -38,15 +38,12 @@ import {
} from '../../../Cache/VariablesAndData'; } from '../../../Cache/VariablesAndData';
import { CMOptions } from '../../../Config/VariablesAndData'; import { CMOptions } from '../../../Config/VariablesAndData';
import ResetBonus from '../../../Sim/SimulationEvents/ResetAscension'; import ResetBonus from '../../../Sim/SimulationEvents/ResetAscension';
import {
Beautify,
FormatTime,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../../HelperFunctions/GetCPS'; import GetCPS from '../../HelperFunctions/GetCPS';
import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank'; import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank';
import { ColourGreen, ColourRed, ColourTextPre } from '../../VariablesAndData'; import { ColourGreen, ColourRed, ColourTextPre } from '../../VariablesAndData';
import { StatsListing, StatsHeader, StatsMissDisp } from './CreateDOMElements'; 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 * This function creates the "Lucky" section of the stats page
+1 -1
View File
@@ -4,7 +4,7 @@ import {
CacheTimeTillNextPrestige, CacheTimeTillNextPrestige,
} from '../../Cache/VariablesAndData'; } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting'; import Beautify from '../BeautifyAndFormatting/Beautify';
/** /**
* This function creates a header object for tooltips. * This function creates a header object for tooltips.
+1 -1
View File
@@ -192,7 +192,7 @@ export function TooltipCreateCalculationSection(tooltip) {
} }
if (TooltipType === 'b') { if (TooltipType === 'b') {
tooltip.appendChild( tooltip.appendChild(
TooltipCreateHeader('Buildings left till next additional achievement'), TooltipCreateHeader('Buildings (price / PP) left till next achievement'),
); );
tooltip.lastChild.id = 'CMTooltipNextAchievementHeader'; // eslint-disable-line no-param-reassign tooltip.lastChild.id = 'CMTooltipNextAchievementHeader'; // eslint-disable-line no-param-reassign
const production = document.createElement('div'); const production = document.createElement('div');
+2 -4
View File
@@ -1,8 +1,4 @@
import UpdateTooltips from './UpdateTooltips'; import UpdateTooltips from './UpdateTooltips';
import {
Beautify,
GetTimeColour,
} from '../BeautifyAndFormatting/BeautifyFormatting';
import { import {
SimpleTooltipElements, SimpleTooltipElements,
TooltipName, TooltipName,
@@ -10,6 +6,8 @@ import {
} from '../VariablesAndData'; } from '../VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding'; 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 */ /** All general functions related to creating and updating tooltips */
+32 -9
View File
@@ -1,3 +1,4 @@
import ColourOfPP from '../../../Cache/PP/ColourOfPP';
import { import {
CacheObjects1, CacheObjects1,
CacheObjects10, CacheObjects10,
@@ -5,12 +6,11 @@ import {
CacheObjectsNextAchievement, CacheObjectsNextAchievement,
} from '../../../Cache/VariablesAndData'; } from '../../../Cache/VariablesAndData';
import { CMOptions } from '../../../Config/VariablesAndData'; import { CMOptions } from '../../../Config/VariablesAndData';
import BuyBuildingsBonusIncome from '../../../Sim/SimulationEvents/BuyBuildingBonusIncome';
import { SimObjects } from '../../../Sim/VariablesAndData'; import { SimObjects } from '../../../Sim/VariablesAndData';
import { import Beautify from '../../BeautifyAndFormatting/Beautify';
Beautify, import FormatTime from '../../BeautifyAndFormatting/FormatTime';
FormatTime, import GetTimeColour from '../../BeautifyAndFormatting/GetTimeColour';
GetTimeColour,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../../HelperFunctions/GetCPS'; import GetCPS from '../../HelperFunctions/GetCPS';
import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank'; import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank';
import { import {
@@ -101,13 +101,36 @@ export default function Building() {
} }
} }
if (CacheObjectsNextAchievement[TooltipName].AmountNeeded < 101) { const ObjectsTillNext = CacheObjectsNextAchievement[TooltipName];
if (ObjectsTillNext.AmountNeeded < 101) {
l('CMTooltipProductionLeft').style.marginBottom = '4px'; l('CMTooltipProductionLeft').style.marginBottom = '4px';
l('CMTooltipNextAchievementHeader').style.display = ''; l('CMTooltipNextAchievementHeader').style.display = '';
l('CMTooltipNextAchievement').textContent = Beautify(
CacheObjectsNextAchievement[TooltipName].AmountNeeded, let PPOfAmount;
); if (Game.cookiesPs) {
PPOfAmount =
Math.max(
ObjectsTillNext.price - (Game.cookies + GetWrinkConfigBank()),
0,
) /
Game.cookiesPs +
ObjectsTillNext.price /
BuyBuildingsBonusIncome(TooltipName, ObjectsTillNext.AmountNeeded);
} else
PPOfAmount =
ObjectsTillNext.price /
BuyBuildingsBonusIncome(TooltipName, ObjectsTillNext.AmountNeeded);
l('CMTooltipNextAchievement').textContent = `${Beautify(
ObjectsTillNext.AmountNeeded,
)} / ${Beautify(ObjectsTillNext.price)} / `;
l('CMTooltipNextAchievement').style.color = 'white'; l('CMTooltipNextAchievement').style.color = 'white';
const PPFrag = document.createElement('span');
if (CMOptions.PPDisplayTime) PPFrag.textContent = FormatTime(PPOfAmount);
else PPFrag.textContent = Beautify(PPOfAmount);
PPFrag.className =
ColourTextPre + ColourOfPP({ pp: PPOfAmount }, ObjectsTillNext.price);
l('CMTooltipNextAchievement').appendChild(PPFrag);
} else { } else {
l('CMTooltipNextAchievementHeader').style.display = 'none'; l('CMTooltipNextAchievementHeader').style.display = 'none';
l('CMTooltipProductionLeft').style.marginBottom = '0px'; l('CMTooltipProductionLeft').style.marginBottom = '0px';
@@ -1,5 +1,5 @@
import { CMOptions } from '../../../Config/VariablesAndData'; import { CMOptions } from '../../../Config/VariablesAndData';
import { Beautify } from '../../BeautifyAndFormatting/BeautifyFormatting'; import Beautify from '../../BeautifyAndFormatting/Beautify';
import { TooltipName } from '../../VariablesAndData'; import { TooltipName } from '../../VariablesAndData';
import * as Create from '../CreateTooltip'; import * as Create from '../CreateTooltip';
@@ -1,9 +1,7 @@
import { CacheNoGoldSwitchCookiesPS } from '../../../Cache/VariablesAndData'; import { CacheNoGoldSwitchCookiesPS } from '../../../Cache/VariablesAndData';
import { CMOptions } from '../../../Config/VariablesAndData'; import { CMOptions } from '../../../Config/VariablesAndData';
import { import Beautify from '../../BeautifyAndFormatting/Beautify';
Beautify, import GetTimeColour from '../../BeautifyAndFormatting/GetTimeColour';
GetTimeColour,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import CalculateGrimoireRefillTime from '../../HelperFunctions/CalculateGrimoireRefillTime'; import CalculateGrimoireRefillTime from '../../HelperFunctions/CalculateGrimoireRefillTime';
import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank'; import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank';
import { ColourTextPre, TooltipName } from '../../VariablesAndData'; import { ColourTextPre, TooltipName } from '../../VariablesAndData';
@@ -1,5 +1,5 @@
import { CMOptions } from '../../../Config/VariablesAndData'; import { CMOptions } from '../../../Config/VariablesAndData';
import { Beautify } from '../../BeautifyAndFormatting/BeautifyFormatting'; import Beautify from '../../BeautifyAndFormatting/Beautify';
import * as Create from '../CreateTooltip'; import * as Create from '../CreateTooltip';
/** /**
@@ -1,6 +1,6 @@
import { CacheGods } from '../../../Cache/VariablesAndData'; import { CacheGods } from '../../../Cache/VariablesAndData';
import { CMOptions } from '../../../Config/VariablesAndData'; import { CMOptions } from '../../../Config/VariablesAndData';
import { Beautify } from '../../BeautifyAndFormatting/BeautifyFormatting'; import Beautify from '../../BeautifyAndFormatting/Beautify';
import { TooltipName, TooltipType } from '../../VariablesAndData'; import { TooltipName, TooltipType } from '../../VariablesAndData';
import * as Create from '../CreateTooltip'; import * as Create from '../CreateTooltip';
+3 -5
View File
@@ -3,11 +3,9 @@ import {
CacheUpgrades, CacheUpgrades,
} from '../../../Cache/VariablesAndData'; } from '../../../Cache/VariablesAndData';
import { CMOptions } from '../../../Config/VariablesAndData'; import { CMOptions } from '../../../Config/VariablesAndData';
import { import Beautify from '../../BeautifyAndFormatting/Beautify';
Beautify, import FormatTime from '../../BeautifyAndFormatting/FormatTime';
FormatTime, import GetTimeColour from '../../BeautifyAndFormatting/GetTimeColour';
GetTimeColour,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../../HelperFunctions/GetCPS'; import GetCPS from '../../HelperFunctions/GetCPS';
import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank'; import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank';
import { import {
@@ -2,11 +2,8 @@ import GetCPSBuffMult from '../../../Cache/CPS/GetCPSBuffMult';
import { CacheEdifice, CacheLucky } from '../../../Cache/VariablesAndData'; import { CacheEdifice, CacheLucky } from '../../../Cache/VariablesAndData';
import ToggleToolWarnPos from '../../../Config/Toggles/ToggleToolWarnPos'; import ToggleToolWarnPos from '../../../Config/Toggles/ToggleToolWarnPos';
import { CMOptions } from '../../../Config/VariablesAndData'; import { CMOptions } from '../../../Config/VariablesAndData';
import Beautify from '../../BeautifyAndFormatting/Beautify';
import { import FormatTime from '../../BeautifyAndFormatting/FormatTime';
Beautify,
FormatTime,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../../HelperFunctions/GetCPS'; import GetCPS from '../../HelperFunctions/GetCPS';
import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank'; import GetWrinkConfigBank from '../../HelperFunctions/GetWrinkConfigBank';
import { import {
@@ -2,7 +2,7 @@ import {
CacheWrinklersFattest, CacheWrinklersFattest,
CacheWrinklersTotal, CacheWrinklersTotal,
} from '../../../Cache/VariablesAndData'; } from '../../../Cache/VariablesAndData';
import { Beautify } from '../../BeautifyAndFormatting/BeautifyFormatting'; import Beautify from '../../BeautifyAndFormatting/Beautify';
import { TooltipName } from '../../VariablesAndData'; import { TooltipName } from '../../VariablesAndData';
import * as Create from '../CreateTooltip'; import * as Create from '../CreateTooltip';
+1 -1
View File
@@ -1,6 +1,6 @@
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { SimObjects } from '../../Sim/VariablesAndData'; import { SimObjects } from '../../Sim/VariablesAndData';
import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting'; import Beautify from '../BeautifyAndFormatting/Beautify';
import { import {
TooltipWrinkler, TooltipWrinkler,
TooltipWrinklerArea, TooltipWrinklerArea,
@@ -1,6 +1,5 @@
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { FormatTime } from '../../Disp/BeautifyAndFormatting/BeautifyFormatting'; import FormatTime from '../../Disp/BeautifyAndFormatting/FormatTime';
import CalculateGrimoireRefillTime from '../../Disp/HelperFunctions/CalculateGrimoireRefillTime'; import CalculateGrimoireRefillTime from '../../Disp/HelperFunctions/CalculateGrimoireRefillTime';
import { import {
BackupGrimoireDraw, BackupGrimoireDraw,
@@ -1,9 +1,7 @@
import jscolor from '@eastdesire/jscolor'; import jscolor from '@eastdesire/jscolor';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { import Beautify from '../../Disp/BeautifyAndFormatting/Beautify';
Beautify as CMBeautify, import FormatTime from '../../Disp/BeautifyAndFormatting/FormatTime';
FormatTime,
} from '../../Disp/BeautifyAndFormatting/BeautifyFormatting';
import { AddAuraInfo, AddDragonLevelUpTooltip } from '../../Disp/Dragon/Dragon'; import { AddAuraInfo, AddDragonLevelUpTooltip } from '../../Disp/Dragon/Dragon';
import AddMenu from '../../Disp/MenuSections/AddMenus'; import AddMenu from '../../Disp/MenuSections/AddMenus';
import UpdateTitle from '../../Disp/TabTitle/TabTitle'; import UpdateTitle from '../../Disp/TabTitle/TabTitle';
@@ -146,7 +144,7 @@ export default function ReplaceNative() {
let title = 'Cookie Clicker'; let title = 'Cookie Clicker';
if (Game.season === 'fools') title = 'Cookie Baker'; if (Game.season === 'fools') title = 'Cookie Baker';
// eslint-disable-next-line no-unused-vars // 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' Game.cookies === 1 ? 'cookie' : 'cookies'
} - ${title}`; } - ${title}`;
UpdateTitle(); UpdateTitle();
+106
View File
@@ -0,0 +1,106 @@
import { before, describe, it } from 'mocha';
import { assert } from 'chai';
import FormatTime from '../../src/Disp/BeautifyAndFormatting/FormatTime';
import { CMOptions } from '../../src/Config/VariablesAndData';
describe('FormatTime', function () {
it('Format when time is Infinity', function () {
assert.equal(FormatTime(Infinity, 0), Infinity);
});
it('Format when time is negative', function () {
assert.equal(FormatTime(-1, 0), 'Negative time period');
});
describe('TimeFormat = 0', function () {
before(function () {
CMOptions.TimeFormat = 0;
});
describe('Longformat = 0', function () {
it('Format when time is 0', function () {
assert.equal(FormatTime(0, 0), '0s');
});
it('Format when time is 1 second', function () {
assert.equal(FormatTime(1, 0), '1s');
});
it('Format when time is over 1 minute', function () {
assert.equal(FormatTime(61, 0), '1m, 1s');
});
it('Format when time is over 1 hour', function () {
assert.equal(FormatTime(3601, 0), '1h, 0m, 1s');
});
it('Format when time is over 1 day', function () {
assert.equal(FormatTime(86401, 0), '1d, 0h, 0m, 1s');
});
it('Format when time is over 1 year', function () {
assert.equal(FormatTime(31536001, 0), '1y, 0d, 0h, 0m, 1s');
});
it('Format when time is over >9000 days', function () {
assert.equal(FormatTime(777600001, 0), '>9000d');
});
it('Format when time is over >99.9 years', function () {
assert.equal(FormatTime(3155760001, 0), '>9000d');
});
});
describe('Longformat = 1', function () {
it('Format when time is 0', function () {
assert.equal(FormatTime(0, 1), '0 seconds');
});
it('Format when time is 1 second', function () {
assert.equal(FormatTime(1, 1), '1 second');
});
it('Format when time is over 1 minute', function () {
assert.equal(FormatTime(61, 1), '1 minute, 1 second');
});
it('Format when time is over 1 hour', function () {
assert.equal(FormatTime(3601, 1), '1 hour, 0 minutes, 1 second');
});
it('Format when time is over 1 day', function () {
assert.equal(
FormatTime(86401, 1),
'1 day, 0 hours, 0 minutes, 1 second',
);
});
it('Format when time is over 1 year', function () {
assert.equal(
FormatTime(31536001, 1),
'1 year, 0 days, 0 hours, 0 minutes, 1 second',
);
});
it('Format when time is over >9000 days', function () {
assert.equal(FormatTime(777600001, 1), 'Over 9000 days!');
});
it('Format when time is over >99.9 years', function () {
assert.equal(FormatTime(3155760001, 1), 'Over 9000 days!');
});
});
});
describe('TimeFormat = 1', function () {
before(function () {
CMOptions.TimeFormat = 1;
});
it('Format when time is 0', function () {
assert.equal(FormatTime(0, 0), '00:00:00:00:00');
});
it('Format when time is 1 second', function () {
assert.equal(FormatTime(1, 0), '00:00:00:00:01');
});
it('Format when time is over 1 minute', function () {
assert.equal(FormatTime(61, 0), '00:00:00:01:01');
});
it('Format when time is over 1 hour', function () {
assert.equal(FormatTime(3601, 0), '00:00:01:00:01');
});
it('Format when time is over 1 day', function () {
assert.equal(FormatTime(86401, 0), '00:01:00:00:01');
});
it('Format when time is over 1 year', function () {
assert.equal(FormatTime(31536001, 0), '01:00:00:00:01');
});
it('Format when time is over >9000 days', function () {
assert.equal(FormatTime(777600001, 0), '24:240:00:00:01');
});
it('Format when time is over >99.9 years', function () {
assert.equal(FormatTime(3155760001, 0), 'XX:XX:XX:XX:XX');
});
});
});