Change line width
This commit is contained in:
parent
694a3fffb4
commit
7f5cdf2cc3
@ -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": {
|
||||
|
@ -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;
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,7 @@ import { ActionError } from '../Errors';
|
||||
@registerAction
|
||||
export class GrabHeroAttributesAction extends ActionController {
|
||||
async run(args: Args, task: Task): Promise<any> {
|
||||
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 });
|
||||
|
@ -6,16 +6,10 @@ import { Task } from '../Storage/TaskQueue';
|
||||
@registerAction
|
||||
export class UpgradeBuildingAction extends ActionController {
|
||||
async run(args: Args, task: Task): Promise<any> {
|
||||
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');
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -25,13 +25,7 @@ export class TaskQueueRenderer {
|
||||
tasks.forEach(task => {
|
||||
ul.append(
|
||||
jQuery('<li></li>').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
|
||||
)
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user