From 7f5cdf2cc3df8369f318a4a25a27c2372658e945 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Fri, 3 Apr 2020 13:06:11 +0300 Subject: [PATCH] Change line width --- package.json | 6 +++--- src/Action/ActionController.ts | 6 +----- src/Action/CheckBuildingRemainingTimeAction.ts | 6 +----- src/Action/GrabHeroAttributesAction.ts | 9 ++------- src/Action/UpgradeBuildingAction.ts | 10 ++-------- src/Scheduler.ts | 16 +++------------- src/Storage/TaskQueue.ts | 10 ++-------- src/Task/TaskController.ts | 5 +---- src/TaskQueueRenderer.ts | 8 +------- 9 files changed, 16 insertions(+), 60 deletions(-) diff --git a/package.json b/package.json index e4bf994..e0c45cf 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,9 @@ "coverage": "nyc mocha", "build:dev": "webpack", "build": "webpack --env.production", - "format": "prettier --tab-width=4 --single-quote --trailing-comma es5 --write '{src,tests}/**/*.{ts,js}'", - "format-check": "prettier --tab-width=4 --single-quote --trailing-comma es5 --check '{src,tests}/**/*.{ts,js}'", - "format-wp": "prettier --tab-width=4 --single-quote --trailing-comma es5 --write 'webpack.config.js'", + "format": "prettier --tab-width=4 --print-width 120 --single-quote --trailing-comma es5 --write '{src,tests}/**/*.{ts,js}'", + "format-check": "prettier --tab-width=4 --print-width 120 --single-quote --trailing-comma es5 --check '{src,tests}/**/*.{ts,js}'", + "format-wp": "prettier --tab-width=4 --print-width 120 --single-quote --trailing-comma es5 --write 'webpack.config.js'", "format-md": "prettier --write './*.md'" }, "devDependencies": { diff --git a/src/Action/ActionController.ts b/src/Action/ActionController.ts index 0835a5e..94a6c5a 100644 --- a/src/Action/ActionController.ts +++ b/src/Action/ActionController.ts @@ -9,11 +9,7 @@ export function registerAction(constructor: Function) { actionMap[constructor.name] = constructor; } -export function createAction( - name: string, - state: GameState, - scheduler: Scheduler -): ActionController | undefined { +export function createAction(name: string, state: GameState, scheduler: Scheduler): ActionController | undefined { const storedFunction = actionMap[name]; if (storedFunction === undefined) { return undefined; diff --git a/src/Action/CheckBuildingRemainingTimeAction.ts b/src/Action/CheckBuildingRemainingTimeAction.ts index 3db7549..8c1e920 100644 --- a/src/Action/CheckBuildingRemainingTimeAction.ts +++ b/src/Action/CheckBuildingRemainingTimeAction.ts @@ -10,11 +10,7 @@ export class CheckBuildingRemainingTimeAction extends ActionController { if (timer.length === 1) { const remainingSeconds = Number(timer.attr('value')); if (remainingSeconds > 0) { - throw new BuildingQueueFullError( - task.id, - remainingSeconds + 1, - 'Building queue is full' - ); + throw new BuildingQueueFullError(task.id, remainingSeconds + 1, 'Building queue is full'); } } } diff --git a/src/Action/GrabHeroAttributesAction.ts b/src/Action/GrabHeroAttributesAction.ts index 42ab785..46f0a25 100644 --- a/src/Action/GrabHeroAttributesAction.ts +++ b/src/Action/GrabHeroAttributesAction.ts @@ -6,9 +6,7 @@ import { ActionError } from '../Errors'; @registerAction export class GrabHeroAttributesAction extends ActionController { async run(args: Args, task: Task): Promise { - const healthElement = jQuery( - '#attributes .attribute.health .powervalue .value' - ); + const healthElement = jQuery('#attributes .attribute.health .powervalue .value'); if (healthElement.length !== 1) { throw new ActionError(task.id, 'Health dom element not found'); } @@ -16,10 +14,7 @@ export class GrabHeroAttributesAction extends ActionController { let normalized = text.replace(/[^0-9]/g, ''); const value = Number(normalized); if (isNaN(value)) { - throw new ActionError( - task.id, - `Health value "${text}" (${normalized}) couldn't be converted to number` - ); + throw new ActionError(task.id, `Health value "${text}" (${normalized}) couldn't be converted to number`); } this.state.set('hero', { health: value }); diff --git a/src/Action/UpgradeBuildingAction.ts b/src/Action/UpgradeBuildingAction.ts index 81a39fd..c688be2 100644 --- a/src/Action/UpgradeBuildingAction.ts +++ b/src/Action/UpgradeBuildingAction.ts @@ -6,16 +6,10 @@ import { Task } from '../Storage/TaskQueue'; @registerAction export class UpgradeBuildingAction extends ActionController { async run(args: Args, task: Task): Promise { - const btn = jQuery( - '.upgradeButtonsContainer .section1 button.green.build' - ); + const btn = jQuery('.upgradeButtonsContainer .section1 button.green.build'); if (btn.length !== 1) { - throw new TryLaterError( - task.id, - 15 * 60, - 'No upgrade button, try later' - ); + throw new TryLaterError(task.id, 15 * 60, 'No upgrade button, try later'); } btn.trigger('click'); diff --git a/src/Scheduler.ts b/src/Scheduler.ts index 3b63e21..8f086b0 100644 --- a/src/Scheduler.ts +++ b/src/Scheduler.ts @@ -1,10 +1,6 @@ import { markPage, sleepShort, timestamp } from './utils'; import { UpgradeBuildingTask } from './Task/UpgradeBuildingTask'; -import { - AbortTaskError, - BuildingQueueFullError, - TryLaterError, -} from './Errors'; +import { AbortTaskError, BuildingQueueFullError, TryLaterError } from './Errors'; import { Task, TaskId, TaskList, TaskQueue } from './Storage/TaskQueue'; import { ActionQueue } from './Storage/ActionQueue'; import { Command } from './Common'; @@ -49,10 +45,7 @@ export class Scheduler { private scheduleHeroAdventure() { if (!this.taskQueue.hasNamed(SendOnAdventureTask.name)) { - this.taskQueue.push( - new Command(SendOnAdventureTask.name, {}), - timestamp() - ); + this.taskQueue.push(new Command(SendOnAdventureTask.name, {}), timestamp()); } } @@ -75,10 +68,7 @@ export class Scheduler { try { if (actionCommand) { - return await this.processActionCommand( - actionCommand, - taskCommand - ); + return await this.processActionCommand(actionCommand, taskCommand); } if (taskCommand) { diff --git a/src/Storage/TaskQueue.ts b/src/Storage/TaskQueue.ts index b02cc2c..403a829 100644 --- a/src/Storage/TaskQueue.ts +++ b/src/Storage/TaskQueue.ts @@ -102,10 +102,7 @@ export class TaskQueue { private getItems(): TaskList { const serialized = localStorage.getItem(QUEUE_NAME); - const storedItems = - serialized !== null - ? (JSON.parse(serialized) as Array<{ [key: string]: any }>) - : []; + const storedItems = serialized !== null ? (JSON.parse(serialized) as Array<{ [key: string]: any }>) : []; const items: TaskList = []; storedItems.forEach(obj => { items.push(new Task(obj.id || uniqId(), +obj.ts, obj.cmd)); @@ -114,10 +111,7 @@ export class TaskQueue { } private flushItems(items: TaskList): void { - localStorage.setItem( - QUEUE_NAME, - JSON.stringify(TaskQueue.normalize(items)) - ); + localStorage.setItem(QUEUE_NAME, JSON.stringify(TaskQueue.normalize(items))); } private log(...args) { diff --git a/src/Task/TaskController.ts b/src/Task/TaskController.ts index 6a0b195..24e94c2 100644 --- a/src/Task/TaskController.ts +++ b/src/Task/TaskController.ts @@ -8,10 +8,7 @@ export function registerTask(constructor: Function) { taskMap[constructor.name] = constructor; } -export function createTask( - name: string, - scheduler: Scheduler -): TaskController | undefined { +export function createTask(name: string, scheduler: Scheduler): TaskController | undefined { const storedFunction = taskMap[name]; if (storedFunction === undefined) { return undefined; diff --git a/src/TaskQueueRenderer.ts b/src/TaskQueueRenderer.ts index bbecf48..a94e69e 100644 --- a/src/TaskQueueRenderer.ts +++ b/src/TaskQueueRenderer.ts @@ -25,13 +25,7 @@ export class TaskQueueRenderer { tasks.forEach(task => { ul.append( jQuery('
  • ').text( - formatDate(task.ts) + - ' ' + - task.cmd.name + - ' ' + - JSON.stringify(task.cmd.args) + - ' ' + - task.id + formatDate(task.ts) + ' ' + task.cmd.name + ' ' + JSON.stringify(task.cmd.args) + ' ' + task.id ) ); });