Flint works, arrowheads... almost. BASEMAT DATA!
parent
d11741dc02
commit
4da31d058e
|
|
@ -19,14 +19,14 @@ import { GATHER_FLINT, MAKE_ARROWHEAD } from '../tasks/CoreTasks.js';
|
||||||
// })
|
// })
|
||||||
// });
|
// });
|
||||||
|
|
||||||
registerAction('Gather Flint', (qty) => {
|
registerAction('Gather Flint', () => {
|
||||||
const taskState = new TaskState(GATHER_FLINT);
|
const taskState = new TaskState(GATHER_FLINT);
|
||||||
Game.current.board.addTask(taskState);
|
Game.current.board.addTask(taskState);
|
||||||
});
|
});
|
||||||
|
|
||||||
registerAction('Create Arrowhead', (qty) => {
|
registerAction('Create Arrowhead', (qty) => {
|
||||||
const rock = new ItemState(FLINT_NORMAL, 1, null);
|
const rock = new ItemState(FLINT_NORMAL, 1, null);
|
||||||
const task = new TaskState(MAKE_ARROWHEAD).setData({
|
const task = new TaskState(MAKE_ARROWHEAD, {
|
||||||
baseMaterial: rock
|
baseMaterial: rock
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ import { Task } from "@tasks";
|
||||||
import { Game } from '@game';
|
import { Game } from '@game';
|
||||||
import { FLINT_NORMAL, SLATE_NORMAL } from '../items/CoreItems.js';
|
import { FLINT_NORMAL, SLATE_NORMAL } from '../items/CoreItems.js';
|
||||||
import { ItemState } from "@items";
|
import { ItemState } from "@items";
|
||||||
|
import { Popup } from "../../../src/ui/Popup.js";
|
||||||
|
import { inspect } from 'util';
|
||||||
|
|
||||||
export const GATHER_FLINT = new Task('core:gather-flint')
|
export const GATHER_FLINT = new Task('core:gather-flint')
|
||||||
.setName('Gather Flint')
|
.setName('Gather Flint')
|
||||||
|
|
@ -12,28 +14,16 @@ export const GATHER_FLINT = new Task('core:gather-flint')
|
||||||
.setCompletionEvent(() => {
|
.setCompletionEvent(() => {
|
||||||
const qty = Math.floor(Math.random() * 5) + 1;
|
const qty = Math.floor(Math.random() * 5) + 1;
|
||||||
Game.current.inv.add(new ItemState(FLINT_NORMAL, 1, null));
|
Game.current.inv.add(new ItemState(FLINT_NORMAL, 1, null));
|
||||||
})
|
});
|
||||||
|
|
||||||
// export const GATHER_SLATE = new Task('core:gather-slate')
|
|
||||||
// .setName('Gather Slate')
|
|
||||||
// .setStatus('SCAVENGING')
|
|
||||||
// .setWork(1000)
|
|
||||||
// .setTasklistVisibility(true)
|
|
||||||
// .setCategory("work")
|
|
||||||
// .setCompletionEvent(() => {
|
|
||||||
// const qty = Math.floor(Math.random() * 5) + 1;
|
|
||||||
// Game.current.inv.add(SLATE_NORMAL, qty);
|
|
||||||
// });
|
|
||||||
|
|
||||||
export const MAKE_ARROWHEAD = new Task<{
|
export const MAKE_ARROWHEAD = new Task<{
|
||||||
baseMaterial: ItemState
|
baseMaterial: ItemState
|
||||||
}>('core:gather-slate')
|
}>('core:gather-slate')
|
||||||
.setName('Gather Slate')
|
.setName('Gather Slate')
|
||||||
.setStatus('SCAVENGING')
|
.setStatus('SCAVENGING')
|
||||||
.setWork(1000)
|
.setWork(1)
|
||||||
.setTasklistVisibility(true)
|
.setTasklistVisibility(true)
|
||||||
.setCategory("work")
|
.setCategory("work")
|
||||||
.setCompletionEvent((data) => {
|
.setCompletionEvent((data) => {
|
||||||
const qty = Math.floor(Math.random() * 5) + 1;
|
Popup.show(inspect(data));
|
||||||
Game.current.inv.add(SLATE_NORMAL, qty);
|
|
||||||
});
|
});
|
||||||
|
|
@ -2,6 +2,8 @@ import { Serializable } from 'frigid';
|
||||||
import { Task, TaskState } from './registries/Tasks.js';
|
import { Task, TaskState } from './registries/Tasks.js';
|
||||||
import { render, Renderable, panels } from './ui/UI.js';
|
import { render, Renderable, panels } from './ui/UI.js';
|
||||||
|
|
||||||
|
const taskTypes = {};
|
||||||
|
|
||||||
export class TaskList extends Serializable implements Renderable {
|
export class TaskList extends Serializable implements Renderable {
|
||||||
tasks: TaskState<any>[] = [];
|
tasks: TaskState<any>[] = [];
|
||||||
|
|
||||||
|
|
@ -32,7 +34,6 @@ export class TaskList extends Serializable implements Renderable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const taskTypes = {};
|
// export function registerTask(name, clazz) {
|
||||||
export function registerTask(name, clazz) {
|
// taskTypes[name] = clazz;
|
||||||
taskTypes[name] = clazz;
|
// }
|
||||||
}
|
|
||||||
|
|
@ -6,14 +6,14 @@ export type ItemID = string;
|
||||||
|
|
||||||
const items = new Map<ItemID, Item>();
|
const items = new Map<ItemID, Item>();
|
||||||
|
|
||||||
|
export type PropertyValue = number | boolean;
|
||||||
|
|
||||||
// ITEMS SHALL BE SINGULAR
|
// ITEMS SHALL BE SINGULAR
|
||||||
export class Item extends Serializable {
|
export class Item extends Serializable {
|
||||||
|
|
||||||
name = '';
|
name = '';
|
||||||
id: ItemID = '';
|
id: ItemID = '';
|
||||||
props: {
|
props: Map<string, PropertyValue> = new Map();
|
||||||
[propName: string]: any
|
|
||||||
};
|
|
||||||
|
|
||||||
setName(name) {
|
setName(name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
@ -40,7 +40,8 @@ export class Item extends Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
getProperty(prop: ItemProperty) {
|
getProperty(prop: ItemProperty) {
|
||||||
return this.props[prop.name] ?? null;
|
if(this.props.has(prop.name)) return this.props.get(prop.name);
|
||||||
|
else return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { Game } from '../Game.js';
|
||||||
import { panels } from '../ui/UI.js';
|
import { panels } from '../ui/UI.js';
|
||||||
import { progressbar, ProgressbarStyle } from '../Progressbar.js';
|
import { progressbar, ProgressbarStyle } from '../Progressbar.js';
|
||||||
|
|
||||||
const tasks: Map<string, Task<any>> = new Map();
|
export const tasks: Map<string, Task<any>> = new Map();
|
||||||
export type TaskCategory = "self" | "work" | "craft" | "idle";
|
export type TaskCategory = "self" | "work" | "craft" | "idle";
|
||||||
|
|
||||||
export class Task<Data> {
|
export class Task<Data> {
|
||||||
|
|
@ -67,18 +67,13 @@ export class TaskState<T> extends Serializable {
|
||||||
this.testCompletion();
|
this.testCompletion();
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(task: Task<T>) {
|
constructor(task: Task<T>, data: T = {} as T) {
|
||||||
super();
|
super();
|
||||||
this.taskId = task.id;
|
this.taskId = task.id;
|
||||||
this.progress = 0;
|
this.progress = 0;
|
||||||
this.worker = null;
|
this.worker = null;
|
||||||
// preset the data to nothing JIC
|
// preset the data to nothing JIC
|
||||||
this.data = {} as T;
|
|
||||||
}
|
|
||||||
|
|
||||||
setData(data: T) {
|
|
||||||
this.data = data;
|
this.data = data;
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stopJob() {
|
stopJob() {
|
||||||
|
|
@ -92,7 +87,7 @@ export class TaskState<T> extends Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
testCompletion() {
|
testCompletion() {
|
||||||
if (this.completed) {
|
if (this.taskId && this.completed) {
|
||||||
this.task.completionEvent(this.data);
|
this.task.completionEvent(this.data);
|
||||||
Game.current.board.removeTask(this);
|
Game.current.board.removeTask(this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import InventoryView from './view/InventoryView.js';
|
||||||
import MultiplayerView from './view/MultiplayerView.js';
|
import MultiplayerView from './view/MultiplayerView.js';
|
||||||
import { View } from './View.js';
|
import { View } from './View.js';
|
||||||
import { ActionsView } from './view/ActionsView.js';
|
import { ActionsView } from './view/ActionsView.js';
|
||||||
|
import { tasks } from '@tasks';
|
||||||
|
|
||||||
const clamp = (min, max, value) => Math.min(Math.max(value, min), max);
|
const clamp = (min, max, value) => Math.min(Math.max(value, min), max);
|
||||||
|
|
||||||
|
|
@ -55,6 +56,10 @@ export class Menu implements Renderable {
|
||||||
// debugging hotkeys
|
// debugging hotkeys
|
||||||
} else if (key.full === '1') {
|
} else if (key.full === '1') {
|
||||||
Popup.show(inspect(stats));
|
Popup.show(inspect(stats));
|
||||||
|
} else if (key.full === '2') {
|
||||||
|
Popup.show(inspect(tasks));
|
||||||
|
} else if (key.full === '3') {
|
||||||
|
Popup.show(inspect(stats));
|
||||||
} else if (key.full === 'z') {
|
} else if (key.full === 'z') {
|
||||||
Game.current.pawns.push(new Pawn());
|
Game.current.pawns.push(new Pawn());
|
||||||
} else if (key.full === 'x') {
|
} else if (key.full === 'x') {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue