coh-content-db v2.0.0-rc.2
coh-content-db
City of Heroes Content Database
Installation
npm install coh-content-db
Usage
There are two ways to use this package; As a data provider, or a db consumer.
As a data provider
Data providers utilize the various -Data
interfaces provided in this package to construct server group data packages
that can be loaded into the db for consumption by DB consumers such as Badger.
For an example data package, see the coh-content-db-homecoming project.
Defining archetypes, map, badges, etc.
To define content, create a new instance using the appropriate Data
interface and provide values for the required fields:
///test-badge.ts
import {BadgeData} from 'coh-content-db'
export const TEST_BADGE: BadgeData = {
key: 'test-badge',
type: 'ACHIEVEMENT',
name: [{value: 'Test Badge'}, {alignment: 'P', value: 'My Badge for Praetorians'}],
alignment: ['H', 'V', 'P'],
}
Then, create a ServerGroupData
instance and load your content into the appropriate field.
import {ServerGroupData} from 'coh-content-db'
import {TEST_BADGE} from './test-badge'
export const TEST_SERVER_GROUP: ServerGroupData = {
key: 'my-server-group',
name: 'My Server Group',
badges: [TEST_BADGE],
}
As a DB consumer
Create a new database instance, then load a server-group data pack, such as coh-content-db-homecoming:
import {CohContentDatabase} from 'coh-content-db';
import {Homecoming} from 'coh-content-db-homecoming';
const db = new CohContentDatabase();
db.loadServerGroupData(new Homecoming());
Once loaded, you can start retrieving the loaded data using the keys associated with the various content:
List loaded server groups:
db.listServerGroups();
Get a server group by key and list the badges:
const sg = db.getServerGroup("server-group-key");
for (const badge of sg.badges) {
console.log(badge.key)
}
Publish
Tags matching the pattern v<X>.<Y>.<Z>
will attempt to publish to npm (this can only be achieved by the package manager (n15g).
npm version 1.4.x
npm run push
4 months ago
4 months ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago