Merge pull request #756 from Aktanusa/master

Push fixes to pages
This commit is contained in:
Daniël van Noord
2021-04-06 11:57:14 +02:00
committed by GitHub
16 changed files with 1198 additions and 76 deletions

View File

@@ -15,12 +15,24 @@ module.exports = {
parserOptions: { parserOptions: {
ecmaVersion: 12, 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/*'], ignorePatterns: ['*CookieMonster*.js', 'dist/*', 'node_modules/*'],
rules: { rules: {
'import/no-mutable-exports': 'off', 'import/no-mutable-exports': 'off', // We need to this throughout Cookie Monster
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'func-names': 'off', 'func-names': 'off', // To allow unnamed arrow functions
'prefer-destructuring': ['error', { object: true, array: false }], 'prefer-destructuring': ['error', { object: true, array: false }], // Importing arrays and then destructuring them seems to fail
'max-len': [ 'max-len': [
1, 1,
{ {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1054
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -44,13 +44,17 @@
}, },
"homepage": "https://github.com/Aktanusa/CookieMonster#readme", "homepage": "https://github.com/Aktanusa/CookieMonster#readme",
"devDependencies": { "devDependencies": {
"eslint": "^7.19.0", "@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.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",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "2.2.1", "prettier": "2.2.1",
"ts-loader": "^8.1.0",
"typescript": "^4.2.3",
"webpack": "^5.24.4", "webpack": "^5.24.4",
"webpack-cli": "^4.5.0" "webpack-cli": "^4.5.0"
}, },

View File

@@ -1,53 +0,0 @@
/* eslint-disable max-classes-per-file */
/** This describes all forms of settings used by Cookie Monster */
/** The basic setting class */
export class Setting {
constructor(type, group) {
this.type = type;
this.group = group;
}
}
/** The standard toggle setting class */
export class SettingStandard extends Setting {
constructor(type, group, label, desc, toggle, func = null) {
super(type, group);
this.label = label;
this.desc = desc;
this.toggle = toggle;
if (func) {
this.func = func;
}
}
}
/** The colour picker setting class */
export class SettingColours extends Setting {
constructor(type, group, desc) {
super(type, group);
this.desc = desc;
}
}
/** The volume level setting class */
export class SettingVolume extends Setting {
constructor(type, group, label, desc) {
super(type, group);
this.label = label;
this.desc = desc;
for (let i = 0; i < 101; i++) {
this.label[i] = `${i}%`;
}
}
}
/** The number input setting class */
export class SettingInputNumber extends Setting {
constructor(type, group, label, desc, min, max) {
super(type, group);
this.label = label;
this.desc = desc;
this.min = min;
this.max = max;
}
}

View File

@@ -0,0 +1,11 @@
/** The basic setting class */
export default class Setting {
type: string;
group: string;
constructor(type: string, group: string) {
this.type = type;
this.group = group;
}
}

View File

@@ -0,0 +1,11 @@
import Setting from './BaseSetting';
/** The colour picker setting class */
export default class SettingColours extends Setting {
desc: string;
constructor(type: string, group: string, desc: string) {
super(type, group);
this.desc = desc;
}
}

View File

@@ -0,0 +1,27 @@
import Setting from './BaseSetting';
/** The number input setting class */
export default class SettingInputNumber extends Setting {
label: string[];
desc: string;
min: number;
max: number;
constructor(
type: string,
group: string,
label: string[],
desc: string,
min: number,
max: number,
) {
super(type, group);
this.label = label;
this.desc = desc;
this.min = min;
this.max = max;
}
}

View File

@@ -0,0 +1,29 @@
import Setting from './BaseSetting';
/** The standard toggle setting class */
export default class SettingStandard extends Setting {
label: string[];
desc: string;
toggle: boolean;
func: () => void;
constructor(
type: string,
group: string,
label: string[],
desc: string,
toggle: boolean,
func?: () => void,
) {
super(type, group);
this.label = label;
this.desc = desc;
this.toggle = toggle;
if (func !== undefined) {
this.func = func;
}
}
}

View File

@@ -0,0 +1,17 @@
import Setting from './BaseSetting';
/** The volume level setting class */
export default class SettingVolume extends Setting {
label: string[];
desc: string;
constructor(type: string, group: string, label: string[], desc: string) {
super(type, group);
this.label = label;
this.desc = desc;
for (let i = 0; i < 101; i++) {
this.label[i] = `${i}%`;
}
}
}

View File

@@ -14,12 +14,10 @@ import UpdateUpgrades from '../Disp/BuildingsUpgrades/Upgrades';
import RefreshScale from '../Disp/HelperFunctions/RefreshScale'; import RefreshScale from '../Disp/HelperFunctions/RefreshScale';
import { UpdateFavicon } from '../Disp/TabTitle/FavIcon'; import { UpdateFavicon } from '../Disp/TabTitle/FavIcon';
import { SimDoSims } from '../Sim/VariablesAndData'; import { SimDoSims } from '../Sim/VariablesAndData';
import { import SettingColours from './SettingClasses/SettingColours.ts';
SettingStandard, import SettingInputNumber from './SettingClasses/SettingInputNumber.ts';
SettingColours, import SettingStandard from './SettingClasses/SettingStandard.ts';
SettingVolume, import SettingVolume from './SettingClasses/SettingVolume.ts';
SettingInputNumber,
} from './SettingClasses';
/** This includes all options of CookieMonster and their relevant data */ /** This includes all options of CookieMonster and their relevant data */
const Config = { const Config = {
@@ -529,7 +527,7 @@ const Config = {
'Statistics', 'Statistics',
['Missing Achievements OFF', 'Missing Normal Achievements ON'], ['Missing Achievements OFF', 'Missing Normal Achievements ON'],
'Shows missing normal achievements in statistics menu.', 'Shows missing normal achievements in statistics menu.',
false, true,
), ),
UpStats: new SettingStandard( UpStats: new SettingStandard(
'bool', 'bool',

View File

@@ -19,7 +19,9 @@ export function AddAuraInfo(aura) {
const timeToRecover = FormatTime( const timeToRecover = FormatTime(
priceOfChange / (bonusCPS + Game.cookiesPs), priceOfChange / (bonusCPS + Game.cookiesPs),
); );
const bonusCPSPercentage = Beautify((bonusCPS / Game.cookiesPs) * 100); let bonusCPSPercentage;
if (Game.cookiesPs === 0) bonusCPSPercentage = Beautify(Infinity);
else bonusCPSPercentage = Beautify((bonusCPS / Game.cookiesPs) * 100);
l('dragonAuraInfo').style.minHeight = '60px'; l('dragonAuraInfo').style.minHeight = '60px';
l('dragonAuraInfo').style.margin = '8px'; l('dragonAuraInfo').style.margin = '8px';

9
tsconfig.json Normal file
View File

@@ -0,0 +1,9 @@
{
"compilerOptions": {
"module": "ES2020",
"noImplicitAny": true,
"sourceMap": true,
"target": "ES6",
"strictNullChecks": true,
}
}

View File

@@ -7,11 +7,18 @@ module.exports = function (env) {
optimization: { optimization: {
minimize: !!env.production, minimize: !!env.production,
}, },
entry: { entry: './src/CookieMonster.js',
CookieMonster: { resolve: {
import: './src/CookieMonster.js', extensions: ['.ts', '.js'],
filename: './CookieMonster.js', },
}, module: {
rules: [
{
test: /\.tsx?/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
}, },
output: { output: {
filename: 'CookieMonster.js', filename: 'CookieMonster.js',