5th 中文文档教程
5th
该项目创建任何人都可以与另一个基于 JavaScript 的项目一起使用的对象 处理常见用例的第 5 版应用程序,例如制作角色, 处理战斗甚至计划遭遇。
Usage
要在您的应用程序中使用此库,只需将其包含在 npm
中:
npm i --save 5th
您需要提供自己的响应处理程序、处理程序工厂、实体 网关和网关工厂对象(如果需要)。 他们将需要回应 具体方法集。 稍后我们将在此处表示详细信息。
Handler Factory
您必须使用“make”方法在代码库中实现单个对象,该方法 接受一个字符串并生成一个带有“句柄”方法的对象,该方法接受一个 对象并对其进行操作。 一个例子:
// HandlerFactory.js
const handlers = {
'select race': {
handle({ character }) {
// do something with the character and its newly created race
}
}
}
module.exports = class {
make(type) {
if (!handlers.hasOwnProperty(type)) {
// throw an error of some sort
}
return handlers[type]
}
}
5th
This project creates objects which anyone can use with another JavaScript-based 5th edition application to handle common use cases, like making a character, handling combat or even planning an encounter.
Usage
To use this library in your application, simply include it with npm
:
npm i --save 5th
You will need to provide your own response handler, handler factory, entity gateway and gateway factory objects if required. They will need to respond to a specific set of methods. We will denote details here later.
Handler Factory
You must implement a single object in your codebase with a "make" method which takes a string and generates an object with a "handle" method which takes an object and operates on it. An example:
// HandlerFactory.js
const handlers = {
'select race': {
handle({ character }) {
// do something with the character and its newly created race
}
}
}
module.exports = class {
make(type) {
if (!handlers.hasOwnProperty(type)) {
// throw an error of some sort
}
return handlers[type]
}
}