Skip to content

Commit

Permalink
add loot containers
Browse files Browse the repository at this point in the history
  • Loading branch information
Razzmatazzz committed Sep 25, 2023
1 parent fa40f18 commit 3bc8c27
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
10 changes: 10 additions & 0 deletions datasources/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ class MapAPI extends WorkerKV {
return false;
});
}

async getLootContainer(context, id) {
await this.init(context);
return this.cache.LootContainer[id];
}

async getAllLootContainers(context) {
await this.init(context);
return Object.values(this.cache.LootContainer);
}
}

module.exports = MapAPI;
14 changes: 14 additions & 0 deletions resolvers/mapResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ module.exports = {
}
return context.util.paginate(bosses, args);
},
async lootContainers(obj, args, context, info) {
let containers = context.data.map.getAllLootContainers(context);
return context.util.paginate(containers, args);
},
async maps(obj, args, context, info) {
let maps = false;
let filters = {
Expand Down Expand Up @@ -50,6 +54,16 @@ module.exports = {
return context.data.item.getItem(context, data.key);
},
},
LootContainer: {
name(data, args, context, info) {
return context.data.map.getLocale(data.name, context, info);
},
},
LootContainerPosition: {
lootContainer(data, args, context, info) {
return context.data.map.getLootContainer(context, data.lootContainer);
},
},
Map: {
accessKeys(data, args, context, info) {
return context.data.item.getItemsByIDs(context, data.accessKeys);
Expand Down
13 changes: 13 additions & 0 deletions schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,17 @@ type Lock {
#terrainElevation: Float
}
type LootContainer {
id: ID!
name: String!
normalizedName: String!
}
type LootContainerPosition {
lootContainer: LootContainer
position: MapPosition
}
type Map {
id: ID!
tarkovDataId: ID
Expand All @@ -677,6 +688,7 @@ type Map {
extracts: [MapExtract]
locks: [Lock]
hazards: [MapHazard]
lootContainers: [LootContainerPosition]
#svg: MapSvg
}
Expand Down Expand Up @@ -1220,6 +1232,7 @@ type Query {
items(ids: [ID], name: String, names: [String], type: ItemType, types: [ItemType], categoryNames: [ItemCategoryName], handbookCategoryNames: [HandbookCategoryName] bsgCategoryId: String, bsgCategoryIds: [String], bsgCategory: String, lang: LanguageCode, limit: Int, offset: Int): [Item]!
itemCategories(lang: LanguageCode, limit: Int, offset: Int): [ItemCategory]!
handbookCategories(lang: LanguageCode, limit: Int, offset: Int): [ItemCategory]!
lootContainers(lang: LanguageCode, limit: Int, offset: Int): [LootContainer]
maps(lang: LanguageCode, name: [String!], enemies: [String!], limit: Int, offset: Int): [Map]!
questItems(lang: LanguageCode): [QuestItem]
status: ServerStatus!
Expand Down

0 comments on commit 3bc8c27

Please sign in to comment.