Change line width
This commit is contained in:
parent
694a3fffb4
commit
7f5cdf2cc3
@ -15,9 +15,9 @@
|
|||||||
"coverage": "nyc mocha",
|
"coverage": "nyc mocha",
|
||||||
"build:dev": "webpack",
|
"build:dev": "webpack",
|
||||||
"build": "webpack --env.production",
|
"build": "webpack --env.production",
|
||||||
"format": "prettier --tab-width=4 --single-quote --trailing-comma es5 --write '{src,tests}/**/*.{ts,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 --single-quote --trailing-comma es5 --check '{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 --single-quote --trailing-comma es5 --write 'webpack.config.js'",
|
"format-wp": "prettier --tab-width=4 --print-width 120 --single-quote --trailing-comma es5 --write 'webpack.config.js'",
|
||||||
"format-md": "prettier --write './*.md'"
|
"format-md": "prettier --write './*.md'"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -9,11 +9,7 @@ export function registerAction(constructor: Function) {
|
|||||||
actionMap[constructor.name] = constructor;
|
actionMap[constructor.name] = constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createAction(
|
export function createAction(name: string, state: GameState, scheduler: Scheduler): ActionController | undefined {
|
||||||
name: string,
|
|
||||||
state: GameState,
|
|
||||||
scheduler: Scheduler
|
|
||||||
): ActionController | undefined {
|
|
||||||
const storedFunction = actionMap[name];
|
const storedFunction = actionMap[name];
|
||||||
if (storedFunction === undefined) {
|
if (storedFunction === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -10,11 +10,7 @@ export class CheckBuildingRemainingTimeAction extends ActionController {
|
|||||||
if (timer.length === 1) {
|
if (timer.length === 1) {
|
||||||
const remainingSeconds = Number(timer.attr('value'));
|
const remainingSeconds = Number(timer.attr('value'));
|
||||||
if (remainingSeconds > 0) {
|
if (remainingSeconds > 0) {
|
||||||
throw new BuildingQueueFullError(
|
throw new BuildingQueueFullError(task.id, remainingSeconds + 1, 'Building queue is full');
|
||||||
task.id,
|
|
||||||
remainingSeconds + 1,
|
|
||||||
'Building queue is full'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,7 @@ import { ActionError } from '../Errors';
|
|||||||
@registerAction
|
@registerAction
|
||||||
export class GrabHeroAttributesAction extends ActionController {
|
export class GrabHeroAttributesAction extends ActionController {
|
||||||
async run(args: Args, task: Task): Promise<any> {
|
async run(args: Args, task: Task): Promise<any> {
|
||||||
const healthElement = jQuery(
|
const healthElement = jQuery('#attributes .attribute.health .powervalue .value');
|
||||||
'#attributes .attribute.health .powervalue .value'
|
|
||||||
);
|
|
||||||
if (healthElement.length !== 1) {
|
if (healthElement.length !== 1) {
|
||||||
throw new ActionError(task.id, 'Health dom element not found');
|
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, '');
|
let normalized = text.replace(/[^0-9]/g, '');
|
||||||
const value = Number(normalized);
|
const value = Number(normalized);
|
||||||
if (isNaN(value)) {
|
if (isNaN(value)) {
|
||||||
throw new ActionError(
|
throw new ActionError(task.id, `Health value "${text}" (${normalized}) couldn't be converted to number`);
|
||||||
task.id,
|
|
||||||
`Health value "${text}" (${normalized}) couldn't be converted to number`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state.set('hero', { health: value });
|
this.state.set('hero', { health: value });
|
||||||
|
@ -6,16 +6,10 @@ import { Task } from '../Storage/TaskQueue';
|
|||||||
@registerAction
|
@registerAction
|
||||||
export class UpgradeBuildingAction extends ActionController {
|
export class UpgradeBuildingAction extends ActionController {
|
||||||
async run(args: Args, task: Task): Promise<any> {
|
async run(args: Args, task: Task): Promise<any> {
|
||||||
const btn = jQuery(
|
const btn = jQuery('.upgradeButtonsContainer .section1 button.green.build');
|
||||||
'.upgradeButtonsContainer .section1 button.green.build'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (btn.length !== 1) {
|
if (btn.length !== 1) {
|
||||||
throw new TryLaterError(
|
throw new TryLaterError(task.id, 15 * 60, 'No upgrade button, try later');
|
||||||
task.id,
|
|
||||||
15 * 60,
|
|
||||||
'No upgrade button, try later'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
btn.trigger('click');
|
btn.trigger('click');
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
import { markPage, sleepShort, timestamp } from './utils';
|
import { markPage, sleepShort, timestamp } from './utils';
|
||||||
import { UpgradeBuildingTask } from './Task/UpgradeBuildingTask';
|
import { UpgradeBuildingTask } from './Task/UpgradeBuildingTask';
|
||||||
import {
|
import { AbortTaskError, BuildingQueueFullError, TryLaterError } from './Errors';
|
||||||
AbortTaskError,
|
|
||||||
BuildingQueueFullError,
|
|
||||||
TryLaterError,
|
|
||||||
} from './Errors';
|
|
||||||
import { Task, TaskId, TaskList, TaskQueue } from './Storage/TaskQueue';
|
import { Task, TaskId, TaskList, TaskQueue } from './Storage/TaskQueue';
|
||||||
import { ActionQueue } from './Storage/ActionQueue';
|
import { ActionQueue } from './Storage/ActionQueue';
|
||||||
import { Command } from './Common';
|
import { Command } from './Common';
|
||||||
@ -49,10 +45,7 @@ export class Scheduler {
|
|||||||
|
|
||||||
private scheduleHeroAdventure() {
|
private scheduleHeroAdventure() {
|
||||||
if (!this.taskQueue.hasNamed(SendOnAdventureTask.name)) {
|
if (!this.taskQueue.hasNamed(SendOnAdventureTask.name)) {
|
||||||
this.taskQueue.push(
|
this.taskQueue.push(new Command(SendOnAdventureTask.name, {}), timestamp());
|
||||||
new Command(SendOnAdventureTask.name, {}),
|
|
||||||
timestamp()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,10 +68,7 @@ export class Scheduler {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (actionCommand) {
|
if (actionCommand) {
|
||||||
return await this.processActionCommand(
|
return await this.processActionCommand(actionCommand, taskCommand);
|
||||||
actionCommand,
|
|
||||||
taskCommand
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taskCommand) {
|
if (taskCommand) {
|
||||||
|
@ -102,10 +102,7 @@ export class TaskQueue {
|
|||||||
|
|
||||||
private getItems(): TaskList {
|
private getItems(): TaskList {
|
||||||
const serialized = localStorage.getItem(QUEUE_NAME);
|
const serialized = localStorage.getItem(QUEUE_NAME);
|
||||||
const storedItems =
|
const storedItems = serialized !== null ? (JSON.parse(serialized) as Array<{ [key: string]: any }>) : [];
|
||||||
serialized !== null
|
|
||||||
? (JSON.parse(serialized) as Array<{ [key: string]: any }>)
|
|
||||||
: [];
|
|
||||||
const items: TaskList = [];
|
const items: TaskList = [];
|
||||||
storedItems.forEach(obj => {
|
storedItems.forEach(obj => {
|
||||||
items.push(new Task(obj.id || uniqId(), +obj.ts, obj.cmd));
|
items.push(new Task(obj.id || uniqId(), +obj.ts, obj.cmd));
|
||||||
@ -114,10 +111,7 @@ export class TaskQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private flushItems(items: TaskList): void {
|
private flushItems(items: TaskList): void {
|
||||||
localStorage.setItem(
|
localStorage.setItem(QUEUE_NAME, JSON.stringify(TaskQueue.normalize(items)));
|
||||||
QUEUE_NAME,
|
|
||||||
JSON.stringify(TaskQueue.normalize(items))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private log(...args) {
|
private log(...args) {
|
||||||
|
@ -8,10 +8,7 @@ export function registerTask(constructor: Function) {
|
|||||||
taskMap[constructor.name] = constructor;
|
taskMap[constructor.name] = constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createTask(
|
export function createTask(name: string, scheduler: Scheduler): TaskController | undefined {
|
||||||
name: string,
|
|
||||||
scheduler: Scheduler
|
|
||||||
): TaskController | undefined {
|
|
||||||
const storedFunction = taskMap[name];
|
const storedFunction = taskMap[name];
|
||||||
if (storedFunction === undefined) {
|
if (storedFunction === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -25,13 +25,7 @@ export class TaskQueueRenderer {
|
|||||||
tasks.forEach(task => {
|
tasks.forEach(task => {
|
||||||
ul.append(
|
ul.append(
|
||||||
jQuery('<li></li>').text(
|
jQuery('<li></li>').text(
|
||||||
formatDate(task.ts) +
|
formatDate(task.ts) + ' ' + task.cmd.name + ' ' + JSON.stringify(task.cmd.args) + ' ' + task.id
|
||||||
' ' +
|
|
||||||
task.cmd.name +
|
|
||||||
' ' +
|
|
||||||
JSON.stringify(task.cmd.args) +
|
|
||||||
' ' +
|
|
||||||
task.id
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user