Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ItemClass entity and object type #38

Merged
merged 1 commit into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/spelunker-api/src/lib/entities/Item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import DatabaseEntity from '../db/Entity.mjs';
import { worldConnection } from '../db/connections.mjs';

import GameObjectLoot from './GameObjectLoot.mjs';
import ItemClass from './ItemClass.mjs';
import ItemDisplayInfo from './ItemDisplayInfo.mjs';
import ItemLoot from './ItemLoot.mjs';
import ItemSet from './ItemSet.mjs';
Expand Down Expand Up @@ -62,6 +63,10 @@ class Item extends DatabaseEntity {
return NPCLoot.query.where({ Item: this.id }).orderBy('Chance', 'desc');
}

itemClass() {
return ItemClass.find(this.data.class);
}

itemSet() {
return ItemSet.find(this.data.itemset);
}
Expand Down
9 changes: 9 additions & 0 deletions packages/spelunker-api/src/lib/entities/ItemClass.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import DBCEntity from '../dbc/Entity.mjs';

class ItemClass extends DBCEntity {
static get dbc() {
return 'ItemClass';
}
}

export default ItemClass;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {
GraphQLInt,
GraphQLNonNull,
GraphQLObjectType,
GraphQLString,
} from '../../../graphql/index.mjs';

export default new GraphQLObjectType({
name: 'ItemClass',
fields: () => ({
id: { type: new GraphQLNonNull(GraphQLInt) },
name: { type: new GraphQLNonNull(GraphQLString) },
}),
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import CollectionType from '../CollectionType.mjs';
import CurrencyType from '../CurrencyType.mjs';

import GameObjectLootType from './GameObjectLootType.mjs';
import ItemClassType from './ItemClassType.mjs';
import ItemDisplayInfoType from './ItemDisplayInfoType.mjs';
import ItemLootType from './ItemLootType.mjs';
import ItemQualityType from './ItemQualityType.mjs';
Expand All @@ -23,6 +24,7 @@ export default new GraphQLObjectType({
id: { type: new GraphQLNonNull(GraphQLInt) },
name: { type: new GraphQLNonNull(GraphQLString) },
buyPrice: { type: CurrencyType },
itemClass: { type: ItemClassType },
itemSet: { type: ItemSetType },
sellPrice: { type: CurrencyType },
quality: { type: ItemQualityType },
Expand Down
Loading