Skip to content

Commit

Permalink
feat: add ItemClass entity and object type
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenoak committed Dec 3, 2023
1 parent 9da0c9e commit cfe8551
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
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

0 comments on commit cfe8551

Please sign in to comment.